Skip to content

Instantly share code, notes, and snippets.

@artizirk
Created February 18, 2021 20:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save artizirk/0e072b24d593d76d8b95c1e8d3cf2f8a to your computer and use it in GitHub Desktop.
Save artizirk/0e072b24d593d76d8b95c1e8d3cf2f8a to your computer and use it in GitHub Desktop.
Try to import password protected gnupg openpgp by using passwords from csv file
#!/usr/bin/env python3
## Try all of the passwords for gpg openpgp key
from subprocess import run
p = open("/tmp/passwords.csv")
passwords = set()
for line in p.readlines():
passwords.add(line.split(",")[2].strip().replace('"',''))
for password in passwords:
print(password)
try:
#run("GNUPGHOME=/tmp/gnupg gpg --pinentry-mode loopback --passphrase-fd 0 --import test.asc", shell=True, check=True, input=password.encode())
run("gpg --pinentry-mode loopback --passphrase-fd 0 --import /tmp/test.asc", shell=True, check=True, input=password.encode())
except Exception as e:
print(e)
continue
exit()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment