-
Notifications
You must be signed in to change notification settings - Fork 2.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
multibit2john.py should try not to output a "hash" for wrong input #5243
Comments
Our version has a try/except: import sys
_b=sys.version_info[0]<3 and (lambda x:x) or (lambda x:x.encode('latin1'))
try:
from google.protobuf import descriptor as _descriptor
from google.protobuf import message as _message
from google.protobuf import reflection as _reflection
from google.protobuf import symbol_database as _symbol_database
from google.protobuf import descriptor_pb2
except ImportError:
sys.stderr.write("Install the missing protobuf package, use 'pip install protobuf' command to do so.\n")
sys.exit(1)
# @@protoc_insertion_point(imports) Upstream's currently does not: from google.protobuf import descriptor as _descriptor
from google.protobuf import message as _message
from google.protobuf import reflection as _reflection
from google.protobuf import symbol_database as _symbol_database
# @@protoc_insertion_point(imports) I wonder if this was an edit by @kholia or if the old version had it that way, and more importantly whether we want to be adding a try/except when sync'ing with upstream. I suppose it's nice to recommend btcrecover deals with this by shipping a file |
Another observation is our version at least tries to support both Python 2 and 3, and the new one is Python 3 only. So maybe we don't want to update it, unless and until there's a good reason to. It could be tricky to get the |
We could also require that the file looks high-entropy. Do we have any shared Python code we could reuse/invoke for this? |
Hashcat has one mentioned in hashcat/hashcat#3637 just now. |
The entropy testing code they mention is in the kernels, so not in Python. Should be easy to translate or write our own. I've also been thinking of simply importing the Python zlib module and trying compression. For valid |
Unfortunately, there's a lot of potential for tools' misuse and user confusion here: if There's little we can do about it. Print a warning maybe? |
"However, the latter also produces a flood of false positives. Maybe there's room for improvement/unification based on this understanding." "(but then that other one is artificial and not a real Strongcoin wallet, so I don't know if real Strongcoin wallets with this "problem" exist or not)." I personally think the format is fine as is, but I guess an entropy check could reduce a few user errors, although I cant imagine its a prevalent thing that is happening. |
Here are some assorted notes about
multibit2john.py
(and a bit about the corresponding format).multibit2john.py
was introduced by @kholia in #2548. There's an attached file with sample wallets in there. We do not have those in thejohn-samples
repo yet - we need to add them to there.There are 3 kinds of those wallets/keys supported:
$multibit$1
are essentiallyopenssl enc
with MD5 and AES-256. Indeed, the sample from btcrecover (btcrecover/btcrecover/test/test-wallets/multibit-wallet.key
, which by the way we don't have injohn-samples
) is crackable with passwordbtcr-test-password
by bothmultibit2john.py
+john
oropenssl2john.py
+john
(with the correspondingly different formats). However, the latter also produces a flood of false positives. Maybe there's room for improvement/unification based on this understanding.For almost any unidentified file format,
multibit2john.py
happily produces a$multibit$2
hash. The only sanity check is based on filename, and it does not stop the program even if the filename doesn't contain the expected substrings - it merely prints "Make sure that this is a MultiBit HD wallet!", which isn't even clearly worded as a warning. We ought to do better, but looking at 3 sample files in @kholia's archive referenced above (one of which is the same asbtcrecover/btcrecover/test/test-wallets/multibithd-v0.5.0/mbhd.wallet.aes
) there doesn't appear to be a signature we could check for. The best idea I have is to require that the file size be a multiple of 16 (AES block size) and maybe that it's also in a reasonable range (the samples are all around 25K, but maybe that's a baseline size for nearly-empty wallet and it grows with use?)We use btcrecover-derived code for
$multibit$3
, including a pre-generated protobuf parser inprotobuf/wallet_pb2.py
. I wonder if we should sync this with upstream once in a while. This file is nowbtcrecover/bitcoinj_pb2.py
upstream, so we could take it from there and adopt the rename, too. Its content changed quite a bit, but that could be a result of its regeneration with newer compiler.The text was updated successfully, but these errors were encountered: