Skip to content

daverlon/sourcesniffer

Repository files navigation

Sourcesniffer

Kotlin implementation of the Valve Source-engine netchannel protocol.
A research project exploring the limits of Source protocol manipulation.

Decodes and encodes game traffic at the bit level — packet structure, fragmentation, compression, checksums, message decoding and encoding. Built to test ideas around message injection, real-time control, and protocol behavior.

What it does

Core protocol

  • Bit-accurate Source packet parsing (headers, splits, compression, checksums)
  • Network message encoding/decoding both directions

Sniffer example

  • Capture live game traffic externally
  • Can inject chat messages and console commands to the server

Proxy example

  • MITM that sits between client and server
  • Decodes and rewrites player movement in real-time (mouse look, movement keys)
  • Lets you control a player remotely
  • More advanced message control without causing a desync

What's included

Core protocol (packetparser/, messages/)

  • Source packet header parsing (seq/ack, flags, challenge, checksum)
  • Split packet reassembly
  • Compression handling (Source flag + Snappy)
  • Bit-level reader/writer matching engine wire format
  • Full message set: client → server and server → client

Examples (runnable)

  • Proxy (StartProxy.kt): MITM that decodes/encodes live traffic
  • Sniffer (StartSniffer.kt): capture and decode packets from the wire

Project structure

src/main/kotlin/
├── StartProxy.kt          # MITM proxy example
├── StartSniffer.kt        # Packet sniffer example (experimental)
├── proxy/                 # Proxy implementation
├── packetloader/          # pcap4j capture + BPF
├── packetparser/           # Core protocol parsing
│   ├── PacketParser.kt    # Main packet processing
│   ├── SplitPacketHandler.kt
│   └── PacketHeaderHandler.kt
├── messages/              # All netchannel message types
├── messagehandler/        # Message dispatch
├── definitions/           # Protocol constants
└── settings/              # Config

Quickstart

Prerequisites

  • JDK 17+
  • libpcap (macOS/Linux) or packet capture permissions
  • Local jars in ./lib/ (see build.gradle.kts)

Build

./gradlew build

Run the proxy example

  1. Set target server in StartProxy.kt: CSSserver("ip:port")
  2. Set listen port: ProxyServer(listenPort = 6767)
  3. Run main() from your IDE
  4. Connect your game client via the console command connect localhost:6767

Run the sniffer example

  1. Set SnifferSettings.defaultInterfaceIP in AppSettings.kt
  2. Set ports to monitor
  3. Uncomment sniffer loop in StartSniffer.kt and run

Current state

  • Unreliable messages: fully implemented
  • Reliable messages: parsed but ignored (WIP)
  • SVC_PacketEntities: not yet parsed (WIP)
  • Config: hard-coded (next: CLI/config file)
  • Packet dumper: stubbed

Tech

  • Kotlin/JVM
  • pcap4j (capture)
  • snappy-java (compression)
  • JNA (native bridging)

Legal

For research use only. Only inspect traffic you own or have permission to analyze. This project is intentionally user-unfriendly.

About

Source engine network traffic analysis framework - decode and encode packets in real-time

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Languages