Skip to content

Repository files navigation

Instacap-RS

Instacap-Rs is a high-performance, Rust-based network packet capture and anomaly detection tool with optional integration hooks for Kafka and Elasticsearch. It's designed for security analysts, sysadmins, and developers to monitor, analyze, and alert on suspicious network activity in real time.

The Real-Time Network Traffic Analysis project involves several key components and processes:

Data Flow & Processing

1. Network Monitoring

  • Captures live network packets from network interfaces
  • Parses protocols (HTTP, DNS, SSL, TCP, UDP)
  • Extracts metadata like IPs, ports, bytes transferred, connection states

2. Stream Processing Pipeline

  • Real-time data ingestion through Kafka message queues
  • High-performance data processing in Rust
  • Asynchronous processing of thousands of network events per second

3. Machine Learning Analysis

  • Feature extraction from network patterns
  • Anomaly detection using statistical models
  • Risk scoring based on traffic characteristics
  • Pattern recognition for known attack signatures

Technical Components

Infrastructure:

  • Docker containers for easy deployment
  • Kafka for handling high-throughput data streams
  • Elasticsearch as a time-series database
  • Message queues and event-driven architecture

Security Analysis:

  • Detects unusual traffic patterns (data exfiltration, port scanning)
  • Identifies potential brute force attacks
  • Flags suspicious protocol usage
  • Monitors for malware communication patterns

Visualization & Alerting:

  • Real-time dashboards showing network health
  • Traffic volume analysis and trending
  • Geographic mapping of connections
  • Automated alerts for high-risk events

Skills I'll Develop

Programming:

- Rust for systems programming and performance
- Python for machine learning and data science
- Network protocol understanding
- Asynchronous programming patterns

DevOps & Infrastructure:

- Container orchestration with Docker
- Message queue systems (Kafka)
- Database administration (Elasticsearch)
- Monitoring and logging systems

Cybersecurity:

- Network traffic analysis techniques
- Threat detection methodologies
- Incident response workflows
- Security monitoring best practices

Real-World Applications Enterprise Security:

- SOC (Security Operations Center) monitoring
- Network intrusion detection
- Compliance reporting and auditing
- Incident investigation and forensics

Performance Monitoring:

- Network bandwidth analysis
- Application performance monitoring
- Infrastructure health tracking
- Capacity planning

πŸ“Œ Features

  • Real-time network traffic capture
  • Anomaly and threat detection
  • Traffic statistics & performance metrics
  • Optional verbose output for debugging
  • Stub integrations with Kafka and Elasticsearch
  • CLI-based configuration

βš™οΈ Installation

1. Install Dependencies

Ubuntu/Debian

sudo apt-get update
sudo apt-get install libpcap-dev build-essential
CentOS/RHEL/Fedora
sudo yum install libpcap-devel gcc
macOS
brew install libpcap

2. Build the Project

# Clone and navigate
cd instacap-rs

# Build in release mode
cargo build --release

πŸš€ Usage

List Available Interfaces

sudo ./target/release/instacap-rs --help

Basic Example

# Monitor default interface (eth0)
sudo ./target/release/instacap-rs

Custom Interface

sudo ./target/release/instacap-rs -i wlan0

Enable Promiscuous Mode

sudo ./target/release/instacap-rs --promiscuous

Verbose Logging

sudo ./target/release/instacap-rs -v

Advanced Example

sudo ./target/release/instacap-rs \
  -i eth0 \
  -k localhost:9092 \
  -e http://localhost:9200 \
  --promiscuous \
  --timeout 2000 \
  --buffer-size 131072 \
  --anomaly-window 120 \
  --traffic-threshold 2000 \
  --verbose

🧾 Command-Line Options

|----------------------------------------|------------------------------------------------------------|-----------------------------|
| `-i`, `--interface <INTERFACE>`        | Network interface to monitor                               | `eth0`                      |
| `-k`, `--kafka-broker <KAFKA_BROKER>`  | Kafka broker URL                                           | `localhost:9092`           |
| `-e`, `--elasticsearch-url <URL>`      | Elasticsearch endpoint URL                                 | `http://localhost:9200`    |
| `--promiscuous`                        | Enable promiscuous mode to capture all traffic             | `false`                     |
| `--timeout <TIMEOUT>`                  | Packet capture timeout in milliseconds                     | `1000`                      |
| `--buffer-size <BUFFER_SIZE>`         | Buffer size for packet capture in bytes                    | `65536`                     |
| `--anomaly-window <SECONDS>`           | Time window (in seconds) for anomaly detection             | `60`                        |
| `--traffic-threshold <THRESHOLD>`      | Packet count threshold for triggering anomaly detection    | `1000`                      |
| `-v`, `--verbose`                      | Enable verbose output (includes debug-level information)   | `false`                     |

πŸ“ˆ What You’ll See

Startup
[INFO] Starting Instacap-Rs Network Packet Analyzer
[INFO] Interface: eth0
...
[INFO] Packet capture started successfully
Traffic Statistics (every 30s)
[INFO] === Traffic Statistics ===
[INFO] Total packets: 15847
[INFO] Total bytes: 12458392
[INFO] Top protocols: {"TCP": 12453, "UDP": 2847, "ICMP": 547}
Security Alerts
[WARN] Port scan detected: 192.168.1.100: 25 ports in 60s
[ERROR] Brute force attack: 75 attempts to port 22
Final Report (on Ctrl+C)
=== NETWORK SECURITY REPORT ===
- Total packets: 45623
- Suspicious IPs: 5
- Port scan attempts: 3
- Throughput: 78.9 Mbps

🧰 Troubleshooting

Permission Denied
# Requires root permissions
sudo ./target/release/instacap-rs
Interface Not Found
# List interfaces
ip link show       # Linux
ifconfig -a        # macOS/Linux
Build Errors
sudo apt-get install libpcap-dev pkg-config
High CPU Usage
# Tune buffer size or timeout
sudo ./target/release/instacap-rs --buffer-size 32768 --timeout 2000

πŸ”— Integration Notes

  • Kafka: Stubbed out; replace with real Kafka producer implementation.
  • Elasticsearch: Stubbed out; replace with real Elasticsearch client logic.
  • Production: Implement persistence and proper security logging for enterprise use.

πŸ”’ Security Considerations

  • Requires root privileges to capture packets
  • Captures potentially sensitive data
  • Comply with data privacy & retention policies
  • Customize threat detection to your needs
  • Monitor CPU/memory impact in production

🀝 Contributing

  • Pull requests are welcome! For major changes, please open an issue first to discuss improvements or features.

πŸ“„ License

MIT License. See LICENSE for details.

---

### βœ… Summary

This version follows the **standard GitHub README structure**:

1. Project name & description
2. Features
3. Installation
4. Usage
5. Command-line options
6. Expected output
7. Troubleshooting
8. Integration
9. Security
10. Contributing
11. License

Let me know if you'd like this saved as a file (`README.md`) or want badges (build status, licens

Project Directory Structure

Instacap-RS/
β”œβ”€β”€ docker-compose.yml -Runs all components (Rust services, Python ML server, etc.) in isolated containers.
β”œβ”€β”€ packet-capture/ - Captures live network traffic using low-level packet sniffing (like libpcap).
β”‚   β”œβ”€β”€ Dockerfile
β”‚   β”œβ”€β”€ src/
β”‚   β”‚   β”œβ”€β”€ main.rs
β”‚   β”‚   β”œβ”€β”€ packet_capture.rs - Core logic to sniff packets from interfaces
β”‚   β”‚   β”œβ”€β”€ protocol_parser.rs - Decodes Ethernet, IP, TCP/UDP, HTTP, etc.
β”‚   β”‚   β”œβ”€β”€ deep_inspection.rs - Payload analysis (e.g., detecting signatures or anomalies).
β”‚   β”‚   └── performance_metrics.rs - Measures network KPIs β€” latency, jitter, throughput.
β”‚   └── Cargo.toml
β”œβ”€β”€ analysis-engine/ - Analyzes packets for security and performance issues.
β”‚   β”œβ”€β”€ src/
β”‚   β”‚   β”œβ”€β”€ main.rs
β”‚   β”‚   β”œβ”€β”€ anomaly_detector.rs - Checks for unusual patterns (spikes, rare protocols).
β”‚   β”‚   β”œβ”€β”€ threat_detector.rs - Signature/rule-based detection (malware, port scans).
β”‚   β”‚   β”œβ”€β”€ traffic_analyzer.rs -  Summarizes traffic by IP, protocol, etc.
β”‚   β”‚   └── alert_manager.rs - Triggers alerts/logs when rules or thresholds are violated.
β”‚   └── Cargo.toml
β”œβ”€β”€ ml-models/ -  Machine learning models for intelligent anomaly/threat detection.
β”‚   β”œβ”€β”€ anomaly_detection.py - Detects statistical anomalies.
β”‚   β”œβ”€β”€ threat_classification.py - Classifies threats (DDoS, scan, exfiltration).
β”‚   β”œβ”€β”€ performance_predictor.py - Predicts network degradation.
β”‚   └── model_server.py - Exposes ML models via an API (e.g., using FastAPI or Flask).
β”œβ”€β”€ wireshark-integration/ -  Custom filters and dissectors in Wireshark for deeper visualization.
β”‚   β”œβ”€β”€ capture_filters.lua - Predefined capture rules.
β”‚   └── custom_dissectors.lua - Protocol dissection to visualize custom/unknown protocols.
└── configs/
    β”œβ”€β”€ capture.conf - Interfaces and filters for capture.
    β”œβ”€β”€ detection_rules.yaml - Rules for threat/anomaly detection.
    └── thresholds.json - Performance thresholds for alerts.

About

Rust(Instant capture and analysis)

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages