[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M7BWP089VPJH1TZDANQYDBF2":3,"skill-same:01M7BWP089VPJH1TZDANQYDBF2":47},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":16,"categories":17,"keywords":18,"publishedAt":19,"linkOnly":20,"markdownContent":21,"markdownBody":22,"frontMatter":23,"refName":24,"commitSha":25,"skillDirectory":26,"forksCount":27,"repositoryHtmlUrl":28,"repositoryHomepageUrl":29,"ownerHtmlUrl":30,"ownerBlogUrl":6,"ownerDescription":31,"updatedAt":32,"install":33,"resources":46},"01M7BWP089VPJH1TZDANQYDBF2","protocol-reverse-engineering",null,"Master network protocol reverse engineering including packet analysis, protocol dissection, and custom protocol documentation. Use when analyzing network traffic, understanding proprietary protocols, or debugging network communication.","YYC-Cube\u002FYYC3-Knowledge-Base","YYC-Cube","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F235006543?v=4","01M79J2PH4SWD2X0825X6PN748","yyc3","01M79J2PHVK3F6ZBYT8K2SCZCW",1,"MIT","https:\u002F\u002Fgithub.com\u002FYYC-Cube\u002FYYC3-Knowledge-Base\u002Fblob\u002Fmain\u002FYYC3-Plugin-插件协议\u002FYYC3-Plugin-插件协议-plugins-claude\u002Freverse-engineering\u002Fskills\u002Fprotocol-reverse-engineering\u002FSKILL.md",[],[],"2026-11-15 14:19:17",false,"---\nname: protocol-reverse-engineering\ndescription: Master network protocol reverse engineering including packet analysis, protocol dissection, and custom protocol documentation. Use when analyzing network traffic, understanding proprietary protocols, or debugging network communication.\n---\n\n# Protocol Reverse Engineering\n\nComprehensive techniques for capturing, analyzing, and documenting network protocols for security research, interoperability, and debugging.\n\n## Traffic Capture\n\n### Wireshark Capture\n\n```bash\n# Capture on specific interface\nwireshark -i eth0 -k\n\n# Capture with filter\nwireshark -i eth0 -k -f \"port 443\"\n\n# Capture to file\ntshark -i eth0 -w capture.pcap\n\n# Ring buffer capture (rotate files)\ntshark -i eth0 -b filesize:100000 -b files:10 -w capture.pcap\n```\n\n### tcpdump Capture\n\n```bash\n# Basic capture\ntcpdump -i eth0 -w capture.pcap\n\n# With filter\ntcpdump -i eth0 port 8080 -w capture.pcap\n\n# Capture specific bytes\ntcpdump -i eth0 -s 0 -w capture.pcap  # Full packet\n\n# Real-time display\ntcpdump -i eth0 -X port 80\n```\n\n### Man-in-the-Middle Capture\n\n```bash\n# mitmproxy for HTTP\u002FHTTPS\nmitmproxy --mode transparent -p 8080\n\n# SSL\u002FTLS interception\nmitmproxy --mode transparent --ssl-insecure\n\n# Dump to file\nmitmdump -w traffic.mitm\n\n# Burp Suite\n# Configure browser proxy to 127.0.0.1:8080\n```\n\n## Protocol Analysis\n\n### Wireshark Analysis\n\n```\n# Display filters\ntcp.port == 8080\nhttp.request.method == \"POST\"\nip.addr == 192.168.1.1\ntcp.flags.syn == 1 && tcp.flags.ack == 0\nframe contains \"password\"\n\n# Following streams\nRight-click > Follow > TCP Stream\nRight-click > Follow > HTTP Stream\n\n# Export objects\nFile > Export Objects > HTTP\n\n# Decryption\nEdit > Preferences > Protocols > TLS\n  - (Pre)-Master-Secret log filename\n  - RSA keys list\n```\n\n### tshark Analysis\n\n```bash\n# Extract specific fields\ntshark -r capture.pcap -T fields -e ip.src -e ip.dst -e tcp.port\n\n# Statistics\ntshark -r capture.pcap -q -z conv,tcp\ntshark -r capture.pcap -q -z endpoints,ip\n\n# Filter and extract\ntshark -r capture.pcap -Y \"http\" -T json > http_traffic.json\n\n# Protocol hierarchy\ntshark -r capture.pcap -q -z io,phs\n```\n\n### Scapy for Custom Analysis\n\n```python\nfrom scapy.all import *\n\n# Read pcap\npackets = rdpcap(\"capture.pcap\")\n\n# Analyze packets\nfor pkt in packets:\n    if pkt.haslayer(TCP):\n        print(f\"Src: {pkt[IP].src}:{pkt[TCP].sport}\")\n        print(f\"Dst: {pkt[IP].dst}:{pkt[TCP].dport}\")\n        if pkt.haslayer(Raw):\n            print(f\"Data: {pkt[Raw].load[:50]}\")\n\n# Filter packets\nhttp_packets = [p for p in packets if p.haslayer(TCP)\n                and (p[TCP].sport == 80 or p[TCP].dport == 80)]\n\n# Create custom packets\npkt = IP(dst=\"target\")\u002FTCP(dport=80)\u002FRaw(load=\"GET \u002F HTTP\u002F1.1\\r\\n\")\nsend(pkt)\n```\n\n## Protocol Identification\n\n### Common Protocol Signatures\n\n```\nHTTP        - \"HTTP\u002F1.\" or \"GET \" or \"POST \" at start\nTLS\u002FSSL     - 0x16 0x03 (record layer)\nDNS         - UDP port 53, specific header format\nSMB         - 0xFF 0x53 0x4D 0x42 (\"SMB\" signature)\nSSH         - \"SSH-2.0\" banner\nFTP         - \"220 \" response, \"USER \" command\nSMTP        - \"220 \" banner, \"EHLO\" command\nMySQL       - 0x00 length prefix, protocol version\nPostgreSQL  - 0x00 0x00 0x00 startup length\nRedis       - \"*\" RESP array prefix\nMongoDB     - BSON documents with specific header\n```\n\n### Protocol Header Patterns\n\n```\n+--------+--------+--------+--------+\n|  Magic number \u002F Signature         |\n+--------+--------+--------+--------+\n|  Version       |  Flags          |\n+--------+--------+--------+--------+\n|  Length        |  Message Type   |\n+--------+--------+--------+--------+\n|  Sequence Number \u002F Session ID     |\n+--------+--------+--------+--------+\n|  Payload...                       |\n+--------+--------+--------+--------+\n```\n\n## Binary Protocol Analysis\n\n### Structure Identification\n\n```python\n# Common patterns in binary protocols\n\n# Length-prefixed message\nstruct Message {\n    uint32_t length;      # Total message length\n    uint16_t msg_type;    # Message type identifier\n    uint8_t  flags;       # Flags\u002Foptions\n    uint8_t  reserved;    # Padding\u002Falignment\n    uint8_t  payload[];   # Variable-length payload\n};\n\n# Type-Length-Value (TLV)\nstruct TLV {\n    uint8_t  type;        # Field type\n    uint16_t length;      # Field length\n    uint8_t  value[];     # Field data\n};\n\n# Fixed header + variable payload\nstruct Packet {\n    uint8_t  magic[4];    # \"ABCD\" signature\n    uint32_t version;\n    uint32_t payload_len;\n    uint32_t checksum;    # CRC32 or similar\n    uint8_t  payload[];\n};\n```\n\n### Python Protocol Parser\n\n```python\nimport struct\nfrom dataclasses import dataclass\n\n@dataclass\nclass MessageHeader:\n    magic: bytes\n    version: int\n    msg_type: int\n    length: int\n\n    @classmethod\n    def from_bytes(cls, data: bytes):\n        magic, version, msg_type, length = struct.unpack(\n            \">4sHHI\", data[:12]\n        )\n        return cls(magic, version, msg_type, length)\n\ndef parse_messages(data: bytes):\n    offset = 0\n    messages = []\n\n    while offset \u003C len(data):\n        header = MessageHeader.from_bytes(data[offset:])\n        payload = data[offset+12:offset+12+header.length]\n        messages.append((header, payload))\n        offset += 12 + header.length\n\n    return messages\n\n# Parse TLV structure\ndef parse_tlv(data: bytes):\n    fields = []\n    offset = 0\n\n    while offset \u003C len(data):\n        field_type = data[offset]\n        length = struct.unpack(\">H\", data[offset+1:offset+3])[0]\n        value = data[offset+3:offset+3+length]\n        fields.append((field_type, value))\n        offset += 3 + length\n\n    return fields\n```\n\n### Hex Dump Analysis\n\n```python\ndef hexdump(data: bytes, width: int = 16):\n    \"\"\"Format binary data as hex dump.\"\"\"\n    lines = []\n    for i in range(0, len(data), width):\n        chunk = data[i:i+width]\n        hex_part = ' '.join(f'{b:02x}' for b in chunk)\n        ascii_part = ''.join(\n            chr(b) if 32 \u003C= b \u003C 127 else '.'\n            for b in chunk\n        )\n        lines.append(f'{i:08x}  {hex_part:\u003C{width*3}}  {ascii_part}')\n    return '\\n'.join(lines)\n\n# Example output:\n# 00000000  48 54 54 50 2f 31 2e 31  20 32 30 30 20 4f 4b 0d  HTTP\u002F1.1 200 OK.\n# 00000010  0a 43 6f 6e 74 65 6e 74  2d 54 79 70 65 3a 20 74  .Content-Type: t\n```\n\n## Encryption Analysis\n\n### Identifying Encryption\n\n```python\n# Entropy analysis - high entropy suggests encryption\u002Fcompression\nimport math\nfrom collections import Counter\n\ndef entropy(data: bytes) -> float:\n    if not data:\n        return 0.0\n    counter = Counter(data)\n    probs = [count \u002F len(data) for count in counter.values()]\n    return -sum(p * math.log2(p) for p in probs)\n\n# Entropy thresholds:\n# \u003C 6.0: Likely plaintext or structured data\n# 6.0-7.5: Possibly compressed\n# > 7.5: Likely encrypted or random\n\n# Common encryption indicators\n# - High, uniform entropy\n# - No obvious structure or patterns\n# - Length often multiple of block size (16 for AES)\n# - Possible IV at start (16 bytes for AES-CBC)\n```\n\n### TLS Analysis\n\n```bash\n# Extract TLS metadata\ntshark -r capture.pcap -Y \"ssl.handshake\" \\\n    -T fields -e ip.src -e ssl.handshake.ciphersuite\n\n# JA3 fingerprinting (client)\ntshark -r capture.pcap -Y \"ssl.handshake.type == 1\" \\\n    -T fields -e ssl.handshake.ja3\n\n# JA3S fingerprinting (server)\ntshark -r capture.pcap -Y \"ssl.handshake.type == 2\" \\\n    -T fields -e ssl.handshake.ja3s\n\n# Certificate extraction\ntshark -r capture.pcap -Y \"ssl.handshake.certificate\" \\\n    -T fields -e x509sat.printableString\n```\n\n### Decryption Approaches\n\n```bash\n# Pre-master secret log (browser)\nexport SSLKEYLOGFILE=\u002Ftmp\u002Fkeys.log\n\n# Configure Wireshark\n# Edit > Preferences > Protocols > TLS\n# (Pre)-Master-Secret log filename: \u002Ftmp\u002Fkeys.log\n\n# Decrypt with private key (if available)\n# Only works for RSA key exchange\n# Edit > Preferences > Protocols > TLS > RSA keys list\n```\n\n## Custom Protocol Documentation\n\n### Protocol Specification Template\n\n```markdown\n# Protocol Name Specification\n\n## Overview\n\nBrief description of protocol purpose and design.\n\n## Transport\n\n- Layer: TCP\u002FUDP\n- Port: XXXX\n- Encryption: TLS 1.2+\n\n## Message Format\n\n### Header (12 bytes)\n\n| Offset | Size | Field   | Description             |\n| ------ | ---- | ------- | ----------------------- |\n| 0      | 4    | Magic   | 0x50524F54 (\"PROT\")     |\n| 4      | 2    | Version | Protocol version (1)    |\n| 6      | 2    | Type    | Message type identifier |\n| 8      | 4    | Length  | Payload length in bytes |\n\n### Message Types\n\n| Type | Name      | Description            |\n| ---- | --------- | ---------------------- |\n| 0x01 | HELLO     | Connection initiation  |\n| 0x02 | HELLO_ACK | Connection accepted    |\n| 0x03 | DATA      | Application data       |\n| 0x04 | CLOSE     | Connection termination |\n\n### Type 0x01: HELLO\n\n| Offset | Size | Field      | Description              |\n| ------ | ---- | ---------- | ------------------------ |\n| 0      | 4    | ClientID   | Unique client identifier |\n| 4      | 2    | Flags      | Connection flags         |\n| 6      | var  | Extensions | TLV-encoded extensions   |\n\n## State Machine\n```\n\n[INIT] --HELLO--> [WAIT_ACK] --HELLO_ACK--> [CONNECTED]\n|\nDATA\u002FDATA\n|\n[CLOSED] \u003C--CLOSE--+\n\n```\n\n## Examples\n### Connection Establishment\n```\n\nClient -> Server: HELLO (ClientID=0x12345678)\nServer -> Client: HELLO_ACK (Status=OK)\nClient -> Server: DATA (payload)\n\n```\n\n```\n\n### Wireshark Dissector (Lua)\n\n```lua\n-- custom_protocol.lua\nlocal proto = Proto(\"custom\", \"Custom Protocol\")\n\n-- Define fields\nlocal f_magic = ProtoField.string(\"custom.magic\", \"Magic\")\nlocal f_version = ProtoField.uint16(\"custom.version\", \"Version\")\nlocal f_type = ProtoField.uint16(\"custom.type\", \"Type\")\nlocal f_length = ProtoField.uint32(\"custom.length\", \"Length\")\nlocal f_payload = ProtoField.bytes(\"custom.payload\", \"Payload\")\n\nproto.fields = { f_magic, f_version, f_type, f_length, f_payload }\n\n-- Message type names\nlocal msg_types = {\n    [0x01] = \"HELLO\",\n    [0x02] = \"HELLO_ACK\",\n    [0x03] = \"DATA\",\n    [0x04] = \"CLOSE\"\n}\n\nfunction proto.dissector(buffer, pinfo, tree)\n    pinfo.cols.protocol = \"CUSTOM\"\n\n    local subtree = tree:add(proto, buffer())\n\n    -- Parse header\n    subtree:add(f_magic, buffer(0, 4))\n    subtree:add(f_version, buffer(4, 2))\n\n    local msg_type = buffer(6, 2):uint()\n    subtree:add(f_type, buffer(6, 2)):append_text(\n        \" (\" .. (msg_types[msg_type] or \"Unknown\") .. \")\"\n    )\n\n    local length = buffer(8, 4):uint()\n    subtree:add(f_length, buffer(8, 4))\n\n    if length > 0 then\n        subtree:add(f_payload, buffer(12, length))\n    end\nend\n\n-- Register for TCP port\nlocal tcp_table = DissectorTable.get(\"tcp.port\")\ntcp_table:add(8888, proto)\n```\n\n## Active Testing\n\n### Fuzzing with Boofuzz\n\n```python\nfrom boofuzz import *\n\ndef main():\n    session = Session(\n        target=Target(\n            connection=TCPSocketConnection(\"target\", 8888)\n        )\n    )\n\n    # Define protocol structure\n    s_initialize(\"HELLO\")\n    s_static(b\"\\x50\\x52\\x4f\\x54\")  # Magic\n    s_word(1, name=\"version\")       # Version\n    s_word(0x01, name=\"type\")       # Type (HELLO)\n    s_size(\"payload\", length=4)     # Length field\n    s_block_start(\"payload\")\n    s_dword(0x12345678, name=\"client_id\")\n    s_word(0, name=\"flags\")\n    s_block_end()\n\n    session.connect(s_get(\"HELLO\"))\n    session.fuzz()\n\nif __name__ == \"__main__\":\n    main()\n```\n\n### Replay and Modification\n\n```python\nfrom scapy.all import *\n\n# Replay captured traffic\npackets = rdpcap(\"capture.pcap\")\nfor pkt in packets:\n    if pkt.haslayer(TCP) and pkt[TCP].dport == 8888:\n        send(pkt)\n\n# Modify and replay\nfor pkt in packets:\n    if pkt.haslayer(Raw):\n        # Modify payload\n        original = pkt[Raw].load\n        modified = original.replace(b\"client\", b\"CLIENT\")\n        pkt[Raw].load = modified\n        # Recalculate checksums\n        del pkt[IP].chksum\n        del pkt[TCP].chksum\n        send(pkt)\n```\n\n## Best Practices\n\n### Analysis Workflow\n\n1. **Capture traffic**: Multiple sessions, different scenarios\n2. **Identify boundaries**: Message start\u002Fend markers\n3. **Map structure**: Fixed header, variable payload\n4. **Identify fields**: Compare multiple samples\n5. **Document format**: Create specification\n6. **Validate understanding**: Implement parser\u002Fgenerator\n7. **Test edge cases**: Fuzzing, boundary conditions\n\n### Common Patterns to Look For\n\n- Magic numbers\u002Fsignatures at message start\n- Version fields for compatibility\n- Length fields (often before variable data)\n- Type\u002Fopcode fields for message identification\n- Sequence numbers for ordering\n- Checksums\u002FCRCs for integrity\n- Timestamps for timing\n- Session\u002Fconnection identifiers\n","# Protocol Reverse Engineering\n\nComprehensive techniques for capturing, analyzing, and documenting network protocols for security research, interoperability, and debugging.\n\n## Traffic Capture\n\n### Wireshark Capture\n\n```bash\n# Capture on specific interface\nwireshark -i eth0 -k\n\n# Capture with filter\nwireshark -i eth0 -k -f \"port 443\"\n\n# Capture to file\ntshark -i eth0 -w capture.pcap\n\n# Ring buffer capture (rotate files)\ntshark -i eth0 -b filesize:100000 -b files:10 -w capture.pcap\n```\n\n### tcpdump Capture\n\n```bash\n# Basic capture\ntcpdump -i eth0 -w capture.pcap\n\n# With filter\ntcpdump -i eth0 port 8080 -w capture.pcap\n\n# Capture specific bytes\ntcpdump -i eth0 -s 0 -w capture.pcap  # Full packet\n\n# Real-time display\ntcpdump -i eth0 -X port 80\n```\n\n### Man-in-the-Middle Capture\n\n```bash\n# mitmproxy for HTTP\u002FHTTPS\nmitmproxy --mode transparent -p 8080\n\n# SSL\u002FTLS interception\nmitmproxy --mode transparent --ssl-insecure\n\n# Dump to file\nmitmdump -w traffic.mitm\n\n# Burp Suite\n# Configure browser proxy to 127.0.0.1:8080\n```\n\n## Protocol Analysis\n\n### Wireshark Analysis\n\n```\n# Display filters\ntcp.port == 8080\nhttp.request.method == \"POST\"\nip.addr == 192.168.1.1\ntcp.flags.syn == 1 && tcp.flags.ack == 0\nframe contains \"password\"\n\n# Following streams\nRight-click > Follow > TCP Stream\nRight-click > Follow > HTTP Stream\n\n# Export objects\nFile > Export Objects > HTTP\n\n# Decryption\nEdit > Preferences > Protocols > TLS\n  - (Pre)-Master-Secret log filename\n  - RSA keys list\n```\n\n### tshark Analysis\n\n```bash\n# Extract specific fields\ntshark -r capture.pcap -T fields -e ip.src -e ip.dst -e tcp.port\n\n# Statistics\ntshark -r capture.pcap -q -z conv,tcp\ntshark -r capture.pcap -q -z endpoints,ip\n\n# Filter and extract\ntshark -r capture.pcap -Y \"http\" -T json > http_traffic.json\n\n# Protocol hierarchy\ntshark -r capture.pcap -q -z io,phs\n```\n\n### Scapy for Custom Analysis\n\n```python\nfrom scapy.all import *\n\n# Read pcap\npackets = rdpcap(\"capture.pcap\")\n\n# Analyze packets\nfor pkt in packets:\n    if pkt.haslayer(TCP):\n        print(f\"Src: {pkt[IP].src}:{pkt[TCP].sport}\")\n        print(f\"Dst: {pkt[IP].dst}:{pkt[TCP].dport}\")\n        if pkt.haslayer(Raw):\n            print(f\"Data: {pkt[Raw].load[:50]}\")\n\n# Filter packets\nhttp_packets = [p for p in packets if p.haslayer(TCP)\n                and (p[TCP].sport == 80 or p[TCP].dport == 80)]\n\n# Create custom packets\npkt = IP(dst=\"target\")\u002FTCP(dport=80)\u002FRaw(load=\"GET \u002F HTTP\u002F1.1\\r\\n\")\nsend(pkt)\n```\n\n## Protocol Identification\n\n### Common Protocol Signatures\n\n```\nHTTP        - \"HTTP\u002F1.\" or \"GET \" or \"POST \" at start\nTLS\u002FSSL     - 0x16 0x03 (record layer)\nDNS         - UDP port 53, specific header format\nSMB         - 0xFF 0x53 0x4D 0x42 (\"SMB\" signature)\nSSH         - \"SSH-2.0\" banner\nFTP         - \"220 \" response, \"USER \" command\nSMTP        - \"220 \" banner, \"EHLO\" command\nMySQL       - 0x00 length prefix, protocol version\nPostgreSQL  - 0x00 0x00 0x00 startup length\nRedis       - \"*\" RESP array prefix\nMongoDB     - BSON documents with specific header\n```\n\n### Protocol Header Patterns\n\n```\n+--------+--------+--------+--------+\n|  Magic number \u002F Signature         |\n+--------+--------+--------+--------+\n|  Version       |  Flags          |\n+--------+--------+--------+--------+\n|  Length        |  Message Type   |\n+--------+--------+--------+--------+\n|  Sequence Number \u002F Session ID     |\n+--------+--------+--------+--------+\n|  Payload...                       |\n+--------+--------+--------+--------+\n```\n\n## Binary Protocol Analysis\n\n### Structure Identification\n\n```python\n# Common patterns in binary protocols\n\n# Length-prefixed message\nstruct Message {\n    uint32_t length;      # Total message length\n    uint16_t msg_type;    # Message type identifier\n    uint8_t  flags;       # Flags\u002Foptions\n    uint8_t  reserved;    # Padding\u002Falignment\n    uint8_t  payload[];   # Variable-length payload\n};\n\n# Type-Length-Value (TLV)\nstruct TLV {\n    uint8_t  type;        # Field type\n    uint16_t length;      # Field length\n    uint8_t  value[];     # Field data\n};\n\n# Fixed header + variable payload\nstruct Packet {\n    uint8_t  magic[4];    # \"ABCD\" signature\n    uint32_t version;\n    uint32_t payload_len;\n    uint32_t checksum;    # CRC32 or similar\n    uint8_t  payload[];\n};\n```\n\n### Python Protocol Parser\n\n```python\nimport struct\nfrom dataclasses import dataclass\n\n@dataclass\nclass MessageHeader:\n    magic: bytes\n    version: int\n    msg_type: int\n    length: int\n\n    @classmethod\n    def from_bytes(cls, data: bytes):\n        magic, version, msg_type, length = struct.unpack(\n            \">4sHHI\", data[:12]\n        )\n        return cls(magic, version, msg_type, length)\n\ndef parse_messages(data: bytes):\n    offset = 0\n    messages = []\n\n    while offset \u003C len(data):\n        header = MessageHeader.from_bytes(data[offset:])\n        payload = data[offset+12:offset+12+header.length]\n        messages.append((header, payload))\n        offset += 12 + header.length\n\n    return messages\n\n# Parse TLV structure\ndef parse_tlv(data: bytes):\n    fields = []\n    offset = 0\n\n    while offset \u003C len(data):\n        field_type = data[offset]\n        length = struct.unpack(\">H\", data[offset+1:offset+3])[0]\n        value = data[offset+3:offset+3+length]\n        fields.append((field_type, value))\n        offset += 3 + length\n\n    return fields\n```\n\n### Hex Dump Analysis\n\n```python\ndef hexdump(data: bytes, width: int = 16):\n    \"\"\"Format binary data as hex dump.\"\"\"\n    lines = []\n    for i in range(0, len(data), width):\n        chunk = data[i:i+width]\n        hex_part = ' '.join(f'{b:02x}' for b in chunk)\n        ascii_part = ''.join(\n            chr(b) if 32 \u003C= b \u003C 127 else '.'\n            for b in chunk\n        )\n        lines.append(f'{i:08x}  {hex_part:\u003C{width*3}}  {ascii_part}')\n    return '\\n'.join(lines)\n\n# Example output:\n# 00000000  48 54 54 50 2f 31 2e 31  20 32 30 30 20 4f 4b 0d  HTTP\u002F1.1 200 OK.\n# 00000010  0a 43 6f 6e 74 65 6e 74  2d 54 79 70 65 3a 20 74  .Content-Type: t\n```\n\n## Encryption Analysis\n\n### Identifying Encryption\n\n```python\n# Entropy analysis - high entropy suggests encryption\u002Fcompression\nimport math\nfrom collections import Counter\n\ndef entropy(data: bytes) -> float:\n    if not data:\n        return 0.0\n    counter = Counter(data)\n    probs = [count \u002F len(data) for count in counter.values()]\n    return -sum(p * math.log2(p) for p in probs)\n\n# Entropy thresholds:\n# \u003C 6.0: Likely plaintext or structured data\n# 6.0-7.5: Possibly compressed\n# > 7.5: Likely encrypted or random\n\n# Common encryption indicators\n# - High, uniform entropy\n# - No obvious structure or patterns\n# - Length often multiple of block size (16 for AES)\n# - Possible IV at start (16 bytes for AES-CBC)\n```\n\n### TLS Analysis\n\n```bash\n# Extract TLS metadata\ntshark -r capture.pcap -Y \"ssl.handshake\" \\\n    -T fields -e ip.src -e ssl.handshake.ciphersuite\n\n# JA3 fingerprinting (client)\ntshark -r capture.pcap -Y \"ssl.handshake.type == 1\" \\\n    -T fields -e ssl.handshake.ja3\n\n# JA3S fingerprinting (server)\ntshark -r capture.pcap -Y \"ssl.handshake.type == 2\" \\\n    -T fields -e ssl.handshake.ja3s\n\n# Certificate extraction\ntshark -r capture.pcap -Y \"ssl.handshake.certificate\" \\\n    -T fields -e x509sat.printableString\n```\n\n### Decryption Approaches\n\n```bash\n# Pre-master secret log (browser)\nexport SSLKEYLOGFILE=\u002Ftmp\u002Fkeys.log\n\n# Configure Wireshark\n# Edit > Preferences > Protocols > TLS\n# (Pre)-Master-Secret log filename: \u002Ftmp\u002Fkeys.log\n\n# Decrypt with private key (if available)\n# Only works for RSA key exchange\n# Edit > Preferences > Protocols > TLS > RSA keys list\n```\n\n## Custom Protocol Documentation\n\n### Protocol Specification Template\n\n```markdown\n# Protocol Name Specification\n\n## Overview\n\nBrief description of protocol purpose and design.\n\n## Transport\n\n- Layer: TCP\u002FUDP\n- Port: XXXX\n- Encryption: TLS 1.2+\n\n## Message Format\n\n### Header (12 bytes)\n\n| Offset | Size | Field   | Description             |\n| ------ | ---- | ------- | ----------------------- |\n| 0      | 4    | Magic   | 0x50524F54 (\"PROT\")     |\n| 4      | 2    | Version | Protocol version (1)    |\n| 6      | 2    | Type    | Message type identifier |\n| 8      | 4    | Length  | Payload length in bytes |\n\n### Message Types\n\n| Type | Name      | Description            |\n| ---- | --------- | ---------------------- |\n| 0x01 | HELLO     | Connection initiation  |\n| 0x02 | HELLO_ACK | Connection accepted    |\n| 0x03 | DATA      | Application data       |\n| 0x04 | CLOSE     | Connection termination |\n\n### Type 0x01: HELLO\n\n| Offset | Size | Field      | Description              |\n| ------ | ---- | ---------- | ------------------------ |\n| 0      | 4    | ClientID   | Unique client identifier |\n| 4      | 2    | Flags      | Connection flags         |\n| 6      | var  | Extensions | TLV-encoded extensions   |\n\n## State Machine\n```\n\n[INIT] --HELLO--> [WAIT_ACK] --HELLO_ACK--> [CONNECTED]\n|\nDATA\u002FDATA\n|\n[CLOSED] \u003C--CLOSE--+\n\n```\n\n## Examples\n### Connection Establishment\n```\n\nClient -> Server: HELLO (ClientID=0x12345678)\nServer -> Client: HELLO_ACK (Status=OK)\nClient -> Server: DATA (payload)\n\n```\n\n```\n\n### Wireshark Dissector (Lua)\n\n```lua\n-- custom_protocol.lua\nlocal proto = Proto(\"custom\", \"Custom Protocol\")\n\n-- Define fields\nlocal f_magic = ProtoField.string(\"custom.magic\", \"Magic\")\nlocal f_version = ProtoField.uint16(\"custom.version\", \"Version\")\nlocal f_type = ProtoField.uint16(\"custom.type\", \"Type\")\nlocal f_length = ProtoField.uint32(\"custom.length\", \"Length\")\nlocal f_payload = ProtoField.bytes(\"custom.payload\", \"Payload\")\n\nproto.fields = { f_magic, f_version, f_type, f_length, f_payload }\n\n-- Message type names\nlocal msg_types = {\n    [0x01] = \"HELLO\",\n    [0x02] = \"HELLO_ACK\",\n    [0x03] = \"DATA\",\n    [0x04] = \"CLOSE\"\n}\n\nfunction proto.dissector(buffer, pinfo, tree)\n    pinfo.cols.protocol = \"CUSTOM\"\n\n    local subtree = tree:add(proto, buffer())\n\n    -- Parse header\n    subtree:add(f_magic, buffer(0, 4))\n    subtree:add(f_version, buffer(4, 2))\n\n    local msg_type = buffer(6, 2):uint()\n    subtree:add(f_type, buffer(6, 2)):append_text(\n        \" (\" .. (msg_types[msg_type] or \"Unknown\") .. \")\"\n    )\n\n    local length = buffer(8, 4):uint()\n    subtree:add(f_length, buffer(8, 4))\n\n    if length > 0 then\n        subtree:add(f_payload, buffer(12, length))\n    end\nend\n\n-- Register for TCP port\nlocal tcp_table = DissectorTable.get(\"tcp.port\")\ntcp_table:add(8888, proto)\n```\n\n## Active Testing\n\n### Fuzzing with Boofuzz\n\n```python\nfrom boofuzz import *\n\ndef main():\n    session = Session(\n        target=Target(\n            connection=TCPSocketConnection(\"target\", 8888)\n        )\n    )\n\n    # Define protocol structure\n    s_initialize(\"HELLO\")\n    s_static(b\"\\x50\\x52\\x4f\\x54\")  # Magic\n    s_word(1, name=\"version\")       # Version\n    s_word(0x01, name=\"type\")       # Type (HELLO)\n    s_size(\"payload\", length=4)     # Length field\n    s_block_start(\"payload\")\n    s_dword(0x12345678, name=\"client_id\")\n    s_word(0, name=\"flags\")\n    s_block_end()\n\n    session.connect(s_get(\"HELLO\"))\n    session.fuzz()\n\nif __name__ == \"__main__\":\n    main()\n```\n\n### Replay and Modification\n\n```python\nfrom scapy.all import *\n\n# Replay captured traffic\npackets = rdpcap(\"capture.pcap\")\nfor pkt in packets:\n    if pkt.haslayer(TCP) and pkt[TCP].dport == 8888:\n        send(pkt)\n\n# Modify and replay\nfor pkt in packets:\n    if pkt.haslayer(Raw):\n        # Modify payload\n        original = pkt[Raw].load\n        modified = original.replace(b\"client\", b\"CLIENT\")\n        pkt[Raw].load = modified\n        # Recalculate checksums\n        del pkt[IP].chksum\n        del pkt[TCP].chksum\n        send(pkt)\n```\n\n## Best Practices\n\n### Analysis Workflow\n\n1. **Capture traffic**: Multiple sessions, different scenarios\n2. **Identify boundaries**: Message start\u002Fend markers\n3. **Map structure**: Fixed header, variable payload\n4. **Identify fields**: Compare multiple samples\n5. **Document format**: Create specification\n6. **Validate understanding**: Implement parser\u002Fgenerator\n7. **Test edge cases**: Fuzzing, boundary conditions\n\n### Common Patterns to Look For\n\n- Magic numbers\u002Fsignatures at message start\n- Version fields for compatibility\n- Length fields (often before variable data)\n- Type\u002Fopcode fields for message identification\n- Sequence numbers for ordering\n- Checksums\u002FCRCs for integrity\n- Timestamps for timing\n- Session\u002Fconnection identifiers\n",{"name":5,"description":7},"main","87afe6ce96220accf50a345dea46784c8c9f210e","YYC3-Plugin-插件协议\u002FYYC3-Plugin-插件协议-plugins-claude\u002Freverse-engineering\u002Fskills\u002Fprotocol-reverse-engineering",0,"https:\u002F\u002Fgithub.com\u002FYYC-Cube\u002FYYC3-Knowledge-Base","https:\u002F\u002Fkb.yyc3.top\u002F","https:\u002F\u002Fgithub.com\u002FYYC-Cube","万象归元于云枢 | 深栈智启新纪元","2026-11-10 10:37:32",{"source":8,"skillName":5,"commands":34,"prompt":44,"zipAvailable":45},[35,38,41],{"tool":36,"command":37},"npx","npx skills add YYC-Cube\u002FYYC3-Knowledge-Base --skill protocol-reverse-engineering",{"tool":39,"command":40},"bunx","bunx skills add YYC-Cube\u002FYYC3-Knowledge-Base --skill protocol-reverse-engineering",{"tool":42,"command":43},"pnpm","pnpm dlx skills add YYC-Cube\u002FYYC3-Knowledge-Base --skill protocol-reverse-engineering","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002FYYC-Cube\u002FYYC3-Knowledge-Base\u002Fblob\u002Fmain\u002FYYC3-Plugin-插件协议\u002FYYC3-Plugin-插件协议-plugins-claude\u002Freverse-engineering\u002Fskills\u002Fprotocol-reverse-engineering\u002FSKILL.md",true,[],[48,55,62,69,76,83],{"skillNo":49,"name":50,"nameZh":6,"description":51,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":52,"categories":53,"keywords":54,"publishedAt":19},"01M7CTDWHERCXPQCP0K03A86AS","vercel-sandbox","Run agent-browser + Chrome inside Vercel Sandbox microVMs for browser automation from any Vercel-deployed app. Use when the user needs browser automation in a Vercel app (Next.js, SvelteKit, Nuxt, Remix, Astro, etc.), wants to run headless Chrome without binary size limits, needs persistent browser sessions across commands, or wants ephemeral isolated browser environments. Triggers include \"Vercel Sandbox browser\", \"microVM Chrome\", \"agent-browser in sandbox\", \"browser automation on Vercel\", or any task requiring Chrome in a Vercel Sandbox.","https:\u002F\u002Fgithub.com\u002FYYC-Cube\u002FYYC3-Knowledge-Base\u002Fblob\u002Fmain\u002FYYC3-WebSpec-Web标准\u002FYYC3-WebSpec-Web标准-standards\u002Fbrowser-agent\u002Fskills\u002Fvercel-sandbox\u002FSKILL.md",[],[],{"skillNo":56,"name":57,"nameZh":6,"description":58,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":59,"categories":60,"keywords":61,"publishedAt":19},"01M7CTD8D2BNJY54S65M47HEJA","slack","Interact with Slack workspaces using browser automation. Use when the user needs to check unread channels, navigate Slack, send messages, extract data, find information, search conversations, or automate any Slack task. Triggers include \"check my Slack\", \"what channels have unreads\", \"send a message to\", \"search Slack for\", \"extract from Slack\", \"find who said\", or any task requiring programmatic Slack interaction.","https:\u002F\u002Fgithub.com\u002FYYC-Cube\u002FYYC3-Knowledge-Base\u002Fblob\u002Fmain\u002FYYC3-WebSpec-Web标准\u002FYYC3-WebSpec-Web标准-standards\u002Fbrowser-agent\u002Fskills\u002Fslack\u002FSKILL.md",[],[],{"skillNo":63,"name":64,"nameZh":6,"description":65,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":66,"categories":67,"keywords":68,"publishedAt":19},"01M7CTCSSB8ZP3Q58C3YZDZK1W","electron","Automate Electron desktop apps (VS Code, Slack, Discord, Figma, Notion, Spotify, etc.) using agent-browser via Chrome DevTools Protocol. Use when the user needs to interact with an Electron app, automate a desktop app, connect to a running app, control a native app, or test an Electron application. Triggers include \"automate Slack app\", \"control VS Code\", \"interact with Discord app\", \"test this Electron app\", \"connect to desktop app\", or any task requiring automation of a native Electron application.","https:\u002F\u002Fgithub.com\u002FYYC-Cube\u002FYYC3-Knowledge-Base\u002Fblob\u002Fmain\u002FYYC3-WebSpec-Web标准\u002FYYC3-WebSpec-Web标准-standards\u002Fbrowser-agent\u002Fskills\u002Felectron\u002FSKILL.md",[],[],{"skillNo":70,"name":71,"nameZh":6,"description":72,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":73,"categories":74,"keywords":75,"publishedAt":19},"01M7CTCBJY76688V4DCZGWFHGQ","dogfood","Systematically explore and test a web application to find bugs, UX issues, and other problems. Use when asked to \"dogfood\", \"QA\", \"exploratory test\", \"find issues\", \"bug hunt\", \"test this app\u002Fsite\u002Fplatform\", or review the quality of a web application. Produces a structured report with full reproduction evidence -- step-by-step screenshots, repro videos, and detailed repro steps for every issue -- so findings can be handed directly to the responsible teams.","https:\u002F\u002Fgithub.com\u002FYYC-Cube\u002FYYC3-Knowledge-Base\u002Fblob\u002Fmain\u002FYYC3-WebSpec-Web标准\u002FYYC3-WebSpec-Web标准-standards\u002Fbrowser-agent\u002Fskills\u002Fdogfood\u002FSKILL.md",[],[],{"skillNo":77,"name":78,"nameZh":6,"description":79,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":80,"categories":81,"keywords":82,"publishedAt":19},"01M7CTC4H0FFGVEAQR9PA4GA1A","agent-browser","Browser automation CLI for AI agents. Use when the user needs to interact with websites, including navigating pages, filling forms, clicking buttons, taking screenshots, extracting data, testing web apps, or automating any browser task. Triggers include requests to \"open a website\", \"fill out a form\", \"click a button\", \"take a screenshot\", \"scrape data from a page\", \"test this web app\", \"login to a site\", \"automate browser actions\", or any task requiring programmatic web interaction.","https:\u002F\u002Fgithub.com\u002FYYC-Cube\u002FYYC3-Knowledge-Base\u002Fblob\u002Fmain\u002FYYC3-WebSpec-Web标准\u002FYYC3-WebSpec-Web标准-standards\u002Fbrowser-agent\u002Fskills\u002Fagent-browser\u002FSKILL.md",[],[],{"skillNo":84,"name":85,"nameZh":6,"description":86,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":87,"categories":88,"keywords":89,"publishedAt":19},"01M7CTBKVFYBG78FDSABSDJTTQ","shadcn","Manages shadcn components and projects — adding, searching, fixing, debugging, styling, and composing UI, including chat interfaces. Provides project context, component docs, and usage examples. Applies when working with shadcn\u002Fui, component registries, presets, --preset codes, or any project with a components.json file. Also triggers for \"shadcn init\", \"create an app with --preset\", \"switch to --preset\", and for building a design system or applying a DESIGN.md or brand spec to shadcn\u002Fui.","https:\u002F\u002Fgithub.com\u002FYYC-Cube\u002FYYC3-Knowledge-Base\u002Fblob\u002Fmain\u002FYYC3-UI-界面组件\u002FYYC3-UI-界面组件-ui\u002Fskills\u002Fshadcn\u002FSKILL.md",[],[]]