create_interactsh_session
Generate callback domains and capture DNS/HTTP interactions for out-of-band security testing and verification workflows.
Instructions
Generates credentials, registers with interactsh, and returns the connection details.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/server.js:303-331 (handler)Inline handler function executed when the create_interactsh_session tool is called. Creates a session, generates a sample probe host and detailed usage instructions, formats and returns the result.const session = await service.createSession(); const baseDomain = service.domainSuffix || new URL(service.baseUrl).hostname; const probeNonce = crypto .randomBytes(16) .toString('base64') .replace(/[^a-z0-9]/gi, '') .slice(0, 13) .toLowerCase(); const probeHost = `${session.correlationId}${probeNonce}.${baseDomain}`; const instructions = [ 'Probing rules (very important):', '- Build the host as: <correlation_id><nonce13>.<domain>', '- correlation_id: exactly 20 lowercase hex characters (do not alter or truncate).', "- nonce13: exactly 13 lowercase alphanumeric characters [a-z0-9] (no hyphens or uppercase).", '- The label before the first dot must be length 33 (20 + 13).', '- Requests to only <correlation_id>.<domain> (no nonce) will be ignored by interactsh.', '', `Quick test (HTTP recommended): curl -I http://${probeHost}/`, 'Then wait 2–3 seconds and call poll_interactsh_session with the same correlation_id to retrieve events.', 'If you still get zero events, send another probe or use filters (method, protocol, path_contains, text_contains) when polling.', ].join('\n'); return result({ ...session.toJSON(), instructions, sample_probe_host: probeHost, }); }, );
- src/server.js:297-332 (registration)Registration of the create_interactsh_session tool with the MCP server, specifying name, metadata (title, description), and handler function. No input schema defined (takes no parameters).'create_interactsh_session', { title: 'Create interactsh session', description: 'Generates credentials, registers with interactsh, and returns the connection details.', }, async () => { const session = await service.createSession(); const baseDomain = service.domainSuffix || new URL(service.baseUrl).hostname; const probeNonce = crypto .randomBytes(16) .toString('base64') .replace(/[^a-z0-9]/gi, '') .slice(0, 13) .toLowerCase(); const probeHost = `${session.correlationId}${probeNonce}.${baseDomain}`; const instructions = [ 'Probing rules (very important):', '- Build the host as: <correlation_id><nonce13>.<domain>', '- correlation_id: exactly 20 lowercase hex characters (do not alter or truncate).', "- nonce13: exactly 13 lowercase alphanumeric characters [a-z0-9] (no hyphens or uppercase).", '- The label before the first dot must be length 33 (20 + 13).', '- Requests to only <correlation_id>.<domain> (no nonce) will be ignored by interactsh.', '', `Quick test (HTTP recommended): curl -I http://${probeHost}/`, 'Then wait 2–3 seconds and call poll_interactsh_session with the same correlation_id to retrieve events.', 'If you still get zero events, send another probe or use filters (method, protocol, path_contains, text_contains) when polling.', ].join('\n'); return result({ ...session.toJSON(), instructions, sample_probe_host: probeHost, }); }, );
- src/server.js:39-63 (helper)Key helper method in InteractshService class that implements the core session creation logic: generates RSA key pair, correlation ID, secret key, constructs InteractshSession, registers it with the interactsh server, caches it, and returns the session.async createSession() { const { publicKey, privateKey } = crypto.generateKeyPairSync('rsa', { modulusLength: 2048, publicExponent: 0x10001, }); const publicKeyPem = publicKey.export({ type: 'spki', format: 'pem' }); const publicKeyB64 = Buffer.from(publicKeyPem).toString('base64'); const correlationId = this.#generateCorrelationId(); const secretKey = this.#generateSecretKey(); const callbackDomain = this.domainSuffix ? `${correlationId}.${this.domainSuffix}` : correlationId; const session = new InteractshSession({ correlationId, secretKey, privateKey, publicKeyB64, callbackDomain, serverUrl: this.baseUrl, }); await this.#register(session); this.sessions.set(correlationId, session); return session; }
- src/server.js:10-29 (helper)Data class for InteractshSession, holds session details and provides toJSON() for serialization used in tool output.export class InteractshSession { constructor({ correlationId, secretKey, privateKey, publicKeyB64, callbackDomain, serverUrl }) { this.correlationId = correlationId; this.secretKey = secretKey; this.privateKey = privateKey; this.publicKeyB64 = publicKeyB64; this.callbackDomain = callbackDomain; this.serverUrl = serverUrl; } toJSON() { return { correlation_id: this.correlationId, secret_key: this.secretKey, private_key_pem: this.privateKey.export({ type: 'pkcs8', format: 'pem' }), callback_domain: this.callbackDomain, server_url: this.serverUrl, }; } }
- src/server.js:276-286 (helper)Utility function to format tool responses with both text and structured content for MCP compatibility.function result(structured) { return { content: [ { type: 'text', text: JSON.stringify(structured, null, 2), }, ], structuredContent: structured, }; }