mikrotik-rsc-auditor 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +287 -0
- package/SKILL.md +289 -0
- package/examples/minimal-config.rsc +55 -0
- package/examples/sanitized-export.rsc +453 -0
- package/examples/vulnerable-config.rsc +46 -0
- package/package.json +40 -0
- package/references/AUDIT_CHECKS.md +2092 -0
- package/references/COMPLIANCE_MAPPING.md +955 -0
- package/references/EXAMPLES.md +400 -0
- package/references/HARDWARE_COMPATIBILITY.md +609 -0
- package/references/SCRIPTING_PITFALLS.md +452 -0
- package/references/SECURITY_BASELINE.md +1280 -0
- package/references/SYNTAX_REFERENCE.md +1613 -0
- package/scripts/__init__.py +0 -0
- package/scripts/audit_rsc.py +2901 -0
- package/scripts/check_hardware_map.py +337 -0
- package/scripts/conflict_analyzer.py +1551 -0
- package/scripts/conflict_explanations.py +650 -0
- package/scripts/cve_database.py +1111 -0
- package/scripts/device_profiles.py +479 -0
- package/scripts/ioc_analyzer.py +784 -0
- package/scripts/lint_rsc.py +587 -0
- package/scripts/sanitize_rsc.py +72 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 MikroTik RSC Auditor Contributors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,287 @@
|
|
|
1
|
+
<!-- markdownlint-disable MD033 MD041 -->
|
|
2
|
+
|
|
3
|
+
# 🔍 MikroTik RouterOS .rsc Auditor
|
|
4
|
+
|
|
5
|
+
[](LICENSE)
|
|
6
|
+
[](https://www.python.org/downloads/)
|
|
7
|
+
[](https://github.com/nicolodavis/pi)
|
|
8
|
+
[](scripts/audit_rsc.py)
|
|
9
|
+
[](README.md)
|
|
10
|
+
|
|
11
|
+
**Offline static analysis tool for auditing MikroTik RouterOS .rsc configuration files — 108 security checks across 9 domains, CVSS v3.1 scoring, compliance mapping (CIS/NIST/ISO/PCI-DSS), conflict detection, IoC detection, and script linting.**
|
|
12
|
+
|
|
13
|
+
---
|
|
14
|
+
|
|
15
|
+
## ✨ Features
|
|
16
|
+
|
|
17
|
+
| Feature | Description |
|
|
18
|
+
|---------|-------------|
|
|
19
|
+
| 🔒 **108 Security Checks** | Authentication, services, firewall, system hardening, networking, routing, WiFi, scripts, compliance |
|
|
20
|
+
| 📊 **CVSS v3.1 Scoring** | Every finding scored with severity (Critical/High/Medium/Low/Info) and CVSS vector |
|
|
21
|
+
| 🏛️ **Compliance Mapping** | CIS RouterOS Benchmark, NIST SP 800-53, ISO 27001, PCI-DSS per-finding cross-references |
|
|
22
|
+
| 🚨 **Conflict Detection** | 8 rule conflict types — unreachable rules, NAT bypasses, orphan marks, duplicates, and more |
|
|
23
|
+
| 🕵️ **IoC Detection** | 10 compromise indicators — scheduler backdoors, DNS hijacking, cryptominers, C2 patterns |
|
|
24
|
+
| 📝 **Script Linter** | 15+ rules with scope-aware context suppression, guard tracking, CI-ready exit codes |
|
|
25
|
+
| 🧩 **Zero Dependencies** | Pure Python stdlib — install on any system with Python 3.10+ |
|
|
26
|
+
| 🤖 **Pi Agent Integration** | Installable as a pi skill with interactive onboarding for first-time users |
|
|
27
|
+
|
|
28
|
+
---
|
|
29
|
+
|
|
30
|
+
## 🚀 Quick Start
|
|
31
|
+
|
|
32
|
+
```bash
|
|
33
|
+
# Install from PyPI
|
|
34
|
+
pip install mikrotik-rsc-auditor
|
|
35
|
+
|
|
36
|
+
# Audit a RouterOS export
|
|
37
|
+
mikrotik-audit export.rsc
|
|
38
|
+
|
|
39
|
+
# Or use directly from source
|
|
40
|
+
python scripts/audit_rsc.py export.rsc
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
---
|
|
44
|
+
|
|
45
|
+
## 📖 Usage
|
|
46
|
+
|
|
47
|
+
### Basic Audit
|
|
48
|
+
|
|
49
|
+
```bash
|
|
50
|
+
mikrotik-audit export.rsc
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
### JSON Output
|
|
54
|
+
|
|
55
|
+
```bash
|
|
56
|
+
mikrotik-audit export.rsc --format json
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
### HTML Report
|
|
60
|
+
|
|
61
|
+
```bash
|
|
62
|
+
mikrotik-audit export.rsc --format html -o report.html
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
### Severity Filter (High+Critical only)
|
|
66
|
+
|
|
67
|
+
```bash
|
|
68
|
+
mikrotik-audit export.rsc --severity high
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
### Specific Checks
|
|
72
|
+
|
|
73
|
+
```bash
|
|
74
|
+
mikrotik-audit export.rsc --check AUTH-001,FW-003
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
### CVE Vulnerability Check
|
|
78
|
+
|
|
79
|
+
```bash
|
|
80
|
+
mikrotik-audit export.rsc --cve
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
### Live NVD CVE Lookup (requires internet)
|
|
84
|
+
|
|
85
|
+
```bash
|
|
86
|
+
export NVD_API_KEY=your_key
|
|
87
|
+
mikrotik-audit export.rsc --cve --cve-live
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
### Conflict Detection
|
|
91
|
+
|
|
92
|
+
```bash
|
|
93
|
+
mikrotik-audit export.rsc --conflicts
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
### IoC / Compromise Detection
|
|
97
|
+
|
|
98
|
+
```bash
|
|
99
|
+
mikrotik-audit export.rsc --ioc
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
### Lint a Script (development-time validation)
|
|
103
|
+
|
|
104
|
+
```bash
|
|
105
|
+
mikrotik-audit export.rsc --lint my-script.rsc
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
### All Features
|
|
109
|
+
|
|
110
|
+
```bash
|
|
111
|
+
mikrotik-audit export.rsc --cve --conflicts --ioc --format html -o full-report.html
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
---
|
|
115
|
+
|
|
116
|
+
## ⚙️ CLI Flags
|
|
117
|
+
|
|
118
|
+
| Flag | Type | Description | Default |
|
|
119
|
+
|------|------|-------------|---------|
|
|
120
|
+
| `file` | positional | Path to `.rsc` configuration file | required |
|
|
121
|
+
| `--format` | choice | Output format: `text`, `json`, `html` | `text` |
|
|
122
|
+
| `--severity` | choice | Minimum severity: `critical`, `high`, `medium`, `low`, `info` | all |
|
|
123
|
+
| `--check` | string | Comma-separated check IDs to run (e.g., `AUTH-001,FW-003`) | all |
|
|
124
|
+
| `--cve` | flag | Enable CVE vulnerability check using static database | off |
|
|
125
|
+
| `--cve-live` | flag | Enable live NIST NVD API lookup (requires internet) | off |
|
|
126
|
+
| `--conflicts` | flag | Enable 8-type rule conflict analysis | off |
|
|
127
|
+
| `--ioc` | flag | Enable 10-type compromise indicator detection | off |
|
|
128
|
+
| `--lint` | string | Path to a `.rsc` script file to lint (used alongside the config file) | — |
|
|
129
|
+
| `--skip-wifi` | flag | Skip WiFi security checks (for non-wireless devices) | off |
|
|
130
|
+
| `--skip-routing` | flag | Skip routing security checks (BGP/OSPF) | off |
|
|
131
|
+
| `-o, --output` | path | Save report to file instead of stdout | — |
|
|
132
|
+
|
|
133
|
+
---
|
|
134
|
+
|
|
135
|
+
## 🤖 Pi Agent Interactive Mode
|
|
136
|
+
|
|
137
|
+
When installed as a pi agent skill, the auditor offers **interactive onboarding** on first run:
|
|
138
|
+
|
|
139
|
+
1. **Device Role** — Home router / Office gateway / Enterprise / ISP — determines security baseline
|
|
140
|
+
2. **Services in Use** — Multi-select which features this device provides (WiFi, NAT, DHCP, VPN, routing, CAPsMAN)
|
|
141
|
+
3. **Audit Scope** — Quick review / Standard / Compliance — controls check depth
|
|
142
|
+
4. **Conditional Follow-ups** — Compliance framework, WiFi type, routing profile (only if relevant)
|
|
143
|
+
|
|
144
|
+
Answers are saved to `~/.config/mikrotik-auditor/profile.yml` — subsequent runs are fully silent.
|
|
145
|
+
|
|
146
|
+
```bash
|
|
147
|
+
# Install as pi skill
|
|
148
|
+
pi install npm:@scope/mikrotik-rsc-auditor
|
|
149
|
+
|
|
150
|
+
# Run interactively (first time)
|
|
151
|
+
mikrotik-audit export.rsc
|
|
152
|
+
# → asks 3-4 questions, then runs tailored audit
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
---
|
|
156
|
+
|
|
157
|
+
## 📋 Report Formats
|
|
158
|
+
|
|
159
|
+
### Text Report
|
|
160
|
+
Terminal-friendly output with severity grouping, score, top-5 executive summary, and per-finding remediation commands. Includes safety warnings for high-risk changes.
|
|
161
|
+
|
|
162
|
+
### JSON Report
|
|
163
|
+
Structured machine-readable output for pipeline integration:
|
|
164
|
+
|
|
165
|
+
```json
|
|
166
|
+
{
|
|
167
|
+
"meta": { "device_model": "C53UiG+5HPaxD2HPaxD", "version": "7.22.3" },
|
|
168
|
+
"score": { "score": 72, "grade": "B", "by_severity": { "Critical": 0, "High": 2 } },
|
|
169
|
+
"findings": [
|
|
170
|
+
{
|
|
171
|
+
"id": "AUTH-005",
|
|
172
|
+
"name": "SSH weak-crypto enabled",
|
|
173
|
+
"severity": "High",
|
|
174
|
+
"cvss": "7.5",
|
|
175
|
+
"category": "Authentication & Access Control",
|
|
176
|
+
"remediation": "/ip ssh set strong-crypto=yes"
|
|
177
|
+
}
|
|
178
|
+
]
|
|
179
|
+
}
|
|
180
|
+
```
|
|
181
|
+
|
|
182
|
+
### HTML Report
|
|
183
|
+
Self-contained dark-mode compatible HTML with color-coded severity badges, score display, and remediation blocks.
|
|
184
|
+
|
|
185
|
+
---
|
|
186
|
+
|
|
187
|
+
## 🏛️ Compliance Frameworks
|
|
188
|
+
|
|
189
|
+
| Framework | Coverage |
|
|
190
|
+
|-----------|----------|
|
|
191
|
+
| **CIS RouterOS Benchmark v1.x** | 42 controls mapped |
|
|
192
|
+
| **NIST SP 800-53** | 30+ controls (AC, AU, IA, SC, SI, PE, CP) |
|
|
193
|
+
| **ISO 27001** | 25+ controls (A.8, A.9, A.10, A.12, A.13, A.17) |
|
|
194
|
+
| **PCI-DSS** | 15+ requirements (1, 2, 4, 6, 7, 8, 10, 11) |
|
|
195
|
+
|
|
196
|
+
---
|
|
197
|
+
|
|
198
|
+
## 📁 Project Structure
|
|
199
|
+
|
|
200
|
+
```
|
|
201
|
+
mikrotik-rsc-auditor/
|
|
202
|
+
├── scripts/
|
|
203
|
+
│ ├── audit_rsc.py # Main entry point (2,860 lines)
|
|
204
|
+
│ ├── cve_database.py # CVE lookup + NVD API (1,111 lines)
|
|
205
|
+
│ ├── conflict_analyzer.py # 8 conflict types (1,551 lines)
|
|
206
|
+
│ ├── conflict_explanations.py # User-friendly explanations (650 lines)
|
|
207
|
+
│ ├── ioc_analyzer.py # 10 IoC types (784 lines)
|
|
208
|
+
│ ├── sanitize_rsc.py # Config redaction for safe sharing (72 lines)
|
|
209
|
+
│ └── lint_rsc.py # Script linter with scope tracking (587 lines)
|
|
210
|
+
├── references/
|
|
211
|
+
│ ├── AUDIT_CHECKS.md # 108-item audit checklist
|
|
212
|
+
│ ├── SECURITY_BASELINE.md # Secure configuration baseline
|
|
213
|
+
│ ├── SYNTAX_REFERENCE.md # RouterOS .rsc syntax reference
|
|
214
|
+
│ ├── COMPLIANCE_MAPPING.md # CIS/NIST/ISO/PCI-DSS crosswalk
|
|
215
|
+
│ ├── EXAMPLES.md # Idempotent scripting patterns
|
|
216
|
+
│ └── SCRIPTING_PITFALLS.md # Common RouterOS scripting mistakes
|
|
217
|
+
├── examples/
|
|
218
|
+
│ ├── sanitized-export.rsc # Sanitized real-world export
|
|
219
|
+
│ ├── minimal-config.rsc # Minimal secure configuration
|
|
220
|
+
│ └── vulnerable-config.rsc # Deliberately insecure demo config
|
|
221
|
+
├── tests/ # Test suite
|
|
222
|
+
├── CHANGELOG.md # Release history
|
|
223
|
+
├── CONTRIBUTING.md # Contribution guide
|
|
224
|
+
├── LICENSE # MIT license
|
|
225
|
+
├── pyproject.toml # Python packaging
|
|
226
|
+
└── README.md # This file
|
|
227
|
+
```
|
|
228
|
+
|
|
229
|
+
---
|
|
230
|
+
|
|
231
|
+
## 📦 Installation
|
|
232
|
+
|
|
233
|
+
### From PyPI (recommended)
|
|
234
|
+
|
|
235
|
+
```bash
|
|
236
|
+
pip install mikrotik-rsc-auditor
|
|
237
|
+
```
|
|
238
|
+
|
|
239
|
+
### Isolated with pipx
|
|
240
|
+
|
|
241
|
+
```bash
|
|
242
|
+
pipx install mikrotik-rsc-auditor
|
|
243
|
+
```
|
|
244
|
+
|
|
245
|
+
### From source
|
|
246
|
+
|
|
247
|
+
```bash
|
|
248
|
+
git clone https://github.com/your-org/mikrotik-rsc-auditor.git
|
|
249
|
+
cd mikrotik-rsc-auditor
|
|
250
|
+
pip install -e .
|
|
251
|
+
```
|
|
252
|
+
|
|
253
|
+
### As a pi agent skill
|
|
254
|
+
|
|
255
|
+
```bash
|
|
256
|
+
pi install npm:@scope/mikrotik-rsc-auditor
|
|
257
|
+
```
|
|
258
|
+
|
|
259
|
+
---
|
|
260
|
+
|
|
261
|
+
## 📋 Requirements
|
|
262
|
+
|
|
263
|
+
- Python 3.10 or later
|
|
264
|
+
- **Zero external dependencies** — only Python standard library
|
|
265
|
+
- For live CVE lookup: internet access + optional `NVD_API_KEY` environment variable
|
|
266
|
+
- For linting: RouterOS script files (`.rsc`)
|
|
267
|
+
|
|
268
|
+
---
|
|
269
|
+
|
|
270
|
+
## 🤝 Contributing
|
|
271
|
+
|
|
272
|
+
See [CONTRIBUTING.md](CONTRIBUTING.md) for guidelines on reporting bugs, suggesting features, and submitting pull requests.
|
|
273
|
+
|
|
274
|
+
---
|
|
275
|
+
|
|
276
|
+
## 📄 License
|
|
277
|
+
|
|
278
|
+
MIT License — see [LICENSE](LICENSE) for full text.
|
|
279
|
+
|
|
280
|
+
---
|
|
281
|
+
|
|
282
|
+
## 🔗 Related
|
|
283
|
+
|
|
284
|
+
- [MikroTik RouterOS Documentation](https://help.mikrotik.com/docs/)
|
|
285
|
+
- [CIS RouterOS Benchmark](https://www.cisecurity.org/benchmark/mikrotik_routeros)
|
|
286
|
+
- [NIST NVD](https://nvd.nist.gov/)
|
|
287
|
+
- [Pi Agent Framework](https://github.com/nicolodavis/pi)
|
package/SKILL.md
ADDED
|
@@ -0,0 +1,289 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: mikrotik-rsc-auditor
|
|
3
|
+
description: "Audit MikroTik RouterOS configuration files (.rsc) for security issues, compliance gaps, syntax errors, and configuration best practices. Performs comprehensive offline static analysis of exported RouterOS configs. Use when auditing .rsc files, reviewing RouterOS security, or assessing MikroTik device configurations for compliance hardening."
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# MikroTik RouterOS .rsc Auditor
|
|
7
|
+
|
|
8
|
+
Expert-level offline static analysis skill for auditing MikroTik RouterOS exported configuration files (`.rsc`). Covers 100+ audit checks across 9 security domains with CVSS-based severity scoring, compliance mapping (CIS/NIST/ISO/PCI-DSS), and generated remediation scripts.
|
|
9
|
+
|
|
10
|
+
## When to Use
|
|
11
|
+
|
|
12
|
+
- A `.rsc` configuration export is provided for security review
|
|
13
|
+
- Evaluating a RouterOS deployment for security hardening compliance
|
|
14
|
+
- Pre-deployment audit of a configuration before applying to production
|
|
15
|
+
- Post-incident forensic review of router configuration artifacts
|
|
16
|
+
- Compliance audit mapping RouterOS config to CIS/NIST/ISO/PCI-DSS controls
|
|
17
|
+
- Assessing MikroTik hAP, CCR, RB, or Cloud Core Router configurations
|
|
18
|
+
|
|
19
|
+
**NOT for:**
|
|
20
|
+
- Live SSH/REST API interaction with a running RouterOS device
|
|
21
|
+
- Creating new `.rsc` scripts from scratch (see `mikrotik-routeros-rsc` skill)
|
|
22
|
+
- Realtime traffic analysis or SNMP monitoring
|
|
23
|
+
- Configuring CAPsMAN, BGP sessions, or other dynamic protocols
|
|
24
|
+
|
|
25
|
+
## Audit Methodology
|
|
26
|
+
|
|
27
|
+
The audit follows a 9-phase static analysis methodology applied to the entire `.rsc` file:
|
|
28
|
+
|
|
29
|
+
```
|
|
30
|
+
Phase 1: Parse & Normalize — Tokenize the .rsc, extract all config paths
|
|
31
|
+
Phase 2: Authentication Audit — Users, groups, service ACLs, password policies
|
|
32
|
+
Phase 3: Service Surface Audit — All enabled services, their bindings and ACLs
|
|
33
|
+
Phase 4: Firewall & RAW Audit — Filter/NAT/Mangle rules, connection tracking
|
|
34
|
+
Phase 5: System Hardening Audit — Version, NTP, logging, updates, backups
|
|
35
|
+
Phase 6: Network Config Audit — VLANs, bridges, DHCP, DNS, interfaces
|
|
36
|
+
Phase 7: Routing Security Audit — BGP/OSPF auth, filters, prefix limits
|
|
37
|
+
Phase 8: WiFi Security Audit — Encryption, isolation, CAPsMAN, PMF
|
|
38
|
+
Phase 9: Script & Automation — Script permissions, hardcoded secrets, scheduler
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
Each finding is assigned a severity using CVSS v3.1 principles adapted for configuration analysis:
|
|
42
|
+
|
|
43
|
+
| Severity | Score Range | Impact | Example |
|
|
44
|
+
|----------|-------------|--------|---------|
|
|
45
|
+
| **Critical** | 9.0–10.0 | Immediate compromise | Default admin, no firewall, WAN services exposed |
|
|
46
|
+
| **High** | 7.0–8.9 | Significant weakness | Open DNS resolver, SNMP public, no brute-force protection |
|
|
47
|
+
| **Medium** | 4.0–6.9 | Defense-in-depth gap | No remote syslog, NTP not configured, bridge MTU misconfig |
|
|
48
|
+
| **Low** | 0.1–3.9 | Informational | System identity not set, LCD not configured |
|
|
49
|
+
| **Info** | 0.0 | Reference only | RouterOS version reported, model identified |
|
|
50
|
+
|
|
51
|
+
## Audit Check Categories
|
|
52
|
+
|
|
53
|
+
### 1. Authentication & Access Control (AUTH) — 18 checks — Critical
|
|
54
|
+
Default admin, weak/no passwords, users without IP restrictions, SSH crypto, MAC-services (telnet/winbox/ping), WinBox/API on WAN, login restrictions, password policies, RoMON, permissive policies.
|
|
55
|
+
|
|
56
|
+
### 2. Service Hardening (SRV) — 17 checks — High
|
|
57
|
+
DNS open resolver, bandwidth server, proxy/SOCKS/UPnP, neighbor discovery on WAN, SNMP v1/v2c public, Telnet/FTP/PPTP, cloud services, SMB, WebFig HTTP, unused interfaces.
|
|
58
|
+
|
|
59
|
+
### 3. Firewall & Network Security (FW) — 17 checks — Critical/High
|
|
60
|
+
Missing default rules, no WAN drop, no established/related, brute-force protection, bogon filtering (RAW), IPv6 firewall, FastTrack, port knocking, unrestricted WAN access, ICMP rate limiting, DSTNAT controls, broadcast blocking, connection tracking limits.
|
|
61
|
+
|
|
62
|
+
### 4. System Hardening (SYS) — 10 checks — High
|
|
63
|
+
RouterOS version (CVE check), identity, NTP, local logging, remote syslog, update policy, unsigned packages, support output, backup configuration.
|
|
64
|
+
|
|
65
|
+
### 5. Network Configuration (NET) — 9 checks — Medium
|
|
66
|
+
Bridge VLAN filtering, DHCP security, DHCP lease storage on flash-constrained, DNS cache poisoning, MTU, VRRP/HA, hAP ac² offload considerations.
|
|
67
|
+
|
|
68
|
+
### 6. Routing Security (ROUTE) — 9 checks — Medium/High
|
|
69
|
+
BGP MD5 auth, OSPF auth, routing filters, BGP TTL security, prefix limits, dynamic routing on WAN, default route resilience, loopback router ID.
|
|
70
|
+
|
|
71
|
+
### 7. WiFi Security (WIFI) — 13 checks — High/Medium
|
|
72
|
+
Insecure encryption (WEP/TKIP), WPS, guest isolation, hidden SSID, per-band security, client isolation, CAPsMAN encryption, access lists, PMF, password strength, DFS radar handling, hAP ac² flash crisis.
|
|
73
|
+
|
|
74
|
+
### 8. Script & Automation (SCRIPT) — 9 checks — Medium
|
|
75
|
+
Excessive permissions, hardcoded credentials, single-instance guards, error handling, global variable pollution, destructive commands.
|
|
76
|
+
|
|
77
|
+
### 9. Compliance Mapping (COMP) — 6 info checks
|
|
78
|
+
CIS crosswalk, NIST SP 800-53, ISO 27001, PCI-DSS, Mitre ATT&CK, CVSS scoring.
|
|
79
|
+
|
|
80
|
+
## Interactive Onboarding
|
|
81
|
+
|
|
82
|
+
When the user invokes the skill on a `.rsc` file without providing additional context, use `ask_user_question` to gather missing information. This tailors the audit to the specific device and deployment, reducing false positives and irrelevant findings.
|
|
83
|
+
|
|
84
|
+
### Tier 1 Questions (Essential — ask on first run, skip if profile exists)
|
|
85
|
+
|
|
86
|
+
**Question 1: Device Role** — Determines the security baseline severity:
|
|
87
|
+
- Home Router → relaxed defaults (WAN-side UPnP = Info, not Critical)
|
|
88
|
+
- Office/SMB Gateway → medium hardening (VLAN isolation, VPN checks enabled)
|
|
89
|
+
- Enterprise Router → maximum hardening (RADIUS, 802.1X, logging checks = Critical)
|
|
90
|
+
- ISP/DC Router → carrier-grade (BGP security, minimal attack surface focus)
|
|
91
|
+
|
|
92
|
+
**Question 2: Services in Use** — Multi-select; unused services get N/A (excluded from report):
|
|
93
|
+
- Internet Gateway / NAT
|
|
94
|
+
- WiFi Access Point (2.4GHz, 5GHz, or both)
|
|
95
|
+
- DHCP Server
|
|
96
|
+
- DNS Server
|
|
97
|
+
- VPN Server (L2TP/IPsec, SSTP, WireGuard, OpenVPN)
|
|
98
|
+
- Dynamic Routing (BGP, OSPF)
|
|
99
|
+
- CAPsMAN Controller
|
|
100
|
+
|
|
101
|
+
**Question 3: Audit Scope** — Controls check depth:
|
|
102
|
+
- Quick Review → top 15 critical/high checks only (~2 seconds)
|
|
103
|
+
- Standard Audit → all 108 checks with full scoring
|
|
104
|
+
- Compliance Focus → filtered to selected framework
|
|
105
|
+
|
|
106
|
+
### Tier 2 Questions (Conditional — ask only if relevant)
|
|
107
|
+
|
|
108
|
+
**If Compliance Focus selected:** Which framework? (CIS / NIST / ISO / PCI-DSS)
|
|
109
|
+
|
|
110
|
+
**If WiFi selected:** Deployment type? (Home/SOHO / Office-Enterprise / Public Hotspot)
|
|
111
|
+
|
|
112
|
+
**If Routing selected:** Profile? (Single ISP / Multi-homed BGP / Internal OSPF)
|
|
113
|
+
|
|
114
|
+
### Profile Persistence
|
|
115
|
+
|
|
116
|
+
Save answers to `~/.config/mikrotik-auditor/profile.yml` after the first run:
|
|
117
|
+
|
|
118
|
+
```yaml
|
|
119
|
+
version: 1
|
|
120
|
+
device_role: "office"
|
|
121
|
+
services:
|
|
122
|
+
- nat
|
|
123
|
+
- wifi
|
|
124
|
+
- dhcp
|
|
125
|
+
audit_scope: "standard"
|
|
126
|
+
compliance: "cis"
|
|
127
|
+
routing: null
|
|
128
|
+
wifi_type: "home"
|
|
129
|
+
cve_check: "offline"
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
On subsequent runs, if the profile exists, skip all questions and use saved values (silent mode). Offer to re-interview if the user passes `--reconfigure`.
|
|
133
|
+
|
|
134
|
+
### Answer → Audit Mapping
|
|
135
|
+
|
|
136
|
+
| Answer | Effect |
|
|
137
|
+
|--------|--------|
|
|
138
|
+
| `device_role = "home"` | Relaxed severity for WAN-side UPnP, management access |
|
|
139
|
+
| `device_role = "enterprise"` | RADIUS, 802.1X, logging checks become Critical severity |
|
|
140
|
+
| `services = ["wifi"]` | WiFi checks are active. Missing encryption → Critical |
|
|
141
|
+
| `services = []` | WiFi checks set to N/A — excluded from report |
|
|
142
|
+
| `services = ["routing"]` | BGP/OSPF authentication checks enabled |
|
|
143
|
+
| `audit_scope = "quick"` | Only top 15 findings by CVSS score |
|
|
144
|
+
| `audit_scope = "compliance"` | Filter to compliance-mapped checks only |
|
|
145
|
+
| `cve_check = "offline"` | Pass `--cve` to audit_rsc.py |
|
|
146
|
+
| `cve_check = "live"` | Pass `--cve --cve-live` to audit_rsc.py |
|
|
147
|
+
|
|
148
|
+
### Implementation Note
|
|
149
|
+
|
|
150
|
+
All interactivity lives in this SKILL.md — the Python tools remain pure CLI with no interactive logic. The `ask_user_question` tool is a pi agent capability. Profile reading/writing is done via `bash` commands (`cat`, `write`). This separation keeps the CLI tool chainable in pipelines while the skill provides the interactive UX.
|
|
151
|
+
|
|
152
|
+
## Response Approach
|
|
153
|
+
|
|
154
|
+
1. **Check for profile** — If `~/.config/mikrotik-auditor/profile.yml` exists, read it silently. If not, enter interactive onboarding (see Interactive Onboarding section).
|
|
155
|
+
2. **Parse** the `.rsc` file — extract all configuration paths, commands, and parameters
|
|
156
|
+
3. **Apply context** — Use profile answers to tailor check relevance, severity, and scope
|
|
157
|
+
4. **Run audit checks** against each configuration domain in order (AUTH → SRV → FW → SYS → NET → ROUTE → WIFI → SCRIPT → COMP)
|
|
158
|
+
5. **Assign severity** to each finding using the CVSS-based scale, adjusted by device role and hardware profile
|
|
159
|
+
6. **Generate remediation** — produce the exact RouterOS CLI commands to fix each finding
|
|
160
|
+
7. **Score the config** — overall security score (0–100) with per-category breakdown
|
|
161
|
+
8. **Generate reports** — structured JSON, raw text, and Markdown report format with severity grouping
|
|
162
|
+
9. **Map to compliance frameworks** — cross-reference each finding to CIS/NIST/ISO/PCI-DSS controls
|
|
163
|
+
10. **Save profile** — If this was an interactive run, save answers to profile.yml for next time
|
|
164
|
+
|
|
165
|
+
## Report Structure
|
|
166
|
+
|
|
167
|
+
Every audit produces a structured report with these sections:
|
|
168
|
+
```
|
|
169
|
+
1. Meta — device model, RouterOS version, export timestamp, software ID
|
|
170
|
+
2. Risk Score — overall (0-100) with per-category heatmap
|
|
171
|
+
3. Critical Findings — immediate action required (list with CVSS, path, fix)
|
|
172
|
+
4. High Findings — significant security weaknesses (list with CVSS, path, fix)
|
|
173
|
+
5. Medium Findings — defense-in-depth gaps (list with CVSS, path, fix)
|
|
174
|
+
6. Low Findings — informational (list)
|
|
175
|
+
7. Compliance Map — CIS/NIST/ISO/PCI-DSS control mappings per finding
|
|
176
|
+
8. Summary Statistics — counts by severity, category hits, false positive notes
|
|
177
|
+
9. Remediation Commands — per-finding RouterOS CLI commands (consolidation planned)
|
|
178
|
+
10. Hardware Profile — detected device model and applied profile details
|
|
179
|
+
```
|
|
180
|
+
|
|
181
|
+
## Safety Guardrails
|
|
182
|
+
|
|
183
|
+
- **DO NOT** output actual credentials, keys, or certificates found in configs — mask with `[REDACTED]`
|
|
184
|
+
- **DO NOT** suggest `system reset-configuration` unless explicitly requested
|
|
185
|
+
- **DO NOT** recommend firmware downgrades without CVE justification
|
|
186
|
+
- **DO NOT** recommend blocking essential services without understanding the deployment context
|
|
187
|
+
- **ALWAYS** classify findings with severity and note when context may change risk level
|
|
188
|
+
- **ALWAYS** include the exact config path in findings for reproducible reference
|
|
189
|
+
- **ALWAYS** provide remediation CLI commands for every actionable finding
|
|
190
|
+
|
|
191
|
+
## Limitations & Assumptions
|
|
192
|
+
|
|
193
|
+
- Offline analysis cannot verify live state — only what was exported. Some checks (e.g., port knocking state, brute-force detection) inherently require live access.
|
|
194
|
+
- Export file format assumptions: assumes standard `/export` output; `hide-sensitive=yes` masks passwords; `verbose=yes` includes defaults; `compact=yes` (default) omits default values.
|
|
195
|
+
- If `hide-sensitive` was used, password-related checks show `[REDACTED]` values, which must be noted as indeterminate.
|
|
196
|
+
- RouterOS v7 vs v6 syntax differences are flagged but both are validated against their respective grammar.
|
|
197
|
+
- hAP ac² flash space cannot be determined from a config export — requires live `/system resource print`.
|
|
198
|
+
- Device model detection from export header is best-effort (model line may be truncated or absent). When no profile matches, a generic profile is used with default severity and no hardware-specific exclusions.
|
|
199
|
+
|
|
200
|
+
## References
|
|
201
|
+
|
|
202
|
+
- [references/AUDIT_CHECKS.md](references/AUDIT_CHECKS.md) — Complete 100+ item audit checklist with per-check rationale, query, and fix
|
|
203
|
+
- [references/SECURITY_BASELINE.md](references/SECURITY_BASELINE.md) — Secure configuration baseline with service-by-service safe defaults
|
|
204
|
+
- [references/SYNTAX_REFERENCE.md](references/SYNTAX_REFERENCE.md) — RouterOS .rsc syntax and validation rules
|
|
205
|
+
- [references/COMPLIANCE_MAPPING.md](references/COMPLIANCE_MAPPING.md) — CIS/NIST/ISO/PCI-DSS control mapping reference
|
|
206
|
+
- [references/EXAMPLES.md](references/EXAMPLES.md) — Idempotent RouterOS scripting patterns with copy-paste ready code
|
|
207
|
+
- [references/SCRIPTING_PITFALLS.md](references/SCRIPTING_PITFALLS.md) — Common RouterOS scripting mistakes and safe alternatives
|
|
208
|
+
- [references/HARDWARE_COMPATIBILITY.md](references/HARDWARE_COMPATIBILITY.md) — Hardware compatibility matrix with device profiles, severity adjustments, and per-family check applicability for 15+ MikroTik device families
|
|
209
|
+
- [scripts/audit_rsc.py](scripts/audit_rsc.py) — Python tool for automated offline .rsc audit with HTML/JSON/TXT reports
|
|
210
|
+
|
|
211
|
+
## Related Tools
|
|
212
|
+
|
|
213
|
+
The following companion scripts extend the auditor with specialized analysis capabilities:
|
|
214
|
+
|
|
215
|
+
- [scripts/cve_database.py](scripts/cve_database.py) — CVE lookup tool for RouterOS versions. Uses a static database of 9+ known CVEs (CVE-2018-14847 through CVE-2024-23895) with version parsing, wildcard/range matching, and severity scoring. Supports optional live NIST NVD API v2.0 lookup with 24-hour caching. Integrated via `--cve` and `--cve-live` flags.
|
|
216
|
+
|
|
217
|
+
- [scripts/conflict_analyzer.py](scripts/conflict_analyzer.py) — Rule conflict detection for firewall, NAT, and mangle configurations. Detects 8 conflict types: unreachable rules, NAT bypasses firewall, orphan routing marks, interfaces not in interface lists, address list conflicts, missing FastTrack, shadowed rules, and duplicate rules. Integrated via `--conflicts` flag.
|
|
218
|
+
|
|
219
|
+
- [scripts/ioc_analyzer.py](scripts/ioc_analyzer.py) — Indicator of Compromise (IoC) detection for signs of active RouterOS compromise. Checks for: scheduler fetch backdoors (VPNFilter pattern), SOCKS/HTTP proxies (Meris botnet), suspicious files, unknown admin users, DNS hijacking, mangle sniff rules, cryptominer indicators, and C2 patterns (IP:port, Telegram, Discord webhooks). Integrated via `--ioc` flag.
|
|
220
|
+
|
|
221
|
+
- [scripts/lint_rsc.py](scripts/lint_rsc.py) — Heuristic script linter for pre-deployment validation of .rsc scripts. Features scope-tracking engine (5 scope kinds), context-aware suppression, and 15+ rules across 5 categories. Detects destructive commands, unconditional bulk removes, unguarded `add` operations, fixed numeric IDs, bare `import` usage, `:delay` in loops, and credential leakage in `:log` statements. Integrated via `--lint` flag.
|
|
222
|
+
|
|
223
|
+
- [scripts/device_profiles.py](scripts/device_profiles.py) — Device profile definitions for 15+ MikroTik hardware families. Detects device model from export header and tailors audit checks (severity adjustments, N/A exclusions, special hardware checks) to the specific platform. Powers the Hardware Compatibility system.
|
|
224
|
+
|
|
225
|
+
## Hardware Compatibility
|
|
226
|
+
|
|
227
|
+
The auditor includes a hardware-aware device profile system that automatically tailors all 108 security checks to the specific MikroTik device being audited.
|
|
228
|
+
|
|
229
|
+
### How It Works
|
|
230
|
+
|
|
231
|
+
When processing an `.rsc` export, the auditor extracts the device model from the export header (`# model = ...`) and matches it against a library of 15+ device profiles covering all major MikroTik families:
|
|
232
|
+
|
|
233
|
+
| Family | Examples | Key Difference |
|
|
234
|
+
|--------|----------|----------------|
|
|
235
|
+
| **hAP** | ac², ax², ax³, lite | WiFi checks, flash-constrained models, AX stability |
|
|
236
|
+
| **CCR** | CCR1036, CCR2004, CCR2216 | No WiFi, BGP/OSPF critical, FastTrack unsupported on TileGX |
|
|
237
|
+
| **CRS** | CRS3xx, CRS1xx/2xx | No WiFi, HW offload, switch ACL bypass considerations |
|
|
238
|
+
| **RB** | RB750Gr3, RB4011, RB5009 | Varies: some no WiFi, LCD on 4011, containers on 5009 |
|
|
239
|
+
| **cAP/wAP** | cAP ac/ax, wAP ac/ax | CAPsMAN native, some flash-constrained |
|
|
240
|
+
| **CPE** | LHG, SXT, mANTBox | Outdoor, PtP encryption, no LCD |
|
|
241
|
+
| **CHR/x86** | Virtual, bare metal | No hardware constraints, license throughput limits |
|
|
242
|
+
|
|
243
|
+
### What Gets Tailored
|
|
244
|
+
|
|
245
|
+
- **N/A exclusion**: WiFi checks are skipped on CCR, CRS, RB5009, and other non-WiFi devices
|
|
246
|
+
- **Severity adjustment**: Flash-constrained devices (hAP ac², hAP lite) get elevated severity for flash exhaustion checks. BGP security is Critical on ISP/DC routers
|
|
247
|
+
- **Hardware-specific checks**: AX stability warnings apply only to hAP ax²/ax³, LCD PIN checks only to devices with displays
|
|
248
|
+
- **Threshold tuning**: Connection tracking limits, DNS cache sizes, and ICMP rate limits are adjusted based on available RAM and CPU architecture
|
|
249
|
+
|
|
250
|
+
### Supported Platforms
|
|
251
|
+
|
|
252
|
+
See [references/HARDWARE_COMPATIBILITY.md](references/HARDWARE_COMPATIBILITY.md) for the complete device profile reference, including detailed specifications, detection regex, severity adjustment rules, and per-family check applicability matrices.
|
|
253
|
+
|
|
254
|
+
The profile data and detection logic live in [scripts/device_profiles.py](scripts/device_profiles.py), which can be extended with new device profiles as MikroTik releases new hardware.
|
|
255
|
+
|
|
256
|
+
## Development Workflow
|
|
257
|
+
|
|
258
|
+
For engineers developing and deploying RouterOS scripts, the following workflow integrates auditing at every stage:
|
|
259
|
+
|
|
260
|
+
```
|
|
261
|
+
Step 1: Write script with idempotent patterns
|
|
262
|
+
→ Follow the patterns in references/EXAMPLES.md
|
|
263
|
+
→ Review references/SCRIPTING_PITFALLS.md for common mistakes
|
|
264
|
+
|
|
265
|
+
Step 2: Lint the script before deployment
|
|
266
|
+
→ python scripts/lint_rsc.py my-script.rsc --strict
|
|
267
|
+
→ Fix any errors and warnings before proceeding
|
|
268
|
+
|
|
269
|
+
Step 3: Dry-run the import on target device
|
|
270
|
+
→ /import file=my-script.rsc verbose=yes dry-run
|
|
271
|
+
→ Review output for unexpected changes
|
|
272
|
+
|
|
273
|
+
Step 4: Import with :onerror wrapper for safety
|
|
274
|
+
→ :onerror e in={ /import file=my-script.rsc } do={ :log error "Failed: $e" }
|
|
275
|
+
→ This catches both import parse errors and script execution errors
|
|
276
|
+
|
|
277
|
+
Step 5: Audit the deployed configuration
|
|
278
|
+
→ Export config: /export hide-sensitive file=audit-export
|
|
279
|
+
→ Run full audit: python scripts/audit_rsc.py audit-export.rsc --cve --conflicts --ioc
|
|
280
|
+
→ Review findings and apply remediation commands
|
|
281
|
+
```
|
|
282
|
+
|
|
283
|
+
This workflow ensures that scripts are safe to import (steps 1–4) and the resulting configuration is secure (step 5). The `audit_rsc.py` tool with the new `--cve`, `--conflicts`, `--ioc`, and `--lint` flags provides end-to-end coverage from development to post-deployment.
|
|
284
|
+
|
|
285
|
+
## Related Skills
|
|
286
|
+
|
|
287
|
+
- `mikrotik-routeros-rsc` — Creating and editing RouterOS scripts (complementary; this skill audits what that skill creates)
|
|
288
|
+
- `security-auditor` — General security auditing framework (this skill specializes for MikroTik/RouterOS)
|
|
289
|
+
- `vulnerability-scanner` — Vulnerability scanning methodology (this skill focuses on config-specific findings)
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
# Minimal secure config — baseline for testing
|
|
2
|
+
# RouterOS 7.22.3 — hAP ax³
|
|
3
|
+
/interface bridge
|
|
4
|
+
add admin-mac=xx:xx:xx:xx:xx:01 auto-mac=no name=bridge
|
|
5
|
+
/interface list
|
|
6
|
+
add name=WAN
|
|
7
|
+
add name=LAN
|
|
8
|
+
/interface list member
|
|
9
|
+
add interface=ether1 list=WAN
|
|
10
|
+
add interface=bridge list=LAN
|
|
11
|
+
/ip address
|
|
12
|
+
add address=192.168.88.1/24 interface=bridge
|
|
13
|
+
/ip dhcp-server
|
|
14
|
+
add address-pool=default-dhcp interface=bridge name=defconf
|
|
15
|
+
/ip pool
|
|
16
|
+
add name=default-dhcp ranges=192.168.88.10-192.168.88.254
|
|
17
|
+
/ip dhcp-server network
|
|
18
|
+
add address=192.168.88.0/24 dns-server=192.168.88.1 gateway=192.168.88.1
|
|
19
|
+
/ip dns
|
|
20
|
+
set cache-size=2048KiB servers=9.9.9.9,149.112.112.9
|
|
21
|
+
/ip firewall filter
|
|
22
|
+
add action=fasttrack-connection chain=forward connection-state=established,related
|
|
23
|
+
add action=accept chain=input connection-state=established,related
|
|
24
|
+
add action=accept chain=forward connection-state=established,related
|
|
25
|
+
add action=drop chain=input connection-state=invalid
|
|
26
|
+
add action=drop chain=forward connection-state=invalid
|
|
27
|
+
add action=accept chain=input protocol=icmp
|
|
28
|
+
add action=drop chain=input in-interface-list=!LAN
|
|
29
|
+
add action=drop chain=forward in-interface-list=WAN connection-nat-state=!dstnat connection-state=new
|
|
30
|
+
/ip firewall nat
|
|
31
|
+
add action=masquerade chain=srcnat out-interface-list=WAN
|
|
32
|
+
/ip service
|
|
33
|
+
set ftp disabled=yes
|
|
34
|
+
set ssh disabled=no address=192.168.88.0/24
|
|
35
|
+
set telnet disabled=yes
|
|
36
|
+
set www disabled=yes
|
|
37
|
+
set winbox address=192.168.88.0/24
|
|
38
|
+
/ip ssh
|
|
39
|
+
set strong-crypto=yes
|
|
40
|
+
/tool mac-server
|
|
41
|
+
set allowed-interface-list=LAN
|
|
42
|
+
/tool mac-server mac-winbox
|
|
43
|
+
set allowed-interface-list=LAN
|
|
44
|
+
/ip neighbor discovery-settings
|
|
45
|
+
set discover-interface-list=LAN
|
|
46
|
+
/system ntp client
|
|
47
|
+
set enabled=yes
|
|
48
|
+
/system ntp client servers
|
|
49
|
+
add address=de.pool.ntp.org
|
|
50
|
+
/system clock
|
|
51
|
+
set time-zone-name=Europe/Berlin
|
|
52
|
+
/system identity
|
|
53
|
+
set name=minimal-router
|
|
54
|
+
/ip dns static
|
|
55
|
+
add address=192.168.88.1 name=router.lan type=A
|