Skip to content

Commit

Permalink
Documentation fix for Raw Private Key Recovery
Browse files Browse the repository at this point in the history
  • Loading branch information
3rdIteration committed May 6, 2024
1 parent f58c74e commit 0fae89f
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 11 deletions.
9 changes: 6 additions & 3 deletions btcrecover/btcrpass.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,8 +176,8 @@ def init_wildcards(wildcard_custom_list_e = None,
# N.B. that tstr() will not convert string.*case to Unicode correctly if the locale has
# been set to one with a single-byte code page e.g. ISO-8859-1 (Latin1) or Windows-1252
wildcard_sets = {
tstr("h") : tstr(string.hexdigits),
tstr("*") : tstr("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"),
tstr("H") : tstr(string.hexdigits),
tstr("B") : tstr("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"),
tstr("d") : tstr(string.digits),
tstr("a") : tstr(string.ascii_lowercase),
tstr("A") : tstr(string.ascii_uppercase),
Expand Down Expand Up @@ -4856,8 +4856,10 @@ def return_verified_password_or_false(self, passwords): # Raw Privatekey

#Work out what kind of private key we are handling
WIFPrivKey = False

if len(password) == 64: # Likely Hex Private Key (Don't need to do anything)
pass

elif len(password) == 52 and password[0] in ["L","K"]: #Compressed Private Key
try:
password = binascii.hexlify(base58.b58decode_check(password)[1:-1])
Expand All @@ -4871,7 +4873,8 @@ def return_verified_password_or_false(self, passwords): # Raw Privatekey
WIFPrivKey = True
except:
continue

else: # Unsupported Private Key
continue

# Convert the private key from text to raw private key...
try:
Expand Down
4 changes: 2 additions & 2 deletions docs/Usage_Examples/basic_password_recoveries.md
Original file line number Diff line number Diff line change
Expand Up @@ -357,7 +357,7 @@ python btcrecover.py --slip39 --wallet-type ethereum --addrs 0x0Ef61684B1E671dcB
## Raw Private Keys##
BTCRecover an also be used to recover from situations where you have a damaged private key.

This is handled in a similar way to a password recovery, so your private key guesses go in a tokenlist, using the %h wildcard to substitute hexidecimal characters or %b to substitute base58 characters. You can use either a tokenlist or a passwordlist, depending on your situation, as well as the standard typos. If you are using a tokenlist, you will just need to ensure that the private keys being produced match the length and characters required for a private key...
This is handled in a similar way to a password recovery, so your private key guesses go in a tokenlist, using the %H wildcard to substitute hexidecimal characters or %B to substitute base58 characters. You can use either a tokenlist or a passwordlist, depending on your situation, as well as the standard typos. If you are using a tokenlist, you will just need to ensure that the private keys being produced match the length and characters required for a private key...

If you know the address that the private key corresponds to, you can supply that, alternatively you can use an AddressDB.

Expand All @@ -369,7 +369,7 @@ You will also notice that the leading "0x" needs to be removed from the private
{% include "eth_privkey_tokenlist.txt" %}
```

The tokenlist above is an example is a standard Eth private key (with the leading 0x removed) where there are three damanged parts. One single character (%h), one two-character (%2h) and one three-character (%3h) It will take about 20 mintes to run...
The tokenlist above is an example is a standard Eth private key (with the leading 0x removed) where there are three damanged parts. One single character (%H), one two-character (%2H) and one three-character (%3H) It will take about 20 mintes to run...

```
python btcrecover.py --rawprivatekey --addrs 0xB9644424F9E639D1D0F27C4897e696CC324948BB --wallet-type ethereum --tokenlist ./docs/Usage_Examples/eth_privkey_tokenlist.txt
Expand Down
6 changes: 3 additions & 3 deletions docs/Usage_Examples/btc_privkey_tokenlist.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
1ADF94484E9C820D69BC9770542B678DB677E7C354DC4BD27D7E9AC351698CB7
KzTgU27AYQSojvpXaJHS5rm%*oB7k83Q3oCDGAeoD3Rz2BbLFoP19
5JYsdUthE1KzGA%*Xwfomeocw6vwzoTNXzcbJq9e7LcAyt1Svoo8
KzPyZwq13F8tyXJ9si1ovGYo%*btQADi6qD9XbDHRWtfWud7PriHV
KzTgU27AYQSojvpXaJHS5rm%BoB7k83Q3oCDGAeoD3Rz2BbLFoP19
5JYsdUthE1KzGA%BXwfomeocw6vwzoTNXzcbJq9e7LcAyt1Svoo8
KzPyZwq13F8tyXJ9si1ovGYo%BbtQADi6qD9XbDHRWtfWud7PriHV
2 changes: 1 addition & 1 deletion docs/Usage_Examples/eth_privkey_tokenlist.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
5db77aa7aea5%2h7d6b4c64dab21%h972cf4763d4937d3e6e17f580436dcb10%3h
5db77aa7aea5%2H7d6b4c64dab21%H972cf4763d4937d3e6e17f580436dcb10%3H
4 changes: 2 additions & 2 deletions docs/tokenlist_file.md
Original file line number Diff line number Diff line change
Expand Up @@ -180,8 +180,8 @@ The `%d` is a wildcard which is replaced by all combinations of a single digit.
* `%%` - a single `%` (so that `%`’s in your password aren’t confused as wildcards)
* `%^` - a single `^` (so it’s not confused with an anchor if it’s at the beginning of a token)
* `%S` - a single `$` (yes, that’s `%` and a capital `S` that gets replaced by a dollar sign, sorry if that’s confusing)
* `%h` - a single hexidcimal character (0-9, A-F)
* `%*` - a single Base58 character (Bitcoin Base58 Character Set)
* `%H` - a single hexidcimal character (0-9, A-F)
* `%B` - a single Base58 character (Bitcoin Base58 Character Set)
* `%U` - a single Unicode character (All Unicode characters up to 65,535)
* `%e` - Custom String Repeating wildcard, [Read about behaviour and usage](custom_wildcards.md)
* `%f` - Custom String Repeating wildcard, [Read about behaviour and usage](custom_wildcards.md)
Expand Down

0 comments on commit 0fae89f

Please sign in to comment.