03-17-2020, 03:25 PM
(03-17-2020, 09:47 AM)philsmd Wrote: One good thing about hashcat source code, is that we also have several high-level tests (like the test framework in perl)... this is very easy code to understand, even if you are only fluent with python/php etc... it's very straight-forward how the hashes are generated and tested:Thanks alot!
https://github.com/hashcat/hashcat/blob/...pm#L24-L54
or look at the hashcat kernel code:
https://github.com/hashcat/hashcat/blob/...#L299-L348 (there is only one optional exception for the "Nexus" wallet, you might not need this special case in your code)
Now the contents of the hash file is clear, but still i can't get it how to check the password. But hashcat kernel code is quite complex to understand.
Here we have tmps array of 64-bit words, that (i suppose) is a hash from SHA512. It is split into 32-bit words and stored in the key array. Actually, not the whole tmps was transformed, but the first 4 elements of it (256 bits). After that, key is additionally transformed by AES256_set_decrypt_key function that expands the key for use with AES256.
After that we get the iv and data variables. We get them from the same element of esalts_buf(Is it an encrypted master_key?)
iv gets the first four 32-bit words of the value, data gets the 4 last of them, and bits (or bytes?) in both arrays are swapped.
After that, only data is decrypted with ks as key. Output is stored in out and xor'ed with iv. If all the words in the result are the same as pad (0x10101010), then we used the correct hash (and thus the correct password (?)).
So, to check the password we decrypt only half of the master_key and xor it with another, encrypted, part of the master_key, and expect the result to match the pad? Is it correct?