openssl AES256 with a common standardized Password-Based Key Derivation Function - Printable Version +- hashcat Forum (https://hashcat.net/forum) +-- Forum: Support (https://hashcat.net/forum/forum-3.html) +--- Forum: hashcat (https://hashcat.net/forum/forum-45.html) +--- Thread: openssl AES256 with a common standardized Password-Based Key Derivation Function (/thread-8928.html) Pages:
1
2
|
openssl AES256 with a common standardized Password-Based Key Derivation Function - derlange2k - 01-28-2020 Hello everyone, i want to use hashcat to brute-force a password created by multibit classic bitcoin wallet. The wallet key backup uses the following openssl method to generate the backup: openssl enc -p -aes-256-cbc -a -in \<plaintext file\> -out \<ciphertext file\> -pass pass:\<password\> From my little knowledge, this is base64 decoded, salted with MD5 hash, so it could run really fast on GPUs. In the multibit wiki, the followin is stated: The whole private key file is encrypted. This uses AES256 with a common standardized Password-Based Key Derivation Function. For maximum compatibility I have used the same encryption methodology as in OpenSSL so you can also encrypt and decrypt the files using the command line utility 'openssl'. Is it possible to use hashcat with it? RE: openssl AES256 with a common standardized Password-Based Key Derivation Function - philsmd - 01-28-2020 are you talking about this https://github.com/hashcat/hashcat/issues/1538 ? this has nothing todo with the "openssl" tool at all. very different algorithm. RE: openssl AES256 with a common standardized Password-Based Key Derivation Function - derlange2k - 01-28-2020 (01-28-2020, 02:02 PM)philsmd Wrote: are you talking about this https://github.com/hashcat/hashcat/issues/1538 ? Not really. There seems to be some multibit version which uses scrypt, but my key backup is made from the openssl command mentioned above. See here: https://github.com/Multibit-Legacy/multibit/wiki/Export%20and%20limited%20import%20of%20private%20keys I can use the multibit2john python script on that, and john also is saying, that this is a MD5 based KDF. Thank you for your help. RE: openssl AES256 with a common standardized Password-Based Key Derivation Function - derlange2k - 01-28-2020 Examples: encrypted key backup file from multibit: Code: U2FsdGVkX1/Gt5+4m/DQUaahjZ1bZvpbehbiJ8RlZgScHycsuhU6vxfLMpWR1LSHoTJma6igo6eG hash generated by multibit2john.py: Code: hashcat-20200128133332.key:$multibit$1*c6b79fb89bf0d051*a6a18d9d5b66fa5b7a16e227c46566049c1f272cba153abf17cb329591d4b487 Decrypting with openssl: (i've had to add -md md5, otherwise my openssl would use sha1): Code: openssl enc -d -p -aes-256-cbc -a -in hashcat.key -md md5 -out hashcat-decrypt.key -pass pass:test Code: *** WARNING : deprecated key derivation used. out file from openssl: Code: KzWpNf4JJC8StHZE9nYtQZpXbhDyxWypxKBUaZMcBEJSZ2oYTiZd 2020-01-21T21:58:35Z unencrypted key backup from multibit: Code: # KEEP YOUR PRIVATE KEYS SAFE ! So it is for sure MD5 used. I simply don't know how to use it with hashcat. Any help would be really cool. RE: openssl AES256 with a common standardized Password-Based Key Derivation Function - derlange2k - 01-28-2020 Ok, from my understanding it works that way: The salt is: Code: c6b79fb89bf0d051 hashcat should generate MD5 hashes with the given attack mode, salt it with the above salt and compare it with the first two AES blocks: Code: a6a18d9d5b66fa5b7a16e227c46566049c1f272cba153abf17cb329591d4b487 Am i right? EDIT: i've also found out, that iteration count for this is 3, if this helps. RE: openssl AES256 with a common standardized Password-Based Key Derivation Function - derlange2k - 01-28-2020 Maybe this can help: Code: ############### MultiBit ############### From: https://github.com/gurnec/btcrecover/blob/master/btcrecover/btcrpass.py RE: openssl AES256 with a common standardized Password-Based Key Derivation Function - philsmd - 01-29-2020 I don't know about the details, but also the source code you posted says "Multibit Classic" (as the title of the github issue), so maybe there is a lot of confusion because users try to hijack github issues and nobody explains the differences between the formats. I'm also NO python expert, but your code has 2 very strange "problems" and therefore contributes to even further confusion: 1. there is NO good verification that matches your decrypted text (the code only checks for "LK5Q", but your "plaintext" is "KzWp" as far as I understand) 2. the following code also makes NO logical sense to me (maybe I'm a python noob, but this seems like a bug in the code posted): Code: if b58_privkey[0] in b"LK5Q\x0a#": what is the sense to check for a substring "LK5Q", if already a longer string "LK5Q\x0a#" matches ? This is very weird code to me... maybe other guys in here (like @undeath) can make more sense of this code... but it seems to be flawed and not really working with your example "KzWp"... Did you try to use this btcrpass.py tool to crack your file ? Does it even work ? update: I guess it's not a substring test, but it matches every character... i.e. the char b58_privkey[0] could be "L", "K" "5", "Q" "\n" and "#" very weird verification code indeed and there might be room for a lot of false positives if there are no stricter checks RE: openssl AES256 with a common standardized Password-Based Key Derivation Function - philsmd - 01-29-2020 so it seems the only check is that the 32 decrypted bytes are base58 chars and the first needs to start with either L, K, 5 or Q. I think that is approximately a chance of (58^32) / (256^32) .... it's not too bad, but could still result in rare false positives (see https://github.com/hashcat/hashcat/commit/40a5835927f8bc8e39fffd4ed4fa7a9d8e38b69c , here we have "only" MD5, so it should be very fast... which is bad if you try very hard to reduce false positives) Isn't there also a checksum involved with those keys or are they just random bytes converted to base58 ? Maybe not the full data needed for a checksum is within the output of multibit2john or btcrecover. RE: openssl AES256 with a common standardized Password-Based Key Derivation Function - derlange2k - 01-29-2020 (01-29-2020, 03:12 PM)philsmd Wrote: so it seems the only check is that the 32 decrypted bytes are base58 chars and the first needs to start with either L, K, 5 or Q. I really appreciate your answers, philsmd, thank you. Well, i'm not too deep into this, but as far as i know, there is no checksum involved, it is random bytes. btcreover reports the false positive also in the README: Code: Warning: Using the extract-multibit-privkey.py script on a MultiBit Classic key file, as described below, can lead to false positives. A false positive occurs when btcrecover reports that it has found the password, but is mistaken—the password which it displays may not be correct. Would it be possible to integrate it in hashcat? Running it with GPU power would be very faster, i guess. RE: openssl AES256 with a common standardized Password-Based Key Derivation Function - derlange2k - 01-29-2020 btcrecover can operate in 2 modes: 1. Mode: It operates on the full key backup file. This way, btcrecover can compare a second AES block: Code: # If another AES block is available, decrypt and check it as well to avoid false positives 2. Mode: You use the extract script from btcrecover and btcreover operates on the output from the extract script. the script only extracts the first AES block. This mode is for the purpose, if you want to brute-force from a third-party, which you don't want to send the whole backup. Because in case, he is able to brute-force it, he has the wallet and is the owner of the BTC. So in my case, i have the key backup file, so we could check the second AES block, which should avoide false positivs. Maybe i'm wrong? With my limit coding skills i assume it works this way. |