Created
November 11, 2013 00:20
-
-
Save gdoteof/7405829 to your computer and use it in GitHub Desktop.
bitcoin password cracker
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
#!/usr/bin/ruby -w | |
require 'rubygems' | |
require 'json' | |
passphrase = "x" | |
def permute(a0, a1) | |
result = [] | |
a0.each do |element0| | |
a1.each do |element1| | |
result.push(element0+element1) | |
end | |
end | |
return result | |
end | |
def wrap | |
end | |
def pt(a0) | |
a0.each do|element| | |
puts element + "\n" | |
end | |
end | |
def test(phrase) | |
print phrase, "\t" | |
system("./bitcoind", "walletpassphrase", phrase, "20") | |
case $?.exitstatus | |
when 0 | |
puts "Found it! #{phrase}" | |
exit 0 | |
when 127 | |
puts "bitcoind not found in current dir" | |
exit 1 | |
end | |
end | |
shift_lookup = { | |
'z' => 'Z', | |
'Z' => 'z', | |
'x' => 'X', | |
'X' => 'x', | |
'c' => 'C', | |
'C' => 'c', | |
'v' => 'V', | |
'V' => 'v', | |
'b' => 'B', | |
'B' => 'b', | |
'n' => 'N', | |
'N' => 'n', | |
'm' => 'M', | |
'M' => 'm', | |
',' => '<', | |
'<' => ',', | |
'.' => '>', | |
'>' => '.', | |
'/' => '?', | |
'?' => '/', | |
'a' => 'A', | |
'A' => 'a', | |
's' => 'S', | |
'S' => 's', | |
'd' => 'D', | |
'D' => 'd', | |
'f' => 'F', | |
'F' => 'f', | |
'g' => 'G', | |
'G' => 'g', | |
'h' => 'H', | |
'H' => 'h', | |
'j' => 'J', | |
'J' => 'j', | |
'k' => 'K', | |
'K' => 'k', | |
'l' => 'L', | |
'L' => 'l', | |
';' => ':', | |
':' => ';', | |
'\'' => '"', | |
'"' => '\'', | |
'q' => 'Q', | |
'Q' => 'q', | |
'w' => 'W', | |
'W' => 'w', | |
'e' => 'E', | |
'E' => 'e', | |
'r' => 'R', | |
'R' => 'r', | |
't' => 'T', | |
'T' => 't', | |
'y' => 'Y', | |
'Y' => 'y', | |
'u' => 'U', | |
'U' => 'u', | |
'i' => 'I', | |
'I' => 'i', | |
'o' => 'O', | |
'O' => 'o', | |
'p' => 'P', | |
'P' => 'p', | |
'[' => '{', | |
'{' => '[', | |
']' => '}', | |
'}' => ']', | |
'\\' => '|', | |
'|' => '\\', | |
'`' => '~', | |
'~' => '`', | |
'1' => '!', | |
'!' => '1', | |
'2' => '@', | |
'@' => '2', | |
'3' => '#', | |
'#' => '3', | |
'4' => '$', | |
'$' => '4', | |
'5' => '%', | |
'%' => '5', | |
'6' => '^', | |
'^' => '6', | |
'7' => '&', | |
'&' => '7', | |
'8' => '*', | |
'*' => '8', | |
'9' => '(', | |
'(' => '9', | |
'0' => ')', | |
')' => '0', | |
'-' => '_', | |
'_' => '-', | |
'=' => '+', | |
'+' => '=', | |
} | |
def shift_case(word,lookup) | |
out = "" | |
word.split("").each do |letter| | |
out += lookup[letter] | |
end | |
out | |
end | |
testword = "boobly123?><'|\\" | |
puts testword, "reversed", shift_case(testword,shift_lookup) | |
outers = [ | |
'something', | |
'somethingelse', | |
] | |
# takes 'outers' and makes a new list with reversed, case shifted and mirrored versions | |
outers += outers.reverse | |
outers = outers.uniq | |
souters = [] | |
outers.each do |element| | |
souters.push(shift_case(element,shift_lookup)) | |
souters.push(shift_case(element.reverse,shift_lookup)) | |
souters.push(element.reverse); | |
souters.push(element+shift_case(element,shift_lookup)) | |
souters.push(element+shift_case(element.reverse,shift_lookup)) | |
souters.push(element+element.reverse); | |
souters | |
end | |
souters = souters.uniq | |
outers += souters; | |
# take all those changed outers and call the list `ends` | |
ends = outers.uniq | |
inners = [ | |
'something!', | |
'somethingelse' | |
] | |
# takes all the `inners` and adds to the list all combinations of them added together | |
innersinners += permute(inners,inners) | |
middle = innersinners; | |
p0 = ['beginningphrase'] | |
p1 = [ | |
'endofphraseversion1', | |
'endofphraseversion2', | |
'endofphraceversion4', | |
'etc', | |
] | |
#combines all of phrases into new list called phrases | |
phrases = permute(p0,p1) | |
inners = inners.uniq | |
# combines all the possibilities for phrases ++ middle ++ ends | |
# and ends ++ phrases ++ ends | |
testable = [] | |
testable = permute(permute(phrases,middle),ends) | |
testable += permute(permute(ends,phrases),middle) | |
testable += permute(permute(ends,phrases),ends) | |
puts "array length: " | |
puts testable.length | |
puts "array.length.uniq" | |
puts testable.uniq.length | |
testable = testable.uniq | |
puts testable.length | |
nget = gets "press ctrl-d to start; make sure bitcoind is running" | |
testable.each do | element | | |
test(element) | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment