Skip to content

Instantly share code, notes, and snippets.

@a-r-d
Created November 9, 2013 21:19
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save a-r-d/7390175 to your computer and use it in GitHub Desktop.
Save a-r-d/7390175 to your computer and use it in GitHub Desktop.
Really slow brute forcer for encrypted wallet. If you forget it and know the beginning of the password you may be able to get it. However this can only try 10 passwords a second :( Adapted from a script posted on bitcointalk.
#!/usr/bin/ruby -w
=begin
How to use, windows:
go to C:/Program Files (x86)/Bitcoin/daemon/
and execute ".\bitcoin -help"
You will need to create bitcoin.conf file @:
C:\Users\usr\AppData\Roaming\Bitcoin
Paste in the password that help tells you do use.
Now start bitcoind in daemon mode:
".\bitcoin -daemon"
Go to the command line and tst this:
"C:/Program Files (x86)/Bitcoin/daemon/bitcoind.exe" walletpassphrase correctapass 5
--> this should have no result if correct
"C:/Program Files (x86)/Bitcoin/daemon/bitcoind.exe" walletpassphrase wrongpass 5
--> should return: error: {"code":-14,"message":"Error: The wallet passphrase entered was incorrect."}
Make sure you put quotes around the path.
Run the sscript:
C:\Program Files (x86)\Bitcoin\daemon> ruby "C:\pathtoscript\brute_forcer.rb"
=end
class Cracker
def initialize(coindloc, basepass, char_array, password_range)
@coindlocation = coindloc
@basepassword = basepass
@char_array = char_array
@password_range = password_range
@prng = Random.new
end
## This will print the results and actually run the command.
def password_correct?(phrase)
puts "#{@coindlocation} walletpassphrase #{@basepassword}#{phrase} 5"
system("#{@coindlocation} walletpassphrase #{@basepassword}#{phrase} 5")
if $?.exitstatus == 0
puts "Found it: #{@basepassword}#{phrase}\n" * 10
exit 0
elsif $?.exitstatus == 14
puts "failed on: #{@basepassword}#{phrase}\n"
else
puts "unknown error occured. check path"
end
return false
end
# this builds the password guess
def generate_password( perm_number, password_length )
password=""
(1..password_length).each do |char_number| # loop through characters
char_reference = (perm_number / @char_array.length**(char_number-1)).floor % @char_array.length
character = @char_array[char_reference]
password << character
end
password
end
def do_combination( num_combinations, password_length )
(0..num_combinations-1).each do |perm_number| # loop through combinations for a given length
password = generate_password( perm_number, password_length )
return password, perm_number if password_correct?(password)
end
end
def crack()
(@password_range).each do |password_length| # loop to gradually increase password length
num_combinations=@char_array.length**password_length
password, perm_number = do_combination(num_combinations, password_length)
if password
puts "#{password} | Access Granted | #{perm_number} / #{num_combinations}\n"
end
end
end
end
# I removed characters I was sure I didn't use
#characters = "*abcdefghijklmnopqrstuvwyz".split(//) # for if you have no idea
characters = "ghjxcviopbnmrtywe".split(//) #e.g. for typos
basepass = "somebasepass"
coindloc = '"C:\Program Files (x86)\Bitcoin\daemon\bitcoind.exe"'
cracker = Cracker.new( coindloc, basepass, characters, [2,3,4] )
password = cracker.crack()
puts "No luck."
exit 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment