1
0
mirror of https://github.com/hashcat/hashcat.git synced 2025-07-19 13:08:19 +00:00
hashcat/tools/shiro1-to-hashcat.py
Jens Steube 51e47daa1d Fix detection of argon2 kernel_accel_new. Ensure user-defined -n value does not exceed available memory; reduce it if necessary. On devices with unified memory (iGPU), only half of the memory is made available.
Improve unit test for -m 8300. In optimized mode, allow longer passwords, domain names, and salts. In both optimized and pure modes, ensure the domain name does not exceed 63 characters.
Fix SNMPv3 unit test to produce passwords of at least 8 characters, as required by RFC 3414.
Fix file permissions in tools/ folder.
2025-07-14 11:30:21 +02:00

57 lines
1.8 KiB
Python
Executable File

import os
import re
import glob
import argparse
def extract_hashes_from_pcl(file_path):
shiro_pattern = re.compile(br'\$shiro1\$SHA-512\$(\d+)\$[A-Za-z0-9+/=]+\$[A-Za-z0-9+/=]+')
try:
with open(file_path, 'rb') as f:
data = f.read()
matches = shiro_pattern.finditer(data)
extracted_hashes = []
for match in matches:
full_match = match.group(0).decode()
print(f'[+] Found Shiro 1 hash: {full_match}')
extracted_hashes.append(full_match)
if not extracted_hashes:
print(f"No Shiro 1 hashes found in {file_path}")
return None
return extracted_hashes
except Exception as e:
print(f"Failed to parse {file_path}: {e}")
return None
def main():
parser = argparse.ArgumentParser(description="Extract Apache Shiro 1 hashes from .pcl files for use with Hashcat.")
parser.add_argument("input_dir", help="Directory path containing the .pcl files")
parser.add_argument("output_file", help="Output file to save the hashes")
args = parser.parse_args()
pcl_files = glob.glob(os.path.join(args.input_dir, '*.pcl'))
all_hashes = []
for pcl_file in pcl_files:
print(f"Processing {pcl_file}")
hashes = extract_hashes_from_pcl(pcl_file)
if hashes:
all_hashes.extend(hashes)
if all_hashes:
with open(args.output_file, 'w') as f:
for hashcat_hash in all_hashes:
f.write(f"{hashcat_hash}\n")
print(f"Extracted hashes have been saved to {args.output_file}!\nTotal hashes: {len(all_hashes)}\nRun hashcat with mode 12150!")
else:
print("No hashes were extracted.")
if __name__ == '__main__':
main()