So I'm having an issue with HashCat not being able to crack a hash. I have written a python program that cracks it just fine but I don't think I am entering the mask right for hashcat. I've tried ?b and ?h since the key that the python program brings back is a hex string bf851a
hashcat -m 1410 -a 3 c88cedb68bf463557d9fee922b43fb3e6de00472b98c12e492d24f0774512f72:595d5727ecd598bc ?b?b?b
Here is the Python code for reference:
def
sha256(ascii_input: str) -> str:
byte_input = ascii_input.encode('latin-1')
# Using 'latin-1' to match previous behavior
return
hashlib.sha256(byte_input).hexdigest()
def
int_to_uint8_array(num: int, length: int) -> bytes:
return
num.to_bytes(length, byteorder='big')
def
find_key(hash_input: str, min_bits: int, max_bits: int) -> Optional[str]:
salt = bytes([89, 93, 87, 39, 236, 213, 152, 188])
salt_hex = salt.hex()
print("Salt:", list(salt))
print("Hex Salt:", salt_hex)
for
y
in
range(min_bits, max_bits):
min_key = 2 ** y
max_key = 2 ** (y + 1)
for
i
in
range(min_key, max_key):
byte_length = math.ceil((y + 1) / 8)
key_bytes = int_to_uint8_array(i, byte_length)
key_hex = key_bytes.hex()
# Concatenate key bytes with salt
salted_key = key_bytes + salt
# Convert to ASCII string using 'latin-1'
ascii_str = salted_key.decode('latin-1')
# Compute SHA-256 hash using hashlib
current_hash = sha256(ascii_str)
if
current_hash == hash_input:
print(f"Key found: {key_hex}")
return key_hex
if i % 1000000 == 0:
print(f"Checked key: {key_hex}")
print('Search complete. Key not found.')
return NoneAny help on this would be greatly appreciated.