Post
Topic
Board Bitcoin Technical Support
Re: Encrypted wallet.dat, lost password, any solutions?
by
Revalin
on 11/01/2014, 05:42:41 UTC
Could you help me with a script Revalin? I have tried some of the ones listed earlier but did not  help me find my password.
I know the first 7 characters with 100%. Following is 2 words. I have a list of words for words_1 and words_2, I might have also used either a ! or ^^ at the end.
Ex: Known(Words_1)(Words_2)(special)

Thanks!

Here you go:

Code:
#!/usr/bin/ruby -w
require 'net/http'
require 'json'

$rpc_pass = "some-password"
passphrase = 'IKnowThisPart'
words_1 = ['one', 'two', 'three']
words_2 = ['btc', 'ltc', 'usd']
words_3 = ['', '!', '^^']

def test(passphrase)
  puts passphrase.inspect
  request = Net::HTTP::Post.new("/")
  request.basic_auth "", $rpc_pass
  request.body = { method:"walletpassphrase", params:[passphrase, 1] }.to_json
  response = Net::HTTP.new("localhost", 8332).request(request)
  if response.code == "401" ; puts "Incorrect RPC user/pass" ; exit 1 ; end
  ret = JSON.parse response.body
  if ret["error"].nil? ; puts "\nFound it! #{passphrase.inspect}" ; exit ; end
  return if ret["error"]["code"] == -14 # wrong passphrase
  raise "WTF? #{ret.inspect}"
end

words_1.each do |w1|
  words_2.each do |w2|
    words_3.each do |w3|
      test(passphrase + w1 + w2 + w3)
    end
  end
end

puts "No luck."
exit 1