Skip to content
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

Added bitlocker2john.py #5564

Merged
merged 3 commits into from
Nov 9, 2024
Merged

Conversation

holly-o
Copy link
Contributor

@holly-o holly-o commented Nov 5, 2024

Added Python script to extract hashes for BitLocker-encrypted volumes

Added Python script to extract hashes for BitLocker-encrypted volumes
@solardiz
Copy link
Member

solardiz commented Nov 5, 2024

Thank you @holly-o.

@exploide You might want to help us review this, although since it's a new script we can as well merge first - it shouldn't hurt.

Copy link
Member

@solardiz solardiz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The script is missing a shebang line. Is it Python 3 only or is it also compatible with Python 2? Depending on this, please start it with either #!/usr/bin/env python3 or #!/usr/bin/env python. For this sort of updates to the main script within this PR, please amend the one existing commit and force-push.

You could also want to update doc/README.BitLocker to mention this script as (the recommended?) alternative to our compiled bitlocker2john program (making that program a secondary choice?)

run/bitlocker2john.py Outdated Show resolved Hide resolved
run/bitlocker2john.py Show resolved Hide resolved
Removed references to hashcat and updated comments to reflect that both user password and recovery key hashes are supported.
@holly-o holly-o requested a review from solardiz November 6, 2024 13:40
Copy link
Member

@solardiz solardiz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for these updates, they mostly look good. I suggest a couple of minor edits, can you please incorporate those as well?

For such fixups within a PR, we normally amend the existing commit and force-push, not add more commits. But if you're not used to work like that (or if the git client software you use doesn't let you), it's OK if you add commits (I will then need to temporarily allow squash-and-merge for this repo and use that on this specific PR).

Thanks again!

$bitlocker$3$16$4b10ca85ab17a7419990d92f75abc848$1048558$12$a015f77b68aed80106000000$60$11e39cfd4dc9f647cef46b843347a3677c0706d3653f3477d44c72c8e36e8e02e010744dc384a419ff487a0190b42da0a29229d57a0bc3c6a7193f7


Alternatively, run compiled script bitlocker2john. Found at tools/john/src/bitlocker2john.c
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The C program isn't a script and we do not have a tools/john directory and people are not expected to compile just one C file manually. So I'd replace this line with:

Alternatively, run the compiled program bitlocker2john, which is normally
built from source along with the rest of John the Ripper and is included
pre-built in John the Ripper binary releases.

@@ -0,0 +1,240 @@
#!/usr/bin/python3
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use the env trick here for consistency with our other scripts and not to rely on specific location of python3. So the line should be:

#!/usr/bin/env python3

@solardiz
Copy link
Member

solardiz commented Nov 7, 2024

This failed our CI whitespace-errors check, please also fix this minor detail:

Run git diff-index --check --cached b1b622f691d40196815939e4736a5da71befd206
doc/README.BitLocker:9: trailing whitespace.
+extract hashes from password protected BitLocker encrypted volumes. 
run/bitlocker2john.py:4: trailing whitespace.
+# Supported modes: 
run/bitlocker2john.py:100: trailing whitespace.
+    print("\nParsing description...")    
run/bitlocker2john.py:105: trailing whitespace.
+    print("\nParsing volume header block...")        
run/bitlocker2john.py:150: trailing whitespace.
+        
run/bitlocker2john.py:158: trailing whitespace.
+    entry_size = uint_to_int(block[0:2]) 
run/bitlocker2john.py:160: trailing whitespace.
+    value_type = uint_to_int(block[4:6]) 
run/bitlocker2john.py:219: trailing whitespace.
+        
run/bitlocker2john.py:226: trailing whitespace.
+        

@solardiz
Copy link
Member

solardiz commented Nov 7, 2024

Oh, we also need to add a doc/NEWS entry mentioning this contribution.

@holly-o holly-o force-pushed the bleeding-jumbo branch 2 times, most recently from 1e3e4cb to 1d33f8f Compare November 8, 2024 11:34
Updated README.Bitlocker to include Python script usage.
Fixed whitespace.
Updated doc/NEWS
@solardiz solardiz merged commit 74a3b7a into openwall:bleeding-jumbo Nov 9, 2024
35 of 36 checks passed
$bitlocker$0$16$4a67bc123abedc43d60b3ece78ec6d1e$1048558$12$a015f77b68aed80103000000$60$2dbacf4710d3d42aa4f7baeedff85d72fc892f8f3457271901c0d2eccc3de890f081b3335740a5b5f1473892569ec0455d1aa2fd0075ac073a5f7b2a
$bitlocker$1$16$4a67bc123abedc43d60b3ece78ec6d1e$1048558$12$a015f77b68aed80103000000$60$2dbacf4710d3d42aa4f7baeedff85d72fc892f8f3457271901c0d2eccc3de890f081b3335740a5b5f1473892569ec0455d1aa2fd0075ac073a5f7b2a
$bitlocker$2$16$4b10ca85ab17a7419990d92f75abc848$1048558$12$a015f77b68aed80106000000$60$11e39cfd4dc9f647cef46b843347a3677c0706d3653f3477d44c72c8e36e8e02e010744dc384a419ff487a0190b42da0a29229d57a0bc3c6a7193f7
$bitlocker$3$16$4b10ca85ab17a7419990d92f75abc848$1048558$12$a015f77b68aed80106000000$60$11e39cfd4dc9f647cef46b843347a3677c0706d3653f3477d44c72c8e36e8e02e010744dc384a419ff487a0190b42da0a29229d57a0bc3c6a7193f7
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've just merged this PR (thanks!) but now I notice that the two example Recovery Password "hashes" given here are somehow one character too short - last field is 119 instead of 120 chars. Do we maybe have a bug where a leading zero is omitted? In my testing of the script, I got all strings of the same length, but maybe I just didn't trigger that bug.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not seeing such bug in the current script, so maybe it was in some older revision? I think I'll "fix" these "hashes" by inserting a 0 after $60$, just so that they're a correct illustration. But I'd appreciate @holly-o's comments here.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I edited one of my known hashes to add as an example, and accidentally removed a character. The script should always output len 120.
Thanks for your fix!

@exploide
Copy link
Contributor

exploide commented Nov 9, 2024

@exploide You might want to help us review this, although since it's a new script we can as well merge first - it shouldn't hurt.

Sorry for being late. I had a quick look, no deep dive or actual testing but I think it looks good. Only some formatting things or minor idiomatic points. Noting that needs a fix now and it's probably fine being merged.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants