Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.soft-sys.math.mathematica > #10967 > unrolled thread
| Started by | Murta <rodrigomurtax@gmail.com> |
|---|---|
| First post | 2012-07-18 05:40 +0000 |
| Last post | 2012-07-18 05:40 +0000 |
| Articles | 1 — 1 participant |
Back to article view | Back to comp.soft-sys.math.mathematica
Recover lost PGP passphrase with Mathematica! (Done) Murta <rodrigomurtax@gmail.com> - 2012-07-18 05:40 +0000
| From | Murta <rodrigomurtax@gmail.com> |
|---|---|
| Date | 2012-07-18 05:40 +0000 |
| Subject | Recover lost PGP passphrase with Mathematica! (Done) |
| Message-ID | <ju5i99$3s2$1@smc.vnet.net> |
Hi all!
Long time ago, I have made one PGP key with one big passphrase that I have
forgot. I just know some words of it, and could remember that I have mixed
some Portuguese with German and English in it.
Just for hobby, I tried to break up it using Mathematica, and I get a positive result!..
To do it you'll need to use a Mac with the free GPG installed (GnuPG).
You will need just to save the testFile.gpg (cryptographed with the lost passphase key) in your notebook directory and create a possibility list with some clues of your lost passphrase.
I find my in almost 50.000 combinations!.. (10 minutes)
Don't forget that is necessary to save the notebook before run, it need you r notebook directory (copy and paste do not work)
There is the code,
(*------------------------------------------------------------------------*)
(*Function to create combinations of words*)
phrase[possibilidades_]:=Module[{$frases},
$frases=Distribute[possibilidades,List];
$frases=StringJoin@@Riffle[#," "]&/@$frases
]
(*Testing 1 Phrase*)
test1Phrase[pass_,fileName_]:=Module[{test,string,path=NotebookDirectory[],count},
count:=Length@ReadList["!ls '"<>path<>"'",Record];
test=count;
string="! /usr/local/bin/gpg --batch -q -o '@path/outputRand.txt' --passphrase '@pass' --decrypt '@path/@fileName'";
string=StringReplace[string,{"@pass"-> pass,"@path/"-> path,"@fileName" -> fileName,"outputRand"-> ToString@RandomInteger[10^6]}];
Run[string];
If[count==test,False,True]
];
(*Tests each combination*)
testPhraseList[listFrases_,fileName_]:=Module[{return},
i=1;qtd=Length[listFrases];
return=Catch[(i++;If[test1Phrase[#,fileName],Throw[#]])&/@listFrases];
If[Length[return]==0,return,"passphrase not found"]
]
(*Nice progress bar*)
pBar=Dynamic[Row[{ProgressIndicator[i,{0,qtd}]," ",NumberForm[100. i/qtd,{\[Infinity],2}],"% "}]];
(*Using the code*)
(*list of possible words*)
possibleList={{"Minha","Mein","Meine","meine"},
{"Terra","terra","grund","Grund","Land","land"},
{"tem","habe","have"},
{"Palms","palms","palmeiras","Palmeiras"},
{"onde","where"},
{"sing","canta","singt"},
{"der","o","the","die","das","a"},
{"sabia","Sabia","sabi=E1","Sabi=E1"}
};
(*creating list of combinations*)
(listaFrases=phrase[possibleList])//Length
(*testing it!*)
pBar
testPhraseList[listaFrases,"testFile.gpg"]
(*the function will print the file if it find it..*)
(*------------------------------------------------------------------------*)
Good luck if you need it!
Back to top | Article view | comp.soft-sys.math.mathematica
csiph-web