Skip to main content
Glama

nikto

Scan web servers for vulnerabilities like outdated software, misconfigurations, and security issues to identify potential attack vectors.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
targetYesTarget URL
portNoPort(s) to scan
sslNoForce SSL mode
timeoutNoTimeout for requests
useragentNoUser-Agent string
tuningNoTuning mode
outputNoOutput file
proxyNoUse proxy
basicAuthNoBasic authentication credentials (username:password)
rootNoRoot directory
cookiesNoCookies to include
rawOptionsNoRaw nikto options

Implementation Reference

  • Core handler function that executes the Nikto web vulnerability scanner by spawning the 'nikto' process, sanitizes options, captures output, extracts findings (lines starting with '+'), and logs results.
    async function runNikto(target: string, rawOptions: string[] = []): Promise<{ fullOutput: string; findings: string[] }> {
      console.error(`Executing Nikto: target=${target}, raw_options=${rawOptions.join(' ')}`);
      if (!target.startsWith('http://') && !target.startsWith('https://')) {
        throw new Error("Target must be a valid URL starting with http:// or https://");
      }
      let options: string[];
      try {
        options = sanitizeOptions(rawOptions);
      } catch (error: any) {
        throw error;
      }
      let fullOutput = "";
      let findings: string[] = [];
      try {
        const baseArgs = ['-h', target, ...options];
        fullOutput += `--- Vulnerability Scan ---\nExecuting: nikto ${baseArgs.join(' ')}\n`;
        try {
          const result = await runSpawnCommand('nikto', baseArgs);
          fullOutput += `Exit Code: ${result.code}\nStdout:\n${result.stdout}\nStderr:\n${result.stderr}\n`;
          findings = result.stdout.split('\n').filter(line => line.startsWith('+') && !line.includes('+ No web server')).map(line => line.trim());
        } catch (error: any) {
          fullOutput += `Nikto command failed to execute: ${error.message}\n`;
        }
        if (currentUserSession.mode === UserMode.PROFESSIONAL) {
          await logMessage(`Ran Nikto against ${target}.\nOptions: ${options.join(' ')}\nFound: ${findings.length} potential issues.`);
        }
        return { fullOutput, findings };
      } catch (error: any) {
        console.error("Fatal error setting up Nikto execution:", error);
        if (currentUserSession.mode === UserMode.PROFESSIONAL) {
          await logMessage(`Nikto FAILED fatally before execution.\nTarget: ${target}\nOptions: ${options.join(' ')}\nError: ${error.message}`);
        }
        throw new Error(`Nikto setup failed fatally: ${error.message}`);
      }
    }
  • Zod schema defining the input parameters and validation for the 'nikto' tool, including target URL (required), optional ports, SSL, timeouts, auth, and raw options.
    const niktoToolSchema = z.object({
      target: z.string().url().describe("Target URL"),
      port: z.string().optional().describe("Port(s) to scan"),
      ssl: z.boolean().optional().describe("Force SSL mode"),
      timeout: z.number().int().optional().describe("Timeout for requests"),
      useragent: z.string().optional().describe("User-Agent string"),
      tuning: z.string().optional().describe("Tuning mode"),
      output: z.string().optional().describe("Output file"),
      proxy: z.string().optional().describe("Use proxy"),
      basicAuth: z.string().optional().describe("Basic authentication credentials (username:password)"),
      root: z.string().optional().describe("Root directory"),
      cookies: z.string().optional().describe("Cookies to include"),
      rawOptions: z.array(z.string()).optional().describe("Raw nikto options")
    }).describe(
  • src/index.ts:605-613 (registration)
    Declares 'nikto' capability in the MCP server's capabilities object, enabling tool discovery.
    "setMode": {},
    "generateWordlist": {},
    "cancelScan": {},
    "createClientReport": {},
    "nmapScan": {},
    "runJohnTheRipper": {},
    "runHashcat": {},
    "gobuster": {},
    "nikto": {}
  • src/index.ts:1159-1191 (registration)
    Registers the 'nikto' tool with the MCP server using server.tool(), constructs options from inputs, calls runNikto handler, formats response for student/professional modes.
    server.tool("nikto", niktoToolSchema.shape, async (args /*: z.infer<typeof niktoToolSchema> */ /*, extra */) => {
      const { target, port, ssl, timeout, useragent, tuning, output, proxy, basicAuth, root, cookies, rawOptions } = args;
      console.error(`Received nikto request:`, args);
      try {
        const constructedOptions: string[] = [];
        constructedOptions.push('-nointeractive');
        if (port) constructedOptions.push('-p', port);
        if (ssl) constructedOptions.push('-ssl');
        if (timeout) constructedOptions.push('-Timeout', timeout.toString());
        if (useragent) constructedOptions.push('-useragent', useragent);
        if (tuning) constructedOptions.push('-Tuning', tuning);
        if (output) constructedOptions.push('-o', output);
        if (proxy) constructedOptions.push('-useproxy', proxy);
        if (basicAuth) { constructedOptions.push('-id', basicAuth); }
        if (root) constructedOptions.push('-root', root);
        if (cookies) constructedOptions.push('-Cookies', cookies);
        if (rawOptions) constructedOptions.push(...rawOptions);
    
        const { fullOutput, findings } = await runNikto(target, constructedOptions);
        const responseContent: any[] = [];
        if (currentUserSession.mode === UserMode.STUDENT) {
          responseContent.push({ type: "text", text: `Found ${findings.length} issues at ${target}` });
          if (findings.length > 0) { /* Categorize and add explanations */ }
          else { responseContent.push({ type: "text", text: "\n**No significant issues found...**" }); }
        } else {
          responseContent.push({ type: "text", text: `Found ${findings.length} issues at ${target}` });
          if (findings.length > 0) responseContent.push({ type: "text", text: "\n**Findings:**\n- " + findings.join('\n- ') });
          responseContent.push({ type: "text", text: "\n**Full Output:**\n" + fullOutput });
          if (findings.some(f => f.toLowerCase().includes('injection'))) { /* Suggest follow-up */ }
        }
        return { content: responseContent };
      } catch (error: any) { return { content: [{ type: "text", text: `Error: ${error.message}` }], isError: true }; }
    });
  • Generic helper function to spawn external commands (like 'nikto'), capture stdout/stderr, and handle process lifecycle. Used by runNikto.
    async function runSpawnCommand(command: string, args: string[]): Promise<{ stdout: string; stderr: string; code: number | null }> {
        return new Promise((resolve, reject) => {
            console.error(`Attempting to spawn: ${command} ${args.join(' ')}`); // Added for debugging
            const process = spawn(command, args);
            let stdout = '';
            let stderr = '';
            process.stdout.on('data', (data) => { stdout += data.toString(); });
            process.stderr.on('data', (data) => { stderr += data.toString(); });
            process.on('error', (error) => {
                // Explicitly catch spawn errors (e.g., command not found)
                console.error(`Spawn error for command "${command}": ${error.message}`);
                reject(new Error(`Failed to start command "${command}": ${error.message}`));
            });
            process.on('close', (code) => {
                console.error(`Command "${command}" exited with code ${code}`); // Added for debugging
                resolve({ stdout, stderr, code });
            });
        });
    }
Behavior1/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

Tool has no description.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness1/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Tool has no description.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness1/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Tool has no description.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters1/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Tool has no description.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose1/5

Does the description clearly state what the tool does and how it differs from similar tools?

Tool has no description.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines1/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

Tool has no description.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/DMontgomery40/pentest-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server