We can use the ftplib module in order to build a script to determine if a server offers anonymous logins.
The function anonymousLogin() takes a hostname and returns a Boolean that describes the availability of anonymous logins. The function tries to create an FTP connection with anonymous credentials. If successful, it returns the value "True."
You can find the following code in the filename: checkFTPanonymousLogin.py:
import ftplibdef anonymousLogin(hostname): try: ftp = ftplib.FTP(hostname) ftp.login('anonymous', '') print(ftp.getwelcome()) ftp.set_pasv(1) print(ftp.dir()) print('\n[*] ' + str(hostname) +' FTP Anonymous Logon Succeeded.') return ftp except Exception as e: print(str(e)) print('\n[-] ...