wormclaude 1.0.87 → 1.0.88

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/commands.js CHANGED
@@ -123,14 +123,18 @@ const PT_REASON = {
123
123
  };
124
124
  function formatFinding(x) {
125
125
  const sev = x.severity ? `[${String(x.severity).toUpperCase()}] ` : '';
126
- if (x.type === 'vuln')
127
- return `${sev}${x.name || ''} — ${x.url || ''}`;
128
126
  if (x.type === 'xss')
129
- return `${sev}XSS ${x.param ? 'param ' + x.param : ''} — ${x.url || x.poc || ''}`;
127
+ return `${sev}XSS · param ${x.param || '?'} — ${x.url || ''}`;
130
128
  if (x.type === 'sqli')
131
- return `${sev}SQLi ${x.vulnerable ? 'ZAFİYETLİ' : ''} ${x.params ? '(' + x.params.join(',') + ')' : ''}`;
129
+ return `${sev}SQLi (${x.technique || '?'}) · param ${x.param || '?'} ${x.evidence || ''}`;
130
+ if (x.type === 'subdomain')
131
+ return `alt-alan: ${x.value}`;
132
132
  if (x.type === 'host')
133
133
  return `${x.status || ''} ${x.url || ''}${x.title ? ' · ' + x.title : ''}${x.server ? ' · ' + x.server : ''}`;
134
+ if (x.type === 'weak_headers')
135
+ return `${sev}eksik güvenlik başlıkları: ${(x.missing || []).join(', ')}`;
136
+ if (x.type === 'exposure')
137
+ return `${sev}ifşa: ${x.url || ''} — ${x.evidence || ''}`;
134
138
  if (x.value)
135
139
  return `${x.value}`;
136
140
  return JSON.stringify(x);
@@ -169,9 +173,6 @@ async function pentestCmd(tool, arg, ctx) {
169
173
  }
170
174
  const rep = out.report || {};
171
175
  const lines = [`✓ ${label} tamamlandı — ${rep.target || target}`];
172
- if (out.missing && out.missing.length) {
173
- lines.push(`⚠ Kurulu olmayan araç(lar) atlandı: ${out.missing.join(', ')}`);
174
- }
175
176
  const f = rep.findings || [];
176
177
  if (!f.length) {
177
178
  lines.push('Bulgu yok (hedef yanıt vermedi, temiz, ya da araç kurulu değil).');
package/dist/pentest.js CHANGED
@@ -1,222 +1,4 @@
1
- // WormClaude güvenlik tarama İSTEMCİ ince runner.
2
- //
3
- // Bu modül JENERİK bir çalıştırıcıdır: hiç payload/şablon/araç-seçimi içermez.
4
- // Sunucudan bir komut PLANI alır, komutları YEREL makinede çalıştırır (trafik kullanıcının
5
- // IP'sinden çıkar), ham çıktıyı sunucuya geri gönderir. Tüm zeka sunucuda kalır.
6
- //
7
- // Güvenlik: yalnız PT_ALLOWED'daki ikililer çalıştırılır (ele geçirilmiş/kötü sunucunun
8
- // istemcide rastgele komut çalıştırmasını engeller). Komutlar SHELL'siz spawn edilir (enjeksiyon yok).
9
- import { spawn, spawnSync } from 'node:child_process';
10
- import { statSync, mkdirSync, writeFileSync, readdirSync, renameSync, chmodSync, rmSync } from 'node:fs';
11
- import * as path from 'node:path';
12
- import * as os from 'node:os';
13
- // İstemci-tarafı allowlist (sunucudakiyle aynı; çift güvence).
14
- export const PT_ALLOWED = new Set(['httpx', 'nuclei', 'dalfox', 'sqlmap', 'subfinder', 'katana', 'nmap', 'ffuf']);
15
- const MAX_OUT = 200_000;
16
- // CLI'nin yönettiği araç dizini — PATH'e dokunmadan araçları burada tutarız.
17
- export function managedBinDir() {
18
- return path.join(os.homedir(), '.wormclaude', 'bin');
19
- }
20
- // İkiliyi PATH üzerinde çöz. Windows'ta Node spawn(shell:false) PATHEXT aramaz →
21
- // 'dalfox' verilse 'dalfox.exe'yi bulamaz; bu yüzden elle çözüyoruz.
22
- // Döner: {path, viaCmd} — viaCmd ise .cmd/.bat olduğu için cmd.exe ile sarılır.
23
- export function resolveBin(bin) {
24
- const isWin = process.platform === 'win32';
25
- const exts = isWin ? (process.env.PATHEXT || '.EXE;.CMD;.BAT;.COM').split(';').filter(Boolean) : [''];
26
- const isFile = (p) => { try {
27
- return statSync(p).isFile();
28
- }
29
- catch {
30
- return false;
31
- } };
32
- const classify = (p) => ({ path: p, viaCmd: /\.(cmd|bat)$/i.test(p) });
33
- // Mutlak/parçalı yol verildiyse doğrudan dene.
34
- if (bin.includes('/') || bin.includes('\\')) {
35
- if (isFile(bin))
36
- return classify(bin);
37
- for (const e of exts)
38
- if (e && isFile(bin + e))
39
- return classify(bin + e);
40
- return null;
41
- }
42
- // Önce CLI'nin yönettiği dizin, sonra sistem PATH.
43
- const dirs = [managedBinDir(), ...(process.env.PATH || '').split(path.delimiter)].filter(Boolean);
44
- for (const d of dirs) {
45
- const base = path.join(d, bin);
46
- if (!isWin && isFile(base))
47
- return classify(base);
48
- for (const e of exts) {
49
- const cand = e ? base + e : base;
50
- if (isFile(cand))
51
- return classify(cand);
52
- }
53
- }
54
- return null;
55
- }
56
- // ── Otomatik araç kurucu (tek-binary GitHub release'leri) ─────────────────────
57
- // sqlmap (python) ve nmap (installer) hariç — onlar elle/paketle kurulur.
58
- const TOOL_REPOS = {
59
- dalfox: 'hahwul/dalfox',
60
- nuclei: 'projectdiscovery/nuclei',
61
- httpx: 'projectdiscovery/httpx',
62
- subfinder: 'projectdiscovery/subfinder',
63
- katana: 'projectdiscovery/katana',
64
- ffuf: 'ffuf/ffuf',
65
- };
66
- function platTokens() {
67
- const p = process.platform, a = process.arch;
68
- const osSyn = p === 'win32' ? /windows|win/i : p === 'darwin' ? /darwin|macos|mac/i : /linux/i;
69
- const archSyn = a === 'arm64' ? /arm64|aarch64/i : /amd64|x86_64|x64/i;
70
- return { osSyn, archSyn };
71
- }
72
- async function ghLatestAsset(repo) {
73
- try {
74
- const r = await fetch(`https://api.github.com/repos/${repo}/releases/latest`, {
75
- headers: { 'User-Agent': 'wormclaude', Accept: 'application/vnd.github+json' },
76
- signal: AbortSignal.timeout(15000),
77
- });
78
- if (!r.ok)
79
- return null;
80
- const rel = await r.json();
81
- const { osSyn, archSyn } = platTokens();
82
- const assets = (rel.assets || []).filter((x) => {
83
- const n = String(x.name);
84
- if (!/\.(zip|tar\.gz|tgz)$/i.test(n))
85
- return false;
86
- if (/sha256|\.txt$|\.deb$|\.rpm$|checksum|cdx|musl/i.test(n))
87
- return false;
88
- return osSyn.test(n) && archSyn.test(n);
89
- });
90
- const pref = process.platform === 'win32' ? /\.zip$/i : /\.tar\.gz$|\.tgz$/i;
91
- assets.sort((x, y) => (pref.test(y.name) ? 1 : 0) - (pref.test(x.name) ? 1 : 0));
92
- const a0 = assets[0];
93
- return a0 ? { name: a0.name, url: a0.browser_download_url } : null;
94
- }
95
- catch {
96
- return null;
97
- }
98
- }
99
- function spawnSyncOk(cmd, args) {
100
- try {
101
- const r = spawnSync(cmd, args, { stdio: 'ignore', windowsHide: true });
102
- return !r.error && r.status === 0;
103
- }
104
- catch {
105
- return false;
106
- }
107
- }
108
- function extractArchive(archive, destDir) {
109
- // tar (Windows 10+ bsdtar) zip'i de açar; unix'te de mevcut.
110
- if (spawnSyncOk('tar', ['-xf', archive, '-C', destDir]))
111
- return true;
112
- if (process.platform === 'win32' && /\.zip$/i.test(archive)) {
113
- return spawnSyncOk('powershell', ['-NoProfile', '-NonInteractive', '-Command',
114
- `Expand-Archive -LiteralPath "${archive}" -DestinationPath "${destDir}" -Force`]);
115
- }
116
- return false;
117
- }
118
- function findFile(dir, name) {
119
- const stack = [dir];
120
- while (stack.length) {
121
- const d = stack.pop();
122
- let entries;
123
- try {
124
- entries = readdirSync(d, { withFileTypes: true });
125
- }
126
- catch {
127
- continue;
128
- }
129
- for (const e of entries) {
130
- const full = path.join(d, e.name);
131
- if (e.isDirectory())
132
- stack.push(full);
133
- else if (e.name.toLowerCase() === name.toLowerCase())
134
- return full;
135
- }
136
- }
137
- return null;
138
- }
139
- // Eksik aracı yönetilen dizine indirir (PATH'e dokunmaz). Döner: kuruldu mu.
140
- export async function ensureTool(bin, log) {
141
- if (resolveBin(bin))
142
- return true;
143
- const repo = TOOL_REPOS[bin];
144
- if (!repo)
145
- return false; // sqlmap/nmap otomatik kurulamaz
146
- const dest = managedBinDir();
147
- mkdirSync(dest, { recursive: true });
148
- const asset = await ghLatestAsset(repo);
149
- if (!asset) {
150
- log(` ${bin}: uygun sürüm bulunamadı (GitHub ${repo})`);
151
- return false;
152
- }
153
- let buf;
154
- try {
155
- const r = await fetch(asset.url, { headers: { 'User-Agent': 'wormclaude' }, signal: AbortSignal.timeout(120000) });
156
- if (!r.ok) {
157
- log(` ${bin}: indirme hatası ${r.status}`);
158
- return false;
159
- }
160
- buf = Buffer.from(await r.arrayBuffer());
161
- }
162
- catch {
163
- log(` ${bin}: indirme zaman aşımı`);
164
- return false;
165
- }
166
- // Arşiv uzantısını koru — Expand-Archive fallback'i .zip uzantısına bakar.
167
- const ext = /\.tar\.gz$/i.test(asset.name) ? '.tar.gz' : /\.tgz$/i.test(asset.name) ? '.tgz' : '.zip';
168
- const tmp = path.join(dest, `.dl_${bin}${ext}`);
169
- const exDir = path.join(dest, `.ex_${bin}`);
170
- try {
171
- rmSync(exDir, { recursive: true, force: true });
172
- }
173
- catch { /* */ }
174
- writeFileSync(tmp, buf);
175
- mkdirSync(exDir, { recursive: true });
176
- const ok = extractArchive(tmp, exDir);
177
- try {
178
- rmSync(tmp, { force: true });
179
- }
180
- catch { /* */ }
181
- if (!ok) {
182
- log(` ${bin}: arşiv açılamadı`);
183
- try {
184
- rmSync(exDir, { recursive: true, force: true });
185
- }
186
- catch { /* */ }
187
- return false;
188
- }
189
- const want = process.platform === 'win32' ? bin + '.exe' : bin;
190
- const found = findFile(exDir, want);
191
- if (!found) {
192
- log(` ${bin}: arşivde çalıştırılabilir yok`);
193
- try {
194
- rmSync(exDir, { recursive: true, force: true });
195
- }
196
- catch { /* */ }
197
- return false;
198
- }
199
- const target = path.join(dest, want);
200
- try {
201
- try {
202
- rmSync(target, { force: true });
203
- }
204
- catch { /* */ }
205
- renameSync(found, target);
206
- if (process.platform !== 'win32')
207
- chmodSync(target, 0o755);
208
- }
209
- catch {
210
- log(` ${bin}: yerleştirme hatası`);
211
- return false;
212
- }
213
- try {
214
- rmSync(exDir, { recursive: true, force: true });
215
- }
216
- catch { /* */ }
217
- log(` ✓ ${bin} kuruldu → ${target}`);
218
- return true;
219
- }
1
+ const MAX_BODY = 262_144; // 256 KB cevap gövdesi üst sınırı
220
2
  async function postJson(config, p, body, timeoutMs) {
221
3
  try {
222
4
  const r = await fetch(`${config.baseUrl}${p}`, {
@@ -234,78 +16,69 @@ async function postJson(config, p, body, timeoutMs) {
234
16
  return { ok: false, reason: e?.name === 'TimeoutError' ? 'timeout' : 'upstream_error' };
235
17
  }
236
18
  }
237
- function runStep(step) {
238
- return new Promise((resolve) => {
239
- // İstemci allowlist zorlaması — sunucu ne derse desin, izinsiz ikili ÇALIŞMAZ.
240
- if (!PT_ALLOWED.has(step.bin)) {
241
- resolve({ id: step.id, ran: false, exit: -1, stdout: '', stderr: `engellendi: izinli olmayan ikili "${step.bin}"` });
242
- return;
243
- }
244
- // Windows dahil PATH'te çöz (yoksa = kurulu değil).
245
- const found = resolveBin(step.bin);
246
- if (!found) {
247
- resolve({ id: step.id, ran: false, exit: -1, stdout: '', stderr: `çalıştırılamadı (kurulu değil?): ${step.bin}` });
248
- return;
249
- }
250
- let out = '', err = '', done = false;
251
- let child;
19
+ function hostOf(u) {
20
+ try {
21
+ return new URL(u).hostname.toLowerCase();
22
+ }
23
+ catch {
24
+ return '';
25
+ }
26
+ }
27
+ // Tek bir istek-spec'ini yerelde çalıştır. allowed dışı host → atlanır (SSRF koruması).
28
+ async function execReq(req, allowed) {
29
+ const t0 = Date.now();
30
+ const h = hostOf(req.url);
31
+ if (!allowed.has(h)) {
32
+ return { id: req.id, ms: 0, error: `izin-dışı host: ${h}` };
33
+ }
34
+ try {
35
+ const r = await fetch(req.url, {
36
+ method: req.method || 'GET',
37
+ headers: req.headers,
38
+ body: req.body,
39
+ redirect: 'follow',
40
+ signal: AbortSignal.timeout(Math.max(3, req.timeout || 20) * 1000),
41
+ });
42
+ let body = '';
252
43
  try {
253
- child = found.viaCmd
254
- ? spawn('cmd.exe', ['/d', '/s', '/c', found.path, ...step.args], { shell: false, windowsHide: true })
255
- : spawn(found.path, step.args, { shell: false, windowsHide: true });
256
- }
257
- catch {
258
- resolve({ id: step.id, ran: false, exit: -1, stdout: '', stderr: `başlatılamadı (kurulu değil?): ${step.bin}` });
259
- return;
44
+ const buf = await r.arrayBuffer();
45
+ body = Buffer.from(buf).toString('utf8').slice(0, MAX_BODY);
260
46
  }
261
- const to = setTimeout(() => { try {
262
- child.kill('SIGKILL');
263
- }
264
- catch { /* */ } }, Math.max(5, step.timeout) * 1000);
265
- child.stdout?.on('data', (d) => { if (out.length < MAX_OUT)
266
- out += d.toString(); });
267
- child.stderr?.on('data', (d) => { if (err.length < 4000)
268
- err += d.toString(); });
269
- child.on('error', () => {
270
- if (done)
271
- return;
272
- done = true;
273
- clearTimeout(to);
274
- resolve({ id: step.id, ran: false, exit: -1, stdout: out, stderr: `çalıştırılamadı (kurulu değil?): ${step.bin}` });
275
- });
276
- child.on('close', (code) => {
277
- if (done)
278
- return;
279
- done = true;
280
- clearTimeout(to);
281
- resolve({ id: step.id, ran: true, exit: code ?? -1, stdout: out, stderr: err });
282
- });
283
- });
47
+ catch { /* gövde okunamadı */ }
48
+ const headers = {};
49
+ r.headers.forEach((v, k) => { headers[k] = v; });
50
+ return { id: req.id, status: r.status, headers, body, ms: Date.now() - t0, url: r.url };
51
+ }
52
+ catch (e) {
53
+ return { id: req.id, ms: Date.now() - t0, error: e?.name === 'TimeoutError' ? 'timeout' : (e?.message || 'fetch error').slice(0, 80) };
54
+ }
284
55
  }
285
- // Tam akış: plan al → yerelde çalıştırrapor gönder. log() ile ilerleme bildirir.
56
+ // Tam akış: plan al → her round'da istekleri yerelde at/exec ile analiz ettir done'a dek döngü.
286
57
  export async function runPentest(config, tool, target, scopeAck, log) {
287
58
  const plan = await postJson(config, '/pentest/plan', { tool, target, scope_ack: scopeAck }, 15000);
288
59
  if (!plan.ok)
289
60
  return { ok: false, reason: plan.reason, plan };
290
- // Eksik araçları yönetilen dizine otomatik kur (PATH'e dokunmadan).
291
- const needed = [...new Set(plan.steps.map((s) => s.bin))];
292
- for (const b of needed) {
293
- if (resolveBin(b))
294
- continue;
295
- log(`Araç eksik: ${b} ${TOOL_REPOS[b] ? 'otomatik kuruluyor…' : 'otomatik kurulamaz (elle kur)'}`);
296
- if (TOOL_REPOS[b])
297
- await ensureTool(b, log);
298
- }
299
- log(`Plan alındı (${plan.steps.length} adım). Yerelde çalıştırılıyor trafik senin IP'nden çıkıyor…`);
300
- const results = [];
301
- const missing = [];
302
- for (const s of plan.steps) {
303
- log(` → ${s.bin} ${s.args.slice(0, 3).join(' ')}…`);
304
- const r = await runStep(s);
305
- if (!r.ran && /kurulu değil/.test(r.stderr))
306
- missing.push(s.bin);
307
- results.push(r);
308
- }
309
- const report = await postJson(config, '/pentest/report', { job_id: plan.job_id, results }, 30000);
310
- return { ok: !!report.ok, plan, report, missing: [...new Set(missing)] };
61
+ const allowed = new Set((plan.allowed_hosts || [plan.host || '']).map((x) => x.toLowerCase()));
62
+ let requests = plan.requests || [];
63
+ let round = plan.round || 1;
64
+ let report = null;
65
+ for (let guard = 0; guard < 8 && requests.length; guard++) {
66
+ log(`Tur ${round}: ${requests.length} istek yerelde atılıyor trafik senin IP'nden çıkıyor…`);
67
+ // İstekleri sınırlı eşzamanlılıkla çalıştır (hedefi yormamak için 6'şarlı)
68
+ const responses = [];
69
+ const CONC = 6;
70
+ for (let i = 0; i < requests.length; i += CONC) {
71
+ const batch = requests.slice(i, i + CONC);
72
+ const rs = await Promise.all(batch.map((req) => execReq(req, allowed)));
73
+ responses.push(...rs);
74
+ }
75
+ report = await postJson(config, '/pentest/exec', { job_id: plan.job_id, responses }, 30000);
76
+ if (!report.ok)
77
+ return { ok: false, reason: report.reason, plan, report };
78
+ if (report.done)
79
+ break;
80
+ requests = report.requests || [];
81
+ round = report.round || round + 1;
82
+ }
83
+ return { ok: true, plan, report };
311
84
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "wormclaude",
3
- "version": "1.0.87",
3
+ "version": "1.0.88",
4
4
  "description": "WormClaude CLI - uncensored security+code assistant (ink TUI, Claude-style)",
5
5
  "type": "module",
6
6
  "bin": {