Last active
December 5, 2023 22:24
-
-
Save gmolveau/fc177d28cb36b2bd790cfa627087385e to your computer and use it in GitHub Desktop.
Python 7zip bruteforce
This file contains 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
import subprocess | |
import sys | |
def main(): | |
archive = sys.argv[1] | |
dictionary = sys.argv[2] | |
with open(dictionary, "r") as dic: | |
for line in dic: | |
word = line.rstrip('\n') | |
stdout = subprocess.call( | |
"7z t -p'{0}' {1}".format(word, archive), | |
stderr=subprocess.DEVNULL, | |
stdout=subprocess.DEVNULL, | |
shell=True | |
) | |
if stdout == 0: | |
print("Password found: " + word) | |
return | |
print("Password not found.") | |
if __name__ == "__main__": | |
if len(sys.argv) == 3: | |
main() | |
else: | |
print("missing args") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment