yes
This commit is contained in:
commit
9c3189cac2
3219 files changed
+1984040
No files matched your search
@@ -0,0 +1,138 @@
|
||||
#!/usr/bin/env python3
|
||||
"""
|
||||
run_chacha_capture.py - Capture ChaCha20 session keys from game process.
|
||||
Attaches to running game and hooks the ChaCha20 implementation to extract keys.
|
||||
The captured key+nonce can then be used by the MITM proxy to decrypt traffic.
|
||||
"""
|
||||
|
||||
import frida
|
||||
import sys
|
||||
import os
|
||||
import time
|
||||
import json
|
||||
|
||||
SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__))
|
||||
JS_PATH = os.path.join(SCRIPT_DIR, 'capture_chacha_key.js')
|
||||
PROCESS_NAME = 'Paralogue-Win64-Shipping.exe'
|
||||
OUTPUT_DIR = os.path.join(SCRIPT_DIR, 'captures')
|
||||
os.makedirs(OUTPUT_DIR, exist_ok=True)
|
||||
|
||||
KEY_FILE = os.path.join(OUTPUT_DIR, 'chacha_session_key.json')
|
||||
|
||||
captured_keys = []
|
||||
chacha_states = []
|
||||
|
||||
|
||||
def on_message(message, data):
|
||||
if message['type'] == 'error':
|
||||
print(f'[!] {message["description"]}')
|
||||
return
|
||||
|
||||
p = message.get('payload', {})
|
||||
if not isinstance(p, dict):
|
||||
return
|
||||
|
||||
t = p.get('t', '')
|
||||
|
||||
if t == 'ready':
|
||||
print(f'[*] {p["msg"]}')
|
||||
elif t == 'info':
|
||||
print(f'[*] {p["msg"]}')
|
||||
elif t == 'status':
|
||||
print(f'[*] Status: {p["calls"]} ChaCha20 calls, {p["unique_keys"]} unique keys')
|
||||
elif t in ('chacha_key', 'chacha_key_avx'):
|
||||
src = 'AVX' if t == 'chacha_key_avx' else 'ENTRY'
|
||||
key = p['key']
|
||||
nonce = p['nonce']
|
||||
counter = p['counter']
|
||||
r8 = p.get('r8_data', 'N/A')
|
||||
call_num = p.get('call_num', 0)
|
||||
|
||||
print(f'\n{"="*60}')
|
||||
print(f' *** ChaCha20 KEY CAPTURED ({src}) ***')
|
||||
print(f' Call #{call_num}')
|
||||
print(f' Key (32B): {key}')
|
||||
print(f' Nonce (12B): {nonce}')
|
||||
print(f' Counter: {counter}')
|
||||
if r8 != 'N/A':
|
||||
print(f' r8 data: {r8}')
|
||||
print(f'{"="*60}\n')
|
||||
|
||||
entry = {
|
||||
'source': src,
|
||||
'key_hex': key,
|
||||
'nonce_hex': nonce,
|
||||
'counter_hex': counter,
|
||||
'r8_data': r8,
|
||||
'call_num': call_num,
|
||||
'timestamp': time.time()
|
||||
}
|
||||
captured_keys.append(entry)
|
||||
|
||||
# Save immediately
|
||||
with open(KEY_FILE, 'w') as f:
|
||||
json.dump(captured_keys, f, indent=2)
|
||||
print(f' Saved to {KEY_FILE}')
|
||||
|
||||
elif t == 'chacha_state' and data:
|
||||
raw = bytes(data)
|
||||
chacha_states.append(raw)
|
||||
state_file = os.path.join(OUTPUT_DIR, f'chacha_state_{len(chacha_states)}.bin')
|
||||
with open(state_file, 'wb') as f:
|
||||
f.write(raw)
|
||||
print(f' State binary saved to {state_file}')
|
||||
|
||||
|
||||
def main():
|
||||
print('=' * 60)
|
||||
print(' ChaCha20 Key Capture Tool')
|
||||
print(' Attach to game and capture encryption keys at runtime')
|
||||
print('=' * 60)
|
||||
|
||||
with open(JS_PATH, 'r') as f:
|
||||
js_code = f.read()
|
||||
|
||||
# Find the game process
|
||||
session = None
|
||||
print(f'[*] Looking for {PROCESS_NAME}...')
|
||||
while True:
|
||||
try:
|
||||
device = frida.get_local_device()
|
||||
for proc in device.enumerate_processes():
|
||||
if proc.name == PROCESS_NAME:
|
||||
print(f'[*] Found {PROCESS_NAME} (PID {proc.pid}), attaching...')
|
||||
session = frida.attach(proc.pid)
|
||||
break
|
||||
if session:
|
||||
break
|
||||
except frida.ProcessNotFoundError:
|
||||
pass
|
||||
except Exception as e:
|
||||
print(f'[!] {e}')
|
||||
time.sleep(1)
|
||||
|
||||
print(f'[*] Attached. Installing ChaCha20 hooks...')
|
||||
script = session.create_script(js_code)
|
||||
script.on('message', on_message)
|
||||
script.load()
|
||||
|
||||
print('[*] Hooks active. Connect to a server in-game to trigger encryption.')
|
||||
print('[*] Keys will be saved to captures/chacha_session_key.json')
|
||||
print('[*] Press Ctrl+C to stop.\n')
|
||||
|
||||
try:
|
||||
while True:
|
||||
time.sleep(0.5)
|
||||
except KeyboardInterrupt:
|
||||
pass
|
||||
|
||||
print(f'\n[*] Captured {len(captured_keys)} unique keys.')
|
||||
if captured_keys:
|
||||
print(f'[*] Keys saved to {KEY_FILE}')
|
||||
|
||||
session.detach()
|
||||
print('[*] Done.')
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
Reference in new issue
Block a user