public inbox for gentoo-user@lists.gentoo.org
 help / color / mirror / Atom feed
* [gentoo-user] [OT] Script to crack gpg passphrase
@ 2011-04-26 14:20 Mick
  2011-04-26 14:34 ` Paul Hartman
  0 siblings, 1 reply; 8+ messages in thread
From: Mick @ 2011-04-26 14:20 UTC (permalink / raw
  To: gentoo-user

This is less sinister than what it sounds, but nevertheless necessary
when one forgets the passphrase and has no revocation cert handy.

I am trying to come up with a script to crack the passphrase, but my
poor scripting ability (non-existent really) hampers my efforts.
Looking at google I ended up with this modified example:
=======================================
#!/bin/bash
#

# try all word in test.txt
for word in $(cat test.txt); do

  # try to encrypt with $word passphrase
  echo "${word}" | gpg --passphrase-fd 0 --no-tty -a --export
seckey.gpg -o file;

  # if decrypt is successfull; stop
  if [ $? -eq 0 ]; then

    echo "GPG passphrase is: ${word}";
    exit 0;

  fi

done;

exit 1;
=======================================

The file test.txt has a list of passwords (one in each line, no
spaces) I am told 'sound like' the passphrase the user had set.

The output file is not created (therefore I assume that the script
does not work) but prints out the public key and only the first
passphrase in the list:

=======================================
$ ./crackgpg.sh
gpg: enabled debug flags: memstat
gpg: writing to stdout
-----BEGIN PGP PUBLIC KEY BLOCK-----
Version: GnuPG v2.0.17 (GNU/Linux)
[snip ...]

-----END PGP PUBLIC KEY BLOCK-----
random usage: poolsize=600 mixed=0 polls=0/0 added=0/0
              outmix=0 getlvl1=0/0 getlvl2=0/0
secmem usage: 0/32768 bytes in 0 block
GPG passphrase is: sebpirleydrodujrem
=======================================

Any idea what I could use in the above script to make it try one word
at a time, not ask for confirmation and print the *successful*
passphrase word at the end?  Any other scripting suggestions also
welcome.
-- 
Regards,
Mick



^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2011-04-28 16:49 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-04-26 14:20 [gentoo-user] [OT] Script to crack gpg passphrase Mick
2011-04-26 14:34 ` Paul Hartman
2011-04-26 15:42   ` Mick
2011-04-26 20:24     ` Mick
2011-04-27 18:15       ` felix
2011-04-27 18:56         ` Mick
2011-04-28 14:04           ` Mick
2011-04-28 16:47             ` Michael Orlitzky

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox