Post
Topic
Board Bitcoin Technical Support
Re: Encrypted wallet.dat, lost password, any solutions?
by
niklas
on 06/04/2013, 19:33:21 UTC
Maybe this will help someone with mistyped password on Windows. This is a short Powershell script that tries the passwords read from standard input as rapidly as the particular cryptocoin client will allow.
Code:
#
# Please put the correct username/password below
#
$h = new-object Net.WebClient
$h.Credentials = new-object Net.NetworkCredential("user","pass")
$h.Encoding = [Text.Encoding]::Default
#
# read the passord guesses from standard input
#
$Input | foreach {
    try {
        $p = $_ # + 'Kongreßstraße'
        Write-Output "Trying '$p'"
        $r = $h.UploadString('http://localhost:8332/','{"method":"walletpassphrase","params":["'+$p+'",1]}')
        # Write-Output $r
        #
        # Correct password found!
        #
        break
    }
    catch [Net.WebException] {
        $e = $_
    switch -wildcard ($e.Exception.Message) {
    "*(401) Unauthorized*" {
    Write-Output "Fix the user/pass!"
    Exit-PSSession
    }
    "*(500) Internal Server Error*" {
    continue
    }
    default {
                $e | Format-List -Force
    Exit-PSSession
            }
        }
    }
}
#
# Exiting without success!
#
Write-Output "Exiting!"

You can either feed it a file/dictionary of possible passwords:
Code:
powershell -executionpolicy bypass -file bitcrack.ps1 < dictionary.txt
or a pipe in the one-per-line output from the password generator:
Code:
generator.exe | powershell -executionpolicy bypass -file bitcrack.ps1
.

For someone who already has the Ruby installed on their Windows machine you can take those programs and delete the system() call and the case/end statement below it. Also change 'print phrase, "\t"' to 'puts phrase'. They should speed up the checks to the maximum achievable without hacking the wallet-handling code in the Satoshi client.

Thank you, 2112, this looks promising.

I have changed the brute.rb script from Revalin according to your suggestions and I am now using it as a password generator for your powershell script. It took some trying but now I know that there is something like a decent cli on windows Smiley

The whole thing runs very fast now. Problem is, I still do have the problems with the umlauts. Again I have checked that using a fresh, empty wallet with a password containing umlauts -which was not found. If I set the password to one without umlauts, your script finds it.

I assume that this has something to do with the encodings settings in your script. I already tried changing the encoding to 'BigEndianUnicode' and 'UTF8', but in both circumstances, the password was not found.

Do you have any further ideas.

Slightly less desperated, maybe even a bit optimistic ...

Niklas