Using ftplib to brute force FTP user credentials

One of the main uses that can be given to this library is to check if an FTP server is vulnerable to a brute-force attack using a dictionary. For example, with this script we can execute an attack using a dictionary of users and passwords against an FTP server. We test with all possible user and password combinations until we find the right one.

We will know that the combination is a good one if, when connecting, we obtain the "230 Login successful" string as an answer.

You can find the following code in the filename: ftp_brute_force.py:

import ftplibimport sysdef brute_force(ip,users_file,passwords_file):    try:        ud=open(users_file,"r")        pd=open(passwords_file,"r")                users= ud.readlines() passwords= ...

Get Mastering Python for Networking and Security now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.