mirror of
https://github.com/hashcat/hashcat.git
synced 2024-11-22 08:08:10 +00:00
Tool truecrypt2hashcat.py code cleanup
This commit is contained in:
parent
f7ba563a28
commit
e5352ac401
@ -1,5 +1,10 @@
|
|||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
|
|
||||||
|
#
|
||||||
|
# Author......: See docs/credits.txt
|
||||||
|
# License.....: MIT
|
||||||
|
#
|
||||||
|
|
||||||
from argparse import ArgumentParser, ArgumentTypeError
|
from argparse import ArgumentParser, ArgumentTypeError
|
||||||
|
|
||||||
|
|
||||||
@ -23,9 +28,10 @@ def validate_offset(offset):
|
|||||||
offset = BOOTABLE_OFFSET + HIDDEN_OFFSET
|
offset = BOOTABLE_OFFSET + HIDDEN_OFFSET
|
||||||
try:
|
try:
|
||||||
offset = int(offset)
|
offset = int(offset)
|
||||||
assert offset >= 0
|
except ValueError as e:
|
||||||
except (AssertionError, ValueError):
|
raise ArgumentTypeError("value is nether number nor allowed string") from e
|
||||||
raise ArgumentTypeError("offset is nether non-negative number nor bootable, hidden or bootable+hidden value")
|
if offset < 0:
|
||||||
|
raise ArgumentTypeError("value cannot be less than zero")
|
||||||
return offset
|
return offset
|
||||||
|
|
||||||
|
|
||||||
@ -42,14 +48,18 @@ if __name__ == "__main__":
|
|||||||
|
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
|
|
||||||
|
try:
|
||||||
with open(args.path, "rb") as file:
|
with open(args.path, "rb") as file:
|
||||||
file.seek(args.offset)
|
file.seek(args.offset)
|
||||||
|
|
||||||
header = file.read(HEADER_LENGTH)
|
header = file.read(HEADER_LENGTH)
|
||||||
|
|
||||||
assert len(header) == HEADER_LENGTH, "less data than needed"
|
if len(header) < HEADER_LENGTH:
|
||||||
|
parser.error("file contains less data than needed")
|
||||||
|
|
||||||
salt, data = header[:SALT_LENGTH], header[SALT_LENGTH:]
|
salt, data = header[:SALT_LENGTH], header[SALT_LENGTH:]
|
||||||
|
|
||||||
hash = SIGNATURE + salt.hex() + "$" + data.hex()
|
hash = SIGNATURE + salt.hex() + "$" + data.hex()
|
||||||
print(hash)
|
print(hash)
|
||||||
|
except IOError as e:
|
||||||
|
parser.error(e.strerror.lower())
|
||||||
|
Loading…
Reference in New Issue
Block a user