@profullstack/threatcrush 0.1.8 → 0.1.10
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/index.js +158 -9
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/index.ts +182 -12
package/package.json
CHANGED
package/src/index.ts
CHANGED
|
@@ -3,6 +3,15 @@
|
|
|
3
3
|
import { Command } from "commander";
|
|
4
4
|
import chalk from "chalk";
|
|
5
5
|
import readline from "readline";
|
|
6
|
+
import { execSync } from "node:child_process";
|
|
7
|
+
import { readFileSync } from "node:fs";
|
|
8
|
+
import { join } from "node:path";
|
|
9
|
+
|
|
10
|
+
let PKG_VERSION = "0.1.8";
|
|
11
|
+
try {
|
|
12
|
+
const pkg = JSON.parse(readFileSync(join(__dirname, "..", "package.json"), "utf-8"));
|
|
13
|
+
PKG_VERSION = pkg.version;
|
|
14
|
+
} catch {}
|
|
6
15
|
|
|
7
16
|
const LOGO = `
|
|
8
17
|
${chalk.green(" ████████╗██╗ ██╗██████╗ ███████╗ █████╗ ████████╗")}
|
|
@@ -15,6 +24,9 @@ ${chalk.dim(" C R U S H")}
|
|
|
15
24
|
`;
|
|
16
25
|
|
|
17
26
|
const API_URL = process.env.THREATCRUSH_API_URL || "https://threatcrush.com";
|
|
27
|
+
const PKG_NAME = "@profullstack/threatcrush";
|
|
28
|
+
|
|
29
|
+
// ─── Helpers ───
|
|
18
30
|
|
|
19
31
|
async function promptEmail(): Promise<string | null> {
|
|
20
32
|
const rl = readline.createInterface({ input: process.stdin, output: process.stdout });
|
|
@@ -54,7 +66,7 @@ async function emailGate(): Promise<boolean> {
|
|
|
54
66
|
console.log(chalk.green(`\n ✓ You're on the list!`));
|
|
55
67
|
console.log(chalk.dim(` Referral code: ${chalk.white(result.referral_code)}`));
|
|
56
68
|
console.log(chalk.dim(` Share: ${API_URL}?ref=${result.referral_code}`));
|
|
57
|
-
console.log(chalk.green(`\n 🎁 Refer a friend →
|
|
69
|
+
console.log(chalk.green(`\n 🎁 Refer a friend → they save $100, you earn $100 in crypto via CoinPayPortal\n`));
|
|
58
70
|
} else {
|
|
59
71
|
console.log(chalk.green(`\n ✓ Thanks! We'll notify you when ThreatCrush launches.\n`));
|
|
60
72
|
}
|
|
@@ -62,22 +74,85 @@ async function emailGate(): Promise<boolean> {
|
|
|
62
74
|
return true;
|
|
63
75
|
}
|
|
64
76
|
|
|
77
|
+
function detectPackageManager(): string {
|
|
78
|
+
// Check what installed us
|
|
79
|
+
try {
|
|
80
|
+
const npmGlobal = execSync("npm ls -g --depth=0 --json 2>/dev/null", { encoding: "utf-8" });
|
|
81
|
+
if (npmGlobal.includes(PKG_NAME)) return "npm";
|
|
82
|
+
} catch {}
|
|
83
|
+
try {
|
|
84
|
+
execSync("pnpm --version", { stdio: "pipe" });
|
|
85
|
+
return "pnpm";
|
|
86
|
+
} catch {}
|
|
87
|
+
try {
|
|
88
|
+
execSync("yarn --version", { stdio: "pipe" });
|
|
89
|
+
return "yarn";
|
|
90
|
+
} catch {}
|
|
91
|
+
try {
|
|
92
|
+
execSync("bun --version", { stdio: "pipe" });
|
|
93
|
+
return "bun";
|
|
94
|
+
} catch {}
|
|
95
|
+
return "npm";
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
// ─── Program ───
|
|
99
|
+
|
|
65
100
|
const program = new Command();
|
|
66
101
|
|
|
67
102
|
program
|
|
68
103
|
.name("threatcrush")
|
|
69
|
-
.description(
|
|
70
|
-
|
|
104
|
+
.description(
|
|
105
|
+
`${chalk.green("⚡ ThreatCrush")} — All-in-one security agent
|
|
106
|
+
|
|
107
|
+
Monitor every connection on every port. Detect live attacks,
|
|
108
|
+
scan your code, pentest your APIs, and alert you in real-time.
|
|
71
109
|
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
110
|
+
${chalk.dim("Website:")} ${chalk.green("https://threatcrush.com")}
|
|
111
|
+
${chalk.dim("GitHub:")} ${chalk.green("https://github.com/profullstack/threatcrush")}
|
|
112
|
+
${chalk.dim("npm:")} ${chalk.green("https://www.npmjs.com/package/@profullstack/threatcrush")}
|
|
113
|
+
${chalk.dim("License:")} ${chalk.green("$499 lifetime")} (or $399 with referral)
|
|
114
|
+
|
|
115
|
+
${chalk.dim("Examples:")}
|
|
116
|
+
${chalk.green("$")} threatcrush monitor ${chalk.dim("# Real-time monitoring")}
|
|
117
|
+
${chalk.green("$")} threatcrush tui ${chalk.dim("# Interactive dashboard")}
|
|
118
|
+
${chalk.green("$")} threatcrush scan ./src ${chalk.dim("# Scan code for vulns")}
|
|
119
|
+
${chalk.green("$")} threatcrush pentest URL ${chalk.dim("# Pen test a URL")}
|
|
120
|
+
${chalk.green("$")} threatcrush modules install ${chalk.dim("# Install a module")}
|
|
121
|
+
${chalk.green("$")} threatcrush update ${chalk.dim("# Update to latest")}
|
|
122
|
+
${chalk.green("$")} threatcrush remove ${chalk.dim("# Uninstall completely")}`)
|
|
123
|
+
.version(PKG_VERSION, "-v, --version", "Show version number")
|
|
124
|
+
.helpOption("-h, --help", "Show this help")
|
|
125
|
+
.addHelpText("after", `
|
|
126
|
+
${chalk.dim("─────────────────────────────────────────────────────")}
|
|
127
|
+
${chalk.dim("Modules:")}
|
|
128
|
+
ThreatCrush uses pluggable security modules. Core modules included:
|
|
129
|
+
${chalk.green("network-monitor")} All TCP/UDP traffic, port scans, SYN floods
|
|
130
|
+
${chalk.green("log-watcher")} nginx, Apache, syslog, journald
|
|
131
|
+
${chalk.green("ssh-guard")} Failed logins, brute force, tunneling
|
|
132
|
+
${chalk.green("code-scanner")} Vulnerabilities, secrets, dependency CVEs
|
|
133
|
+
${chalk.green("pentest-engine")} SQLi, XSS, SSRF, API fuzzing
|
|
134
|
+
${chalk.green("dns-monitor")} DNS tunneling, DGA detection
|
|
135
|
+
${chalk.green("firewall-rules")} Auto-blocks via iptables/nftables
|
|
136
|
+
${chalk.green("alert-system")} Slack, Discord, email, webhook, PagerDuty
|
|
137
|
+
|
|
138
|
+
Browse community modules: ${chalk.green("threatcrush store")}
|
|
139
|
+
`);
|
|
140
|
+
|
|
141
|
+
// ─── Gated commands (coming soon) ───
|
|
142
|
+
|
|
143
|
+
const gatedCommand = (name: string, desc: string, aliases?: string[]) => {
|
|
144
|
+
const cmd = program.command(name).description(desc).action(async () => {
|
|
75
145
|
await emailGate();
|
|
76
146
|
});
|
|
147
|
+
if (aliases) {
|
|
148
|
+
for (const alias of aliases) {
|
|
149
|
+
cmd.alias(alias);
|
|
150
|
+
}
|
|
151
|
+
}
|
|
77
152
|
};
|
|
78
153
|
|
|
79
154
|
gatedCommand("monitor", "Real-time security monitoring (all ports, all protocols)");
|
|
80
|
-
gatedCommand("tui", "Interactive security dashboard (htop for security)");
|
|
155
|
+
gatedCommand("tui", "Interactive security dashboard (htop for security)", ["dashboard"]);
|
|
81
156
|
gatedCommand("init", "Auto-detect services and configure ThreatCrush");
|
|
82
157
|
gatedCommand("scan", "Scan codebase for vulnerabilities and secrets");
|
|
83
158
|
gatedCommand("pentest", "Penetration test URLs and APIs");
|
|
@@ -85,13 +160,107 @@ gatedCommand("status", "Show daemon status and loaded modules");
|
|
|
85
160
|
gatedCommand("start", "Start the ThreatCrush daemon");
|
|
86
161
|
gatedCommand("stop", "Stop the ThreatCrush daemon");
|
|
87
162
|
gatedCommand("logs", "Tail daemon logs");
|
|
88
|
-
gatedCommand("update", "Update CLI and all installed modules");
|
|
89
163
|
gatedCommand("activate", "Activate your license key");
|
|
90
164
|
|
|
165
|
+
// ─── Real commands ───
|
|
166
|
+
|
|
167
|
+
program
|
|
168
|
+
.command("update")
|
|
169
|
+
.description("Update ThreatCrush CLI and all installed modules")
|
|
170
|
+
.option("--cli", "Update CLI only")
|
|
171
|
+
.option("--modules", "Update modules only")
|
|
172
|
+
.action(async (opts) => {
|
|
173
|
+
console.log(LOGO);
|
|
174
|
+
|
|
175
|
+
if (opts.modules) {
|
|
176
|
+
console.log(chalk.yellow(" Module updates coming soon.\n"));
|
|
177
|
+
return;
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
const pm = detectPackageManager();
|
|
181
|
+
console.log(chalk.dim(` Detected package manager: ${pm}\n`));
|
|
182
|
+
|
|
183
|
+
const commands: Record<string, string> = {
|
|
184
|
+
npm: `npm update -g ${PKG_NAME}`,
|
|
185
|
+
pnpm: `pnpm update -g ${PKG_NAME}`,
|
|
186
|
+
yarn: `yarn global upgrade ${PKG_NAME}`,
|
|
187
|
+
bun: `bun update -g ${PKG_NAME}`,
|
|
188
|
+
};
|
|
189
|
+
|
|
190
|
+
const cmd = commands[pm] || commands.npm;
|
|
191
|
+
console.log(chalk.green(` → ${cmd}\n`));
|
|
192
|
+
|
|
193
|
+
try {
|
|
194
|
+
execSync(cmd, { stdio: "inherit" });
|
|
195
|
+
console.log(chalk.green("\n ✓ ThreatCrush updated successfully!\n"));
|
|
196
|
+
|
|
197
|
+
// Show new version
|
|
198
|
+
try {
|
|
199
|
+
const newVersion = execSync(`${pm === "npm" ? "npm" : pm} list -g ${PKG_NAME} --depth=0`, {
|
|
200
|
+
encoding: "utf-8",
|
|
201
|
+
stdio: ["pipe", "pipe", "pipe"],
|
|
202
|
+
});
|
|
203
|
+
const match = newVersion.match(/@[\d.]+/);
|
|
204
|
+
if (match) {
|
|
205
|
+
console.log(chalk.dim(` Version: ${match[0]}\n`));
|
|
206
|
+
}
|
|
207
|
+
} catch {}
|
|
208
|
+
} catch (err) {
|
|
209
|
+
console.log(chalk.red("\n ✗ Update failed. Try manually:\n"));
|
|
210
|
+
console.log(chalk.dim(` ${cmd}\n`));
|
|
211
|
+
}
|
|
212
|
+
});
|
|
213
|
+
|
|
214
|
+
program
|
|
215
|
+
.command("remove")
|
|
216
|
+
.description("Uninstall ThreatCrush CLI completely")
|
|
217
|
+
.alias("uninstall")
|
|
218
|
+
.action(async () => {
|
|
219
|
+
console.log(LOGO);
|
|
220
|
+
|
|
221
|
+
const rl = readline.createInterface({ input: process.stdin, output: process.stdout });
|
|
222
|
+
const confirm = await new Promise<string>((resolve) => {
|
|
223
|
+
rl.question(chalk.yellow(" Are you sure you want to uninstall ThreatCrush? (y/N): "), (answer) => {
|
|
224
|
+
rl.close();
|
|
225
|
+
resolve(answer.trim().toLowerCase());
|
|
226
|
+
});
|
|
227
|
+
});
|
|
228
|
+
|
|
229
|
+
if (confirm !== "y" && confirm !== "yes") {
|
|
230
|
+
console.log(chalk.dim("\n Cancelled.\n"));
|
|
231
|
+
return;
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
const pm = detectPackageManager();
|
|
235
|
+
console.log(chalk.dim(`\n Detected package manager: ${pm}\n`));
|
|
236
|
+
|
|
237
|
+
const commands: Record<string, string> = {
|
|
238
|
+
npm: `npm uninstall -g ${PKG_NAME}`,
|
|
239
|
+
pnpm: `pnpm remove -g ${PKG_NAME}`,
|
|
240
|
+
yarn: `yarn global remove ${PKG_NAME}`,
|
|
241
|
+
bun: `bun remove -g ${PKG_NAME}`,
|
|
242
|
+
};
|
|
243
|
+
|
|
244
|
+
const cmd = commands[pm] || commands.npm;
|
|
245
|
+
console.log(chalk.green(` → ${cmd}\n`));
|
|
246
|
+
|
|
247
|
+
try {
|
|
248
|
+
execSync(cmd, { stdio: "inherit" });
|
|
249
|
+
console.log(chalk.green("\n ✓ ThreatCrush has been uninstalled.\n"));
|
|
250
|
+
console.log(chalk.dim(" We're sorry to see you go! 👋\n"));
|
|
251
|
+
console.log(chalk.dim(" Config files may remain at /etc/threatcrush/"));
|
|
252
|
+
console.log(chalk.dim(" Logs may remain at /var/log/threatcrush/"));
|
|
253
|
+
console.log(chalk.dim(" State may remain at /var/lib/threatcrush/\n"));
|
|
254
|
+
} catch (err) {
|
|
255
|
+
console.log(chalk.red("\n ✗ Uninstall failed. Try manually:\n"));
|
|
256
|
+
console.log(chalk.dim(` ${cmd}\n`));
|
|
257
|
+
}
|
|
258
|
+
});
|
|
259
|
+
|
|
91
260
|
program
|
|
92
261
|
.command("modules")
|
|
93
262
|
.description("Manage security modules")
|
|
94
|
-
.argument("[action]", "list | install | remove | available")
|
|
263
|
+
.argument("[action]", "list | install | remove | available | update")
|
|
95
264
|
.argument("[name]", "module name")
|
|
96
265
|
.action(async () => {
|
|
97
266
|
await emailGate();
|
|
@@ -106,9 +275,10 @@ program
|
|
|
106
275
|
await emailGate();
|
|
107
276
|
});
|
|
108
277
|
|
|
109
|
-
// Default action (no command)
|
|
110
|
-
program.action(
|
|
111
|
-
|
|
278
|
+
// Default action (no command — show help)
|
|
279
|
+
program.action(() => {
|
|
280
|
+
console.log(LOGO);
|
|
281
|
+
program.help();
|
|
112
282
|
});
|
|
113
283
|
|
|
114
284
|
program.parse();
|