Is there any way to make the script not check passwords with spaces between them?
Sure:
#!/usr/bin/ruby
require "net/http"
require "json"
$rpc_pass = "rpc-pass"
words = ['pass1', 'pass2', 'pass3', 'pass4']
max_words = 4
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
(1..max_words).each do |n_words|
words.repeated_permutation(n_words).each { |p| test p.join }
end
puts "No luck."
This should be much faster. For a list of 30 words it will take less than a day, and 50 words will take about a week.