meltedinhex/analyst-ai-pack / skills/reverse-engineering-custom-c2-protocols
reverse-engineering-custom-c2-protocols
VerifiedReverses proprietary command-and-control protocols: locating send/recv routines, recovering the message framing and encryption/encoding, and reconstructing the command set to build a decoder or emulator. Activates for requests to reverse a custom C2 protocol, decode beacon traffic, or document a malware command structure.
| File | Kind | Size |
|---|---|---|
| LICENSE | other | 340 B |
| SKILL.md | skill md | 3.3 KB |
| references/api-reference.md | markdown | 1.1 KB |
| scripts/analyst.py | script | 2.0 KB |
scripts/analyst.py
View on GitHub#!/usr/bin/env python3
"""Decode a simple length-prefixed, XOR-obfuscated C2 message stream.
This is a configurable reference decoder for the common framing
``[magic][len LE][opcode][flags][payload]`` with a single-byte XOR over the payload. Adjust the
field sizes/crypto to match the protocol you reversed. It only parses bytes from a capture
file; it makes no network connections.
"""
from __future__ import annotations
import argparse
import json
import struct
import sys
from pathlib import Path
def xor(data: bytes, key: int) -> bytes:
return bytes(b ^ key for b in data)
def decode(stream: bytes, key: int, magic: bytes) -> dict:
messages = []
off = 0
n = len(stream)
while off + 10 <= n:
if stream[off:off + len(magic)] != magic:
off += 1
continue
p = off + len(magic)
(length,) = struct.unpack_from("<I", stream, p)
opcode = stream[p + 4]
flags = stream[p + 5]
start = p + 6
end = start + length
if end > n:
break
payload = xor(stream[start:end], key)
messages.append({
"offset": off,
"opcode": opcode,
"flags": flags,
"length": length,
"payload_preview": payload[:64].decode("latin-1"),
})
off = end
return {"messages": messages, "count": len(messages)}
def main(argv: list[str] | None = None) -> int:
parser = argparse.ArgumentParser(description="Decode custom C2 framing")
sub = parser.add_subparsers(dest="cmd", required=True)
p = sub.add_parser("decode")
p.add_argument("file")
p.add_argument("--key", default="0x00", help="single-byte XOR key, e.g. 0x5a")
p.add_argument("--magic", default="", help="hex magic prefix, e.g. 4d5a4331")
args = parser.parse_args(argv)
stream = Path(args.file).read_bytes()
magic = bytes.fromhex(args.magic) if args.magic else b""
print(json.dumps(decode(stream, int(args.key, 0), magic), indent=2))
return 0
if __name__ == "__main__":
sys.exit(main())
Related skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| slack-gif-creatoranthropics/skillsKnowledge and utilities for creating animated GIFs optimized for Slack. Provides constraints, validation tools, and animation concepts. Use when users request animated GIFs for Slack like "make me a GIF of X doing Y for Slack." | Stars: 197k | Updated | Claude CodeCodex | Verified | Install |
| ponytailDietrichGebert/ponytailLazy senior dev mode for any coding task: the smallest change that fully solves it, and a reply a busy human understands in one read. | Stars: 194k | Updated | Claude CodeCodex | Verified | Install |
| ponytail-debtDietrichGebert/ponytailHarvest every shortcut: comment into one debt ledger, so deferrals get tracked instead of forgotten. One-shot report. | Stars: 194k | Updated | Claude CodeCodex | Verified | Install |
| ponytail-debtDietrichGebert/ponytailList every `shortcut:` comment (and older `ponytail:` ones) as a debt ledger. One-shot report, changes nothing. Use for "ponytail debt", "what did ponytail defer", "list the shortcuts", /ponytail-debt. | Stars: 194k | Updated | Claude CodeCodex | Verified | Install |