├── .gitignore ├── PYAnonymousFTP.py └── README.md /.gitignore: -------------------------------------------------------------------------------- 1 | # Byte-compiled / optimized / DLL files 2 | __pycache__/ 3 | *.py[cod] 4 | 5 | # C extensions 6 | *.so 7 | 8 | # Distribution / packaging 9 | .Python 10 | env/ 11 | build/ 12 | develop-eggs/ 13 | dist/ 14 | downloads/ 15 | eggs/ 16 | lib/ 17 | lib64/ 18 | parts/ 19 | sdist/ 20 | var/ 21 | *.egg-info/ 22 | .installed.cfg 23 | *.egg 24 | 25 | # PyInstaller 26 | # Usually these files are written by a python script from a template 27 | # before PyInstaller builds the exe, so as to inject date/other infos into it. 28 | *.manifest 29 | *.spec 30 | 31 | # Installer logs 32 | pip-log.txt 33 | pip-delete-this-directory.txt 34 | 35 | # Unit test / coverage reports 36 | htmlcov/ 37 | .tox/ 38 | .coverage 39 | .cache 40 | nosetests.xml 41 | coverage.xml 42 | 43 | # Translations 44 | *.mo 45 | *.pot 46 | 47 | # Django stuff: 48 | *.log 49 | 50 | # Sphinx documentation 51 | docs/_build/ 52 | 53 | # PyBuilder 54 | target/ 55 | -------------------------------------------------------------------------------- /PYAnonymousFTP.py: -------------------------------------------------------------------------------- 1 | import os 2 | import time 3 | import datetime 4 | import socket 5 | import random 6 | import signal 7 | import ipaddr 8 | 9 | #import threading #WILL SUPPORT 10 | #import ipaddr #GOOGLE SORCE CODE 11 | 12 | #status = 0 # status of connection 13 | 14 | def Menu(): 15 | # global loggin 16 | global choice 17 | global verbose 18 | global net4 19 | print "\n\ 20 | ##############################\n\ 21 | # SCRIPT KID THING #\n\ 22 | # KiLlSwiTch-GUI #\n\ 23 | ##############################\n\ 24 | This tools is for scanning the net for FTP\n\ 25 | Servers using FTP and anonymous connections.\n\ 26 | \n\ 27 | 1)Use IP RANGE AND CONNECT and check for Anonymous logins.\n\ 28 | 2)WILL USE MASKING AND SUPPORT IN FUTURE\n\ 29 | 3)IP List Creator\n" 30 | #logging = str(raw_input("[*] Would you like to enable loging? Yes(Y) or No(N)")) #Will Support Logging of data and what you want to store 31 | verbose = str(raw_input("[*] Would you like it verbose or VV? Yes(Y) or VV(vv) or Enter for NO: ")) 32 | if verbose == "yes" or verbose == "Yes" or verbose == "YES" or verbose == "y" or verbose == "Y" or verbose == "v": 33 | verbose = 1 34 | print bcolors.Green + "[*] Verbose Activated", bcolors.ENDC 35 | elif verbose == "VV" or verbose == "vv": 36 | verbose = 2 37 | print bcolors.Green + "[*] VERY Verbose Activated", bcolors.ENDC 38 | choice = str(raw_input("[*] What would you like to do: ")) 39 | return choice, #logging # will return loggin value 40 | 41 | def ChoiceSelection(): 42 | global status 43 | if choice == "1": 44 | if verbose == 1 or verbose == 2: 45 | print bcolors.Green + "[*] Starting Ip Range Creation", bcolors.ENDC 46 | #print "\nWhat is you network range you would like to scan using masking?" 47 | #print "Using classfull maksing:\n\ 48 | #/8 = 255.0.0.0 ex. 192.0.0.0/8\n\ 49 | #/16 = 255.255.0.0 ex. 192.168.0.0/16\n\ 50 | #/24 = 255.255.255.0 ex. 192.168.1.0/24\n\ 51 | # Classless is also supported:\n\ 52 | #/25 = 255.255.255.128 ex. 192.168.1.0/25 = .0 -> .127\n" 53 | #net4 = raw_input("[*]What is your IP: ") #Still not working -- NEED TO CONVERT OUTPUT TO STRING 54 | #net4 = ipaddr.IPv4Network(net4) #Still not working 55 | start_ip = raw_input("[*] What is your start IP: ") 56 | end_ip = raw_input("[*] What is your ending IP: ") 57 | ipRange(start_ip,end_ip) 58 | status = 0 59 | #port = [] 60 | #port.append(21) 61 | #port.append(990) 62 | if verbose == 1 or verbose == 2: 63 | print bcolors.Green + "[*] starting Port Scan", bcolors.ENDC 64 | for address in ip_range: 65 | portscan(address,port) 66 | if status == 1: 67 | if verbose == 1 or verbose == 2: 68 | print bcolors.Green + "[*] Starting Anonymous Login at:", address, bcolors.ENDC 69 | AnonLogin(address,port) 70 | status = 0 71 | if choice == "3": 72 | count = 0 73 | net4 = raw_input("[*]What is your IP: ") 74 | if verbose == 1 or verbose == 2: 75 | print bcolors.Green + "[*] starting to open file as Ipaddress.txt", bcolors.ENDC 76 | try: 77 | output = open("Ipaddress.txt" ,"ab+") 78 | except: 79 | print bcolors.Red + "Could not make file!", bcolors.ENDC 80 | main() 81 | net4 = ipaddr.IPv4Network(net4) 82 | if verbose == 1 or verbose == 2: 83 | print bcolors.Green + "[*] starting to write IP's to file", bcolors.ENDC 84 | for x in net4.iterhosts(): # will use this for masking 85 | count += 1 86 | k = x 87 | k = str(k) 88 | try: 89 | output.write(k + "\n"); 90 | except: 91 | print bcolors.Red + "Could not write to file!", bcolors.ENDC 92 | print IOError 93 | print "Returning home...." 94 | main() 95 | output.close() 96 | print bcolors.Green + "[*] Saved as Ipaddress.txt in working DIR", bcolors.ENDC 97 | print bcolors.Green + "[*] Worte:", count, " IP's", bcolors.ENDC 98 | 99 | main() 100 | 101 | def signal_handler(signum, frame): 102 | raise Exception("Timed out!") 103 | 104 | 105 | def ipRange(start_ip, end_ip): 106 | global ip_range 107 | start = list(map(int, start_ip.split("."))) 108 | end = list(map(int, end_ip.split("."))) 109 | temp = start 110 | ip_range = [] 111 | ip_range.append(start_ip) 112 | while temp != end: 113 | start[3] += 1 114 | for i in (3, 2, 1): 115 | if temp[i] == 256: 116 | temp[i] = 0 117 | temp[i-1] += 1 118 | ip_range.append(".".join(map(str, temp))) 119 | return ip_range 120 | 121 | def AnonLogin(address,port): 122 | ftp=socket.socket(socket.AF_INET, socket.SOCK_STREAM) 123 | ftp.settimeout(9) 124 | try: 125 | ftp.connect((address, port)); # passing it our address and port we want to connect to 126 | banner=ftp.recv(45) 127 | signal.signal(signal.SIGALRM, signal_handler) 128 | signal.alarm(3) 129 | try: 130 | banner += ftp.recv(1024) # receive the rest of the banner 131 | except: 132 | pass 133 | if verbose == 1 or verbose ==2: 134 | print banner 135 | banner.replace("\r\n", ' ') 136 | ftp.send("USER anonymous\r\n") 137 | ftp.recv(1024) 138 | ftp.send("PASS anon@\r\n") 139 | response=ftp.recv(1024) 140 | if verbose == 1 or verbose == 2: 141 | print response 142 | try: 143 | if response.index("230")!=-1: 144 | status="Success" 145 | print bcolors.Cyan + "$$$$$$--Money--$$$$$$", bcolors.ENDC 146 | print "[*]", address, "is a", status, "at a Anonymous login on PORT:", port 147 | input("Press Enter to continue...") 148 | except ValueError: 149 | status="Failure" 150 | if verbose == 1 or verbose == 2: 151 | print bcolors.FAIL + "[*]", status, "at logging in at", address, bcolors.ENDC 152 | else: 153 | print status 154 | except socket.error: # if we cant connect at all we will pass 155 | pass 156 | ftp.close() 157 | return 158 | 159 | def portscan(address,port): # will perfrom a socket connection and if error detection is seen it will return status of 0 160 | global verbose 161 | global status 162 | status = 0 163 | port = [21] #still working this list / LOOP out but it works for now 164 | address = str(address) 165 | for portscan in port: 166 | try: 167 | s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) 168 | s.settimeout(1) #how long will we wait to hear for a connection "NEED TO ADD OPTION FOR THIS" 169 | s.connect((address,21)) 170 | if verbose == 1 or verbose == 2: 171 | print bcolors.Magenta + "[*]", address,"on: ",portscan,"is OPEN", bcolors.ENDC 172 | if portscan == 990: 173 | print bcolors.Magenta + "[-] Found a SFTP service possibly on", portscan, bcolors.ENDC 174 | s.shutdown(socket.SHUT_RDWR) 175 | s.close 176 | status = 1 177 | except socket.error as msg: # we can print the caught error 178 | if verbose == 2: 179 | print bcolors.Yellow +"[*]", msg, bcolors.ENDC 180 | print bcolors.Yellow + "[*] Failure on port:", portscan, "at:", address, bcolors.ENDC 181 | err = True 182 | except: continue # if its not a socket error? Do i need this? 183 | finally: #insuring that the socket is closed to be reopened 184 | s.close() 185 | return status 186 | 187 | 188 | class bcolors: 189 | HEADER = '\033[95m' 190 | OKBLUE = '\033[94m' 191 | OKGREEN = '\033[92m' 192 | WARNING = '\033[93m' 193 | FAIL = '\033[91m' 194 | ENDC = '\033[0m' 195 | Red = '\033[91m' 196 | Green = '\033[92m' 197 | Blue = '\033[94m' 198 | Cyan = '\033[96m' 199 | White = '\033[97m' 200 | Yellow = '\033[93m' 201 | Magenta = '\033[95m' 202 | Grey = '\033[90m' 203 | Black = '\033[90m' 204 | Default = '\033[99m' 205 | 206 | 207 | def main(): 208 | global choice 209 | global port 210 | global verbose 211 | global start_ip 212 | global end_ip 213 | print bcolors.WARNING + "Warning: This will be used at your own risk scanning the web :)" + bcolors.ENDC 214 | port = 21 # global port we want to check 215 | Menu() #Print Menu 216 | ChoiceSelection() # What we do if we pick something 217 | 218 | 219 | 220 | if __name__=="__main__": 221 | main() 222 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | PyAnonymousFTP 2 | ============== 3 | 4 | Anonymous FTP Scanner Script- Generates IP's between two ranges, scans 21 and attempts a anonymous connection 5 | --------------------------------------------------------------------------------