How jamesbinford/rustbucket works
Project Type and Purpose
• Rustbucket is a standalone, full-stack (self-contained) network honeypot written in Rust.
• It emulates multiple protocols on configurable ports, captures attacker interactions, logs them, and optionally uses the ChatGPT API to generate dynamic responses.
Main Components
a. Configuration Loader
– Reads Config.toml (or environment) to determine:
• Ports to monitor
• Emulated services (SMTP, HTTP, FTP, etc.)
• ChatGPT API key & prompts
• Logging targets & batch sizes
b. Network Listener & Service Registry
– “registration.rs” registers which ports/protocols to emulate
– A Tokio‐based listener accepts TCP connections on those ports
c. Protocol Handler
– “handler.rs” dispatches each connection to the correct emulator
– Emulators follow protocol state machines (e.g., SMTP handshake, HTTP responses)
– Integrates with chatgpt.rs when configured to generate dynamic replies
d. ChatGPT Integration
– “chatgpt.rs” encapsulates API calls to OpenAI
– Manages rate limits, retries, and injects prompt templates from config
e. Logging Pipeline (a modular, asynchronous pipeline)
1. Log Collector (“log_collector.rs”) gathers raw interaction data
2. Log Batcher (“log_batcher.rs”) buffers events into batches
3. Log Compressor (“log_compressor.rs”) gzips or otherwise compresses batches
4. Log Uploader (“log_uploader.rs”) writes compressed batches to disk, cloud storage, or remote API
f. Application Entry Point
– “main.rs” ties everything together, initializes the async runtime, launches listeners, and spins up the logging pipeline
g. CI / Deployment
– GitHub Actions CI (ci.yml) runs linting, tests, and build
– Dockerfile for containerized deployment
Relationships and Data Flows
– Config Loader → Application Entry → Network Listener & Registry
– Incoming Connection → Handler → [Emulator Logic → optional ChatGPT API call] → Handler → Log Collector
– Log Collector → Log Batcher → Log Compressor → Log Uploader → Storage (local/remote)
– Handler ←→ ChatGPT API (external service)
– The async runtime (Tokio) underpins all concurrency, allowing many connections and log‐pipeline tasks to run in parallel
Architectural Patterns & Principles
– Modular separation of concerns: networking, protocol logic, AI integration, and logging are distinct modules
– Async pipeline pattern for efficient, backpressured logging
– Configuration-driven design (TOML) for maximum flexibility
– Externalized service integration (ChatGPT, storage) to keep core logic lean