Created
January 20, 2020 12:16
-
-
Save JavanXD/c7b92a34e19511d44e3c55fb922e0e85 to your computer and use it in GitHub Desktop.
python 7z_bruteforce.py rockyou.txt test.7z
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python3 | |
# python 7z_bruteforce.py rockyou.txt test.7z | |
import concurrent.futures | |
import os | |
import subprocess | |
import sys | |
FNULL = open(os.devnull, 'w') | |
found = False | |
def try_password(aPassword, aFile): | |
global FNULL, myExecutor, found | |
try: | |
if not found: | |
print(aPassword) | |
myRet = subprocess.call(["7z", "t", "-p" + aPassword, aFile], stdout=FNULL, stderr=subprocess.STDOUT) | |
if myRet == 0: | |
print ("The password is: " + aPassword) | |
found = True | |
# TODO: kill process | |
except Exception as ex: | |
print(str(ex)) | |
myFilename = sys.argv[2] | |
myPasswordFile = sys.argv[1] | |
print ("File to crack: " + myFilename) | |
print ("Password list: " + myPasswordFile) | |
myFile = open(myPasswordFile, "rt") | |
myExecutor = concurrent.futures.ThreadPoolExecutor(max_workers=3) | |
# Test a Password | |
#myExecutor.submit(try_password, "123456", myFilename) | |
try: | |
for myLine in iter(myFile): | |
myPassword = myLine.strip('\n') | |
myExecutor.submit(try_password, myPassword, myFilename) | |
except Exception as ex: | |
print(str(ex)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment