* [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
* Re: [gentoo-user] [OT] Script to crack gpg passphrase
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
0 siblings, 1 reply; 8+ messages in thread
From: Paul Hartman @ 2011-04-26 14:34 UTC (permalink / raw
To: gentoo-user
On Tue, Apr 26, 2011 at 9:20 AM, Mick <michaelkintzios@gmail.com> wrote:
> 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.
Haven't tried it, but Google led me to this:
http://www.roguedaemon.net/rephrase/
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [gentoo-user] [OT] Script to crack gpg passphrase
2011-04-26 14:34 ` Paul Hartman
@ 2011-04-26 15:42 ` Mick
2011-04-26 20:24 ` Mick
0 siblings, 1 reply; 8+ messages in thread
From: Mick @ 2011-04-26 15:42 UTC (permalink / raw
To: gentoo-user
On 26 April 2011 15:34, Paul Hartman <paul.hartman+gentoo@gmail.com> wrote:
> On Tue, Apr 26, 2011 at 9:20 AM, Mick <michaelkintzios@gmail.com> wrote:
>> 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.
>
> Haven't tried it, but Google led me to this:
>
> http://www.roguedaemon.net/rephrase/
Thanks Paul, it seems no longer maintained (compiled for 2.4 kernel and gcc3).
--
Regards,
Mick
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [gentoo-user] [OT] Script to crack gpg passphrase
2011-04-26 15:42 ` Mick
@ 2011-04-26 20:24 ` Mick
2011-04-27 18:15 ` felix
0 siblings, 1 reply; 8+ messages in thread
From: Mick @ 2011-04-26 20:24 UTC (permalink / raw
To: gentoo-user
[-- Attachment #1: Type: Text/Plain, Size: 892 bytes --]
On Tuesday 26 April 2011 16:42:50 Mick wrote:
> On 26 April 2011 15:34, Paul Hartman <paul.hartman+gentoo@gmail.com> wrote:
> > On Tue, Apr 26, 2011 at 9:20 AM, Mick <michaelkintzios@gmail.com> wrote:
> >> 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.
> >
> > Haven't tried it, but Google led me to this:
> >
> > http://www.roguedaemon.net/rephrase/
>
> Thanks Paul, it seems no longer maintained (compiled for 2.4 kernel and
> gcc3).
Actually, it installs and runs! Thank you. :-)
Alas though, it didn't crack the suspected passphrase. :-(
Back to plan A. Any ideas how I can improve my script?
--
Regards,
Mick
[-- Attachment #2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 198 bytes --]
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [gentoo-user] [OT] Script to crack gpg passphrase
2011-04-26 20:24 ` Mick
@ 2011-04-27 18:15 ` felix
2011-04-27 18:56 ` Mick
0 siblings, 1 reply; 8+ messages in thread
From: felix @ 2011-04-27 18:15 UTC (permalink / raw
To: gentoo-user
On Tue, Apr 26, 2011 at 09:24:44PM +0100, Mick wrote:
> Back to plan A. Any ideas how I can improve my script?
Do you have any guesses as to your passphrase or is it a total shot in
the dark, could be anything from one word to a poem?
Unless you can narrow it down tremendously, you're wasting time and it
will never be recovered.
--
... _._. ._ ._. . _._. ._. ___ .__ ._. . .__. ._ .. ._.
Felix Finch: scarecrow repairman & rocket surgeon / felix@crowfix.com
GPG = E987 4493 C860 246C 3B1E 6477 7838 76E9 182E 8151 ITAR license #4933
I've found a solution to Fermat's Last Theorem but I see I've run out of room o
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [gentoo-user] [OT] Script to crack gpg passphrase
2011-04-27 18:15 ` felix
@ 2011-04-27 18:56 ` Mick
2011-04-28 14:04 ` Mick
0 siblings, 1 reply; 8+ messages in thread
From: Mick @ 2011-04-27 18:56 UTC (permalink / raw
To: gentoo-user
[-- Attachment #1: Type: Text/Plain, Size: 953 bytes --]
On Wednesday 27 April 2011 19:15:46 felix@crowfix.com wrote:
> On Tue, Apr 26, 2011 at 09:24:44PM +0100, Mick wrote:
> > Back to plan A. Any ideas how I can improve my script?
>
> Do you have any guesses as to your passphrase or is it a total shot in
> the dark, could be anything from one word to a poem?
>
> Unless you can narrow it down tremendously, you're wasting time and it
> will never be recovered.
There are some candidate passphrases. I tried them all with rephrase and all
the permutations that I could think of.
Now I am trying app-crypt/nasty, for brute force cracking, but I can't get it
to work. :-(
It keeps popping up my pinentry and asking me for my default key passphrase,
not the key I am trying to feed to it.
Is there a way to change that script I posted so that it a)takes the
passphrases from a file, or b)incrementally tries {a,b,...,z}, and/or capitals
and/or numbers?
--
Regards,
Mick
[-- Attachment #2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 198 bytes --]
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [gentoo-user] [OT] Script to crack gpg passphrase
2011-04-27 18:56 ` Mick
@ 2011-04-28 14:04 ` Mick
2011-04-28 16:47 ` Michael Orlitzky
0 siblings, 1 reply; 8+ messages in thread
From: Mick @ 2011-04-28 14:04 UTC (permalink / raw
To: gentoo-user
On 27 April 2011 19:56, Mick <michaelkintzios@gmail.com> wrote:
> On Wednesday 27 April 2011 19:15:46 felix@crowfix.com wrote:
>> On Tue, Apr 26, 2011 at 09:24:44PM +0100, Mick wrote:
>> > Back to plan A. Any ideas how I can improve my script?
>>
>> Do you have any guesses as to your passphrase or is it a total shot in
>> the dark, could be anything from one word to a poem?
>>
>> Unless you can narrow it down tremendously, you're wasting time and it
>> will never be recovered.
>
> There are some candidate passphrases. I tried them all with rephrase and all
> the permutations that I could think of.
>
> Now I am trying app-crypt/nasty, for brute force cracking, but I can't get it
> to work. :-(
>
> It keeps popping up my pinentry and asking me for my default key passphrase,
> not the key I am trying to feed to it.
>
> Is there a way to change that script I posted so that it a)takes the
> passphrases from a file, or b)incrementally tries {a,b,...,z}, and/or capitals
> and/or numbers?
I'm making some good progress!
First I used the key to encrypt a file:
gpg -e file.txt
Then run this script to try to decrypt it:
==========================================
#!/bin/bash
#
# try all word in test.txt
for word in $(cat test.txt); do
# try to decrypt with word
echo "${word}" | gpg --passphrase-fd 0 -q --batch --no-tty --output
file_success.txt -d file.txt.gpg;
# if decrypt is successfull; stop
if [ $? -eq 0 ]; then
echo "GPG passphrase is: ${word}";
exit 0;
fi
done;
exit 1;
==========================================
This finds the passphrase and prints it out on the terminal. However, its
success depends on the dictionary file I use. Also, it's not particularly
fast ...
Any idea how I can create a dictionary file? I've used apg but it's <aheam!>
too random. :-)
I have been given something like 6 passphrases that may have been used. The
problem is that at the time of creation the passphrase was typed in
incorrectly (twice!) So I would need to use some method of generating a
dictionary with potential typos of these known passphrases (pretty much how
the rephrase application works). What is a good way to generate such a file
by imputing a range of candidate characters?
Finally, is there a way or parallelising the run so that it speeds up?
--
Regards,
Mick
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [gentoo-user] [OT] Script to crack gpg passphrase
2011-04-28 14:04 ` Mick
@ 2011-04-28 16:47 ` Michael Orlitzky
0 siblings, 0 replies; 8+ messages in thread
From: Michael Orlitzky @ 2011-04-28 16:47 UTC (permalink / raw
To: gentoo-user
On 04/28/2011 10:04 AM, Mick wrote:
> This finds the passphrase and prints it out on the terminal. However, its
> success depends on the dictionary file I use. Also, it's not particularly
> fast ...
>
> Any idea how I can create a dictionary file? I've used apg but it's <aheam!>
> too random. :-)
>
> I have been given something like 6 passphrases that may have been used. The
> problem is that at the time of creation the passphrase was typed in
> incorrectly (twice!) So I would need to use some method of generating a
> dictionary with potential typos of these known passphrases (pretty much how
> the rephrase application works). What is a good way to generate such a file
> by imputing a range of candidate characters?
>
> Finally, is there a way or parallelising the run so that it speeds up?
>
If you know the actual passphrase is "close" to some known passphrase,
read up on the concept of Levenshtein distance:
http://en.wikipedia.org/wiki/Levenshtein_distance
If you can define a function that computes all passwords of Levenshtein
distance 1 from a given password, then you can run that function twice
to get the password of distance 2,3... Three or four is probably a good
place to stop.
Then you can take those six known passwords, and compute all words of
distance 1,2,3 from all of them. Stick those in a list, and try them.
^ 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