Skip to content

cubiculus/Mikrotik_audit

Repository files navigation

πŸ” MikroTik Audit Tool

License: MIT Python 3.9+ Coverage Tests Security: Bandit GitHub Release

Professional automated audit tool for MikroTik RouterOS with security checks, web interface, and detailed reporting.

ΠŸΡ€ΠΎΡ„Π΅ΡΡΠΈΠΎΠ½Π°Π»ΡŒΠ½Ρ‹ΠΉ инструмСнт для Π°Π²Ρ‚ΠΎΠΌΠ°Ρ‚ΠΈΠ·ΠΈΡ€ΠΎΠ²Π°Π½Π½ΠΎΠ³ΠΎ Π°ΡƒΠ΄ΠΈΡ‚Π° MikroTik RouterOS с Π²Π΅Π±-интСрфСйсом, ΠΏΡ€ΠΎΠ²Π΅Ρ€ΠΊΠΎΠΉ бСзопасности ΠΈ Π³Π΅Π½Π΅Ρ€Π°Ρ†ΠΈΠ΅ΠΉ ΠΎΡ‚Ρ‡Ρ‘Ρ‚ΠΎΠ².

πŸ“– Documentation / ДокумСнтация

EN:

RU:

βœ… Tested On

RouterOS Version: 7.22 (stable) Hardware: hAP axΒ³ (C53UiG+5HPaxD2HPaxD) Python: 3.13 Last Tested: March 2026 Tests: 639 passed βœ… Coverage: 75% πŸ“Š

Features Verified:

  • βœ… CLI Π°ΡƒΠ΄ΠΈΡ‚ (3 уровня + 6 ΠΏΡ€ΠΎΡ„ΠΈΠ»Π΅ΠΉ)
  • βœ… Π’Π΅Π±-интСрфСйс (dashboard, история, сравнСниС)
  • βœ… ΠŸΡ€ΠΎΠ²Π΅Ρ€ΠΊΠ° бСзопасности (57 ΠΏΡ€ΠΎΠ²Π΅Ρ€ΠΎΠΊ)
  • βœ… Π”Π΅Ρ‚Π΅ΠΊΡ‚ΠΎΡ€ ΠΊΠΎΠ½Ρ„Π»ΠΈΠΊΡ‚ΠΎΠ² ΠΏΡ€Π°Π²ΠΈΠ» (8 Ρ‚ΠΈΠΏΠΎΠ²)
  • βœ… IoC дСтСкция (10 ΠΈΠ½Π΄ΠΈΠΊΠ°Ρ‚ΠΎΡ€ΠΎΠ² ΠΊΠΎΠΌΠΏΡ€ΠΎΠΌΠ΅Ρ‚Π°Ρ†ΠΈΠΈ)
  • βœ… Live CVE lookup (NIST NVD API)
  • βœ… ΠžΡ„Π»Π°ΠΉΠ½-Ρ€Π΅ΠΆΠΈΠΌ (RSC парсСр)
  • βœ… Автопатчинг (dry-run, rollback)
  • βœ… Анализ ΠΊΠΎΠ½Ρ‚Π΅ΠΉΠ½Π΅Ρ€ΠΎΠ²
  • βœ… Wi-Fi ΠΏΡ€ΠΎΠ²Π΅Ρ€ΠΊΠΈ
  • βœ… ВсС Ρ„ΠΎΡ€ΠΌΠ°Ρ‚Ρ‹ ΠΎΡ‚Ρ‡Ρ‘Ρ‚ΠΎΠ² (HTML, JSON, TXT, Markdown)

πŸš€ Quick Start

⚑ One-Line Install

Linux/Mac:

bash <(curl -Ls https://raw.githubusercontent.com/cubiculus/Mikrotik_audit/main/scripts/quick_install.sh)

Windows:

scripts\install.bat

πŸ“‹ Manual Install

# Clone repository
git clone https://github.com/cubiculus/Mikrotik_audit.git
cd Mikrotik_audit

# Create virtual environment
python -m venv venv

# Activate (Windows)
venv\Scripts\activate

# Install dependencies
pip install -r requirements.txt

# Install web interface (optional)
pip install -r requirements-web.txt

🎯 CLI Usage

# Run basic audit
python -m src.cli audit --router-ip 192.168.88.1 --ssh-user admin

# Run with profile (WiFi, security, network, etc.)
python -m src.cli audit --profile wifi --ssh-user admin

# Run with redaction (hide sensitive data)
python -m src.cli audit --redact --ssh-user admin

# Generate all report formats
python -m src.cli audit --all-formats --ssh-user admin

# Offline mode (analyze RSC file)
python -m src.cli audit --offline-file export.rsc

🌐 Web Interface

# Start web server
python -m src.cli web-server --port 5000

# Open browser
# http://127.0.0.1:5000

Features:

  • πŸ“Š Dashboard with statistics
  • πŸ“ Audit history
  • πŸ” Compare reports ("before/after")
  • πŸ“₯ Export reports (HTML, JSON, TXT, MD)
  • ⚑ Real-time audit progress

🎯 Use Cases

Scenario Why It Matters
Before firmware updates Document configuration and identify issues before upgrading
Security audits Detect misconfigurations, vulnerabilities, IoC indicators
Configuration conflicts Find unreachable rules, NAT bypasses, orphan marks
Handing over Generate comprehensive documentation
Forum troubleshooting Share sanitized reports for help
Compliance Maintain audit trails
Pre-deployment Verify configuration before production

πŸ”‘ Features

Security Analysis

  • 57 security checks across all RouterOS components
  • CVE vulnerability detection with live NIST NVD API lookup
  • IoC detection (10 indicators of compromise)
  • Wi-Fi security (WPS, WEP, WPA1/TKIP detection)
  • Service hardening (SSH, Winbox, API restrictions)

Conflict Detection

  • Unreachable rules (shadowed by catch-all)
  • NAT bypasses firewall
  • Orphan routing marks
  • Interface not in WAN/LAN lists
  • Address list conflicts
  • Missing FastTrack rules
  • Duplicate rules

Audit Profiles

  • wifi β€” Wi-Fi security checks
  • protocols β€” SNMP, UPnP, Proxy, RoMON
  • system β€” System-level checks
  • security β€” Firewall and security
  • network β€” Interfaces and routing
  • containers β€” Container analysis

Web Interface

  • Dashboard with real-time statistics
  • Audit history with SQLite storage
  • Compare reports ("before/after")
  • Export to all formats
  • Real-time progress via SSE

Offline Mode

  • Analyze RSC files without router connection
  • /export hide-sensitive support
  • Same analyzers as online mode

Auto-Patching

  • Dry-run mode (preview changes)
  • Confirmation for each change
  • Automatic rollback capability
  • Backup before changes

Reports

  • HTML β€” Interactive with charts
  • JSON β€” Machine-readable
  • TXT β€” Plain text
  • Markdown β€” Forum-friendly

πŸ“ Project Structure

Mikrotik_audit/
β”œβ”€β”€ src/
β”‚   β”œβ”€β”€ auditor.py              # Main audit orchestrator
β”‚   β”œβ”€β”€ security_analyzer.py    # Security checks (57 rules)
β”‚   β”œβ”€β”€ conflict_analyzer.py    # Conflict detection (8 types)
β”‚   β”œβ”€β”€ ioc_analyzer.py         # IoC detection (10 indicators)
β”‚   β”œβ”€β”€ patcher.py              # Auto-patching with rollback
β”‚   β”œβ”€β”€ rsc_parser.py           # Offline RSC parser
β”‚   β”œβ”€β”€ cve_database.py         # CVE database + NVD API
β”‚   β”œβ”€β”€ commands.py             # Audit commands + profiles
β”‚   β”œβ”€β”€ cli.py                  # CLI interface
β”‚   β”œβ”€β”€ web/                    # Web interface
β”‚   β”‚   β”œβ”€β”€ app.py              # Flask server
β”‚   β”‚   β”œβ”€β”€ database.py         # SQLite models
β”‚   β”‚   └── templates/          # HTML templates
β”‚   └── lab/                    # Lab tools
β”‚       └── config_generator.py # Test config generator
β”œβ”€β”€ tests/                      # 639 tests
β”œβ”€β”€ docs/                       # Documentation
β”œβ”€β”€ scripts/                    # Install/run scripts
β”œβ”€β”€ audit-reports/              # Generated reports (git-ignored)
└── requirements*.txt           # Dependencies

βš™οΈ CLI Parameters

Audit Command

Parameter Description Required Default
--router-ip Router IP address or hostname Yes* -
--ssh-port SSH port No 22
--ssh-user SSH username Yes -
--ssh-key-file Path to SSH private key No** -
--ssh-key-passphrase Passphrase for SSH key No -
--audit-level Audit level (Basic/Standard/Comprehensive) No Standard
--profile Audit profile (wifi/security/network/etc.) No -
--output-dir Output directory for reports No ./audit-reports
--skip-security Skip security analysis No False
--max-workers Maximum parallel workers No 0 (auto)
--redact Redact sensitive data No False
--all-formats Generate all report formats No False
--connect-timeout SSH connection timeout (seconds) No 30
--command-timeout Command timeout (seconds) No 120
--no-backup Skip system backup No False
--no-cve-check Disable CVE check No False
--offline-file RSC file for offline analysis No* -

* Either --router-ip or --offline-file must be provided ** Either MIKROTIK_PASSWORD or --ssh-key-file must be provided

Web Server Command

Parameter Description Default
--host Host to bind to 127.0.0.1
--port Port to listen on 5000
--debug Enable debug mode False

Environment Variables

MIKROTIK_PASSWORD=your_password
MIKROTIK_SSH_KEY_FILE=~/.ssh/id_rsa
MIKROTIK_SSH_KEY_PASSPHRASE=key_passphrase
MIKROTIK_CONNECT_TIMEOUT=30
MIKROTIK_COMMAND_TIMEOUT=120
NVD_API_KEY=your_nist_api_key  # Optional, for higher rate limits

πŸ§ͺ Testing

# Run all tests
pytest

# Run with coverage
pytest --cov=src --cov-report=html

# Run specific test file
pytest tests/test_security_analyzer.py -v

# Run web tests
pytest tests/web/ -v

Test Statistics:

  • Total tests: 639
  • Passed: 639 βœ…
  • Coverage: 75%

πŸ“Έ Screenshots

Web Dashboard

Web Dashboard

HTML Report

HTML Report

Conflict Detection

Conflicts

πŸ”— Links

πŸ“„ License

MIT License - see LICENSE for details.


Made with ❀️ for the MikroTik community

About

Automated security audit tool for MikroTik RouterOS. 57 checks, CVE lookup, conflict detection, web UI & reports.

Topics

Resources

Contributing

Security policy

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages