# SneakyScanner Deployment Guide ## Table of Contents 1. [Overview](#overview) 2. [Prerequisites](#prerequisites) 3. [Quick Start](#quick-start) 4. [Configuration](#configuration) 5. [First-Time Setup](#first-time-setup) 6. [Running the Application](#running-the-application) 7. [Using the Web Interface](#using-the-web-interface) 8. [Volume Management](#volume-management) 9. [Health Monitoring](#health-monitoring) 10. [Troubleshooting](#troubleshooting) 11. [Security Considerations](#security-considerations) 12. [Upgrading](#upgrading) 13. [Backup and Restore](#backup-and-restore) --- ## Overview SneakyScanner is deployed as a Docker container running a Flask web application with an integrated network scanner. The application requires privileged mode and host networking to perform network scans using masscan and nmap. **Architecture:** - **Web Application**: Flask app on port 5000 with modern web UI - **Database**: SQLite (persisted to volume) - **Background Jobs**: APScheduler for async scan execution - **Scanner**: masscan, nmap, sslyze, Playwright - **Config Creator**: Web-based CIDR-to-YAML configuration builder - **Scheduling**: Cron-based scheduled scans with dashboard management --- ## Prerequisites ### System Requirements - **Operating System**: Linux (Ubuntu 20.04+, Debian 11+, or similar) - **Docker**: Version 20.10+ or Docker Engine 24.0+ - **Docker Compose**: Version 2.0+ (or docker-compose 1.29+) - **Memory**: Minimum 2GB RAM (4GB+ recommended) - **Disk Space**: Minimum 5GB free space - **Permissions**: Root/sudo access for Docker privileged mode ### Network Requirements - Outbound internet access for Docker image downloads - Access to target networks for scanning - Port 5000 available on host (or configure alternative) ### Install Docker and Docker Compose **Ubuntu/Debian:** ```bash # Install Docker curl -fsSL https://get.docker.com -o get-docker.sh sudo sh get-docker.sh # Add your user to docker group sudo usermod -aG docker $USER newgrp docker # Verify installation docker --version docker compose version ``` **Other Linux distributions:** See [Docker installation guide](https://docs.docker.com/engine/install/) --- ## Quick Start For users who want to get started immediately with the web application: **Option 1: Automated Setup (Recommended)** ```bash # 1. Clone the repository git clone cd SneakyScan # 2. Run the setup script ./setup.sh # 3. Access the web interface # Open browser to: http://localhost:5000 # Login with password from ./admin_password.txt or ./logs/admin_password.txt ``` The setup script automatically: - Generates secure random keys (SECRET_KEY, ENCRYPTION_KEY) - Prompts for password or generates a random one - Creates required directories - Builds Docker image - Starts the application - Auto-initializes database on first run **Option 2: Manual Setup** ```bash # 1. Clone the repository git clone cd SneakyScan # 2. Create environment file cp .env.example .env # Edit .env and set SECRET_KEY and SNEAKYSCANNER_ENCRYPTION_KEY # Optionally set INITIAL_PASSWORD (leave blank for auto-generation) nano .env # 3. Build and start (database auto-initializes on first run) docker compose up --build -d # 4. Check logs for auto-generated password (if not set in .env) docker compose logs web | grep "Password" # Or check: ./logs/admin_password.txt # 5. Access the web interface # Open browser to: http://localhost:5000 ``` **Alternative: Standalone CLI Scanner** For quick one-off scans without the web interface: ```bash # Build and run with standalone compose file docker compose -f docker-compose-standalone.yml build docker compose -f docker-compose-standalone.yml up # Results saved to ./output/ directory ``` **Note**: `docker-compose.yml` (web application) is now the default. Use `docker-compose-standalone.yml` for CLI-only scans. --- ## Configuration ### Environment Variables SneakyScanner is configured via environment variables. The recommended approach is to use a `.env` file. #### Creating Your .env File ```bash # Copy the example file cp .env.example .env # Generate secure keys # SECRET_KEY: Flask session secret (64-character hex string) python3 -c "import secrets; print('SECRET_KEY=' + secrets.token_hex(32))" >> .env # SNEAKYSCANNER_ENCRYPTION_KEY: Fernet key for database encryption (32 url-safe base64 bytes) python3 -c "from cryptography.fernet import Fernet; print('SNEAKYSCANNER_ENCRYPTION_KEY=' + Fernet.generate_key().decode())" >> .env # Edit other settings as needed nano .env ``` #### Key Configuration Options | Variable | Description | Default | Required | |----------|-------------|---------|----------| | `FLASK_ENV` | Environment mode (`production` or `development`) | `production` | Yes | | `FLASK_DEBUG` | Enable debug mode (`true` or `false`) | `false` | Yes | | `SECRET_KEY` | Flask session secret (change in production!) | `dev-secret-key-change-in-production` | **Yes** | | `SNEAKYSCANNER_ENCRYPTION_KEY` | Encryption key for sensitive settings | (empty) | **Yes** | | `DATABASE_URL` | SQLite database path | `sqlite:////app/data/sneakyscanner.db` | Yes | | `INITIAL_PASSWORD` | Password for first-run initialization (leave empty to auto-generate) | (empty) | No | | `LOG_LEVEL` | Logging level (DEBUG, INFO, WARNING, ERROR) | `INFO` | No | | `SCHEDULER_EXECUTORS` | Number of concurrent scan threads | `2` | No | | `SCHEDULER_JOB_DEFAULTS_MAX_INSTANCES` | Max instances of same job | `3` | No | | `CORS_ORIGINS` | CORS allowed origins (comma-separated) | `*` | No | **Important Security Note:** - **ALWAYS** change `SECRET_KEY` and `SNEAKYSCANNER_ENCRYPTION_KEY` in production - Never commit `.env` file to version control - Use strong, randomly-generated keys --- ## First-Time Setup ### Step 1: Prepare Directories The application needs these directories (created automatically by Docker): ```bash # Verify directories exist ls -la configs/ data/ output/ logs/ # If missing, create them mkdir -p configs data output logs ``` ### Step 2: Configure Scan Targets You can create scan configurations in two ways: **Option A: Using the Web UI (Recommended - Phase 4 Feature)** 1. Navigate to **Configs** in the web interface 2. Click **"Create New Config"** 3. Use the CIDR-based config creator for quick setup: - Enter site name - Enter CIDR range (e.g., `192.168.1.0/24`) - Select expected ports from dropdowns - Click **"Generate Config"** 4. Or use the **YAML Editor** for advanced configurations 5. Save and use immediately in scans or schedules **Option B: Manual YAML Files** Create YAML configuration files manually in the `configs/` directory: ```bash # Example configuration cat > configs/my-network.yaml < # Rebuild and start docker compose -f docker-compose.yml build docker compose -f docker-compose.yml up -d ``` --- ## Backup and Restore ### Automated Backup Script Create `backup.sh`: ```bash #!/bin/bash BACKUP_DIR="backups/$(date +%Y%m%d_%H%M%S)" mkdir -p "$BACKUP_DIR" # Stop application for consistent backup docker compose -f docker-compose.yml stop web # Backup database cp data/sneakyscanner.db "$BACKUP_DIR/" # Backup outputs (last 30 days only) find output/ -type f -mtime -30 -exec cp --parents {} "$BACKUP_DIR/" \; # Backup configs cp -r configs/ "$BACKUP_DIR/" # Restart application docker compose -f docker-compose.yml start web echo "Backup complete: $BACKUP_DIR" ``` Make executable and schedule with cron: ```bash chmod +x backup.sh # Add to crontab (daily at 2 AM) crontab -e # Add line: 0 2 * * * /path/to/SneakyScan/backup.sh ``` ### Restore from Backup ```bash # Stop application docker compose -f docker-compose.yml down # Restore files cp backups/YYYYMMDD_HHMMSS/sneakyscanner.db data/ cp -r backups/YYYYMMDD_HHMMSS/configs/* configs/ cp -r backups/YYYYMMDD_HHMMSS/output/* output/ # Start application docker compose -f docker-compose.yml up -d ``` --- ## Support and Further Reading - **Project README**: `README.md` - General project information - **API Documentation**: `docs/API_REFERENCE.md` - Complete REST API reference - **Roadmap**: `docs/ROADMAP.md` - Project roadmap, feature plans, and architecture - **Issue Tracker**: File bugs and feature requests on GitHub --- ## What's New ### Phase 4 (2025-11-17) - Config Creator ✅ - **CIDR-based Config Creator**: Web UI for generating scan configs from CIDR ranges - **YAML Editor**: Built-in editor with syntax highlighting (CodeMirror) - **Config Management UI**: List, view, edit, download, and delete configs via web interface - **Config Upload**: Direct YAML file upload for advanced users - **REST API**: 7 new config management endpoints - **Schedule Protection**: Prevents deleting configs used by active schedules ### Phase 3 (2025-11-14) - Dashboard & Scheduling ✅ - **Dashboard**: Summary stats, recent scans, trend charts - **Scheduled Scans**: Cron-based scheduling with web UI management - **Scan History**: Detailed scan results with full data display - **Chart.js Integration**: Port count trends over time ### Phase 2 (2025-11-14) - Web Application Core ✅ - **REST API**: Complete API for scan management - **Background Jobs**: APScheduler-based async execution - **Authentication**: Session-based login system - **Database Integration**: SQLite with SQLAlchemy ORM ### Coming Soon: Phase 5 - Email, Webhooks & Comparisons - Email notifications for infrastructure changes - Webhook integrations (Slack, PagerDuty, custom) - Scan comparison reports - Alert rule configuration --- **Last Updated**: 2025-11-17 **Version**: Phase 4 - Config Creator Complete