@memrov2/pentcloud-metasploit 0.1.0 → 0.1.1-dev.0
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.
- package/package.json +2 -2
- package/src/worker.d.mts +2 -0
- package/src/worker.mjs +18 -3
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@memrov2/pentcloud-metasploit",
|
|
3
|
-
"version": "0.1.0",
|
|
3
|
+
"version": "0.1.1-dev.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"description": "Cloudflare-native metasploit tool pack",
|
|
@@ -33,6 +33,6 @@
|
|
|
33
33
|
"access": "public"
|
|
34
34
|
},
|
|
35
35
|
"dependencies": {
|
|
36
|
-
"@memrov2/pentcloud-tool-runtime": "0.1.0"
|
|
36
|
+
"@memrov2/pentcloud-tool-runtime": "0.1.1-dev.0"
|
|
37
37
|
}
|
|
38
38
|
}
|
package/src/worker.d.mts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { DurableObject } from "cloudflare:workers";
|
|
2
2
|
export declare class MetasploitRunner extends DurableObject {
|
|
3
|
+
ready(): Promise<{ image: string; instance: "standard-2" }>;
|
|
3
4
|
fetch(request: Request): Promise<Response>;
|
|
5
|
+
retire(): Promise<{ stopped: boolean; retired: true }>;
|
|
4
6
|
stop(): Promise<{ stopped: boolean }>;
|
|
5
7
|
}
|
package/src/worker.mjs
CHANGED
|
@@ -21,6 +21,7 @@ export class MetasploitRunner extends DurableObject {
|
|
|
21
21
|
return result;
|
|
22
22
|
}
|
|
23
23
|
async #ready() {
|
|
24
|
+
if (await this.ctx.storage.get("retired")) throw new Error("Owned tool runtime is retired");
|
|
24
25
|
const c = this.ctx.container,
|
|
25
26
|
image = c.images.metasploit;
|
|
26
27
|
if (!image) throw new Error("Configure the metasploit named image");
|
|
@@ -58,11 +59,11 @@ export class MetasploitRunner extends DurableObject {
|
|
|
58
59
|
MSF_MCP_MIN_THREADS: "1",
|
|
59
60
|
MSF_MCP_MAX_THREADS: "4",
|
|
60
61
|
},
|
|
61
|
-
instance:
|
|
62
|
+
instance: "standard-2",
|
|
62
63
|
enableInternet: true,
|
|
63
64
|
labels: { pack: "metasploit", version: lock.packVersion },
|
|
64
65
|
});
|
|
65
|
-
await c.setInactivityTimeout(
|
|
66
|
+
await c.setInactivityTimeout(240000);
|
|
66
67
|
const deadline = Date.now() + 180000;
|
|
67
68
|
let verified = false;
|
|
68
69
|
while (Date.now() < deadline) {
|
|
@@ -90,7 +91,7 @@ export class MetasploitRunner extends DurableObject {
|
|
|
90
91
|
signal: AbortSignal.timeout(5000),
|
|
91
92
|
});
|
|
92
93
|
await r.body?.cancel();
|
|
93
|
-
if ([200, 400, 405, 406].includes(r.status)) return token;
|
|
94
|
+
if ([200, 400, 405, 406].includes(r.status)) {await c.setInactivityTimeout(120000);return token;}
|
|
94
95
|
if (r.status === 401)
|
|
95
96
|
throw new Error("Internal MCP authentication failed");
|
|
96
97
|
} catch (error) {
|
|
@@ -102,6 +103,12 @@ export class MetasploitRunner extends DurableObject {
|
|
|
102
103
|
"Official Metasploit MCP server did not become ready within 180 seconds",
|
|
103
104
|
);
|
|
104
105
|
}
|
|
106
|
+
ready() {
|
|
107
|
+
return this.#serial(async () => {
|
|
108
|
+
await this.#ready();
|
|
109
|
+
return { image: this.ctx.container.images.metasploit, instance: "standard-2" };
|
|
110
|
+
});
|
|
111
|
+
}
|
|
105
112
|
async fetch(request) {
|
|
106
113
|
const url = new URL(request.url);
|
|
107
114
|
if (
|
|
@@ -126,6 +133,14 @@ export class MetasploitRunner extends DurableObject {
|
|
|
126
133
|
}),
|
|
127
134
|
);
|
|
128
135
|
}
|
|
136
|
+
retire() {
|
|
137
|
+
return this.#serial(async () => {
|
|
138
|
+
await this.ctx.storage.put("retired", true);
|
|
139
|
+
if (this.ctx.container.running) await this.ctx.container.destroy();
|
|
140
|
+
await this.ctx.storage.delete("mcp-token");
|
|
141
|
+
return { stopped: !this.ctx.container.running, retired: true };
|
|
142
|
+
});
|
|
143
|
+
}
|
|
129
144
|
stop() {
|
|
130
145
|
return this.#serial(async () => {
|
|
131
146
|
if (this.ctx.container.running) await this.ctx.container.destroy();
|