#!/usr/bin/env python3 """Extract only the application assembly from a locally supplied .NET bundle. No downloading or execution of the original application. Output remains private analysis material; it is not needed at runtime and must not be distributed here. """ import argparse import io from pathlib import Path import struct import zlib parser = argparse.ArgumentParser(description=__doc__) parser.add_argument('exe', type=Path) parser.add_argument('output', type=Path, help='Output DLL path, outside this project') args = parser.parse_args() data = args.exe.read_bytes() signature = bytes.fromhex('8b1202b96a612038727b930214d7a03213f5b9e6efae3318ee3b2dce24b36aae') position = data.find(signature) if position < 8: parser.error('No .NET bundle signature found') offset = struct.unpack_from(' 4096: raise ValueError('Unexpected string length') return stream.read(length).decode('utf-8') raise ValueError('Invalid string prefix') major, minor, count = unpack('