Skip to content

Instantly share code, notes, and snippets.

@PeterTheOne
Last active December 24, 2015 04:29
Show Gist options
  • Save PeterTheOne/6744304 to your computer and use it in GitHub Desktop.
Save PeterTheOne/6744304 to your computer and use it in GitHub Desktop.
Brute force mistyped GPG passwords. script.js creates a list of possible passwords by scrambling a string by switching the positions of two neighboring characters, script.sh tries them.
// http://stackoverflow.com/a/1431113/782920
String.prototype.replaceAt=function(index, character) {
return this.substr(0, index) + character + this.substr(index + character.length);
}
function scramble(text) {
var result = text + '\n';
for (var i = 0; i < text.length -1; i++) {
var temp = text;
temp = temp.replaceAt(i, text.charAt(i + 1));
temp = temp.replaceAt(i + 1, text.charAt(i));
result += temp + '\n';
}
console.log(result);
}
scramble('test');
#!/bin/bash
#
for word in $(cat passwords.txt); do
echo "${word}" | gpg --passphrase-fd 0 -q --batch --allow-multiple-messages --no-tty --output output.txt -d msg.asc;
if [ $? -eq 0 ]; then
echo "GPGP passphrase is: ${word}";
exit 0;
fi
done;
exit 1;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment