@memrov2/pentcloud-metasploit 0.0.0-stage → 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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 PentCloud contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,11 @@
1
- # Temporary Holding Version
1
+ # PentCloud metasploit
2
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.
3
+ Official Metasploit HTTP MCP in a separate native Cloudflare runtime. **Version 0.1.0 SDK.** The npm package contains adapter code only. Vendor image redistribution requires a separate component-license review. No PostgreSQL or public callback/listener endpoint is configured.
4
+
5
+ ```sh
6
+ npm install @memrov2/pentcloud-metasploit@0.1.0
7
+ ```
8
+
9
+ Use an existing MCP client with `runner.fetch(request)` through a private binding. Call `runner.stop()` when the owned run ends.
10
+
11
+ Configure the matching named Container image. See [interfaces, build instructions, verification and limits](https://github.com/Memrov/PentCloud-tools/blob/main/docs/remaining-bundles.md) before integration. This package does not deploy or modify PentCloud.
@@ -0,0 +1,8 @@
1
+ # Third-party notices
2
+
3
+ The original PentCloud adapter source and type declarations in this npm SDK are MIT licensed. The tarball includes pin metadata, but no third-party tool executables, source archives, datasets or container images.
4
+
5
+ - Metasploit Framework core: [BSD-3-Clause](https://github.com/rapid7/metasploit-framework/blob/master/LICENSE), with third-party component exceptions listed in that file.
6
+ - The pinned vendor image includes Nmap and other separately licensed components. Its digest in `tools.lock.json` identifies the upstream image; the adapter license does not license that image or its contents.
7
+
8
+ Upstream programs, data and image dependencies retain their own licenses and notices. Image builders preserve those notices. Building or distributing a separate image requires compliance with its components' terms; this adapter SDK grants no additional rights to them. Image-specific cautions in `tools.lock.json` remain in effect.
package/package.json CHANGED
@@ -1,6 +1,38 @@
1
1
  {
2
2
  "name": "@memrov2/pentcloud-metasploit",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "0.1.1-dev.0",
4
+ "type": "module",
5
+ "license": "MIT",
6
+ "description": "Cloudflare-native metasploit tool pack",
7
+ "repository": {
8
+ "type": "git",
9
+ "url": "https://github.com/Memrov/PentCloud-tools.git",
10
+ "directory": "packages/metasploit"
11
+ },
12
+ "engines": {
13
+ "node": ">=22"
14
+ },
15
+ "exports": {
16
+ ".": {
17
+ "types": "./src/index.d.mts",
18
+ "import": "./src/index.mjs"
19
+ },
20
+ "./worker": {
21
+ "types": "./src/worker.d.mts",
22
+ "import": "./src/worker.mjs"
23
+ },
24
+ "./tools.lock.json": "./tools.lock.json"
25
+ },
26
+ "files": [
27
+ "src",
28
+ "tools.lock.json",
29
+ "LICENSE",
30
+ "THIRD_PARTY_NOTICES.md"
31
+ ],
32
+ "publishConfig": {
33
+ "access": "public"
34
+ },
35
+ "dependencies": {
36
+ "@memrov2/pentcloud-tool-runtime": "0.1.1-dev.0"
37
+ }
38
+ }
@@ -0,0 +1,2 @@
1
+ import type { PackLock } from "@memrov2/pentcloud-tool-runtime";
2
+ export declare const lock: PackLock;
package/src/index.mjs ADDED
@@ -0,0 +1,2 @@
1
+ import lock from "../tools.lock.json" with { type: "json" };
2
+ export { lock };
@@ -0,0 +1,7 @@
1
+ import { DurableObject } from "cloudflare:workers";
2
+ export declare class MetasploitRunner extends DurableObject {
3
+ ready(): Promise<{ image: string; instance: "standard-2" }>;
4
+ fetch(request: Request): Promise<Response>;
5
+ retire(): Promise<{ stopped: boolean; retired: true }>;
6
+ stop(): Promise<{ stopped: boolean }>;
7
+ }
package/src/worker.mjs ADDED
@@ -0,0 +1,151 @@
1
+ import { DurableObject } from "cloudflare:workers";
2
+ import { lock } from "./index.mjs";
3
+ const decode = (x) => new TextDecoder().decode(x);
4
+ const digest = async () =>
5
+ [
6
+ ...new Uint8Array(
7
+ await crypto.subtle.digest(
8
+ "SHA-256",
9
+ new TextEncoder().encode(JSON.stringify(lock)),
10
+ ),
11
+ ),
12
+ ]
13
+ .map((v) => v.toString(16).padStart(2, "0"))
14
+ .join("");
15
+ /** Private binding only. The upstream MCP server owns RPC processes and tools. */
16
+ export class MetasploitRunner extends DurableObject {
17
+ #queue = Promise.resolve();
18
+ #serial(action) {
19
+ const result = this.#queue.then(action);
20
+ this.#queue = result.catch(() => {});
21
+ return result;
22
+ }
23
+ async #ready() {
24
+ if (await this.ctx.storage.get("retired")) throw new Error("Owned tool runtime is retired");
25
+ const c = this.ctx.container,
26
+ image = c.images.metasploit;
27
+ if (!image) throw new Error("Configure the metasploit named image");
28
+ let token = await this.ctx.storage.get("mcp-token");
29
+ if (!token) {
30
+ if (c.running)
31
+ throw new Error(
32
+ "RPC authentication state missing; stop this owned runtime before restarting",
33
+ );
34
+ token = crypto.randomUUID() + crypto.randomUUID();
35
+ await this.ctx.storage.put("mcp-token", token);
36
+ }
37
+ if (c.running) {
38
+ if ((await c.inspect())?.image !== image)
39
+ throw new Error(
40
+ "Image changed; stop the current runtime before upgrading",
41
+ );
42
+ } else
43
+ c.start({
44
+ image,
45
+ entrypoint: [
46
+ "/usr/src/metasploit-framework/msfmcpd",
47
+ "--mcp-transport",
48
+ "http",
49
+ "--enable-dangerous-actions",
50
+ ],
51
+ env: {
52
+ MSF_MCP_HOST: "0.0.0.0",
53
+ MSF_MCP_PORT: "3000",
54
+ MSF_MCP_AUTH_TOKEN: token,
55
+ MSF_API_TYPE: "messagepack",
56
+ MSF_API_SSL: "false",
57
+ MSF_AUTO_START_RPC: "true",
58
+ MSF_MCP_WORKERS: "1",
59
+ MSF_MCP_MIN_THREADS: "1",
60
+ MSF_MCP_MAX_THREADS: "4",
61
+ },
62
+ instance: "standard-2",
63
+ enableInternet: true,
64
+ labels: { pack: "metasploit", version: lock.packVersion },
65
+ });
66
+ await c.setInactivityTimeout(240000);
67
+ const deadline = Date.now() + 180000;
68
+ let verified = false;
69
+ while (Date.now() < deadline) {
70
+ try {
71
+ if (!verified) {
72
+ const p = await c.exec(
73
+ ["/bin/cat", "/opt/pentcloud-metasploit/pack.json"],
74
+ { signal: AbortSignal.timeout(5000) },
75
+ );
76
+ const r = await p.output();
77
+ if (
78
+ r.exitCode !== 0 ||
79
+ JSON.parse(decode(r.stdout)).lockSha256 !== (await digest())
80
+ )
81
+ throw new Error("Pack image and SDK pins do not match");
82
+ verified = true;
83
+ }
84
+ const r = await c
85
+ .getTcpPort(3000)
86
+ .fetch("http://localhost:3000/", {
87
+ headers: {
88
+ Authorization: "Bearer " + token,
89
+ Accept: "application/json, text/event-stream",
90
+ },
91
+ signal: AbortSignal.timeout(5000),
92
+ });
93
+ await r.body?.cancel();
94
+ if ([200, 400, 405, 406].includes(r.status)) {await c.setInactivityTimeout(120000);return token;}
95
+ if (r.status === 401)
96
+ throw new Error("Internal MCP authentication failed");
97
+ } catch (error) {
98
+ if (/pins do not match|authentication/.test(error.message)) throw error;
99
+ }
100
+ await new Promise((r) => setTimeout(r, 1000));
101
+ }
102
+ throw new Error(
103
+ "Official Metasploit MCP server did not become ready within 180 seconds",
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
+ }
112
+ async fetch(request) {
113
+ const url = new URL(request.url);
114
+ if (
115
+ !["/", "/mcp"].includes(url.pathname) ||
116
+ url.search ||
117
+ !["GET", "POST", "DELETE"].includes(request.method)
118
+ )
119
+ return new Response("Unsupported MCP request", { status: 400 });
120
+ const token = await this.#serial(() => this.#ready());
121
+ const headers = new Headers(request.headers);
122
+ headers.set("Authorization", "Bearer " + token);
123
+ headers.delete("Cookie");
124
+ headers.delete("Host");
125
+ return this.ctx.container
126
+ .getTcpPort(3000)
127
+ .fetch(
128
+ new Request("http://localhost:3000/", {
129
+ method: request.method,
130
+ headers,
131
+ body: request.method === "GET" ? undefined : request.body,
132
+ duplex: "half",
133
+ }),
134
+ );
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
+ }
144
+ stop() {
145
+ return this.#serial(async () => {
146
+ if (this.ctx.container.running) await this.ctx.container.destroy();
147
+ await this.ctx.storage.delete("mcp-token");
148
+ return { stopped: !this.ctx.container.running };
149
+ });
150
+ }
151
+ }
@@ -0,0 +1,24 @@
1
+ {
2
+ "schemaVersion": 1,
3
+ "packId": "metasploit",
4
+ "packVersion": "0.1.0",
5
+ "platform": "linux/amd64",
6
+ "baseImage": "docker.io/metasploitframework/metasploit-framework@sha256:8096709486bce8b5f35980f2aea42dc7cd83e34ebbeb4d56eab3339847de258d",
7
+ "tools": [
8
+ {
9
+ "tool": "metasploit",
10
+ "version": "image-8096709486bc"
11
+ }
12
+ ],
13
+ "assets": [],
14
+ "executables": [],
15
+ "runtime": {
16
+ "vcpu": 2,
17
+ "memoryMib": 2048,
18
+ "diskMb": 8000,
19
+ "enableInternet": true
20
+ },
21
+ "privateOnlyReasons": [
22
+ "Vendor image includes Nmap; public image redistribution requires review."
23
+ ]
24
+ }