Skip to content

Instantly share code, notes, and snippets.

@gmolveau
Last active December 5, 2023 22:24
Show Gist options
  • Save gmolveau/fc177d28cb36b2bd790cfa627087385e to your computer and use it in GitHub Desktop.
Save gmolveau/fc177d28cb36b2bd790cfa627087385e to your computer and use it in GitHub Desktop.
Python 7zip bruteforce
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