nsauditor-ai 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.
Files changed (60) hide show
  1. package/CONTRIBUTING.md +24 -0
  2. package/LICENSE +21 -0
  3. package/README.md +584 -0
  4. package/bin/nsauditor-ai-mcp.mjs +2 -0
  5. package/bin/nsauditor-ai.mjs +2 -0
  6. package/cli.mjs +939 -0
  7. package/config/services.json +304 -0
  8. package/docs/EULA-nsauditor-ai.md +324 -0
  9. package/index.mjs +15 -0
  10. package/mcp_server.mjs +382 -0
  11. package/package.json +44 -0
  12. package/plugin_manager.mjs +829 -0
  13. package/plugins/arp_scanner.mjs +162 -0
  14. package/plugins/db_scanner.mjs +248 -0
  15. package/plugins/dns_scanner.mjs +369 -0
  16. package/plugins/dnssd-scanner.mjs +245 -0
  17. package/plugins/ftp_banner_check.mjs +247 -0
  18. package/plugins/host_up_check.mjs +337 -0
  19. package/plugins/http_probe.mjs +290 -0
  20. package/plugins/llmnr_scanner.mjs +130 -0
  21. package/plugins/mdns_scanner.mjs +522 -0
  22. package/plugins/netbios_scanner.mjs +737 -0
  23. package/plugins/opensearch_scanner.mjs +276 -0
  24. package/plugins/os_detector.mjs +436 -0
  25. package/plugins/ping_checker.mjs +271 -0
  26. package/plugins/port_scanner.mjs +250 -0
  27. package/plugins/result_concluder.mjs +274 -0
  28. package/plugins/snmp_scanner.mjs +278 -0
  29. package/plugins/ssh_scanner.mjs +421 -0
  30. package/plugins/sunrpc_scanner.mjs +339 -0
  31. package/plugins/syn_scanner.mjs +314 -0
  32. package/plugins/tls_scanner.mjs +225 -0
  33. package/plugins/upnp_scanner.mjs +441 -0
  34. package/plugins/webapp_detector.mjs +246 -0
  35. package/plugins/wsd_scanner.mjs +290 -0
  36. package/utils/attack_map.mjs +180 -0
  37. package/utils/capabilities.mjs +53 -0
  38. package/utils/conclusion_utils.mjs +70 -0
  39. package/utils/cpe.mjs +74 -0
  40. package/utils/cve_validator.mjs +64 -0
  41. package/utils/cvss.mjs +129 -0
  42. package/utils/delta_reporter.mjs +110 -0
  43. package/utils/export_csv.mjs +82 -0
  44. package/utils/finding_queue.mjs +64 -0
  45. package/utils/finding_schema.mjs +36 -0
  46. package/utils/host_iterator.mjs +166 -0
  47. package/utils/license.mjs +29 -0
  48. package/utils/net_validation.mjs +66 -0
  49. package/utils/nvd_cache.mjs +77 -0
  50. package/utils/nvd_client.mjs +130 -0
  51. package/utils/oui.mjs +107 -0
  52. package/utils/plugin_discovery.mjs +89 -0
  53. package/utils/prompts.mjs +143 -0
  54. package/utils/raw_report_html.mjs +170 -0
  55. package/utils/redact.mjs +79 -0
  56. package/utils/report_html.mjs +236 -0
  57. package/utils/sarif.mjs +225 -0
  58. package/utils/scan_history.mjs +248 -0
  59. package/utils/scheduler.mjs +157 -0
  60. package/utils/webhook.mjs +177 -0
@@ -0,0 +1,24 @@
1
+ # Contributing to NSAuditor AI
2
+
3
+ All contributions to this repository are licensed under the MIT license
4
+ (Developer Certificate of Origin — DCO).
5
+
6
+ ## How to Contribute
7
+
8
+ 1. Fork the repo and create a feature branch
9
+ 2. Add a `Signed-off-by` line to your commits: `git commit -s`
10
+ 3. Include tests for any new or changed behavior (Node.js `--test` runner)
11
+ 4. Submit a PR
12
+
13
+ ## Plugin Contributions
14
+
15
+ Follow the plugin interface in `plugins/` — each plugin exports:
16
+ - `default` object with `id`, `name`, `priority`, `requirements`, `run()`
17
+ - `conclude({ result, host })` adapter for Result Concluder
18
+ - Optional `authoritativePorts` Set
19
+
20
+ ## What We Won't Accept
21
+
22
+ - Code that transmits scan data externally (violates Zero Data Exfiltration)
23
+ - Phone-home, analytics, or usage tracking
24
+ - Dependencies that weaken the offline-first guarantee
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2024-present Nsasoft US LLC
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,584 @@
1
+ # NSAuditor AI
2
+
3
+ **Security Intelligence Without Data Exposure.**
4
+
5
+ A modular, AI-assisted network security audit platform that scans, understands, prioritizes, and tracks vulnerabilities — without ever requiring your data to leave your infrastructure.
6
+
7
+ [![MIT License](https://img.shields.io/badge/license-MIT-blue.svg)](LICENSE)
8
+ [![Node.js 20+](https://img.shields.io/badge/node-20%2B-green.svg)](https://nodejs.org)
9
+ [![Tests](https://img.shields.io/badge/tests-487%20passing-brightgreen.svg)](#tests)
10
+
11
+ ---
12
+
13
+ NSAuditor AI is the open-source core of a privacy-first security intelligence platform built by [Nsasoft US LLC](https://www.nsauditor.com/ai/). It orchestrates 20+ specialized scanning plugins against target hosts, fuses their results through an intelligent concluder, and optionally produces AI-powered vulnerability reports — all running entirely on your machine.
14
+
15
+ **Zero Data Exfiltration by design.** NSAuditor AI works fully offline. AI analysis, CVE correlation, and continuous monitoring all happen locally. External calls (to AI APIs, NVD, etc.) are opt-in and use your own API keys. We never see your scan data.
16
+
17
+ ## What It Does
18
+
19
+ ```
20
+ Scan → Verify → Prioritize → Track → Act
21
+ ```
22
+
23
+ - **27 scanner plugins** probe networks across ICMP, TCP, UDP, HTTP, TLS, SNMP, DNS, SMB, RPC, mDNS, UPnP, WS-Discovery, and more
24
+ - **Smart result fusion** — the Result Concluder merges all plugin outputs into a normalized view with OS detection, service fingerprinting, and evidence linking
25
+ - **Structured finding format** — all findings use a common schema with category, severity, evidence, and remediation — enabling consistent SARIF export and MCP integration
26
+ - **AI-powered analysis** — send redacted scan results to OpenAI or Claude (your keys, your choice) for vulnerability assessments and remediation guidance
27
+ - **Verified vulnerabilities (Pro)** — safe, non-destructive probes confirm findings are real, not just version-matched guesses. If it can't be verified, it's flagged as "potential" not "confirmed"
28
+ - **Continuous monitoring (CTEM)** — watch mode rescans on a schedule, diffs against previous results, and fires webhook alerts on changes
29
+ - **MCP integration** — expose scanning tools to AI assistants like Claude Code via Model Context Protocol
30
+ - **CI/CD ready** — SARIF output with `--fail-on` severity gating for pipeline integration
31
+
32
+ ## Editions
33
+
34
+ NSAuditor AI is available in three editions:
35
+
36
+ | | Community (Free) | Pro ($49/mo) | Enterprise ($2k+/yr) |
37
+ |---|:---:|:---:|:---:|
38
+ | 20+ scanner plugins | ✅ | ✅ | ✅ |
39
+ | AI analysis (OpenAI, Claude, Ollama) | ✅ (basic prompts) | ✅ (enriched) | ✅ (enriched) |
40
+ | Structured finding format | ✅ | ✅ | ✅ |
41
+ | CTEM watch mode | ✅ | ✅ | ✅ |
42
+ | SARIF + CSV export | ✅ | ✅ | ✅ |
43
+ | CVE matching + MITRE ATT&CK | — | ✅ | ✅ |
44
+ | Parallel analysis agents | — | ✅ | ✅ |
45
+ | Verified vulnerabilities (safe probes) | — | ✅ | ✅ |
46
+ | Risk scoring + prioritization | — | ✅ | ✅ |
47
+ | Intelligence-enriched AI prompts | — | ✅ | ✅ |
48
+ | Advanced CTEM + trend analysis | — | ✅ | ✅ |
49
+ | Cloud scanners (AWS/GCP/Azure) | — | — | ✅ |
50
+ | Zero Trust assessment | — | — | ✅ |
51
+ | Compliance (NIST/HIPAA/GDPR/PCI) | — | — | ✅ |
52
+ | Docker per-scan isolation | — | — | ✅ |
53
+ | Air-gapped deployment | — | — | ✅ |
54
+
55
+ **This repository is the Community Edition** — fully functional, MIT-licensed, no restrictions. Pro and Enterprise features are available via the [`@nsasoft/nsauditor-ai-ee`](https://www.nsauditor.com/ai/pricing) package.
56
+
57
+ → [Start a free 14-day Pro trial](https://www.nsauditor.com/ai/trial) (no credit card)
58
+
59
+ ---
60
+
61
+ ## Quick Start
62
+
63
+ ```bash
64
+ # Install globally
65
+ npm install -g nsauditor-ai
66
+
67
+ # Configure (optional — scans work fully offline without AI)
68
+ cat > .env << 'EOF'
69
+ AI_ENABLED=true
70
+ AI_PROVIDER=ollama # openai | claude | ollama
71
+ OLLAMA_MODEL=llama3 # For local AI (no API key needed)
72
+ # OPENAI_API_KEY=sk-... # Or use OpenAI
73
+ # ANTHROPIC_API_KEY=sk-ant-... # Or use Claude
74
+ OPENAI_REDACT=true
75
+ EOF
76
+
77
+ # Scan a host with all plugins
78
+ nsauditor-ai scan --host 192.168.1.1 --plugins all
79
+
80
+ # Scan a subnet in parallel
81
+ nsauditor-ai scan --host 192.168.1.0/24 --plugins all --parallel 10
82
+
83
+ # Start the MCP server for AI assistants
84
+ nsauditor-ai-mcp
85
+ ```
86
+
87
+ Or run without installing:
88
+
89
+ ```bash
90
+ npx nsauditor-ai scan --host 192.168.1.1 --plugins all
91
+ ```
92
+
93
+ Or clone and run from source:
94
+
95
+ ```bash
96
+ git clone https://github.com/nsasoft/nsauditor-ai.git
97
+ cd nsauditor-ai
98
+ npm install
99
+ node --env-file=.env cli.mjs scan --host 192.168.1.1 --plugins all
100
+ ```
101
+
102
+ Results land in `./out/<host>_<timestamp>/`:
103
+
104
+ | File | Contents |
105
+ |---|---|
106
+ | `scan_conclusion_raw.json` | Full unredacted conclusion (admin reference) |
107
+ | `scan_conclusion_raw.html` | Admin RAW HTML with filters and full detail |
108
+ | `scan_response_ai_payload.json` | Redacted payload sent to AI |
109
+ | `scan_response_ai.json` | Raw AI API response |
110
+ | `scan_response_ai.txt` | AI conclusion (markdown) |
111
+ | `scan_response_ai.html` | Styled HTML report with CVE links and badges |
112
+
113
+ > Works on Node 20+ (tested on Node 22).
114
+
115
+ ---
116
+
117
+ ## Plugins
118
+
119
+ ### Core Scanners
120
+
121
+ | ID | Name | Protocols | Purpose |
122
+ |---|---|---|---|
123
+ | 001 | Ping Checker | ICMP/ARP | Reachability + TTL-based OS hints |
124
+ | 002 | SSH Scanner | TCP:22 | Banner, version fingerprinting, timeout policy |
125
+ | 003 | Port Scanner | TCP/UDP | Bulk open port detection (populates context for downstream plugins) |
126
+ | 004 | FTP Banner Check | TCP:21 | FTP daemon version detection |
127
+ | 005 | Host Up Check | TCP/UDP | Quick multi-probe reachability confirmation |
128
+ | 006 | HTTP Probe | TCP:80/443 | Headers, server token, vendor hints |
129
+ | 007 | SNMP Scanner | UDP:161 | sysDescr, OIDs, serial/hardware/firmware extraction |
130
+ | 008 | Result Concluder | Meta | Fuses all plugin outputs (always runs last) |
131
+ | 009 | DNS Scanner | TCP/UDP:53 | `version.bind` CHAOS/TXT + A record lookup |
132
+ | 010 | Webapp Detector | HTTP | Technology stack fingerprinting via wappalyzer |
133
+ | 011 | TLS Scanner | TCP:443+ | TLS version + cipher enumeration per port |
134
+ | 012 | OpenSearch Scanner | HTTP:9200+ | OpenSearch/Dashboards version + Linux/Node.js hints |
135
+ | 013 | OS Detector | Meta | Derives distro/OS from all prior banners with TTL fallback |
136
+ | 014 | NetBIOS Scanner | UDP:137/TCP:445 | NetBIOS/SMB enumeration + SMB2 null session probe |
137
+ | 015 | SUN RPC Scanner | TCP/UDP:111 | RPC portmapper service discovery (NFS, mountd) |
138
+ | 016 | WS-Discovery | UDP:3702 | Multicast device discovery with XML metadata |
139
+ | 024 | TCP SYN Scanner | TCP (Nmap) | SYN half-open scan via Nmap wrapper (optional) |
140
+
141
+ ### Discovery Plugins
142
+
143
+ | Name | Purpose |
144
+ |---|---|
145
+ | ARP Scanner | MAC resolution + OUI vendor lookup + OS hints |
146
+ | mDNS/Bonjour Scanner | Local service discovery + friendly names from TXT records |
147
+ | UPnP/SSDP Scanner | Device discovery + description XML parsing |
148
+ | DNS-SD Scanner | DNS Service Discovery announcements |
149
+ | LLMNR Scanner | Link-local multicast name resolution |
150
+ | DB Scanner | Database service detection (MySQL, PostgreSQL, Redis, etc.) |
151
+
152
+ ### Pro/Enterprise Plugins (via @nsasoft/nsauditor-ai-ee)
153
+
154
+ | ID | Name | Tier | Purpose |
155
+ |---|---|---|---|
156
+ | 020 | AWS Cloud Scanner | Enterprise | Security group + IAM policy analysis |
157
+ | 021 | GCP Cloud Scanner | Enterprise | Firewall rules + IAM bindings |
158
+ | 022 | Azure Cloud Scanner | Enterprise | NSG rules + RBAC analysis |
159
+ | 023 | Zero Trust Checker | Enterprise | Segmentation, encryption, identity, lateral movement scoring |
160
+
161
+ ---
162
+
163
+ ## How Results Are Fused
164
+
165
+ The Result Concluder (plugin 008) merges all plugin outputs into a normalized structure:
166
+
167
+ 1. **Imports** each plugin's `conclude()` adapter to get normalized `ServiceRecord` objects
168
+ 2. **Merges** services by `(protocol, port)`, preferring authoritative records
169
+ 3. **Selects OS** — OS Detector result first, then high-signal hints (Windows services, HTTP tokens), finally TTL fallback
170
+ 4. **Produces** a unified `{ summary, host, services, evidence }` output
171
+ 5. **Enriches** host details with names from mDNS, UPnP, NetBIOS; MAC + vendor from ARP
172
+
173
+ ---
174
+
175
+ ## AI Analysis
176
+
177
+ NSAuditor AI supports three AI providers for vulnerability analysis. **All providers work in all tiers** — CE, Pro, and Enterprise. AI is optional; the platform is fully functional without it.
178
+
179
+ **Providers:** OpenAI (GPT-4o), Anthropic Claude (Sonnet/Opus), Ollama (fully local)
180
+
181
+ **What changes by tier is the prompt content, not the provider:**
182
+
183
+ - **CE** — basic scan-summary prompts (services, ports, versions detected)
184
+ - **Pro** — intelligence-enriched prompts (CVE matches, MITRE techniques, risk scores, verification status injected into the prompt). Same API call, vastly better output
185
+ - **Enterprise** — Pro prompts + compliance context
186
+
187
+ **Redaction:** Before any data reaches an AI API, the redaction pipeline masks IP addresses, MAC addresses, serial numbers, and configurable confidential keywords. Admin RAW reports retain full detail for internal review.
188
+
189
+ ```ini
190
+ # .env
191
+ AI_PROVIDER=claude
192
+ ANTHROPIC_API_KEY=sk-ant-... # Your key — never sent to Nsasoft
193
+ ANTHROPIC_MODEL=claude-sonnet-4-20250514
194
+ OPENAI_PROMPT_MODE=optimized
195
+ OPENAI_REDACT=true
196
+ ```
197
+
198
+ For fully local AI (no external API calls), use [Ollama](https://ollama.ai):
199
+
200
+ ```ini
201
+ AI_PROVIDER=ollama
202
+ OLLAMA_MODEL=llama3
203
+ ```
204
+
205
+ ---
206
+
207
+ ## Continuous Monitoring (CTEM)
208
+
209
+ Watch mode enables periodic rescanning with delta detection and webhook alerts:
210
+
211
+ ```bash
212
+ nsauditor-ai scan --host 192.168.1.0/24 --plugins all \
213
+ --watch --interval 15 \
214
+ --webhook-url https://hooks.example.com/security \
215
+ --alert-severity high
216
+ ```
217
+
218
+ - **Scheduling** with configurable intervals and concurrency control
219
+ - **Delta detection** — new, removed, and changed services highlighted between cycles
220
+ - **Webhook alerts** — JSON POST with retry (exponential backoff, no retry on 4xx)
221
+ - **SSRF protection** — private, loopback, and cloud metadata addresses blocked at the scan entry point and inside `sendWebhook()`. Set `NSA_ALLOW_ALL_HOSTS=1` to scan RFC 1918 ranges (local network auditing)
222
+ - **Scan history** stored in `.scan_history/` (JSONL format, 7-day retention in CE)
223
+
224
+ ---
225
+
226
+ ## MCP Server
227
+
228
+ Expose scanning capabilities to AI assistants via [Model Context Protocol](https://modelcontextprotocol.io):
229
+
230
+ ```bash
231
+ nsauditor-ai-mcp
232
+ # or
233
+ npx nsauditor-ai-mcp
234
+ ```
235
+
236
+ **CE Tools:**
237
+
238
+ | Tool | Purpose |
239
+ |---|---|
240
+ | `scan_host` | Run full scan against a host with plugin selection |
241
+ | `list_plugins` | List available scanner plugins with metadata |
242
+
243
+ **Pro Tools** (requires license key + `@nsasoft/nsauditor-ai-ee`):
244
+
245
+ | Tool | Purpose |
246
+ |---|---|
247
+ | `probe_service` | Deep scan a specific port/service |
248
+ | `get_vulnerabilities` | Query CVEs by CPE string |
249
+ | `risk_summary` | Prioritized risk overview from last scan |
250
+ | `scan_compare` | Diff two scan results with risk weighting |
251
+ | `save_finding` | Save a validated finding to the finding queue (schema-checked) |
252
+
253
+ **Enterprise Tools** (requires Enterprise license):
254
+
255
+ | Tool | Purpose |
256
+ |---|---|
257
+ | `start_assessment` | Multi-host orchestrated assessment workflow |
258
+ | `prioritize_risks` | Cross-host risk prioritization |
259
+ | `compliance_check` | Compliance mapping with gap analysis |
260
+ | `export_report` | Generate formatted compliance report |
261
+
262
+ Security: SSRF protection on all host inputs (blocks RFC 1918, loopback, fc00::/7, cloud metadata), port validation (1–65535), CPE format enforcement, dependency injection for test isolation.
263
+
264
+ ---
265
+
266
+ ## CLI Reference
267
+
268
+ ```
269
+ nsauditor-ai scan [options]
270
+ ```
271
+
272
+ | Flag | Description | Default |
273
+ |---|---|---|
274
+ | `--host <target>` | Target: IP, hostname, CIDR, dash range. Aliases: `--ip`, `--target` | *required*\* |
275
+ | `--host-file <path>` | File with one host per line (`#` comments, blank lines OK) | — |
276
+ | `--plugins <list>` | Comma-separated plugin IDs or `all` | `all` |
277
+ | `--ports <list>` | Comma-separated ports to pass to plugins | — |
278
+ | `--out <dir>` | Custom output directory | `out/` |
279
+ | `--parallel <n>` | Concurrent host scans | `1` |
280
+ | `--output-format <fmt>` | Output format: `sarif` for CI/CD | — |
281
+ | `--fail-on <sev>` | Exit code 2 if findings ≥ severity: `critical\|high\|medium\|low\|info` | — |
282
+ | `--insecure-https` | Accept self-signed TLS certificates | `false` |
283
+ | `--watch` | Enable CTEM continuous scanning | `false` |
284
+ | `--interval <min>` | Rescan interval in minutes (requires `--watch`) | `60` |
285
+ | `--webhook-url <url>` | Webhook URL for delta alerts | — |
286
+ | `--alert-severity <sev>` | Minimum severity for webhook alerts | `high` |
287
+
288
+ \* Either `--host` or `--host-file` is required.
289
+
290
+ ### Host Formats
291
+
292
+ | Format | Example | Description |
293
+ |---|---|---|
294
+ | Single IP | `192.168.1.1` | Scan one host |
295
+ | Hostname | `example.com` | Resolved via DNS |
296
+ | CIDR | `192.168.1.0/24` | All usable hosts (min prefix: /16) |
297
+ | Dash range (short) | `192.168.1.1-50` | Last-octet range |
298
+ | Dash range (full) | `10.0.0.1-10.0.1.254` | IP-to-IP range (max 65534) |
299
+ | Host file | `--host-file targets.txt` | One host/CIDR/range per line |
300
+
301
+ ### Examples
302
+
303
+ ```bash
304
+ # Full scan with self-signed cert tolerance
305
+ nsauditor-ai scan --host 192.168.1.1 --plugins all --insecure-https
306
+
307
+ # Parallel subnet scan
308
+ nsauditor-ai scan --host 192.168.1.0/24 --plugins all --parallel 10
309
+
310
+ # Targeted scan: TLS + HTTP + DNS + OS detection
311
+ nsauditor-ai scan --host 192.168.1.8 --plugins 011,006,009,013,008
312
+
313
+ # SARIF output for CI/CD, fail on high+ findings
314
+ nsauditor-ai scan --host 10.0.0.5 --plugins all --output-format sarif --fail-on high
315
+
316
+ # Continuous monitoring with webhook alerts
317
+ nsauditor-ai scan --host 192.168.1.0/24 --plugins all \
318
+ --watch --interval 30 \
319
+ --webhook-url https://hooks.example.com/alerts \
320
+ --alert-severity high
321
+
322
+ # Hosts from file with 4 parallel scans
323
+ nsauditor-ai scan --host-file targets.txt --plugins all --parallel 4
324
+ ```
325
+
326
+ ---
327
+
328
+ ## Configuration
329
+
330
+ ### Environment Variables (.env)
331
+
332
+ **AI configuration:**
333
+
334
+ ```ini
335
+ AI_ENABLED=false # Set to true to enable AI analysis
336
+ AI_PROVIDER=openai # openai | claude | ollama
337
+ OPENAI_API_KEY=sk-... # Your OpenAI key
338
+ OPENAI_MODEL=gpt-4o-mini
339
+ ANTHROPIC_API_KEY=sk-ant-... # Your Claude key
340
+ ANTHROPIC_MODEL=claude-sonnet-4-20250514
341
+ OPENAI_PROMPT_MODE=optimized # basic | pro | optimized
342
+ OPENAI_REDACT=true # Redact before sending to AI
343
+ CONFIDENTIAL_KEYWORDS=serial,password,token,secret
344
+ ```
345
+
346
+ **Plugin-specific:**
347
+
348
+ ```ini
349
+ TLS_SCANNER_TIMEOUT_MS=8000
350
+ TLS_SCANNER_VERSIONS=TLSv1,TLSv1.1,TLSv1.2,TLSv1.3
351
+ TLS_SCANNER_PORTS=443:https,465:smtps,563:nntps,993:imaps,995:pop3s
352
+ OPENSEARCH_SCANNER_TIMEOUT_MS=6000
353
+ OPENSEARCH_SCANNER_INSECURE_TLS=false
354
+ DNS_TIMEOUT_MS=800
355
+ HTTP_PROBE_TIMEOUT_MS=6000
356
+ WEBAPP_DETECTOR_TIMEOUT_MS=6000
357
+ SMB_NULL_SESSION=false
358
+ SMB_NULL_SESSION_TIMEOUT=5000
359
+ ENABLE_SYN_SCAN=false
360
+ SYN_SCAN_PORTS=
361
+ SYN_SCAN_TIMEOUT=30000
362
+ PING_FALLBACK=true
363
+ PING_FALLBACK_TIMEOUT=2000
364
+ ```
365
+
366
+ **Licensing (Pro/Enterprise):**
367
+
368
+ ```ini
369
+ NSAUDITOR_LICENSE_KEY=pro_eyJhbGci... # Pro or Enterprise license key
370
+ NSAUDITOR_PLUGIN_PATH= # Additional plugin directories (colon-separated)
371
+ ```
372
+
373
+ **Security overrides:**
374
+
375
+ ```ini
376
+ NSA_ALLOW_ALL_HOSTS=1 # Allow scanning private/RFC 1918 ranges (local network auditing)
377
+ NSA_AI_TIMEOUT_MS=120000 # AI provider call timeout in ms (default: 120000 = 2 min)
378
+ ```
379
+
380
+ **Debug:**
381
+
382
+ ```ini
383
+ NSA_VERBOSE=true # Verbose PluginManager logging
384
+ DEBUG_MODE=true # Plugin-level debug output
385
+ ```
386
+
387
+ ---
388
+
389
+ ## Developing Plugins
390
+
391
+ NSAuditor AI uses a plug-and-play plugin system. Plugins are auto-discovered from `./plugins/` — no registration needed.
392
+
393
+ ### Plugin Interface
394
+
395
+ ```javascript
396
+ // plugins/0xx_my_scanner.mjs
397
+ export default {
398
+ id: "0xx",
399
+ name: "My Scanner",
400
+ description: "What it probes",
401
+ priority: 300, // Lower runs first; Concluder is 100000
402
+ protocols: ["tcp"],
403
+ ports: [1234],
404
+
405
+ requirements: { // All optional
406
+ host: "up", // Skip if host unreachable
407
+ tcp_open: [1234], // Skip if port not open
408
+ },
409
+
410
+ // requiredCapabilities: ["enterprise"], // EE plugins only
411
+
412
+ async run(host, port, opts = {}) {
413
+ const { context } = opts; // Shared state + OUI helpers
414
+ return {
415
+ up: true,
416
+ program: "my-service",
417
+ version: "1.0.0",
418
+ data: [{
419
+ probe_protocol: "tcp",
420
+ probe_port: 1234,
421
+ probe_info: "OK",
422
+ response_banner: "my-service/1.0.0"
423
+ }]
424
+ };
425
+ },
426
+
427
+ // Adapter for Result Concluder
428
+ conclude({ result, host }) {
429
+ return [{
430
+ port: 1234,
431
+ protocol: "tcp",
432
+ service: "my-service",
433
+ program: result.program,
434
+ version: result.version,
435
+ status: "open",
436
+ info: null,
437
+ banner: result.data?.[0]?.response_banner || null,
438
+ source: "my-scanner",
439
+ evidence: result.data || [],
440
+ authoritative: true
441
+ }];
442
+ },
443
+
444
+ authoritativePorts: new Set(["tcp:1234"])
445
+ };
446
+ ```
447
+
448
+ ### Plugin Tips
449
+
450
+ - Use env-driven timeouts for all network calls
451
+ - Always close sockets on all code paths with a small post-banner linger
452
+ - Keep `probe_info` and `response_banner` concise — full detail goes in evidence
453
+ - Use `authoritativePorts` to take precedence over other plugins for the same port
454
+ - Plugins can also be loaded from external npm packages via `NSAUDITOR_PLUGIN_PATH`
455
+
456
+ ---
457
+
458
+ ## Pro & Enterprise Activation
459
+
460
+ Install the EE package alongside the CE platform:
461
+
462
+ ```bash
463
+ npm install -g @nsasoft/nsauditor-ai-ee
464
+ ```
465
+
466
+ Set your license key:
467
+
468
+ ```bash
469
+ echo "NSAUDITOR_LICENSE_KEY=pro_eyJhbGci..." >> ~/.nsauditor/.env
470
+ # or export directly
471
+ export NSAUDITOR_LICENSE_KEY=pro_eyJhbGci...
472
+ ```
473
+
474
+ Verify:
475
+
476
+ ```bash
477
+ nsauditor-ai license --status
478
+ # ✓ Pro license active | Expires: 2027-04-04
479
+
480
+ nsauditor-ai license --capabilities
481
+ # ✓ intelligenceEngine ✓ riskScoring ✓ proAI ✓ advancedCTEM ...
482
+ ```
483
+
484
+ No license key? Everything in this repository works perfectly without one. The CE is not crippled — it's a complete, production-ready security scanner.
485
+
486
+ → [Pricing](https://www.nsauditor.com/ai/pricing) · [Start free trial](https://www.nsauditor.com/ai/trial) · [Enterprise contact](https://www.nsauditor.com/ai/enterprise)
487
+
488
+ ---
489
+
490
+ ## Tests
491
+
492
+ Run all 487 tests:
493
+
494
+ ```bash
495
+ npm test
496
+ ```
497
+
498
+ Run a specific suite:
499
+
500
+ ```bash
501
+ node --test tests/tls_scanner.test.mjs
502
+ node --test tests/port_scanner.test.mjs
503
+ node --test tests/result_concluder.test.mjs
504
+ node --test tests/os_detector.test.mjs
505
+ node --test tests/mcp_server.test.mjs
506
+ node --test tests/attack_map.test.mjs
507
+ ```
508
+
509
+ Tests use Node.js built-in `--test` runner with the `assert` module — no external test framework. Each test is self-contained with inline fixtures and lightweight network stubs.
510
+
511
+ ---
512
+
513
+ ## Troubleshooting
514
+
515
+ | Issue | Solution |
516
+ |---|---|
517
+ | No DNS banner | Provider may block CHAOS/TXT (`version.bind`) or UDP/53 |
518
+ | OpenSearch over self-signed TLS | Set `OPENSEARCH_SCANNER_INSECURE_TLS=true` |
519
+ | TLS shows "closed" | Service may require SNI — set `TLS_SCANNER_SNI=hostname` |
520
+ | RPC not detected | Ensure port 111 is accessible and RPC portmapper is running |
521
+ | WS-Discovery timeout | Check network config and firewall for multicast on UDP 3702 |
522
+ | SYN scan requires root | Run with `sudo` or use TCP connect scanner (plugin 003) instead |
523
+ | Webhook URL rejected | Private/loopback/cloud metadata blocked by SSRF guard. Use `NSA_ALLOW_ALL_HOSTS=1` to allow RFC 1918 scan targets |
524
+ | EE plugins not loading | Verify `@nsasoft/nsauditor-ai-ee` is installed and license key is set |
525
+
526
+ ---
527
+
528
+ ## Contributing
529
+
530
+ We welcome contributions! See [CONTRIBUTING.md](CONTRIBUTING.md) for guidelines.
531
+
532
+ **Quick version:**
533
+
534
+ 1. Fork the repo and create a feature branch
535
+ 2. Add a `Signed-off-by` line to your commits (`git commit -s`)
536
+ 3. Include tests for any new or changed behavior
537
+ 4. Submit a PR
538
+
539
+ **All contributions to this repository are under the MIT license.** For Enterprise Edition contributions, see the [nsauditor-ai-ee](https://www.nsauditor.com/ai/enterprise) repository which requires a signed IP Assignment Agreement.
540
+
541
+ **What we won't accept:** Code that phones home, transmits scan data externally, or weakens the Zero Data Exfiltration boundary.
542
+
543
+ ### Requesting or Contributing Plugins
544
+
545
+ Check `./plugins/` first. If a plugin doesn't exist:
546
+
547
+ - **Request it:** Open an issue with scope, target ports, protocols, and example banners
548
+ - **Build it:** Follow the plugin interface above, include tests, and update this README
549
+
550
+ Commonly requested plugins: RDP, VNC, SMTP/POP3/IMAP, MySQL/PostgreSQL/MSSQL/MongoDB/Redis, LDAP, RabbitMQ/Kafka/MQTT, SIP, NTP, Modbus/S7/DNP3/BACnet, WordPress/Jenkins/GitLab detectors.
551
+
552
+ ---
553
+
554
+ ## Architecture
555
+
556
+ For the full technical architecture, see [ARCHITECTURE.md](docs/architecture.md).
557
+
558
+ **Tech stack:** Node.js 20+ · ES Modules (.mjs) · OpenAI + Anthropic SDKs · Node.js built-in test runner · MCP stdio transport
559
+
560
+ **Design patterns:** Factory (PluginManager.create) · Strategy (orchestrated/legacy execution) · Context (shared state) · Adapter (plugin conclude()) · Guard Clause (requirement gating) · Capability gating (CE/Pro/EE) · Semaphore (concurrency control) · Delta (scan history diff) · Boundary Guard (SSRF/injection protection) · Finding Queue (structured intermediate format) · Parallel Agents (concurrent specialized analysis) · Verification Probes (safe non-destructive confirmation)
561
+
562
+ ---
563
+
564
+ ## Privacy & Security
565
+
566
+ NSAuditor AI is built on a **Zero Data Exfiltration (ZDE)** architecture:
567
+
568
+ - **No telemetry.** No analytics. No usage tracking. No phone-home.
569
+ - **No data processing.** Nsasoft US LLC never sees, stores, or processes your scan results.
570
+ - **AI is opt-in.** External AI calls use your own API keys. Redaction runs locally first.
571
+ - **License validation is offline.** JWT signature verified locally with an embedded public key.
572
+ - **Fully air-gappable.** Every feature works without internet access (Enterprise includes offline NVD feeds).
573
+
574
+ Nsasoft US LLC is not a data processor, data controller, or business associate under any data protection regulation. You own and control all data produced by NSAuditor AI.
575
+
576
+ ---
577
+
578
+ ## License
579
+
580
+ **MIT** — see [LICENSE](LICENSE) for the full text.
581
+
582
+ © 2024-present Nsasoft US LLC. "NSAuditor" and "NSAuditor AI" are trademarks of Nsasoft US LLC.
583
+
584
+ The Pro and Enterprise features available via `@nsasoft/nsauditor-ai-ee` are licensed under a separate proprietary license. See [www.nsauditor.com/ai/pricing](https://www.nsauditor.com/ai/pricing) for details.
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env node
2
+ import '../mcp_server.mjs';
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env node
2
+ import '../cli.mjs';