Skip to main content
Glama

directory_scan

Scan web directories and files using dirb, dirsearch, gobuster, or feroxbuster to identify hidden paths and resources on target URLs for security assessment.

Instructions

Advanced directory scanning with dirb/dirsearch/gobuster/feroxbuster

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
targetYesTarget URL
toolNoDirectory scanning tool to use
recursiveNoEnable recursive scanning

Implementation Reference

  • src/index.ts:323-339 (registration)
    Registration of the 'directory_scan' tool in the MCP tools list, including name, description, and input schema definition.
    {
      name: "directory_scan",
      description: "Advanced directory scanning with dirb/dirsearch/gobuster/feroxbuster",
      inputSchema: {
        type: "object",
        properties: {
          target: { type: "string", description: "Target URL" },
          tool: { 
            type: "string", 
            enum: ["dirb", "dirsearch", "gobuster", "feroxbuster"],
            description: "Directory scanning tool to use" 
          },
          recursive: { type: "boolean", description: "Enable recursive scanning" }
        },
        required: ["target"]
      }
    },
  • MCP tool call handler in switch statement that delegates to DirectoryScannerEngine.scanDirectories with parsed arguments.
    case "directory_scan":
      return respond(await this.directoryScanner.scanDirectories(args.target, { 
        tool: args.tool || 'dirsearch',
        recursive: args.recursive 
      }));
  • Core implementation of directory scanning logic: configures tool, executes selected scanner (dirb/dirsearch/gobuster/feroxbuster), parses results, analyzes risks, and returns structured ScanResult.
    async scanDirectories(target: string, config: Partial<DirectoryScanConfiguration> = {}): Promise<ScanResult> {
      try {
        const defaultConfig: DirectoryScanConfiguration = {
          tool: 'dirsearch',
          wordlist: this.getDefaultWordlist(),
          extensions: ['php', 'asp', 'aspx', 'jsp', 'html', 'htm', 'txt', 'xml', 'json', 'js', 'css'],
          threads: 30,
          timeout: 10,
          recursive: true,
          max_depth: 3,
          status_codes: [200, 201, 204, 301, 302, 307, 308, 401, 403, 405, 500],
          user_agent: 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36',
          delay: 0,
          ...config
        };
        
        console.error(`🔍 Directory scanning ${target} with ${defaultConfig.tool}`);
        
        let results: DirectoryResult[] = [];
        
        switch (defaultConfig.tool) {
          case 'dirb':
            results = await this.runDirb(target, defaultConfig);
            break;
          case 'dirsearch':
            results = await this.runDirsearch(target, defaultConfig);
            break;
          case 'gobuster':
            results = await this.runGobuster(target, defaultConfig);
            break;
          case 'feroxbuster':
            results = await this.runFeroxbuster(target, defaultConfig);
            break;
          default:
            throw new Error(`Unsupported tool: ${defaultConfig.tool}`);
        }
        
        // Analyze and categorize results
        const analyzedResults = this.analyzeResults(results);
        const sensitiveFiles = analyzedResults.filter(r => r.is_sensitive);
        const accessibleDirs = analyzedResults.filter(r => r.is_directory && r.status_code === 200);
        const highRiskFindings = analyzedResults.filter(r => r.risk_level === 'high' || r.risk_level === 'critical');
        
        return {
          target,
          timestamp: new Date().toISOString(),
          tool: 'directory_scanner',
          results: {
            scan_tool: defaultConfig.tool,
            total_discovered: results.length,
            accessible_directories: accessibleDirs.length,
            sensitive_files: sensitiveFiles.length,
            high_risk_findings: highRiskFindings.length,
            status_code_breakdown: this.groupByStatusCode(results),
            risk_level_breakdown: this.groupByRiskLevel(analyzedResults),
            discovered_paths: analyzedResults,
            security_recommendations: this.generateSecurityRecommendations(analyzedResults)
          },
          status: 'success'
        };
        
      } catch (error) {
        return {
          target,
          timestamp: new Date().toISOString(),
          tool: 'directory_scanner',
          results: {},
          status: 'error',
          error: error instanceof Error ? error.message : String(error)
        };
      }
    }
  • TypeScript interface defining configuration options for directory scanning tools, used in scanDirectories method.
    export interface DirectoryScanConfiguration {
      tool: 'dirb' | 'dirsearch' | 'gobuster' | 'feroxbuster';
      wordlist?: string;
      extensions?: string[];
      threads: number;
      timeout: number;
      recursive: boolean;
      max_depth: number;
      status_codes: number[];
      user_agent?: string;
      headers?: Record<string, string>;
      proxy?: string;
      delay?: number;
    }
  • Helper method to execute dirsearch tool, construct command with config, capture output, and parse into DirectoryResult array. Similar methods exist for other tools.
    private async runDirsearch(target: string, config: DirectoryScanConfiguration): Promise<DirectoryResult[]> {
      try {
        // Check if dirsearch is installed
        try {
          await execAsync('dirsearch -h', { timeout: 5000 });
        } catch {
          console.warn('dirsearch not found, skipping dirsearch scan');
          return [];
        }
        
        const extensions = config.extensions?.join(',') || 'php,asp,aspx,jsp,html';
        const statusCodes = config.status_codes.join(',');
        
        let command = `dirsearch -u ${target} -e ${extensions} -t ${config.threads} --timeout ${config.timeout}`;
        command += ` --include-status ${statusCodes}`;
        
        if (config.recursive) {
          command += ` -r --max-recursion-depth ${config.max_depth}`;
        }
        
        if (config.wordlist) {
          command += ` -w ${config.wordlist}`;
        }
        
        if (config.user_agent) {
          command += ` --user-agent "${config.user_agent}"`;
        }
        
        command += ' --format simple --quiet-mode';
        
        console.error(`Executing: ${command}`);
        
        const { stdout } = await execAsync(command, { 
          timeout: 600000, // 10 minutes
          maxBuffer: 1024 * 1024 * 20 // 20MB
        });
        
        return this.parseDirsearchOutput(stdout, target);
        
      } catch (error) {
        console.error('Dirsearch execution error:', error);
        return [];
      }
    }
Behavior2/5

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

No annotations are provided, so the description carries full burden for behavioral disclosure. It mentions 'Advanced directory scanning' but doesn't specify whether this is passive reconnaissance or active testing, what permissions or access are needed, potential impact on target systems, or output format. For a security scanning tool with zero annotation coverage, this is a significant gap.

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

Conciseness4/5

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

The description is a single, efficient phrase that front-loads the core functionality. However, it could be more structured by explicitly stating the purpose before listing tools, but it avoids unnecessary verbosity.

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

Completeness2/5

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

Given the complexity of a security scanning tool with no annotations and no output schema, the description is incomplete. It lacks details on behavior, output, error handling, and differentiation from siblings, making it inadequate for safe and effective use by an AI agent.

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

Parameters3/5

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

Schema description coverage is 100%, with clear parameter documentation in the schema. The description adds no additional parameter semantics beyond implying tool selection from the listed options, which is already covered by the enum. Baseline 3 is appropriate as the schema does the heavy lifting.

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

Purpose3/5

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

The description states the tool performs 'Advanced directory scanning' and lists specific tools (dirb/dirsearch/gobuster/feroxbuster), which clarifies the action and implementation method. However, it doesn't differentiate from sibling tools like 'directory_bruteforce' or 'fuzzing_directories', leaving ambiguity about when to choose this over those alternatives.

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

Usage Guidelines2/5

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

The description provides no guidance on when to use this tool versus alternatives. With siblings like 'directory_bruteforce' and 'fuzzing_directories' available, there's no indication of context, prerequisites, or comparative advantages, leaving the agent without usage direction.

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/adriyansyah-mf/mcp-pentest'

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