Files
ctf/2026/insomnihack/misc/extract_private_keys.py
2026-03-22 21:54:37 +01:00

15 lines
340 B
Python

import re
with open('./mdumpng.bin', 'rb') as f:
data = f.read().decode('utf-8')
# Find all complete RSA keys
keys = re.findall(
r'-----BEGIN (?:RSA|OPENSSH) PRIVATE KEY-----[\s\S]{100,3000}?-----END (?:RSA|OPENSSH) PRIVATE KEY-----',
data
)
for i, k in enumerate(keys):
print(f"=== KEY {i} ===")
print(k)
print()