clawsec 0.0.1
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/README.md +560 -0
- package/dist/bin/clawsec.d.ts +7 -0
- package/dist/bin/clawsec.d.ts.map +1 -0
- package/dist/bin/clawsec.js +12 -0
- package/dist/bin/clawsec.js.map +1 -0
- package/dist/src/actions/block.d.ts +22 -0
- package/dist/src/actions/block.d.ts.map +1 -0
- package/dist/src/actions/block.js +83 -0
- package/dist/src/actions/block.js.map +1 -0
- package/dist/src/actions/confirm.d.ts +35 -0
- package/dist/src/actions/confirm.d.ts.map +1 -0
- package/dist/src/actions/confirm.js +156 -0
- package/dist/src/actions/confirm.js.map +1 -0
- package/dist/src/actions/executor.d.ts +64 -0
- package/dist/src/actions/executor.d.ts.map +1 -0
- package/dist/src/actions/executor.js +114 -0
- package/dist/src/actions/executor.js.map +1 -0
- package/dist/src/actions/index.d.ts +13 -0
- package/dist/src/actions/index.d.ts.map +1 -0
- package/dist/src/actions/index.js +15 -0
- package/dist/src/actions/index.js.map +1 -0
- package/dist/src/actions/log.d.ts +19 -0
- package/dist/src/actions/log.d.ts.map +1 -0
- package/dist/src/actions/log.js +63 -0
- package/dist/src/actions/log.js.map +1 -0
- package/dist/src/actions/types.d.ts +85 -0
- package/dist/src/actions/types.d.ts.map +1 -0
- package/dist/src/actions/types.js +78 -0
- package/dist/src/actions/types.js.map +1 -0
- package/dist/src/actions/warn.d.ts +22 -0
- package/dist/src/actions/warn.d.ts.map +1 -0
- package/dist/src/actions/warn.js +84 -0
- package/dist/src/actions/warn.js.map +1 -0
- package/dist/src/approval/agent-confirm.d.ts +104 -0
- package/dist/src/approval/agent-confirm.d.ts.map +1 -0
- package/dist/src/approval/agent-confirm.js +173 -0
- package/dist/src/approval/agent-confirm.js.map +1 -0
- package/dist/src/approval/index.d.ts +14 -0
- package/dist/src/approval/index.d.ts.map +1 -0
- package/dist/src/approval/index.js +9 -0
- package/dist/src/approval/index.js.map +1 -0
- package/dist/src/approval/native.d.ts +56 -0
- package/dist/src/approval/native.d.ts.map +1 -0
- package/dist/src/approval/native.js +196 -0
- package/dist/src/approval/native.js.map +1 -0
- package/dist/src/approval/store.d.ts +88 -0
- package/dist/src/approval/store.d.ts.map +1 -0
- package/dist/src/approval/store.js +192 -0
- package/dist/src/approval/store.js.map +1 -0
- package/dist/src/approval/types.d.ts +119 -0
- package/dist/src/approval/types.d.ts.map +1 -0
- package/dist/src/approval/types.js +6 -0
- package/dist/src/approval/types.js.map +1 -0
- package/dist/src/approval/webhook.d.ts +170 -0
- package/dist/src/approval/webhook.d.ts.map +1 -0
- package/dist/src/approval/webhook.js +362 -0
- package/dist/src/approval/webhook.js.map +1 -0
- package/dist/src/cli/commands/audit.d.ts +43 -0
- package/dist/src/cli/commands/audit.d.ts.map +1 -0
- package/dist/src/cli/commands/audit.js +115 -0
- package/dist/src/cli/commands/audit.js.map +1 -0
- package/dist/src/cli/commands/feedback.d.ts +27 -0
- package/dist/src/cli/commands/feedback.d.ts.map +1 -0
- package/dist/src/cli/commands/feedback.js +228 -0
- package/dist/src/cli/commands/feedback.js.map +1 -0
- package/dist/src/cli/commands/index.d.ts +11 -0
- package/dist/src/cli/commands/index.d.ts.map +1 -0
- package/dist/src/cli/commands/index.js +13 -0
- package/dist/src/cli/commands/index.js.map +1 -0
- package/dist/src/cli/commands/status.d.ts +20 -0
- package/dist/src/cli/commands/status.d.ts.map +1 -0
- package/dist/src/cli/commands/status.js +122 -0
- package/dist/src/cli/commands/status.js.map +1 -0
- package/dist/src/cli/commands/test.d.ts +23 -0
- package/dist/src/cli/commands/test.d.ts.map +1 -0
- package/dist/src/cli/commands/test.js +134 -0
- package/dist/src/cli/commands/test.js.map +1 -0
- package/dist/src/cli/commands/types.d.ts +81 -0
- package/dist/src/cli/commands/types.d.ts.map +1 -0
- package/dist/src/cli/commands/types.js +6 -0
- package/dist/src/cli/commands/types.js.map +1 -0
- package/dist/src/cli/index.d.ts +17 -0
- package/dist/src/cli/index.d.ts.map +1 -0
- package/dist/src/cli/index.js +267 -0
- package/dist/src/cli/index.js.map +1 -0
- package/dist/src/config/defaults.d.ts +20 -0
- package/dist/src/config/defaults.d.ts.map +1 -0
- package/dist/src/config/defaults.js +123 -0
- package/dist/src/config/defaults.js.map +1 -0
- package/dist/src/config/index.d.ts +8 -0
- package/dist/src/config/index.d.ts.map +1 -0
- package/dist/src/config/index.js +41 -0
- package/dist/src/config/index.js.map +1 -0
- package/dist/src/config/loader.d.ts +99 -0
- package/dist/src/config/loader.d.ts.map +1 -0
- package/dist/src/config/loader.js +242 -0
- package/dist/src/config/loader.js.map +1 -0
- package/dist/src/config/schema.d.ts +627 -0
- package/dist/src/config/schema.d.ts.map +1 -0
- package/dist/src/config/schema.js +585 -0
- package/dist/src/config/schema.js.map +1 -0
- package/dist/src/detectors/destructive/cloud-detector.d.ts +51 -0
- package/dist/src/detectors/destructive/cloud-detector.d.ts.map +1 -0
- package/dist/src/detectors/destructive/cloud-detector.js +556 -0
- package/dist/src/detectors/destructive/cloud-detector.js.map +1 -0
- package/dist/src/detectors/destructive/code-detector.d.ts +59 -0
- package/dist/src/detectors/destructive/code-detector.d.ts.map +1 -0
- package/dist/src/detectors/destructive/code-detector.js +558 -0
- package/dist/src/detectors/destructive/code-detector.js.map +1 -0
- package/dist/src/detectors/destructive/index.d.ts +54 -0
- package/dist/src/detectors/destructive/index.d.ts.map +1 -0
- package/dist/src/detectors/destructive/index.js +168 -0
- package/dist/src/detectors/destructive/index.js.map +1 -0
- package/dist/src/detectors/destructive/shell-detector.d.ts +43 -0
- package/dist/src/detectors/destructive/shell-detector.d.ts.map +1 -0
- package/dist/src/detectors/destructive/shell-detector.js +302 -0
- package/dist/src/detectors/destructive/shell-detector.js.map +1 -0
- package/dist/src/detectors/destructive/types.d.ts +143 -0
- package/dist/src/detectors/destructive/types.d.ts.map +1 -0
- package/dist/src/detectors/destructive/types.js +6 -0
- package/dist/src/detectors/destructive/types.js.map +1 -0
- package/dist/src/detectors/exfiltration/cloud-detector.d.ts +51 -0
- package/dist/src/detectors/exfiltration/cloud-detector.d.ts.map +1 -0
- package/dist/src/detectors/exfiltration/cloud-detector.js +427 -0
- package/dist/src/detectors/exfiltration/cloud-detector.js.map +1 -0
- package/dist/src/detectors/exfiltration/http-detector.d.ts +47 -0
- package/dist/src/detectors/exfiltration/http-detector.d.ts.map +1 -0
- package/dist/src/detectors/exfiltration/http-detector.js +429 -0
- package/dist/src/detectors/exfiltration/http-detector.js.map +1 -0
- package/dist/src/detectors/exfiltration/index.d.ts +44 -0
- package/dist/src/detectors/exfiltration/index.d.ts.map +1 -0
- package/dist/src/detectors/exfiltration/index.js +118 -0
- package/dist/src/detectors/exfiltration/index.js.map +1 -0
- package/dist/src/detectors/exfiltration/network-detector.d.ts +55 -0
- package/dist/src/detectors/exfiltration/network-detector.d.ts.map +1 -0
- package/dist/src/detectors/exfiltration/network-detector.js +504 -0
- package/dist/src/detectors/exfiltration/network-detector.js.map +1 -0
- package/dist/src/detectors/exfiltration/types.d.ts +139 -0
- package/dist/src/detectors/exfiltration/types.d.ts.map +1 -0
- package/dist/src/detectors/exfiltration/types.js +6 -0
- package/dist/src/detectors/exfiltration/types.js.map +1 -0
- package/dist/src/detectors/purchase/domain-detector.d.ts +44 -0
- package/dist/src/detectors/purchase/domain-detector.d.ts.map +1 -0
- package/dist/src/detectors/purchase/domain-detector.js +296 -0
- package/dist/src/detectors/purchase/domain-detector.js.map +1 -0
- package/dist/src/detectors/purchase/form-detector.d.ts +27 -0
- package/dist/src/detectors/purchase/form-detector.d.ts.map +1 -0
- package/dist/src/detectors/purchase/form-detector.js +344 -0
- package/dist/src/detectors/purchase/form-detector.js.map +1 -0
- package/dist/src/detectors/purchase/index.d.ts +65 -0
- package/dist/src/detectors/purchase/index.d.ts.map +1 -0
- package/dist/src/detectors/purchase/index.js +216 -0
- package/dist/src/detectors/purchase/index.js.map +1 -0
- package/dist/src/detectors/purchase/spend-tracker.d.ts +132 -0
- package/dist/src/detectors/purchase/spend-tracker.d.ts.map +1 -0
- package/dist/src/detectors/purchase/spend-tracker.js +313 -0
- package/dist/src/detectors/purchase/spend-tracker.js.map +1 -0
- package/dist/src/detectors/purchase/types.d.ts +139 -0
- package/dist/src/detectors/purchase/types.d.ts.map +1 -0
- package/dist/src/detectors/purchase/types.js +6 -0
- package/dist/src/detectors/purchase/types.js.map +1 -0
- package/dist/src/detectors/purchase/url-detector.d.ts +31 -0
- package/dist/src/detectors/purchase/url-detector.d.ts.map +1 -0
- package/dist/src/detectors/purchase/url-detector.js +292 -0
- package/dist/src/detectors/purchase/url-detector.js.map +1 -0
- package/dist/src/detectors/secrets/api-key-detector.d.ts +30 -0
- package/dist/src/detectors/secrets/api-key-detector.d.ts.map +1 -0
- package/dist/src/detectors/secrets/api-key-detector.js +297 -0
- package/dist/src/detectors/secrets/api-key-detector.js.map +1 -0
- package/dist/src/detectors/secrets/index.d.ts +43 -0
- package/dist/src/detectors/secrets/index.d.ts.map +1 -0
- package/dist/src/detectors/secrets/index.js +261 -0
- package/dist/src/detectors/secrets/index.js.map +1 -0
- package/dist/src/detectors/secrets/pii-detector.d.ts +54 -0
- package/dist/src/detectors/secrets/pii-detector.d.ts.map +1 -0
- package/dist/src/detectors/secrets/pii-detector.js +286 -0
- package/dist/src/detectors/secrets/pii-detector.js.map +1 -0
- package/dist/src/detectors/secrets/token-detector.d.ts +51 -0
- package/dist/src/detectors/secrets/token-detector.d.ts.map +1 -0
- package/dist/src/detectors/secrets/token-detector.js +233 -0
- package/dist/src/detectors/secrets/token-detector.js.map +1 -0
- package/dist/src/detectors/secrets/types.d.ts +157 -0
- package/dist/src/detectors/secrets/types.d.ts.map +1 -0
- package/dist/src/detectors/secrets/types.js +6 -0
- package/dist/src/detectors/secrets/types.js.map +1 -0
- package/dist/src/detectors/website/category-detector.d.ts +22 -0
- package/dist/src/detectors/website/category-detector.d.ts.map +1 -0
- package/dist/src/detectors/website/category-detector.js +162 -0
- package/dist/src/detectors/website/category-detector.js.map +1 -0
- package/dist/src/detectors/website/index.d.ts +53 -0
- package/dist/src/detectors/website/index.d.ts.map +1 -0
- package/dist/src/detectors/website/index.js +232 -0
- package/dist/src/detectors/website/index.js.map +1 -0
- package/dist/src/detectors/website/pattern-matcher.d.ts +33 -0
- package/dist/src/detectors/website/pattern-matcher.d.ts.map +1 -0
- package/dist/src/detectors/website/pattern-matcher.js +121 -0
- package/dist/src/detectors/website/pattern-matcher.js.map +1 -0
- package/dist/src/detectors/website/types.d.ts +105 -0
- package/dist/src/detectors/website/types.d.ts.map +1 -0
- package/dist/src/detectors/website/types.js +6 -0
- package/dist/src/detectors/website/types.js.map +1 -0
- package/dist/src/engine/analyzer.d.ts +87 -0
- package/dist/src/engine/analyzer.d.ts.map +1 -0
- package/dist/src/engine/analyzer.js +427 -0
- package/dist/src/engine/analyzer.js.map +1 -0
- package/dist/src/engine/cache.d.ts +80 -0
- package/dist/src/engine/cache.d.ts.map +1 -0
- package/dist/src/engine/cache.js +167 -0
- package/dist/src/engine/cache.js.map +1 -0
- package/dist/src/engine/index.d.ts +11 -0
- package/dist/src/engine/index.d.ts.map +1 -0
- package/dist/src/engine/index.js +11 -0
- package/dist/src/engine/index.js.map +1 -0
- package/dist/src/engine/llm-client.d.ts +210 -0
- package/dist/src/engine/llm-client.d.ts.map +1 -0
- package/dist/src/engine/llm-client.js +506 -0
- package/dist/src/engine/llm-client.js.map +1 -0
- package/dist/src/engine/types.d.ts +163 -0
- package/dist/src/engine/types.d.ts.map +1 -0
- package/dist/src/engine/types.js +21 -0
- package/dist/src/engine/types.js.map +1 -0
- package/dist/src/feedback/index.d.ts +9 -0
- package/dist/src/feedback/index.d.ts.map +1 -0
- package/dist/src/feedback/index.js +8 -0
- package/dist/src/feedback/index.js.map +1 -0
- package/dist/src/feedback/learner.d.ts +222 -0
- package/dist/src/feedback/learner.d.ts.map +1 -0
- package/dist/src/feedback/learner.js +401 -0
- package/dist/src/feedback/learner.js.map +1 -0
- package/dist/src/feedback/store.d.ts +113 -0
- package/dist/src/feedback/store.d.ts.map +1 -0
- package/dist/src/feedback/store.js +228 -0
- package/dist/src/feedback/store.js.map +1 -0
- package/dist/src/feedback/types.d.ts +126 -0
- package/dist/src/feedback/types.d.ts.map +1 -0
- package/dist/src/feedback/types.js +6 -0
- package/dist/src/feedback/types.js.map +1 -0
- package/dist/src/hooks/before-agent-start/handler.d.ts +37 -0
- package/dist/src/hooks/before-agent-start/handler.d.ts.map +1 -0
- package/dist/src/hooks/before-agent-start/handler.js +109 -0
- package/dist/src/hooks/before-agent-start/handler.js.map +1 -0
- package/dist/src/hooks/before-agent-start/index.d.ts +8 -0
- package/dist/src/hooks/before-agent-start/index.d.ts.map +1 -0
- package/dist/src/hooks/before-agent-start/index.js +7 -0
- package/dist/src/hooks/before-agent-start/index.js.map +1 -0
- package/dist/src/hooks/before-agent-start/prompts.d.ts +48 -0
- package/dist/src/hooks/before-agent-start/prompts.d.ts.map +1 -0
- package/dist/src/hooks/before-agent-start/prompts.js +103 -0
- package/dist/src/hooks/before-agent-start/prompts.js.map +1 -0
- package/dist/src/hooks/before-tool-call/handler.d.ts +42 -0
- package/dist/src/hooks/before-tool-call/handler.d.ts.map +1 -0
- package/dist/src/hooks/before-tool-call/handler.js +226 -0
- package/dist/src/hooks/before-tool-call/handler.js.map +1 -0
- package/dist/src/hooks/before-tool-call/index.d.ts +7 -0
- package/dist/src/hooks/before-tool-call/index.d.ts.map +1 -0
- package/dist/src/hooks/before-tool-call/index.js +6 -0
- package/dist/src/hooks/before-tool-call/index.js.map +1 -0
- package/dist/src/hooks/tool-result-persist/filter.d.ts +72 -0
- package/dist/src/hooks/tool-result-persist/filter.d.ts.map +1 -0
- package/dist/src/hooks/tool-result-persist/filter.js +305 -0
- package/dist/src/hooks/tool-result-persist/filter.js.map +1 -0
- package/dist/src/hooks/tool-result-persist/handler.d.ts +49 -0
- package/dist/src/hooks/tool-result-persist/handler.d.ts.map +1 -0
- package/dist/src/hooks/tool-result-persist/handler.js +217 -0
- package/dist/src/hooks/tool-result-persist/handler.js.map +1 -0
- package/dist/src/hooks/tool-result-persist/index.d.ts +11 -0
- package/dist/src/hooks/tool-result-persist/index.d.ts.map +1 -0
- package/dist/src/hooks/tool-result-persist/index.js +11 -0
- package/dist/src/hooks/tool-result-persist/index.js.map +1 -0
- package/dist/src/index.d.ts +256 -0
- package/dist/src/index.d.ts.map +1 -0
- package/dist/src/index.js +222 -0
- package/dist/src/index.js.map +1 -0
- package/dist/src/notifications/discord.d.ts +10 -0
- package/dist/src/notifications/discord.d.ts.map +1 -0
- package/dist/src/notifications/discord.js +218 -0
- package/dist/src/notifications/discord.js.map +1 -0
- package/dist/src/notifications/index.d.ts +37 -0
- package/dist/src/notifications/index.d.ts.map +1 -0
- package/dist/src/notifications/index.js +68 -0
- package/dist/src/notifications/index.js.map +1 -0
- package/dist/src/notifications/slack.d.ts +10 -0
- package/dist/src/notifications/slack.d.ts.map +1 -0
- package/dist/src/notifications/slack.js +218 -0
- package/dist/src/notifications/slack.js.map +1 -0
- package/dist/src/notifications/telegram.d.ts +10 -0
- package/dist/src/notifications/telegram.d.ts.map +1 -0
- package/dist/src/notifications/telegram.js +242 -0
- package/dist/src/notifications/telegram.js.map +1 -0
- package/dist/src/notifications/types.d.ts +119 -0
- package/dist/src/notifications/types.d.ts.map +1 -0
- package/dist/src/notifications/types.js +6 -0
- package/dist/src/notifications/types.js.map +1 -0
- package/dist/src/proxy/index.d.ts +8 -0
- package/dist/src/proxy/index.d.ts.map +1 -0
- package/dist/src/proxy/index.js +9 -0
- package/dist/src/proxy/index.js.map +1 -0
- package/dist/src/proxy/middleware.d.ts +55 -0
- package/dist/src/proxy/middleware.d.ts.map +1 -0
- package/dist/src/proxy/middleware.js +215 -0
- package/dist/src/proxy/middleware.js.map +1 -0
- package/dist/src/proxy/server.d.ts +57 -0
- package/dist/src/proxy/server.d.ts.map +1 -0
- package/dist/src/proxy/server.js +298 -0
- package/dist/src/proxy/server.js.map +1 -0
- package/dist/src/proxy/types.d.ts +136 -0
- package/dist/src/proxy/types.d.ts.map +1 -0
- package/dist/src/proxy/types.js +6 -0
- package/dist/src/proxy/types.js.map +1 -0
- package/dist/src/sanitization/index.d.ts +10 -0
- package/dist/src/sanitization/index.d.ts.map +1 -0
- package/dist/src/sanitization/index.js +9 -0
- package/dist/src/sanitization/index.js.map +1 -0
- package/dist/src/sanitization/patterns.d.ts +51 -0
- package/dist/src/sanitization/patterns.d.ts.map +1 -0
- package/dist/src/sanitization/patterns.js +266 -0
- package/dist/src/sanitization/patterns.js.map +1 -0
- package/dist/src/sanitization/scanner.d.ts +29 -0
- package/dist/src/sanitization/scanner.d.ts.map +1 -0
- package/dist/src/sanitization/scanner.js +328 -0
- package/dist/src/sanitization/scanner.js.map +1 -0
- package/dist/src/sanitization/types.d.ts +57 -0
- package/dist/src/sanitization/types.d.ts.map +1 -0
- package/dist/src/sanitization/types.js +5 -0
- package/dist/src/sanitization/types.js.map +1 -0
- package/openclaw.plugin.json +114 -0
- package/package.json +63 -0
- package/rules/builtin/README.md +139 -0
- package/rules/builtin/ai-services.yaml +70 -0
- package/rules/builtin/api-keys.yaml +64 -0
- package/rules/builtin/authentication.yaml +56 -0
- package/rules/builtin/aws-security.yaml +57 -0
- package/rules/builtin/azure-security.yaml +58 -0
- package/rules/builtin/cicd-security.yaml +64 -0
- package/rules/builtin/cloud-storage.yaml +64 -0
- package/rules/builtin/container-registry.yaml +55 -0
- package/rules/builtin/crypto-wallets.yaml +71 -0
- package/rules/builtin/database-nosql.yaml +58 -0
- package/rules/builtin/database-sql.yaml +62 -0
- package/rules/builtin/development-env.yaml +67 -0
- package/rules/builtin/docker.yaml +57 -0
- package/rules/builtin/filesystem.yaml +71 -0
- package/rules/builtin/financial-pci.yaml +61 -0
- package/rules/builtin/gcp-security.yaml +57 -0
- package/rules/builtin/git-operations.yaml +68 -0
- package/rules/builtin/healthcare-hipaa.yaml +64 -0
- package/rules/builtin/kubernetes.yaml +60 -0
- package/rules/builtin/messaging-services.yaml +53 -0
- package/rules/builtin/minimal.yaml +47 -0
- package/rules/builtin/mobile-development.yaml +61 -0
- package/rules/builtin/monitoring.yaml +63 -0
- package/rules/builtin/network-security.yaml +57 -0
- package/rules/builtin/package-managers.yaml +74 -0
- package/rules/builtin/payment-processing.yaml +66 -0
- package/rules/builtin/pii-protection.yaml +48 -0
- package/rules/builtin/production-strict.yaml +55 -0
- package/rules/builtin/secrets-management.yaml +63 -0
- package/rules/builtin/serverless.yaml +74 -0
- package/rules/builtin/ssh-security.yaml +66 -0
- package/rules/builtin/terraform.yaml +51 -0
- package/rules/builtin/web-security.yaml +62 -0
|
@@ -0,0 +1,429 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* HTTP Exfiltration Detector
|
|
3
|
+
* Detects HTTP POST/PUT requests that send data to external destinations
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* curl patterns for sending data via POST/PUT
|
|
7
|
+
*/
|
|
8
|
+
const CURL_POST_PATTERNS = [
|
|
9
|
+
// curl -X PUT with data (check PUT first to avoid POST matching)
|
|
10
|
+
{
|
|
11
|
+
pattern: /\bcurl\s+(?:[^|;]+\s+)?(?:-X\s+PUT|-X\s*=?\s*PUT|--request\s+PUT|--request\s*=\s*PUT)\s+(?:[^|;]+\s+)?(?:-d|--data|--data-binary|--data-raw|--data-urlencode|-F|--form)\s+(?:["']?)([^"'\s][^|;]*)/i,
|
|
12
|
+
method: 'PUT',
|
|
13
|
+
description: 'curl PUT with data',
|
|
14
|
+
},
|
|
15
|
+
// curl -X POST with data flags
|
|
16
|
+
{
|
|
17
|
+
pattern: /\bcurl\s+(?:[^|;]+\s+)?(?:-X\s+POST|-X\s*=?\s*POST|--request\s+POST|--request\s*=\s*POST)\s+(?:[^|;]+\s+)?(?:-d|--data|--data-binary|--data-raw|--data-urlencode|-F|--form)\s+(?:["']?)([^"'\s][^|;]*)/i,
|
|
18
|
+
method: 'POST',
|
|
19
|
+
description: 'curl POST with data',
|
|
20
|
+
},
|
|
21
|
+
// curl with data flags (POST is implicit) - but NOT if -X PUT is present
|
|
22
|
+
{
|
|
23
|
+
pattern: /\bcurl\s+(?!.*-X\s+PUT)(?:[^|;]+\s+)?(?:-d|--data|--data-binary|--data-raw|--data-urlencode)\s+(?:["']?)([^"'\s][^|;]*)/i,
|
|
24
|
+
method: 'POST',
|
|
25
|
+
description: 'curl with data (implicit POST)',
|
|
26
|
+
},
|
|
27
|
+
// curl with -T (upload file)
|
|
28
|
+
{
|
|
29
|
+
pattern: /\bcurl\s+(?:[^|;]+\s+)?(?:-T|--upload-file)\s+(?:["']?)([^\s"']+)/i,
|
|
30
|
+
method: 'PUT',
|
|
31
|
+
description: 'curl file upload',
|
|
32
|
+
},
|
|
33
|
+
// curl with form file upload
|
|
34
|
+
{
|
|
35
|
+
pattern: /\bcurl\s+(?:[^|;]+\s+)?(?:-F|--form)\s+(?:["']?)([^"'\s]*@[^\s"';|]+)/i,
|
|
36
|
+
method: 'POST',
|
|
37
|
+
description: 'curl form file upload',
|
|
38
|
+
},
|
|
39
|
+
];
|
|
40
|
+
/**
|
|
41
|
+
* wget patterns for sending data
|
|
42
|
+
*/
|
|
43
|
+
const WGET_POST_PATTERNS = [
|
|
44
|
+
// wget --post-data
|
|
45
|
+
{
|
|
46
|
+
pattern: /\bwget\s+(?:[^|;]+\s+)?(?:--post-data)\s*=?\s*(?:["']?)([^"'\s][^|;]*)/i,
|
|
47
|
+
method: 'POST',
|
|
48
|
+
description: 'wget POST with data',
|
|
49
|
+
},
|
|
50
|
+
// wget --post-file
|
|
51
|
+
{
|
|
52
|
+
pattern: /\bwget\s+(?:[^|;]+\s+)?(?:--post-file)\s*=?\s*(?:["']?)([^\s"']+)/i,
|
|
53
|
+
method: 'POST',
|
|
54
|
+
description: 'wget POST file',
|
|
55
|
+
},
|
|
56
|
+
];
|
|
57
|
+
/**
|
|
58
|
+
* httpie patterns (http/https commands)
|
|
59
|
+
*/
|
|
60
|
+
const HTTPIE_PATTERNS = [
|
|
61
|
+
// http POST with data
|
|
62
|
+
{
|
|
63
|
+
pattern: /\bhttps?\s+POST\s+(\S+)\s+.*(?:=|:=|@)/i,
|
|
64
|
+
method: 'POST',
|
|
65
|
+
description: 'httpie POST with data',
|
|
66
|
+
},
|
|
67
|
+
// http PUT with data
|
|
68
|
+
{
|
|
69
|
+
pattern: /\bhttps?\s+PUT\s+(\S+)\s+.*(?:=|:=|@)/i,
|
|
70
|
+
method: 'PUT',
|
|
71
|
+
description: 'httpie PUT with data',
|
|
72
|
+
},
|
|
73
|
+
];
|
|
74
|
+
/**
|
|
75
|
+
* Code patterns for HTTP exfiltration (fetch, axios, requests, etc.)
|
|
76
|
+
*/
|
|
77
|
+
const CODE_HTTP_PATTERNS = [
|
|
78
|
+
// JavaScript fetch with POST/PUT
|
|
79
|
+
{
|
|
80
|
+
pattern: /\bfetch\s*\(\s*["'`]([^"'`]+)["'`]\s*,\s*\{[^}]*method\s*:\s*["'`](POST|PUT)["'`][^}]*body\s*:/i,
|
|
81
|
+
method: 'POST',
|
|
82
|
+
description: 'fetch with POST/PUT and body',
|
|
83
|
+
},
|
|
84
|
+
{
|
|
85
|
+
pattern: /\bfetch\s*\(\s*["'`]([^"'`]+)["'`]\s*,\s*\{[^}]*body\s*:[^}]*method\s*:\s*["'`](POST|PUT)["'`]/i,
|
|
86
|
+
method: 'POST',
|
|
87
|
+
description: 'fetch with body and POST/PUT',
|
|
88
|
+
},
|
|
89
|
+
// axios.post/put
|
|
90
|
+
{
|
|
91
|
+
pattern: /\baxios\s*\.\s*(post|put)\s*\(\s*["'`]([^"'`]+)["'`]/i,
|
|
92
|
+
method: 'POST',
|
|
93
|
+
description: 'axios POST/PUT',
|
|
94
|
+
},
|
|
95
|
+
// Python requests.post/put
|
|
96
|
+
{
|
|
97
|
+
pattern: /\brequests\s*\.\s*(post|put)\s*\(\s*["'`]([^"'`]+)["'`]/i,
|
|
98
|
+
method: 'POST',
|
|
99
|
+
description: 'Python requests POST/PUT',
|
|
100
|
+
},
|
|
101
|
+
// Python httpx.post/put
|
|
102
|
+
{
|
|
103
|
+
pattern: /\bhttpx\s*\.\s*(post|put)\s*\(\s*["'`]([^"'`]+)["'`]/i,
|
|
104
|
+
method: 'POST',
|
|
105
|
+
description: 'Python httpx POST/PUT',
|
|
106
|
+
},
|
|
107
|
+
// Python urllib with POST data
|
|
108
|
+
{
|
|
109
|
+
pattern: /\burllib\s*\.\s*request\s*\.\s*urlopen\s*\([^)]*data\s*=/i,
|
|
110
|
+
method: 'POST',
|
|
111
|
+
description: 'Python urllib with POST data',
|
|
112
|
+
},
|
|
113
|
+
// Node.js http.request with POST
|
|
114
|
+
{
|
|
115
|
+
pattern: /\bhttp[s]?\s*\.\s*request\s*\([^)]*method\s*:\s*["'`](POST|PUT)["'`]/i,
|
|
116
|
+
method: 'POST',
|
|
117
|
+
description: 'Node http.request POST',
|
|
118
|
+
},
|
|
119
|
+
// Ruby Net::HTTP.post/put
|
|
120
|
+
{
|
|
121
|
+
pattern: /\bNet::HTTP\s*\.\s*(post|put|post_form)\s*\(/i,
|
|
122
|
+
method: 'POST',
|
|
123
|
+
description: 'Ruby Net::HTTP POST',
|
|
124
|
+
},
|
|
125
|
+
// Go http.Post/PostForm
|
|
126
|
+
{
|
|
127
|
+
pattern: /\bhttp\s*\.\s*(Post|PostForm|NewRequest\s*\([^)]*"(POST|PUT)")/i,
|
|
128
|
+
method: 'POST',
|
|
129
|
+
description: 'Go http POST',
|
|
130
|
+
},
|
|
131
|
+
// PowerShell Invoke-WebRequest/RestMethod with POST
|
|
132
|
+
{
|
|
133
|
+
pattern: /\bInvoke-(?:WebRequest|RestMethod)\s+(?:[^|;]+\s+)?-Method\s+(POST|PUT)\s+(?:[^|;]+\s+)?-Body\s+/i,
|
|
134
|
+
method: 'POST',
|
|
135
|
+
description: 'PowerShell POST with body',
|
|
136
|
+
},
|
|
137
|
+
];
|
|
138
|
+
/**
|
|
139
|
+
* Encoded exfiltration patterns (piping encoded data to HTTP tools)
|
|
140
|
+
*/
|
|
141
|
+
const ENCODED_EXFIL_PATTERNS = [
|
|
142
|
+
// base64 | curl
|
|
143
|
+
{
|
|
144
|
+
pattern: /\bbase64\s+(?:[^|]+)?\|\s*curl\b/i,
|
|
145
|
+
method: 'POST',
|
|
146
|
+
description: 'base64 encoded data to curl',
|
|
147
|
+
},
|
|
148
|
+
// gzip/compress | curl
|
|
149
|
+
{
|
|
150
|
+
pattern: /\b(?:gzip|bzip2|xz|compress|tar)\s+(?:[^|]+)?\|\s*curl\b/i,
|
|
151
|
+
method: 'POST',
|
|
152
|
+
description: 'compressed data to curl',
|
|
153
|
+
},
|
|
154
|
+
// openssl enc | curl
|
|
155
|
+
{
|
|
156
|
+
pattern: /\bopenssl\s+enc\s+(?:[^|]+)?\|\s*curl\b/i,
|
|
157
|
+
method: 'POST',
|
|
158
|
+
description: 'encrypted data to curl',
|
|
159
|
+
},
|
|
160
|
+
// xxd/hexdump | curl
|
|
161
|
+
{
|
|
162
|
+
pattern: /\b(?:xxd|hexdump|od)\s+(?:[^|]+)?\|\s*curl\b/i,
|
|
163
|
+
method: 'POST',
|
|
164
|
+
description: 'hex encoded data to curl',
|
|
165
|
+
},
|
|
166
|
+
// Any pipe to curl with POST
|
|
167
|
+
{
|
|
168
|
+
pattern: /\|\s*curl\s+(?:[^|;]+\s+)?(?:-X\s+POST|--data|--data-binary|-d)/i,
|
|
169
|
+
method: 'POST',
|
|
170
|
+
description: 'piped data to curl POST',
|
|
171
|
+
},
|
|
172
|
+
];
|
|
173
|
+
/**
|
|
174
|
+
* Extract URL from curl/wget command
|
|
175
|
+
*/
|
|
176
|
+
function extractUrl(command) {
|
|
177
|
+
// Try to find URL in the command
|
|
178
|
+
const urlPatterns = [
|
|
179
|
+
/\bhttps?:\/\/[^\s"'<>]+/i,
|
|
180
|
+
/\bftp:\/\/[^\s"'<>]+/i,
|
|
181
|
+
];
|
|
182
|
+
for (const pattern of urlPatterns) {
|
|
183
|
+
const match = command.match(pattern);
|
|
184
|
+
if (match) {
|
|
185
|
+
return match[0];
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
return undefined;
|
|
189
|
+
}
|
|
190
|
+
/**
|
|
191
|
+
* Extract data source from command
|
|
192
|
+
*/
|
|
193
|
+
function extractDataSource(command) {
|
|
194
|
+
// Look for file references
|
|
195
|
+
const filePatterns = [
|
|
196
|
+
/-d\s*@([^\s"']+)/i, // curl -d @file
|
|
197
|
+
/--data-binary\s*@([^\s"']+)/i, // curl --data-binary @file
|
|
198
|
+
/-F\s*[^@]*@([^\s"';]+)/i, // curl -F file=@path
|
|
199
|
+
/-T\s*([^\s"']+)/i, // curl -T file
|
|
200
|
+
/--post-file\s*=?\s*([^\s"']+)/i, // wget --post-file
|
|
201
|
+
/--upload-file\s*([^\s"']+)/i, // curl --upload-file
|
|
202
|
+
];
|
|
203
|
+
for (const pattern of filePatterns) {
|
|
204
|
+
const match = command.match(pattern);
|
|
205
|
+
if (match) {
|
|
206
|
+
return match[1];
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
// Look for piped input
|
|
210
|
+
if (command.includes('|')) {
|
|
211
|
+
const pipeMatch = command.match(/([^|]+)\s*\|\s*(?:curl|wget)/i);
|
|
212
|
+
if (pipeMatch) {
|
|
213
|
+
return `piped from: ${pipeMatch[1].trim().substring(0, 50)}`;
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
return undefined;
|
|
217
|
+
}
|
|
218
|
+
/**
|
|
219
|
+
* Match curl POST/PUT commands
|
|
220
|
+
*/
|
|
221
|
+
export function matchCurlCommand(command) {
|
|
222
|
+
for (const { pattern, method, description } of CURL_POST_PATTERNS) {
|
|
223
|
+
const match = command.match(pattern);
|
|
224
|
+
if (match) {
|
|
225
|
+
return {
|
|
226
|
+
matched: true,
|
|
227
|
+
command,
|
|
228
|
+
httpMethod: method,
|
|
229
|
+
destination: extractUrl(command),
|
|
230
|
+
dataSource: extractDataSource(command),
|
|
231
|
+
confidence: 0.9,
|
|
232
|
+
description,
|
|
233
|
+
};
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
return { matched: false, confidence: 0 };
|
|
237
|
+
}
|
|
238
|
+
/**
|
|
239
|
+
* Match wget POST commands
|
|
240
|
+
*/
|
|
241
|
+
export function matchWgetCommand(command) {
|
|
242
|
+
for (const { pattern, method, description } of WGET_POST_PATTERNS) {
|
|
243
|
+
const match = command.match(pattern);
|
|
244
|
+
if (match) {
|
|
245
|
+
return {
|
|
246
|
+
matched: true,
|
|
247
|
+
command,
|
|
248
|
+
httpMethod: method,
|
|
249
|
+
destination: extractUrl(command),
|
|
250
|
+
dataSource: match[1] || extractDataSource(command),
|
|
251
|
+
confidence: 0.9,
|
|
252
|
+
description,
|
|
253
|
+
};
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
return { matched: false, confidence: 0 };
|
|
257
|
+
}
|
|
258
|
+
/**
|
|
259
|
+
* Match httpie commands
|
|
260
|
+
*/
|
|
261
|
+
export function matchHttpieCommand(command) {
|
|
262
|
+
for (const { pattern, method, description } of HTTPIE_PATTERNS) {
|
|
263
|
+
const match = command.match(pattern);
|
|
264
|
+
if (match) {
|
|
265
|
+
return {
|
|
266
|
+
matched: true,
|
|
267
|
+
command,
|
|
268
|
+
httpMethod: method,
|
|
269
|
+
destination: match[1],
|
|
270
|
+
confidence: 0.85,
|
|
271
|
+
description,
|
|
272
|
+
};
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
return { matched: false, confidence: 0 };
|
|
276
|
+
}
|
|
277
|
+
/**
|
|
278
|
+
* Match HTTP client library patterns in code
|
|
279
|
+
*/
|
|
280
|
+
export function matchCodeHttpPattern(code) {
|
|
281
|
+
for (const { pattern, method, description } of CODE_HTTP_PATTERNS) {
|
|
282
|
+
const match = code.match(pattern);
|
|
283
|
+
if (match) {
|
|
284
|
+
// Extract URL from the match
|
|
285
|
+
const url = match[2] || match[1];
|
|
286
|
+
return {
|
|
287
|
+
matched: true,
|
|
288
|
+
command: code,
|
|
289
|
+
httpMethod: typeof match[1] === 'string' && ['post', 'put'].includes(match[1].toLowerCase())
|
|
290
|
+
? match[1].toUpperCase()
|
|
291
|
+
: method,
|
|
292
|
+
destination: url?.startsWith('http') ? url : undefined,
|
|
293
|
+
confidence: 0.85,
|
|
294
|
+
description,
|
|
295
|
+
};
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
return { matched: false, confidence: 0 };
|
|
299
|
+
}
|
|
300
|
+
/**
|
|
301
|
+
* Match encoded exfiltration patterns
|
|
302
|
+
*/
|
|
303
|
+
export function matchEncodedExfiltration(command) {
|
|
304
|
+
for (const { pattern, method, description } of ENCODED_EXFIL_PATTERNS) {
|
|
305
|
+
const match = command.match(pattern);
|
|
306
|
+
if (match) {
|
|
307
|
+
return {
|
|
308
|
+
matched: true,
|
|
309
|
+
command,
|
|
310
|
+
httpMethod: method,
|
|
311
|
+
destination: extractUrl(command),
|
|
312
|
+
dataSource: extractDataSource(command) || 'encoded/piped data',
|
|
313
|
+
confidence: 0.95, // Higher confidence for encoded exfiltration
|
|
314
|
+
description,
|
|
315
|
+
};
|
|
316
|
+
}
|
|
317
|
+
}
|
|
318
|
+
return { matched: false, confidence: 0 };
|
|
319
|
+
}
|
|
320
|
+
/**
|
|
321
|
+
* Comprehensive HTTP exfiltration matching
|
|
322
|
+
*/
|
|
323
|
+
export function matchHttpExfiltration(text) {
|
|
324
|
+
// Try encoded exfiltration first (highest confidence)
|
|
325
|
+
const encodedResult = matchEncodedExfiltration(text);
|
|
326
|
+
if (encodedResult.matched) {
|
|
327
|
+
return encodedResult;
|
|
328
|
+
}
|
|
329
|
+
// Try curl
|
|
330
|
+
const curlResult = matchCurlCommand(text);
|
|
331
|
+
if (curlResult.matched) {
|
|
332
|
+
return curlResult;
|
|
333
|
+
}
|
|
334
|
+
// Try wget
|
|
335
|
+
const wgetResult = matchWgetCommand(text);
|
|
336
|
+
if (wgetResult.matched) {
|
|
337
|
+
return wgetResult;
|
|
338
|
+
}
|
|
339
|
+
// Try httpie
|
|
340
|
+
const httpieResult = matchHttpieCommand(text);
|
|
341
|
+
if (httpieResult.matched) {
|
|
342
|
+
return httpieResult;
|
|
343
|
+
}
|
|
344
|
+
// Try code patterns
|
|
345
|
+
const codeResult = matchCodeHttpPattern(text);
|
|
346
|
+
if (codeResult.matched) {
|
|
347
|
+
return codeResult;
|
|
348
|
+
}
|
|
349
|
+
return { matched: false, confidence: 0 };
|
|
350
|
+
}
|
|
351
|
+
/**
|
|
352
|
+
* HTTP exfiltration detector class
|
|
353
|
+
*/
|
|
354
|
+
export class HttpDetector {
|
|
355
|
+
severity;
|
|
356
|
+
constructor(severity = 'high') {
|
|
357
|
+
this.severity = severity;
|
|
358
|
+
}
|
|
359
|
+
/**
|
|
360
|
+
* Extract text content from tool context
|
|
361
|
+
*/
|
|
362
|
+
extractContent(context) {
|
|
363
|
+
const input = context.toolInput;
|
|
364
|
+
// Direct command field
|
|
365
|
+
if (typeof input.command === 'string') {
|
|
366
|
+
return input.command;
|
|
367
|
+
}
|
|
368
|
+
// Shell/bash command field
|
|
369
|
+
if (typeof input.shell === 'string') {
|
|
370
|
+
return input.shell;
|
|
371
|
+
}
|
|
372
|
+
if (typeof input.bash === 'string') {
|
|
373
|
+
return input.bash;
|
|
374
|
+
}
|
|
375
|
+
// Script field
|
|
376
|
+
if (typeof input.script === 'string') {
|
|
377
|
+
return input.script;
|
|
378
|
+
}
|
|
379
|
+
// Code field
|
|
380
|
+
if (typeof input.code === 'string') {
|
|
381
|
+
return input.code;
|
|
382
|
+
}
|
|
383
|
+
// Text content
|
|
384
|
+
if (typeof input.text === 'string') {
|
|
385
|
+
return input.text;
|
|
386
|
+
}
|
|
387
|
+
// Content field
|
|
388
|
+
if (typeof input.content === 'string') {
|
|
389
|
+
return input.content;
|
|
390
|
+
}
|
|
391
|
+
// Body field (for write operations)
|
|
392
|
+
if (typeof input.body === 'string') {
|
|
393
|
+
return input.body;
|
|
394
|
+
}
|
|
395
|
+
return null;
|
|
396
|
+
}
|
|
397
|
+
detect(context) {
|
|
398
|
+
const content = this.extractContent(context);
|
|
399
|
+
if (!content) {
|
|
400
|
+
return null;
|
|
401
|
+
}
|
|
402
|
+
const result = matchHttpExfiltration(content);
|
|
403
|
+
if (!result.matched) {
|
|
404
|
+
return null;
|
|
405
|
+
}
|
|
406
|
+
const destInfo = result.destination ? ` to ${result.destination}` : '';
|
|
407
|
+
const dataInfo = result.dataSource ? ` (${result.dataSource})` : '';
|
|
408
|
+
return {
|
|
409
|
+
detected: true,
|
|
410
|
+
category: 'exfiltration',
|
|
411
|
+
severity: this.severity,
|
|
412
|
+
confidence: result.confidence,
|
|
413
|
+
reason: `HTTP exfiltration detected: ${result.description || `${result.httpMethod} request`}${destInfo}${dataInfo}`,
|
|
414
|
+
metadata: {
|
|
415
|
+
method: 'http',
|
|
416
|
+
destination: result.destination,
|
|
417
|
+
dataSource: result.dataSource,
|
|
418
|
+
command: result.command,
|
|
419
|
+
},
|
|
420
|
+
};
|
|
421
|
+
}
|
|
422
|
+
}
|
|
423
|
+
/**
|
|
424
|
+
* Create an HTTP detector with the given severity
|
|
425
|
+
*/
|
|
426
|
+
export function createHttpDetector(severity = 'high') {
|
|
427
|
+
return new HttpDetector(severity);
|
|
428
|
+
}
|
|
429
|
+
//# sourceMappingURL=http-detector.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"http-detector.js","sourceRoot":"","sources":["../../../../src/detectors/exfiltration/http-detector.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAUH;;GAEG;AACH,MAAM,kBAAkB,GAAG;IACzB,iEAAiE;IACjE;QACE,OAAO,EAAE,qMAAqM;QAC9M,MAAM,EAAE,KAAK;QACb,WAAW,EAAE,oBAAoB;KAClC;IACD,+BAA+B;IAC/B;QACE,OAAO,EAAE,yMAAyM;QAClN,MAAM,EAAE,MAAM;QACd,WAAW,EAAE,qBAAqB;KACnC;IACD,yEAAyE;IACzE;QACE,OAAO,EA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Q,CAAC,CAAC;AACpC,CAAC"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Exfiltration Detector
|
|
3
|
+
* Main export for detecting data exfiltration attempts via HTTP, cloud, and network methods
|
|
4
|
+
*/
|
|
5
|
+
export type { DetectionContext, ExfiltrationMethod, ExfiltrationDetectionResult, ExfiltrationDetectorConfig, ExfiltrationDetector as IExfiltrationDetector, SubDetector, HttpMatchResult, CloudUploadMatchResult, NetworkMatchResult, } from './types.js';
|
|
6
|
+
export { HttpDetector, createHttpDetector, matchCurlCommand, matchWgetCommand, matchHttpieCommand, matchCodeHttpPattern, matchEncodedExfiltration, matchHttpExfiltration, } from './http-detector.js';
|
|
7
|
+
export { CloudUploadDetector, createCloudUploadDetector, matchAwsS3Upload, matchGcpUpload, matchAzureUpload, matchRcloneUpload, matchOtherCloudUpload, matchCloudSdkUpload, matchCloudUpload, } from './cloud-detector.js';
|
|
8
|
+
export { NetworkDetector, createNetworkDetector, matchNetcatCommand, matchDevTcpPattern, matchSocatCommand, matchTelnetCommand, matchSshExfiltration, matchDnsExfiltration, matchOtherNetworkPattern, matchNetworkExfiltration, } from './network-detector.js';
|
|
9
|
+
import type { DetectionContext, ExfiltrationDetectionResult, ExfiltrationDetectorConfig, ExfiltrationDetector } from './types.js';
|
|
10
|
+
import type { ExfiltrationRule } from '../../config/index.js';
|
|
11
|
+
/**
|
|
12
|
+
* Main exfiltration detector implementation
|
|
13
|
+
*/
|
|
14
|
+
export declare class ExfiltrationDetectorImpl implements ExfiltrationDetector {
|
|
15
|
+
private config;
|
|
16
|
+
private httpDetector;
|
|
17
|
+
private cloudDetector;
|
|
18
|
+
private networkDetector;
|
|
19
|
+
constructor(config: ExfiltrationDetectorConfig);
|
|
20
|
+
detect(context: DetectionContext): Promise<ExfiltrationDetectionResult>;
|
|
21
|
+
/**
|
|
22
|
+
* Get the configured action for detected exfiltration
|
|
23
|
+
*/
|
|
24
|
+
getAction(): "block" | "confirm" | "agent-confirm" | "warn" | "log";
|
|
25
|
+
/**
|
|
26
|
+
* Check if the detector is enabled
|
|
27
|
+
*/
|
|
28
|
+
isEnabled(): boolean;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Create an exfiltration detector from configuration
|
|
32
|
+
*/
|
|
33
|
+
export declare function createExfiltrationDetector(config: ExfiltrationDetectorConfig | ExfiltrationRule): ExfiltrationDetectorImpl;
|
|
34
|
+
/**
|
|
35
|
+
* Create a default exfiltration detector with standard settings
|
|
36
|
+
*/
|
|
37
|
+
export declare function createDefaultExfiltrationDetector(): ExfiltrationDetectorImpl;
|
|
38
|
+
declare const _default: {
|
|
39
|
+
ExfiltrationDetectorImpl: typeof ExfiltrationDetectorImpl;
|
|
40
|
+
createExfiltrationDetector: typeof createExfiltrationDetector;
|
|
41
|
+
createDefaultExfiltrationDetector: typeof createDefaultExfiltrationDetector;
|
|
42
|
+
};
|
|
43
|
+
export default _default;
|
|
44
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/detectors/exfiltration/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,YAAY,EACV,gBAAgB,EAChB,kBAAkB,EAClB,2BAA2B,EAC3B,0BAA0B,EAC1B,oBAAoB,IAAI,qBAAqB,EAC7C,WAAW,EACX,eAAe,EACf,sBAAsB,EACtB,kBAAkB,GACnB,MAAM,YAAY,CAAC;AAGpB,OAAO,EACL,YAAY,EACZ,kBAAkB,EAClB,gBAAgB,EAChB,gBAAgB,EAChB,kBAAkB,EAClB,oBAAoB,EACpB,wBAAwB,EACxB,qBAAqB,GACtB,MAAM,oBAAoB,CAAC;AAG5B,OAAO,EACL,mBAAmB,EACnB,yBAAyB,EACzB,gBAAgB,EAChB,cAAc,EACd,gBAAgB,EAChB,iBAAiB,EACjB,qBAAqB,EACrB,mBAAmB,EACnB,gBAAgB,GACjB,MAAM,qBAAqB,CAAC;AAG7B,OAAO,EACL,eAAe,EACf,qBAAqB,EACrB,kBAAkB,EAClB,kBAAkB,EAClB,iBAAiB,EACjB,kBAAkB,EAClB,oBAAoB,EACpB,oBAAoB,EACpB,wBAAwB,EACxB,wBAAwB,GACzB,MAAM,uBAAuB,CAAC;AAE/B,OAAO,KAAK,EACV,gBAAgB,EAChB,2BAA2B,EAC3B,0BAA0B,EAC1B,oBAAoB,EACrB,MAAM,YAAY,CAAC;AAIpB,OAAO,KAAK,EAAY,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAqDxE;;GAEG;AACH,qBAAa,wBAAyB,YAAW,oBAAoB;IACnE,OAAO,CAAC,MAAM,CAA6B;IAC3C,OAAO,CAAC,YAAY,CAAe;IACnC,OAAO,CAAC,aAAa,CAAsB;IAC3C,OAAO,CAAC,eAAe,CAAkB;gBAE7B,MAAM,EAAE,0BAA0B;IASxC,MAAM,CAAC,OAAO,EAAE,gBAAgB,GAAG,OAAO,CAAC,2BAA2B,CAAC;IAqB7E;;OAEG;IACH,SAAS;IAIT;;OAEG;IACH,SAAS,IAAI,OAAO;CAGrB;AAED;;GAEG;AACH,wBAAgB,0BAA0B,CACxC,MAAM,EAAE,0BAA0B,GAAG,gBAAgB,GACpD,wBAAwB,CAE1B;AAED;;GAEG;AACH,wBAAgB,iCAAiC,IAAI,wBAAwB,CAM5E;;;;;;AAGD,wBAIE"}
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Exfiltration Detector
|
|
3
|
+
* Main export for detecting data exfiltration attempts via HTTP, cloud, and network methods
|
|
4
|
+
*/
|
|
5
|
+
// Re-export HTTP detector
|
|
6
|
+
export { HttpDetector, createHttpDetector, matchCurlCommand, matchWgetCommand, matchHttpieCommand, matchCodeHttpPattern, matchEncodedExfiltration, matchHttpExfiltration, } from './http-detector.js';
|
|
7
|
+
// Re-export cloud upload detector
|
|
8
|
+
export { CloudUploadDetector, createCloudUploadDetector, matchAwsS3Upload, matchGcpUpload, matchAzureUpload, matchRcloneUpload, matchOtherCloudUpload, matchCloudSdkUpload, matchCloudUpload, } from './cloud-detector.js';
|
|
9
|
+
// Re-export network detector
|
|
10
|
+
export { NetworkDetector, createNetworkDetector, matchNetcatCommand, matchDevTcpPattern, matchSocatCommand, matchTelnetCommand, matchSshExfiltration, matchDnsExfiltration, matchOtherNetworkPattern, matchNetworkExfiltration, } from './network-detector.js';
|
|
11
|
+
import { createHttpDetector } from './http-detector.js';
|
|
12
|
+
import { createCloudUploadDetector } from './cloud-detector.js';
|
|
13
|
+
import { createNetworkDetector } from './network-detector.js';
|
|
14
|
+
/**
|
|
15
|
+
* Create a no-detection result
|
|
16
|
+
*/
|
|
17
|
+
function noDetection(severity) {
|
|
18
|
+
return {
|
|
19
|
+
detected: false,
|
|
20
|
+
category: 'exfiltration',
|
|
21
|
+
severity,
|
|
22
|
+
confidence: 0,
|
|
23
|
+
reason: 'No exfiltration detected',
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Combine results from multiple sub-detectors
|
|
28
|
+
*/
|
|
29
|
+
function combineResults(results, defaultSeverity) {
|
|
30
|
+
// Filter out null results
|
|
31
|
+
const validResults = results.filter((r) => r !== null && r.detected);
|
|
32
|
+
if (validResults.length === 0) {
|
|
33
|
+
return noDetection(defaultSeverity);
|
|
34
|
+
}
|
|
35
|
+
// Sort by confidence (highest first)
|
|
36
|
+
validResults.sort((a, b) => b.confidence - a.confidence);
|
|
37
|
+
// Take the highest confidence result
|
|
38
|
+
const best = validResults[0];
|
|
39
|
+
// Boost confidence if multiple detectors matched
|
|
40
|
+
let confidence = best.confidence;
|
|
41
|
+
if (validResults.length > 1) {
|
|
42
|
+
// Boost by 5% for each additional detection, max 0.99
|
|
43
|
+
confidence = Math.min(0.99, confidence + (validResults.length - 1) * 0.05);
|
|
44
|
+
}
|
|
45
|
+
return {
|
|
46
|
+
...best,
|
|
47
|
+
confidence,
|
|
48
|
+
reason: validResults.length > 1
|
|
49
|
+
? `${best.reason} (confirmed by ${validResults.length} detection methods)`
|
|
50
|
+
: best.reason,
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Main exfiltration detector implementation
|
|
55
|
+
*/
|
|
56
|
+
export class ExfiltrationDetectorImpl {
|
|
57
|
+
config;
|
|
58
|
+
httpDetector;
|
|
59
|
+
cloudDetector;
|
|
60
|
+
networkDetector;
|
|
61
|
+
constructor(config) {
|
|
62
|
+
this.config = config;
|
|
63
|
+
// Initialize sub-detectors
|
|
64
|
+
this.httpDetector = createHttpDetector(config.severity);
|
|
65
|
+
this.cloudDetector = createCloudUploadDetector(config.severity);
|
|
66
|
+
this.networkDetector = createNetworkDetector(config.severity);
|
|
67
|
+
}
|
|
68
|
+
async detect(context) {
|
|
69
|
+
// Check if detector is enabled
|
|
70
|
+
if (!this.config.enabled) {
|
|
71
|
+
return noDetection(this.config.severity);
|
|
72
|
+
}
|
|
73
|
+
const results = [];
|
|
74
|
+
// Run HTTP detector
|
|
75
|
+
results.push(this.httpDetector.detect(context));
|
|
76
|
+
// Run cloud upload detector
|
|
77
|
+
results.push(this.cloudDetector.detect(context));
|
|
78
|
+
// Run network detector
|
|
79
|
+
results.push(this.networkDetector.detect(context));
|
|
80
|
+
// Combine results
|
|
81
|
+
return combineResults(results, this.config.severity);
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Get the configured action for detected exfiltration
|
|
85
|
+
*/
|
|
86
|
+
getAction() {
|
|
87
|
+
return this.config.action;
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Check if the detector is enabled
|
|
91
|
+
*/
|
|
92
|
+
isEnabled() {
|
|
93
|
+
return this.config.enabled;
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* Create an exfiltration detector from configuration
|
|
98
|
+
*/
|
|
99
|
+
export function createExfiltrationDetector(config) {
|
|
100
|
+
return new ExfiltrationDetectorImpl(config);
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* Create a default exfiltration detector with standard settings
|
|
104
|
+
*/
|
|
105
|
+
export function createDefaultExfiltrationDetector() {
|
|
106
|
+
return new ExfiltrationDetectorImpl({
|
|
107
|
+
enabled: true,
|
|
108
|
+
severity: 'high',
|
|
109
|
+
action: 'block',
|
|
110
|
+
});
|
|
111
|
+
}
|
|
112
|
+
// Default export
|
|
113
|
+
export default {
|
|
114
|
+
ExfiltrationDetectorImpl,
|
|
115
|
+
createExfiltrationDetector,
|
|
116
|
+
createDefaultExfiltrationDetector,
|
|
117
|
+
};
|
|
118
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/detectors/exfiltration/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAeH,0BAA0B;AAC1B,OAAO,EACL,YAAY,EACZ,kBAAkB,EAClB,gBAAgB,EAChB,gBAAgB,EAChB,kBAAkB,EAClB,oBAAoB,EACpB,wBAAwB,EACxB,qBAAqB,GACtB,MAAM,oBAAoB,CAAC;AAE5B,kCAAkC;AAClC,OAAO,EACL,mBAAmB,EACnB,yBAAyB,EACzB,gBAAgB,EAChB,cAAc,EACd,gBAAgB,EAChB,iBAAiB,EACjB,qBAAqB,EACrB,mBAAmB,EACnB,gBAAgB,GACjB,MAAM,qBAAqB,CAAC;AAE7B,6BAA6B;AAC7B,OAAO,EACL,eAAe,EACf,qBAAqB,EACrB,kBAAkB,EAClB,kBAAkB,EAClB,iBAAiB,EACjB,kBAAkB,EAClB,oBAAoB,EACpB,oBAAoB,EACpB,wBAAwB,EACxB,wBAAwB,GACzB,MAAM,uBAAuB,CAAC;AAQ/B,OAAO,EAAgB,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AACtE,OAAO,EAAuB,yBAAyB,EAAE,MAAM,qBAAqB,CAAC;AACrF,OAAO,EAAmB,qBAAqB,EAAE,MAAM,uBAAuB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CAAC;IAC7B,CAAC;CACF;AAED;;GAEG;AACH,MAAM,UAAU,0BAA0B,CACxC,MAAqD;IAErD,OAAO,IAAI,wBAAwB,CAAC,MAAM,CAAC,CAAC;AAC9C,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,iCAAiC;IAC/C,OAAO,IAAI,wBAAwB,CAAC;QAClC,OAAO,EAAE,IAAI;QACb,QAAQ,EAAE,MAAM;QAChB,MAAM,EAAE,OAAO;KAChB,CAAC,CAAC;AACL,CAAC;AAED,iBAAiB;AACjB,eAAe;IACb,wBAAwB;IACxB,0BAA0B;IAC1B,iCAAiC;CAClC,CAAC"}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Network Exfiltration Detector
|
|
3
|
+
* Detects raw network commands used for data exfiltration (netcat, socat, /dev/tcp, etc.)
|
|
4
|
+
*/
|
|
5
|
+
import type { NetworkMatchResult, DetectionContext, ExfiltrationDetectionResult, SubDetector } from './types.js';
|
|
6
|
+
import type { Severity } from '../../config/index.js';
|
|
7
|
+
/**
|
|
8
|
+
* Match netcat patterns
|
|
9
|
+
*/
|
|
10
|
+
export declare function matchNetcatCommand(command: string): NetworkMatchResult;
|
|
11
|
+
/**
|
|
12
|
+
* Match /dev/tcp patterns
|
|
13
|
+
*/
|
|
14
|
+
export declare function matchDevTcpPattern(command: string): NetworkMatchResult;
|
|
15
|
+
/**
|
|
16
|
+
* Match socat patterns
|
|
17
|
+
*/
|
|
18
|
+
export declare function matchSocatCommand(command: string): NetworkMatchResult;
|
|
19
|
+
/**
|
|
20
|
+
* Match telnet patterns
|
|
21
|
+
*/
|
|
22
|
+
export declare function matchTelnetCommand(command: string): NetworkMatchResult;
|
|
23
|
+
/**
|
|
24
|
+
* Match SSH/SCP exfiltration patterns
|
|
25
|
+
*/
|
|
26
|
+
export declare function matchSshExfiltration(command: string): NetworkMatchResult;
|
|
27
|
+
/**
|
|
28
|
+
* Match DNS exfiltration patterns
|
|
29
|
+
*/
|
|
30
|
+
export declare function matchDnsExfiltration(command: string): NetworkMatchResult;
|
|
31
|
+
/**
|
|
32
|
+
* Match other network exfiltration patterns
|
|
33
|
+
*/
|
|
34
|
+
export declare function matchOtherNetworkPattern(command: string): NetworkMatchResult;
|
|
35
|
+
/**
|
|
36
|
+
* Comprehensive network exfiltration matching
|
|
37
|
+
*/
|
|
38
|
+
export declare function matchNetworkExfiltration(text: string): NetworkMatchResult;
|
|
39
|
+
/**
|
|
40
|
+
* Network exfiltration detector class
|
|
41
|
+
*/
|
|
42
|
+
export declare class NetworkDetector implements SubDetector {
|
|
43
|
+
private severity;
|
|
44
|
+
constructor(severity?: Severity);
|
|
45
|
+
/**
|
|
46
|
+
* Extract text content from tool context
|
|
47
|
+
*/
|
|
48
|
+
private extractContent;
|
|
49
|
+
detect(context: DetectionContext): ExfiltrationDetectionResult | null;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Create a network detector with the given severity
|
|
53
|
+
*/
|
|
54
|
+
export declare function createNetworkDetector(severity?: Severity): NetworkDetector;
|
|
55
|
+
//# sourceMappingURL=network-detector.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"network-detector.d.ts","sourceRoot":"","sources":["../../../../src/detectors/exfiltration/network-detector.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EACV,kBAAkB,EAClB,gBAAgB,EAChB,2BAA2B,EAC3B,WAAW,EACZ,MAAM,YAAY,CAAC;AACpB,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AAyOtD;;GAEG;AACH,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,MAAM,GAAG,kBAAkB,CAsBtE;AAED;;GAEG;AACH,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,MAAM,GAAG,kBAAkB,CAsBtE;AAED;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,MAAM,GAAG,kBAAkB,CAsBrE;AAED;;GAEG;AACH,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,MAAM,GAAG,kBAAkB,CAiBtE;AAED;;GAEG;AACH,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,MAAM,GAAG,kBAAkB,CAoBxE;AAED;;GAEG;AACH,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,MAAM,GAAG,kBAAkB,CAexE;AAED;;GAEG;AACH,wBAAgB,wBAAwB,CAAC,OAAO,EAAE,MAAM,GAAG,kBAAkB,CAgB5E;AAED;;GAEG;AACH,wBAAgB,wBAAwB,CAAC,IAAI,EAAE,MAAM,GAAG,kBAAkB,CA4CzE;AAED;;GAEG;AACH,qBAAa,eAAgB,YAAW,WAAW;IACjD,OAAO,CAAC,QAAQ,CAAW;gBAEf,QAAQ,GAAE,QAAiB;IAIvC;;OAEG;IACH,OAAO,CAAC,cAAc;IA6CtB,MAAM,CAAC,OAAO,EAAE,gBAAgB,GAAG,2BAA2B,GAAG,IAAI;CAiCtE;AAED;;GAEG;AACH,wBAAgB,qBAAqB,CAAC,QAAQ,GAAE,QAAiB,GAAG,eAAe,CAElF"}
|