wormclaude 1.0.85 → 1.0.86
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/dist/pentest.js +46 -1
- package/package.json +1 -1
package/dist/pentest.js
CHANGED
|
@@ -7,9 +7,46 @@
|
|
|
7
7
|
// Güvenlik: yalnız PT_ALLOWED'daki ikililer çalıştırılır (ele geçirilmiş/kötü sunucunun
|
|
8
8
|
// istemcide rastgele komut çalıştırmasını engeller). Komutlar SHELL'siz spawn edilir (enjeksiyon yok).
|
|
9
9
|
import { spawn } from 'node:child_process';
|
|
10
|
+
import { statSync } from 'node:fs';
|
|
11
|
+
import * as path from 'node:path';
|
|
10
12
|
// İstemci-tarafı allowlist (sunucudakiyle aynı; çift güvence).
|
|
11
13
|
export const PT_ALLOWED = new Set(['httpx', 'nuclei', 'dalfox', 'sqlmap', 'subfinder', 'katana', 'nmap', 'ffuf']);
|
|
12
14
|
const MAX_OUT = 200_000;
|
|
15
|
+
// İkiliyi PATH üzerinde çöz. Windows'ta Node spawn(shell:false) PATHEXT aramaz →
|
|
16
|
+
// 'dalfox' verilse 'dalfox.exe'yi bulamaz; bu yüzden elle çözüyoruz.
|
|
17
|
+
// Döner: {path, viaCmd} — viaCmd ise .cmd/.bat olduğu için cmd.exe ile sarılır.
|
|
18
|
+
export function resolveBin(bin) {
|
|
19
|
+
const isWin = process.platform === 'win32';
|
|
20
|
+
const exts = isWin ? (process.env.PATHEXT || '.EXE;.CMD;.BAT;.COM').split(';').filter(Boolean) : [''];
|
|
21
|
+
const isFile = (p) => { try {
|
|
22
|
+
return statSync(p).isFile();
|
|
23
|
+
}
|
|
24
|
+
catch {
|
|
25
|
+
return false;
|
|
26
|
+
} };
|
|
27
|
+
const classify = (p) => ({ path: p, viaCmd: /\.(cmd|bat)$/i.test(p) });
|
|
28
|
+
// Mutlak/parçalı yol verildiyse doğrudan dene.
|
|
29
|
+
if (bin.includes('/') || bin.includes('\\')) {
|
|
30
|
+
if (isFile(bin))
|
|
31
|
+
return classify(bin);
|
|
32
|
+
for (const e of exts)
|
|
33
|
+
if (e && isFile(bin + e))
|
|
34
|
+
return classify(bin + e);
|
|
35
|
+
return null;
|
|
36
|
+
}
|
|
37
|
+
const dirs = (process.env.PATH || '').split(path.delimiter).filter(Boolean);
|
|
38
|
+
for (const d of dirs) {
|
|
39
|
+
const base = path.join(d, bin);
|
|
40
|
+
if (!isWin && isFile(base))
|
|
41
|
+
return classify(base);
|
|
42
|
+
for (const e of exts) {
|
|
43
|
+
const cand = e ? base + e : base;
|
|
44
|
+
if (isFile(cand))
|
|
45
|
+
return classify(cand);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
return null;
|
|
49
|
+
}
|
|
13
50
|
async function postJson(config, p, body, timeoutMs) {
|
|
14
51
|
try {
|
|
15
52
|
const r = await fetch(`${config.baseUrl}${p}`, {
|
|
@@ -34,10 +71,18 @@ function runStep(step) {
|
|
|
34
71
|
resolve({ id: step.id, ran: false, exit: -1, stdout: '', stderr: `engellendi: izinli olmayan ikili "${step.bin}"` });
|
|
35
72
|
return;
|
|
36
73
|
}
|
|
74
|
+
// Windows dahil PATH'te çöz (yoksa = kurulu değil).
|
|
75
|
+
const found = resolveBin(step.bin);
|
|
76
|
+
if (!found) {
|
|
77
|
+
resolve({ id: step.id, ran: false, exit: -1, stdout: '', stderr: `çalıştırılamadı (kurulu değil?): ${step.bin}` });
|
|
78
|
+
return;
|
|
79
|
+
}
|
|
37
80
|
let out = '', err = '', done = false;
|
|
38
81
|
let child;
|
|
39
82
|
try {
|
|
40
|
-
child =
|
|
83
|
+
child = found.viaCmd
|
|
84
|
+
? spawn('cmd.exe', ['/d', '/s', '/c', found.path, ...step.args], { shell: false, windowsHide: true })
|
|
85
|
+
: spawn(found.path, step.args, { shell: false, windowsHide: true });
|
|
41
86
|
}
|
|
42
87
|
catch {
|
|
43
88
|
resolve({ id: step.id, ran: false, exit: -1, stdout: '', stderr: `başlatılamadı (kurulu değil?): ${step.bin}` });
|