Last active
December 24, 2015 04:29
-
-
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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