Tool for Packet Logging & Stub Generation (Open Source)

Started by Phantasm, Yesterday at 09:40 AM

Phantasm

Yo MU devs,

I cooked up something small that might help anyone messing with client ↔ server packets. Basically it's a Python-based proxy that logs all MU C1/C2 packets, then spits out a protocol YAML and even auto-generates C++ handler stubs so you don't start from scratch.

Been testing it on GS 55901 — works fine if you just point the client to 127.0.0.1 and let the proxy sit in front. Captures are pretty clean if you keep them short (like just logging in, opening shop, etc.).

Why I made it?

Got tired of manually hex-dumping packets.

Wanted a simple way to track proto changes between seasons.

Makes creating recv/send handler skeletons a whole lot faster.

If anyone gives it a spin, let me know what flows you tested it on (Login, Shop, Events, etc.). Would love to build a more complete proto map together.

bash:

# 1) Proxy client traffic
python mu_wire_kit.py proxy --listen 0.0.0.0:55901 --target 127.0.0.1:55901 --log ./mu.log

# 2) Analyze logs into YAML + CSV
python mu_wire_kit.py analyze --log ./mu.log --yaml ./proto.yaml --csv ./heatmap.csv

# 3) Generate C++ stubs
python mu_wire_kit.py gen --yaml ./proto.yaml --out ./stubs


Download: Mu_Wire_Kit

In the download link if you scroll down through out repositories, loads of things about Mu Community, I believe more than 100 repositories from different Authors not personally mine (enjoy).

If you have more ideas, leave a post and it will do.

Daca ai o idee despre dezvoltarea proiectului initial, nu ezita sa lasi un mesaj, cu idea ta pentru implementare.

On this forum is the first release and more to come, why? I have a beautiful experience in TosaMu community , old player! More than 12 years back I believe when I was a child. So now a DevOps, more to come for this beautiful community!

THIS IS THE INITIAL STAGE!!

— Cheers

Credits:
Phantasm
  •  
    The following users thanked this post: Dorin

Phantasm

Upgrade

What I just upgraded

C3/C4 support (besides C1/C2) — so encrypted/checksummed frames are recognized and logged.

Packet filters on the proxy:

only-dir C→S|S→C

only-head F3,FB

only-sub 03,30

Multi-port capture: proxy-multi lets you log ConnectServer + GameServer at the same time.

Stub generator styles: style muemu emits MUEMU-style recv/send skeletons (PBMSG/PSBMSG layout).

README updated with the new commands.

Quick examples (copy/paste)

Capture both ports at once:
ngingx:
python mu_wire_kit.py proxy-multi --pairs 0.0.0.0:44405->127.0.0.1:44405,0.0.0.0:55901->127.0.0.1:55901 --logdir ./logs

Only log Event/MST stuff (example F3 head, subs 03 and 30) from client→server:
perl:
python mu_wire_kit.py proxy --listen 0.0.0.0:55901 --target 127.0.0.1:55901 --log ./mu.log --only-dir C→S --only-head F3 --only-sub 03,30
Generate MuEmu-style stubs:
css:
python mu_wire_kit.py gen --yaml ./proto.yaml --out ./stubs --style muemu
  •  

Phantasm

New features
------------
PCAP writer (open in Wireshark):
  # single port
  python mu_wire_kit.py proxy --listen 0.0.0.0:55901 --target 127.0.0.1:55901 --log ./mu.log --pcap ./mu.pcap  # multi-port writes one .pcap per pair (to --logdir)
  python mu_wire_kit.py proxy-multi --pairs 0.0.0.0:44405->127.0.0.1:44405,0.0.0.0:55901->127.0.0.1:55901 --logdir ./logs --pcap
C3/C4 XOR + checksum options:
  --xor-key 11aa22bb         # XOR-decode C3/C4 payloads with this repeating key
  --strip-last-checksum      # drop last byte (simple checksum) before analysis/pcap

Focus mode (interactive marks):
  # while proxy runs, press ENTER in the console to insert a '# FOCUS MARK' line
  # later, slice that window and analyze just those packets:
  python mu_wire_kit.py extract --log ./mu.log --out ./focus.log --start 1 --end 2
 python mu_wire_kit.py analyze --log ./focus.log --yaml ./focus.yaml --csv ./focus.csv

YAML field templates → struct parsers:
  # add to your YAML entry e.g.:
  # - name: GC_F3_30
  #   dir: S2C
  #   header: C2
  #   head: 0xF3
  #   sub: 0x30
  #   record_size: 16
  #   fields: [eventId:u1, status:u1, minutes:u2, minLevel:u2, map:u1, feeItem:u2, feeCount:u2, pad:u5]
  python mu_wire_kit.py gen-parsers --yaml ./focus.yaml --out ./parsers
  •  

Powered by SMFPacks Ads Manager Mod