@profullstack/threatcrush 0.13.3 → 0.13.5
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 +35 -26
- package/dist/daemon.js +89 -2
- package/dist/daemon.js.map +1 -1
- package/dist/index.js +100 -14
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -25115,6 +25115,38 @@ var DEFAULT_RULES = [
|
|
|
25115
25115
|
},
|
|
25116
25116
|
enabled: true
|
|
25117
25117
|
},
|
|
25118
|
+
{
|
|
25119
|
+
// A 402 is a paywall saying "pay first". A caller that means to pay gets
|
|
25120
|
+
// one and pays; a podcast app polling a paid feed gets a handful an hour.
|
|
25121
|
+
// Thirty in a minute from one address is a scraper that ignores the answer
|
|
25122
|
+
// and keeps walking URLs: GoogleOther did ~40/min per IP against r4ck's
|
|
25123
|
+
// /api/v1/search on dev2, 2026-09-25. `web-scanner-detection` saw it too,
|
|
25124
|
+
// but it is `medium`, and auto-defence bans at `high` and above, so it fired
|
|
25125
|
+
// every minute and never banned. This one is `high` on purpose.
|
|
25126
|
+
//
|
|
25127
|
+
// It cannot see a proxy swarm that asks once per address; nothing per-IP can.
|
|
25128
|
+
id: "paywall-hammering",
|
|
25129
|
+
title: "Paywall Hammering",
|
|
25130
|
+
description: "Repeated 402 Payment Required responses to the same source",
|
|
25131
|
+
version: "1.0.0",
|
|
25132
|
+
category: "web",
|
|
25133
|
+
severity: "high",
|
|
25134
|
+
source_types: ["log-watcher", "web"],
|
|
25135
|
+
match: {
|
|
25136
|
+
field: "message",
|
|
25137
|
+
operator: "regex",
|
|
25138
|
+
value: "Client error 402:"
|
|
25139
|
+
},
|
|
25140
|
+
threshold: 30,
|
|
25141
|
+
window_seconds: 60,
|
|
25142
|
+
cooldown_seconds: 600,
|
|
25143
|
+
tags: ["web", "scraper", "x402", "paywall"],
|
|
25144
|
+
remediation: {
|
|
25145
|
+
action: "block",
|
|
25146
|
+
description: "Block a scraper that keeps walking a paywall without paying"
|
|
25147
|
+
},
|
|
25148
|
+
enabled: true
|
|
25149
|
+
},
|
|
25118
25150
|
{
|
|
25119
25151
|
id: "port-scan-indicator",
|
|
25120
25152
|
title: "Port Scan Indicators",
|
|
@@ -25623,6 +25655,48 @@ function defaultGateways() {
|
|
|
25623
25655
|
return [...found];
|
|
25624
25656
|
}
|
|
25625
25657
|
|
|
25658
|
+
// src/daemon/firewall/crawlers.ts
|
|
25659
|
+
var import_node_dns = require("dns");
|
|
25660
|
+
var CRAWLER_DOMAINS = ["googlebot.com", "google.com", "search.msn.com"];
|
|
25661
|
+
var systemResolver = {
|
|
25662
|
+
reverse: (ip) => import_node_dns.promises.reverse(ip),
|
|
25663
|
+
lookup: async (host) => (await import_node_dns.promises.lookup(host, { all: true })).map((a) => a.address)
|
|
25664
|
+
};
|
|
25665
|
+
var TIMEOUT_MS = 2e3;
|
|
25666
|
+
var CACHE_MS = 6 * 36e5;
|
|
25667
|
+
function withTimeout(p) {
|
|
25668
|
+
return Promise.race([
|
|
25669
|
+
p,
|
|
25670
|
+
new Promise((_, reject) => setTimeout(() => reject(new Error("dns timeout")), TIMEOUT_MS).unref())
|
|
25671
|
+
]);
|
|
25672
|
+
}
|
|
25673
|
+
function inCrawlerDomain(host) {
|
|
25674
|
+
const h = host.toLowerCase().replace(/\.$/, "");
|
|
25675
|
+
return CRAWLER_DOMAINS.some((d) => h === d || h.endsWith(`.${d}`));
|
|
25676
|
+
}
|
|
25677
|
+
function crawlerVerifier(resolver = systemResolver) {
|
|
25678
|
+
const cache = /* @__PURE__ */ new Map();
|
|
25679
|
+
return async (ip) => {
|
|
25680
|
+
const hit = cache.get(ip);
|
|
25681
|
+
if (hit && hit.until > Date.now()) return hit.host;
|
|
25682
|
+
let host = null;
|
|
25683
|
+
try {
|
|
25684
|
+
const names = await withTimeout(resolver.reverse(ip));
|
|
25685
|
+
for (const name of names.filter(inCrawlerDomain)) {
|
|
25686
|
+
const addrs = await withTimeout(resolver.lookup(name));
|
|
25687
|
+
if (addrs.includes(ip)) {
|
|
25688
|
+
host = name.replace(/\.$/, "");
|
|
25689
|
+
break;
|
|
25690
|
+
}
|
|
25691
|
+
}
|
|
25692
|
+
} catch {
|
|
25693
|
+
host = null;
|
|
25694
|
+
}
|
|
25695
|
+
cache.set(ip, { host, until: Date.now() + CACHE_MS });
|
|
25696
|
+
return host;
|
|
25697
|
+
};
|
|
25698
|
+
}
|
|
25699
|
+
|
|
25626
25700
|
// src/daemon/firewall/remediation.ts
|
|
25627
25701
|
var DEFAULT_CONFIG2 = {
|
|
25628
25702
|
enabled: true,
|
|
@@ -25631,7 +25705,8 @@ var DEFAULT_CONFIG2 = {
|
|
|
25631
25705
|
max_ban_seconds: 86400,
|
|
25632
25706
|
strike_memory_seconds: 86400,
|
|
25633
25707
|
allowlist: [],
|
|
25634
|
-
protect_current_ssh_client: true
|
|
25708
|
+
protect_current_ssh_client: true,
|
|
25709
|
+
spare_verified_crawlers: true
|
|
25635
25710
|
};
|
|
25636
25711
|
var SEVERITY_RANK4 = {
|
|
25637
25712
|
info: 0,
|
|
@@ -25651,9 +25726,10 @@ function explainBlockFailure(err, backend) {
|
|
|
25651
25726
|
return `threatcrushd is running ${who} and cannot manage ${backend}. A ban is written by the daemon, not by whoever asked for it. Fix it with one command, which asks for root itself: threatcrush install-service`;
|
|
25652
25727
|
}
|
|
25653
25728
|
var RemediationManager = class {
|
|
25654
|
-
constructor(adapter, bus2, config) {
|
|
25729
|
+
constructor(adapter, bus2, config, verifyCrawler = crawlerVerifier()) {
|
|
25655
25730
|
this.adapter = adapter;
|
|
25656
25731
|
this.bus = bus2;
|
|
25732
|
+
this.verifyCrawler = verifyCrawler;
|
|
25657
25733
|
this.config = { ...DEFAULT_CONFIG2, ...config };
|
|
25658
25734
|
this.protectedList = [...DEFAULT_PROTECTED, ...this.config.allowlist];
|
|
25659
25735
|
for (const gateway of defaultGateways()) this.protectedList.push(gateway);
|
|
@@ -25665,6 +25741,7 @@ var RemediationManager = class {
|
|
|
25665
25741
|
}
|
|
25666
25742
|
adapter;
|
|
25667
25743
|
bus;
|
|
25744
|
+
verifyCrawler;
|
|
25668
25745
|
config;
|
|
25669
25746
|
blocklist = [];
|
|
25670
25747
|
strikes = {};
|
|
@@ -25706,6 +25783,13 @@ var RemediationManager = class {
|
|
|
25706
25783
|
if (!ip || (0, import_node_net5.isIP)(ip) === 0) return;
|
|
25707
25784
|
if (this.isAllowlisted(ip)) return;
|
|
25708
25785
|
if (this.blocklist.some((b) => b.ip === ip)) return;
|
|
25786
|
+
if (this.config.spare_verified_crawlers) {
|
|
25787
|
+
const crawler = await this.verifyCrawler(ip);
|
|
25788
|
+
if (crawler) {
|
|
25789
|
+
this.logLine(`[remediation] not banning ${ip}: verified crawler ${crawler} (${event.message})`);
|
|
25790
|
+
return;
|
|
25791
|
+
}
|
|
25792
|
+
}
|
|
25709
25793
|
const ruleId = event.details?.rule_id;
|
|
25710
25794
|
await this.ban(ip, event.message, { ruleId, source: "auto" });
|
|
25711
25795
|
}
|
|
@@ -25981,6 +26065,9 @@ function remediationSettings(section) {
|
|
|
25981
26065
|
if (typeof section.protect_current_ssh_client === "boolean") {
|
|
25982
26066
|
settings.protect_current_ssh_client = section.protect_current_ssh_client;
|
|
25983
26067
|
}
|
|
26068
|
+
if (typeof section.spare_verified_crawlers === "boolean") {
|
|
26069
|
+
settings.spare_verified_crawlers = section.spare_verified_crawlers;
|
|
26070
|
+
}
|
|
25984
26071
|
return settings;
|
|
25985
26072
|
}
|
|
25986
26073
|
|
|
@@ -27919,8 +28006,8 @@ var program2 = new Command();
|
|
|
27919
28006
|
program2.name("threatcrush").description(
|
|
27920
28007
|
`${source_default.green("\u26A1 ThreatCrush")} \u2014 All-in-one security agent
|
|
27921
28008
|
|
|
27922
|
-
|
|
27923
|
-
scan your code,
|
|
28009
|
+
Read your logs and watch inbound connections for live attacks,
|
|
28010
|
+
scan your code, spot-check your URLs, and alert you in real-time.
|
|
27924
28011
|
|
|
27925
28012
|
${source_default.dim("Website:")} ${source_default.green("https://threatcrush.com")}
|
|
27926
28013
|
${source_default.dim("GitHub:")} ${source_default.green("https://github.com/profullstack/threatcrush")}
|
|
@@ -27931,26 +28018,25 @@ ${source_default.dim("Examples:")}
|
|
|
27931
28018
|
${source_default.green("$")} threatcrush monitor ${source_default.dim("# Real-time monitoring")}
|
|
27932
28019
|
${source_default.green("$")} threatcrush tui ${source_default.dim("# Interactive dashboard")}
|
|
27933
28020
|
${source_default.green("$")} threatcrush scan ./src ${source_default.dim("# Scan code for vulns")}
|
|
27934
|
-
${source_default.green("$")} threatcrush pentest URL ${source_default.dim("#
|
|
28021
|
+
${source_default.green("$")} threatcrush pentest URL ${source_default.dim("# Quick web checks on a URL")}
|
|
27935
28022
|
${source_default.green("$")} threatcrush modules install ${source_default.dim("# Install a module")}
|
|
27936
28023
|
${source_default.green("$")} threatcrush update ${source_default.dim("# Update to latest")}
|
|
27937
28024
|
${source_default.green("$")} threatcrush remove ${source_default.dim("# Uninstall completely")}`
|
|
27938
28025
|
).version(PKG_VERSION, "-v, --version", "Show version number").helpOption("-h, --help", "Show this help").addHelpText("after", `
|
|
27939
28026
|
${source_default.dim("\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500")}
|
|
27940
28027
|
${source_default.dim("Modules:")}
|
|
27941
|
-
ThreatCrush uses pluggable security modules.
|
|
27942
|
-
${source_default.green("
|
|
27943
|
-
${source_default.green("
|
|
27944
|
-
${source_default.green("
|
|
27945
|
-
${source_default.green("
|
|
27946
|
-
${source_default.green("pentest-engine")} SQLi, XSS, SSRF, API fuzzing
|
|
28028
|
+
ThreatCrush uses pluggable security modules. Built in:
|
|
28029
|
+
${source_default.green("log-watcher")} nginx access log + syslog, attack signatures
|
|
28030
|
+
${source_default.green("ssh-guard")} Failed logins, brute force, root logins, user enumeration
|
|
28031
|
+
${source_default.green("user-journal")} journald
|
|
28032
|
+
${source_default.green("network-monitor")} Inbound connections (conntrack/ss): port scans, SYN floods
|
|
27947
28033
|
${source_default.green("dns-monitor")} DNS tunneling, DGA detection
|
|
27948
|
-
${source_default.green("
|
|
27949
|
-
|
|
28034
|
+
Plus: ${source_default.green("scan")} (code, secrets, dependency CVEs), ${source_default.green("pentest")} (web checks),
|
|
28035
|
+
auto-defend (fail2ban/nftables/iptables) and alerts (Slack, Discord, email, webhook, PagerDuty).
|
|
27950
28036
|
|
|
27951
28037
|
Browse community modules: ${source_default.green("threatcrush store")}
|
|
27952
28038
|
`);
|
|
27953
|
-
program2.command("monitor").description("
|
|
28039
|
+
program2.command("monitor").description("Watch nginx, auth and syslog for attacks in the foreground").option("-m, --module <modules>", "Comma-separated module filter (e.g. ssh-guard,log-watcher)").option("--tui", "Launch the interactive TUI dashboard").option("--demo", "Run the dashboard on canned events (screenshots, no daemon)").action(async (opts) => {
|
|
27954
28040
|
await monitorCommand({
|
|
27955
28041
|
module: opts.module,
|
|
27956
28042
|
tui: opts.tui,
|