"""Private stdio bridge to the pinned user's game. No credentials, socket server or request replay."""
import argparse, hashlib, json, pathlib, sys
sys.stdin.reconfigure(encoding='utf-8')
sys.stdout.reconfigure(encoding='utf-8')
sys.stderr.reconfigure(encoding='utf-8')
def main():
p = argparse.ArgumentParser()
p.add_argument('--pid', type=int, required=True)
p.add_argument('--image', type=pathlib.Path, required=True)
p.add_argument('--sha256', required=True)
args = p.parse_args()
supported = 'e6be8bbe04e6a7ae226d4318945af7f367de13dc5a007a261964d9ba8144e988'
if args.image.name.lower() != 'elitedangerous64.exe':
raise ValueError('Unexpected game image')
with args.image.open('rb') as image:
actual = hashlib.file_digest(image, 'sha256').hexdigest()
if actual != supported or args.sha256.lower() != supported:
raise ValueError('Unsupported game image; native offsets were not verified for this build')
import frida
device = frida.get_local_device()
found = next((x for x in device.enumerate_processes(scope='full') if x.pid == args.pid), None)
if found is None or pathlib.Path(found.parameters.get('path', '')).resolve() != args.image.resolve():
raise ValueError('Native process identity differs from the selected image')
session = device.attach(args.pid)
script = session.create_script(pathlib.Path(__file__).with_name('native-agent.js').read_text(encoding='utf-8'))
script.on('message', lambda message, data: print('Native observer diagnostic: ' + str(message.get('description', message.get('type', 'unknown'))), file=sys.stderr) if message.get('type') == 'error' else None)
try:
script.load()
for line in sys.stdin:
request_id = ''
try:
if len(line) > 32768:
raise ValueError('Native request too large')
request = json.loads(line)
request_id = request['id']
method = request['method']
if method == 'describe': result = script.exports_sync.describe()
elif method == 'native.state': result = script.exports_sync.readstate()
elif method == 'commands.cancel': result = script.exports_sync.cancel()
else: raise ValueError('Native command has no verified handler: ' + method)
print(json.dumps({'id': request_id, 'ok': True, 'result': result}, ensure_ascii=False), flush=True)
except Exception as error:
print(json.dumps({'id': request_id, 'ok': False, 'error': str(error)[:500]}, ensure_ascii=False), flush=True)
finally:
try: script.unload()
finally: session.detach()
if __name__ == '__main__':
try: main()
except Exception as error:
print(type(error).__name__ + ': ' + str(error)[:500], file=sys.stderr)
sys.exit(1)
"""Private stdio bridge to the pinned user's game. No credentials, socket server or request replay."""
import argparse, hashlib, json, pathlib, sys
sys.stdin.reconfigure(encoding='utf-8')
sys.stdout.reconfigure(encoding='utf-8')
sys.stderr.reconfigure(encoding='utf-8')
def main():
p = argparse.ArgumentParser()
p.add_argument('--pid', type=int, required=True)
p.add_argument('--image', type=pathlib.Path, required=True)
p.add_argument('--sha256', required=True)
args = p.parse_args()
supported = 'e6be8bbe04e6a7ae226d4318945af7f367de13dc5a007a261964d9ba8144e988'
if args.image.name.lower() != 'elitedangerous64.exe':
raise ValueError('Unexpected game image')
with args.image.open('rb') as image:
actual = hashlib.file_digest(image, 'sha256').hexdigest()
if actual != supported or args.sha256.lower() != supported:
raise ValueError('Unsupported game image; native offsets were not verified for this build')
import frida
device = frida.get_local_device()
found = next((x for x in device.enumerate_processes(scope='full') if x.pid == args.pid), None)
if found is None or pathlib.Path(found.parameters.get('path', '')).resolve() != args.image.resolve():
raise ValueError('Native process identity differs from the selected image')
session = device.attach(args.pid)
script = session.create_script(pathlib.Path(__file__).with_name('native-agent.js').read_text(encoding='utf-8'))
script.on('message', lambda message, data: print('Native observer diagnostic: ' + str(message.get('description', message.get('type', 'unknown'))), file=sys.stderr) if message.get('type') == 'error' else None)
try:
script.load()
for line in sys.stdin:
request_id = ''
try:
if len(line) > 32768:
raise ValueError('Native request too large')
request = json.loads(line)
request_id = request['id']
method = request['method']
if method == 'describe': result = script.exports_sync.describe()
elif method == 'native.state': result = script.exports_sync.readstate()
elif method == 'commands.cancel': result = script.exports_sync.cancel()
else: raise ValueError('Native command has no verified handler: ' + method)
print(json.dumps({'id': request_id, 'ok': True, 'result': result}, ensure_ascii=False), flush=True)
except Exception as error:
print(json.dumps({'id': request_id, 'ok': False, 'error': str(error)[:500]}, ensure_ascii=False), flush=True)
finally:
try: script.unload()
finally: session.detach()
if __name__ == '__main__':
try: main()
except Exception as error:
print(type(error).__name__ + ': ' + str(error)[:500], file=sys.stderr)
sys.exit(1)