@profullstack/threatcrush 0.13.15 → 0.13.17
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 +1 -1
- package/dist/daemon.js +33 -0
- package/dist/daemon.js.map +1 -1
- package/dist/index.js +92 -27
- package/dist/index.js.map +1 -1
- package/dist/systemd/threatcrushd.service +6 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -13056,20 +13056,27 @@ function initialState(now = Date.now()) {
|
|
|
13056
13056
|
busy: false,
|
|
13057
13057
|
moduleIndex: 0,
|
|
13058
13058
|
moduleFilter: null,
|
|
13059
|
+
sourceFilter: null,
|
|
13059
13060
|
showNoise: false
|
|
13060
13061
|
};
|
|
13061
13062
|
}
|
|
13062
13063
|
function isNoise(event) {
|
|
13063
|
-
|
|
13064
|
+
if (event.severity !== "low" && event.severity !== "info") return false;
|
|
13065
|
+
if (/^Client error 4\d\d:/.test(event.message)) return true;
|
|
13066
|
+
return /\b(veth|docker|br-|cni|cali|flannel|vxlan)[\w.-]*: entered (promiscuous|allmulticast) mode|\(unregistering\): left (promiscuous|allmulticast) mode/.test(event.message);
|
|
13067
|
+
}
|
|
13068
|
+
function matchesFilters(state, e) {
|
|
13069
|
+
return (!state.moduleFilter || e.module === state.moduleFilter) && (!state.sourceFilter || e.source_ip === state.sourceFilter);
|
|
13064
13070
|
}
|
|
13065
13071
|
function visibleEvents(state) {
|
|
13066
|
-
return state.events.filter(
|
|
13067
|
-
(e) => (!state.moduleFilter || e.module === state.moduleFilter) && (state.showNoise || !isNoise(e))
|
|
13068
|
-
);
|
|
13072
|
+
return state.events.filter((e) => matchesFilters(state, e) && (state.showNoise || !isNoise(e)));
|
|
13069
13073
|
}
|
|
13070
13074
|
function hiddenNoise(state) {
|
|
13071
13075
|
if (state.showNoise) return 0;
|
|
13072
|
-
return state.events.filter((e) => (
|
|
13076
|
+
return state.events.filter((e) => matchesFilters(state, e) && isNoise(e)).length;
|
|
13077
|
+
}
|
|
13078
|
+
function hasFilter(state) {
|
|
13079
|
+
return Boolean(state.moduleFilter || state.sourceFilter);
|
|
13073
13080
|
}
|
|
13074
13081
|
function isBanned(state, ip) {
|
|
13075
13082
|
return state.bans.some((b) => b.ip === ip);
|
|
@@ -13206,6 +13213,14 @@ function reducer(state, action) {
|
|
|
13206
13213
|
}
|
|
13207
13214
|
case "clear_module_filter":
|
|
13208
13215
|
return { ...state, moduleFilter: null, scrollBack: 0 };
|
|
13216
|
+
case "toggle_source_filter": {
|
|
13217
|
+
const ip = selectedIp(state);
|
|
13218
|
+
if (!ip) return state;
|
|
13219
|
+
const sourceFilter = state.sourceFilter === ip ? null : ip;
|
|
13220
|
+
return { ...state, sourceFilter, scrollBack: 0 };
|
|
13221
|
+
}
|
|
13222
|
+
case "clear_source_filter":
|
|
13223
|
+
return { ...state, sourceFilter: null, scrollBack: 0 };
|
|
13209
13224
|
case "toggle_noise":
|
|
13210
13225
|
return { ...state, showNoise: !state.showNoise, scrollBack: 0 };
|
|
13211
13226
|
case "counters":
|
|
@@ -13241,6 +13256,7 @@ function reducer(state, action) {
|
|
|
13241
13256
|
firewall: state.firewall,
|
|
13242
13257
|
focus: state.focus,
|
|
13243
13258
|
moduleFilter: state.moduleFilter,
|
|
13259
|
+
sourceFilter: state.sourceFilter,
|
|
13244
13260
|
moduleIndex: state.moduleIndex,
|
|
13245
13261
|
showNoise: state.showNoise
|
|
13246
13262
|
};
|
|
@@ -13536,13 +13552,17 @@ function noiseNote(state) {
|
|
|
13536
13552
|
const hidden = hiddenNoise(state);
|
|
13537
13553
|
return hidden > 0 ? `${hidden} routine 4xx hidden \xB7 n shows` : void 0;
|
|
13538
13554
|
}
|
|
13555
|
+
function filterLabel(state) {
|
|
13556
|
+
return [state.moduleFilter, state.sourceFilter ? `src ${state.sourceFilter}` : null].filter(Boolean).join(" \xB7 ");
|
|
13557
|
+
}
|
|
13539
13558
|
function feedPanel(parent, state, theme, options) {
|
|
13540
13559
|
const following = state.scrollBack === 0;
|
|
13541
13560
|
const shown = visibleEvents(state);
|
|
13542
|
-
const filtered = state
|
|
13561
|
+
const filtered = hasFilter(state);
|
|
13562
|
+
const label = filterLabel(state);
|
|
13543
13563
|
parent.panel(
|
|
13544
13564
|
{
|
|
13545
|
-
title: filtered ? ` LIVE EVENTS \xB7 ${
|
|
13565
|
+
title: filtered ? ` LIVE EVENTS \xB7 ${label} ` : " LIVE EVENTS ",
|
|
13546
13566
|
size: "2.4fr",
|
|
13547
13567
|
border: "rounded",
|
|
13548
13568
|
borderColor: state.connection === "live" ? theme.borderFocused : theme.border,
|
|
@@ -13554,7 +13574,7 @@ function feedPanel(parent, state, theme, options) {
|
|
|
13554
13574
|
(panel) => {
|
|
13555
13575
|
if (filtered && shown.length === 0 && state.events.length > 0) {
|
|
13556
13576
|
panel.spacer(1);
|
|
13557
|
-
panel.text(`No events from ${
|
|
13577
|
+
panel.text(`No events from ${label} yet.`, { fg: theme.muted, align: "center" });
|
|
13558
13578
|
panel.spacer(1);
|
|
13559
13579
|
panel.label("esc shows everything again", { fg: theme.muted, align: "center" });
|
|
13560
13580
|
return;
|
|
@@ -13607,7 +13627,7 @@ function threatsPanel(parent, state, theme, options) {
|
|
|
13607
13627
|
border: "rounded",
|
|
13608
13628
|
borderColor: focused ? theme.borderFocused : theme.border,
|
|
13609
13629
|
titleColor: theme.primary,
|
|
13610
|
-
subtitle: focused ? "b ban \xB7 u unban" : void 0,
|
|
13630
|
+
subtitle: focused ? "click filters feed \xB7 b ban \xB7 u unban" : void 0,
|
|
13611
13631
|
subtitleColor: theme.muted,
|
|
13612
13632
|
padding: [0, 1]
|
|
13613
13633
|
},
|
|
@@ -13632,12 +13652,13 @@ function threatsPanel(parent, state, theme, options) {
|
|
|
13632
13652
|
onSelectRow: options.onThreatSelect,
|
|
13633
13653
|
columns: [
|
|
13634
13654
|
{
|
|
13635
|
-
//
|
|
13636
|
-
//
|
|
13655
|
+
// ▶ marks the source the feed is filtered to; otherwise the glyph
|
|
13656
|
+
// says whether this source is banned, protected, or neither — which
|
|
13657
|
+
// decides what the b key will do to it.
|
|
13637
13658
|
key: "ip",
|
|
13638
13659
|
width: 2,
|
|
13639
|
-
render: (s) => isBanned(state, s.ip) ? "\u2716" : isProtectedRow(state, s.ip) ? "\u26CA" : " ",
|
|
13640
|
-
color: (s) => isBanned(state, s.ip) ? severityColors.critical : isProtectedRow(state, s.ip) ? theme.success : theme.muted
|
|
13660
|
+
render: (s) => state.sourceFilter === s.ip ? "\u25B6" : isBanned(state, s.ip) ? "\u2716" : isProtectedRow(state, s.ip) ? "\u26CA" : " ",
|
|
13661
|
+
color: (s) => state.sourceFilter === s.ip ? theme.primary : isBanned(state, s.ip) ? severityColors.critical : isProtectedRow(state, s.ip) ? theme.success : theme.muted
|
|
13641
13662
|
},
|
|
13642
13663
|
{ key: "ip", width: "fill", color: () => theme.foreground },
|
|
13643
13664
|
{
|
|
@@ -13702,7 +13723,7 @@ function bansPanel(parent, state, theme, options) {
|
|
|
13702
13723
|
}
|
|
13703
13724
|
if (state.bans.length === 0) {
|
|
13704
13725
|
panel.label("nothing banned", { fg: theme.muted });
|
|
13705
|
-
panel.label(fw.dry_run ? "dry-run: bans are simulated" : "bans:
|
|
13726
|
+
panel.label(fw.dry_run ? "dry-run: bans are simulated" : "bans: 5m \u2192 10m \u2192 20m \u2192 40m", {
|
|
13706
13727
|
fg: fw.dry_run ? severityColors.medium : theme.muted
|
|
13707
13728
|
});
|
|
13708
13729
|
return;
|
|
@@ -13767,7 +13788,7 @@ function footer(ui, state, theme) {
|
|
|
13767
13788
|
{ key: "q", label: "quit" },
|
|
13768
13789
|
{ key: "tab", label: state.focus },
|
|
13769
13790
|
{ key: "\u2191\u2193", label: onFeed ? "scroll" : "select" },
|
|
13770
|
-
...state.focus === "modules" ? [{ key: "\u23CE", label: state.moduleFilter ? "unfilter" : "filter" }] : [{ key: "b", label: "ban" }, { key: "u", label: "unban" }],
|
|
13791
|
+
...state.focus === "modules" ? [{ key: "\u23CE", label: state.moduleFilter ? "unfilter" : "filter" }] : state.focus === "threats" || state.focus === "bans" ? [{ key: "\u23CE", label: state.sourceFilter ? "unfilter" : "filter" }, { key: "b", label: "ban" }, { key: "u", label: "unban" }] : [{ key: "b", label: "ban" }, { key: "u", label: "unban" }],
|
|
13771
13792
|
{ key: "p", label: state.paused ? "resume" : "pause" },
|
|
13772
13793
|
{ key: "r", label: "reset" },
|
|
13773
13794
|
{ key: "n", label: state.showNoise ? "hide 4xx" : "show 4xx" }
|
|
@@ -13781,6 +13802,7 @@ function footer(ui, state, theme) {
|
|
|
13781
13802
|
color: severityColors.medium
|
|
13782
13803
|
},
|
|
13783
13804
|
{ label: state.moduleFilter ? `filter: ${state.moduleFilter}` : "", color: theme.primary },
|
|
13805
|
+
{ label: state.sourceFilter ? `src: ${state.sourceFilter}` : "", color: theme.primary },
|
|
13784
13806
|
{
|
|
13785
13807
|
label: state.firewall ? `${state.bans.length} banned${state.firewall.dry_run ? " (dry-run)" : ""}` : "",
|
|
13786
13808
|
color: state.firewall?.dry_run ? severityColors.medium : theme.muted
|
|
@@ -14015,7 +14037,8 @@ async function startDashboard(options = {}) {
|
|
|
14015
14037
|
app.on("key", (event) => {
|
|
14016
14038
|
switch (event.key) {
|
|
14017
14039
|
case "escape":
|
|
14018
|
-
if (state.
|
|
14040
|
+
if (state.sourceFilter) dispatch({ type: "clear_source_filter" });
|
|
14041
|
+
else if (state.moduleFilter) dispatch({ type: "clear_module_filter" });
|
|
14019
14042
|
else quit();
|
|
14020
14043
|
break;
|
|
14021
14044
|
case "q":
|
|
@@ -14024,7 +14047,8 @@ async function startDashboard(options = {}) {
|
|
|
14024
14047
|
break;
|
|
14025
14048
|
case "enter":
|
|
14026
14049
|
case "return":
|
|
14027
|
-
dispatch({ type: "toggle_module_filter" });
|
|
14050
|
+
if (state.focus === "modules") dispatch({ type: "toggle_module_filter" });
|
|
14051
|
+
else if (state.focus === "threats" || state.focus === "bans") dispatch({ type: "toggle_source_filter" });
|
|
14028
14052
|
break;
|
|
14029
14053
|
case "p":
|
|
14030
14054
|
case "space":
|
|
@@ -14073,15 +14097,18 @@ async function startDashboard(options = {}) {
|
|
|
14073
14097
|
renderDashboard(ui, state, theme, {
|
|
14074
14098
|
demo: options.demo,
|
|
14075
14099
|
onFeedScroll: (delta) => dispatch({ type: "scroll", delta: -delta }),
|
|
14076
|
-
// One click
|
|
14077
|
-
//
|
|
14100
|
+
// One click focuses the panel, picks the row, and filters the feed to that
|
|
14101
|
+
// source — "what has this one IP done" in a single click. Clicking the
|
|
14102
|
+
// same row again clears the filter.
|
|
14078
14103
|
onThreatSelect: (row) => {
|
|
14079
14104
|
dispatch({ type: "focus", focus: "threats" });
|
|
14080
14105
|
dispatch({ type: "select_at", index: row });
|
|
14106
|
+
dispatch({ type: "toggle_source_filter" });
|
|
14081
14107
|
},
|
|
14082
14108
|
onBanSelect: (row) => {
|
|
14083
14109
|
dispatch({ type: "focus", focus: "bans" });
|
|
14084
14110
|
dispatch({ type: "select_at", index: row });
|
|
14111
|
+
dispatch({ type: "toggle_source_filter" });
|
|
14085
14112
|
},
|
|
14086
14113
|
// One click on a module both selects it and pins the feed to it; a
|
|
14087
14114
|
// second click on the same module releases the feed.
|
|
@@ -16277,7 +16304,7 @@ var import_readline = __toESM(require("readline"));
|
|
|
16277
16304
|
var import_node_child_process15 = require("child_process");
|
|
16278
16305
|
var import_node_fs36 = require("fs");
|
|
16279
16306
|
var import_node_path24 = require("path");
|
|
16280
|
-
var
|
|
16307
|
+
var import_node_os11 = require("os");
|
|
16281
16308
|
|
|
16282
16309
|
// src/commands/monitor.ts
|
|
16283
16310
|
var import_node_fs7 = require("fs");
|
|
@@ -33830,6 +33857,39 @@ var DEFAULT_RULES = [
|
|
|
33830
33857
|
description: "Block source IP performing exploit probes"
|
|
33831
33858
|
},
|
|
33832
33859
|
enabled: true
|
|
33860
|
+
},
|
|
33861
|
+
{
|
|
33862
|
+
// A real network card entering promiscuous mode can mean someone is
|
|
33863
|
+
// sniffing traffic on the host. The kernel also logs this constantly for
|
|
33864
|
+
// container veth/bridge interfaces, which is normal (a bridge port must be
|
|
33865
|
+
// promiscuous to forward frames), so the negative lookahead excludes every
|
|
33866
|
+
// virtual interface kind and only a physical/primary NIC trips this.
|
|
33867
|
+
id: "nic-promiscuous-mode",
|
|
33868
|
+
title: "Network Interface Entered Promiscuous Mode",
|
|
33869
|
+
description: "A non-virtual network interface entered promiscuous mode, which can indicate packet sniffing",
|
|
33870
|
+
version: "1.0.0",
|
|
33871
|
+
category: "system",
|
|
33872
|
+
severity: "medium",
|
|
33873
|
+
source_types: ["user-journal", "system"],
|
|
33874
|
+
match: {
|
|
33875
|
+
field: "message",
|
|
33876
|
+
operator: "regex",
|
|
33877
|
+
// "[kernel] enp11s0: entered promiscuous mode" trips; veth*, docker*,
|
|
33878
|
+
// br-*, bridge, lo, tap*, vxlan*, cni*, cali*, flannel*, virbr*, kube*
|
|
33879
|
+
// and tailscale* do not.
|
|
33880
|
+
value: "\\b(?!veth|docker|br-|bridge|lo:|lo\\b|tap|vxlan|cni|cali|flannel|virbr|kube|tailscale)[A-Za-z][\\w.-]*: entered promiscuous mode"
|
|
33881
|
+
},
|
|
33882
|
+
threshold: 1,
|
|
33883
|
+
window_seconds: 60,
|
|
33884
|
+
// A legitimate tcpdump flaps it; do not re-alert for an hour.
|
|
33885
|
+
cooldown_seconds: 3600,
|
|
33886
|
+
tags: ["system", "network", "sniffing", "host-integrity"],
|
|
33887
|
+
remediation: {
|
|
33888
|
+
// Host integrity, no attacker address to ban — surface it, do not block.
|
|
33889
|
+
action: "alert",
|
|
33890
|
+
description: "Confirm whether a capture tool or new bridge is expected on this host"
|
|
33891
|
+
},
|
|
33892
|
+
enabled: true
|
|
33833
33893
|
}
|
|
33834
33894
|
];
|
|
33835
33895
|
|
|
@@ -34988,6 +35048,7 @@ async function releaseStaleSocket() {
|
|
|
34988
35048
|
var import_node_child_process12 = require("child_process");
|
|
34989
35049
|
var import_node_fs32 = require("fs");
|
|
34990
35050
|
var import_node_path22 = require("path");
|
|
35051
|
+
var import_node_os10 = require("os");
|
|
34991
35052
|
var UNIT_PATH = "/etc/systemd/system/threatcrushd.service";
|
|
34992
35053
|
var DAEMON_UNIT_NAME = "threatcrushd.service";
|
|
34993
35054
|
function resolveTemplate() {
|
|
@@ -35135,7 +35196,8 @@ async function installServiceCommand() {
|
|
|
35135
35196
|
}
|
|
35136
35197
|
}
|
|
35137
35198
|
const exec = execStartCommand(binPath, nodePath, isNodeScript);
|
|
35138
|
-
const
|
|
35199
|
+
const configDir = (0, import_node_path22.join)((0, import_node_os10.homedir)(), ".threatcrush");
|
|
35200
|
+
const unit = resolveTemplate().replace("{{BIN_PATH}} daemon", exec).replace("{{BIN_PATH}}", binPath).replace("{{CONFIG_DIR}}", configDir);
|
|
35139
35201
|
(0, import_node_fs32.writeFileSync)(UNIT_PATH, unit, { mode: 420 });
|
|
35140
35202
|
console.log(source_default.green(` \u2713 Installed unit file: ${UNIT_PATH}`));
|
|
35141
35203
|
console.log(source_default.dim(` ExecStart=${exec}`));
|
|
@@ -35147,7 +35209,7 @@ async function installServiceCommand() {
|
|
|
35147
35209
|
console.log(source_default.dim(` threatcrush for the new Node and re-run ${source_default.white("threatcrush install-service")}.`));
|
|
35148
35210
|
console.log(source_default.dim(" Installing with a system Node (/usr/bin/node or /usr/local/bin/node) avoids this."));
|
|
35149
35211
|
}
|
|
35150
|
-
ensureSystemDirs();
|
|
35212
|
+
ensureSystemDirs(configDir);
|
|
35151
35213
|
stopUserModeDaemon();
|
|
35152
35214
|
try {
|
|
35153
35215
|
(0, import_node_child_process12.execSync)("systemctl daemon-reload", { stdio: "inherit" });
|
|
@@ -35169,13 +35231,16 @@ async function installServiceCommand() {
|
|
|
35169
35231
|
}
|
|
35170
35232
|
console.log();
|
|
35171
35233
|
}
|
|
35172
|
-
function ensureSystemDirs() {
|
|
35234
|
+
function ensureSystemDirs(configDir) {
|
|
35173
35235
|
const dirs = [
|
|
35174
35236
|
{ path: "/etc/threatcrush", groupWritable: true },
|
|
35175
35237
|
{ path: "/etc/threatcrush/modules", groupWritable: true, sticky: true },
|
|
35176
35238
|
{ path: "/etc/threatcrush/threatcrushd.conf.d", groupWritable: true },
|
|
35177
35239
|
{ path: "/var/log/threatcrush", groupWritable: false },
|
|
35178
|
-
{ path: "/var/lib/threatcrush", groupWritable: false }
|
|
35240
|
+
{ path: "/var/lib/threatcrush", groupWritable: false },
|
|
35241
|
+
// The daemon's own session dir, root-only: it holds the cloud access and
|
|
35242
|
+
// refresh tokens, so nobody else may read or write it.
|
|
35243
|
+
{ path: configDir, groupWritable: false }
|
|
35179
35244
|
// /run/threatcrush is deliberately absent: it lives on a tmpfs, so creating
|
|
35180
35245
|
// it here only lasts until the next reboot. The unit's RuntimeDirectory=
|
|
35181
35246
|
// recreates it on every start instead.
|
|
@@ -36605,7 +36670,7 @@ ${source_default.dim(" C R U S H")}
|
|
|
36605
36670
|
var API_URL6 = process.env.THREATCRUSH_API_URL || "https://threatcrush.com";
|
|
36606
36671
|
var PKG_NAME = "@profullstack/threatcrush";
|
|
36607
36672
|
var DESKTOP_PKG_NAME = "@profullstack/threatcrush-desktop";
|
|
36608
|
-
var INSTALL_CONFIG_PATH = (0, import_node_path24.join)((0,
|
|
36673
|
+
var INSTALL_CONFIG_PATH = (0, import_node_path24.join)((0, import_node_os11.homedir)(), ".threatcrush", "install.json");
|
|
36609
36674
|
function detectPackageManager() {
|
|
36610
36675
|
try {
|
|
36611
36676
|
const npmGlobal = (0, import_node_child_process15.execSync)("npm ls -g --depth=0 --json 2>/dev/null", { encoding: "utf-8" });
|
|
@@ -37078,7 +37143,7 @@ storeCmd.command("search <query>").description("Search for modules in the store"
|
|
|
37078
37143
|
});
|
|
37079
37144
|
storeCmd.command("publish <url>").description("Publish a module from a git URL or web URL").action(async (url) => {
|
|
37080
37145
|
console.log(LOGO2);
|
|
37081
|
-
const configPath = (0, import_node_path24.join)((0,
|
|
37146
|
+
const configPath = (0, import_node_path24.join)((0, import_node_os11.homedir)(), ".threatcrush", "config.json");
|
|
37082
37147
|
let email = "";
|
|
37083
37148
|
try {
|
|
37084
37149
|
const config = JSON.parse((0, import_node_fs36.readFileSync)(configPath, "utf-8"));
|
|
@@ -37098,7 +37163,7 @@ storeCmd.command("publish <url>").description("Publish a module from a git URL o
|
|
|
37098
37163
|
return;
|
|
37099
37164
|
}
|
|
37100
37165
|
try {
|
|
37101
|
-
const dir = (0, import_node_path24.join)((0,
|
|
37166
|
+
const dir = (0, import_node_path24.join)((0, import_node_os11.homedir)(), ".threatcrush");
|
|
37102
37167
|
if (!(0, import_node_fs36.existsSync)(dir)) (0, import_node_fs36.mkdirSync)(dir, { recursive: true });
|
|
37103
37168
|
(0, import_node_fs36.writeFileSync)(configPath, JSON.stringify({ email }, null, 2));
|
|
37104
37169
|
console.log(source_default.dim(` Saved email to ${configPath}`));
|