Skip to main content
Glama

test_active_directory

Perform Active Directory penetration testing to identify security vulnerabilities in domain controllers and network configurations.

Instructions

Comprehensive Active Directory penetration testing

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
targetYesDomain Controller IP address
domainNoDomain name (optional)

Implementation Reference

  • Main handler function for test_active_directory tool. Performs comprehensive Active Directory testing including LDAP enumeration, Kerberos checks, SMB shares, enum4linux, BloodHound collection, and Kerberoasting potential.
    async testActiveDirectory(target: string, domain?: string): Promise<ScanResult> {
      try {
        console.error(`🔍 Testing Active Directory on ${target}${domain ? ` (domain: ${domain})` : ''}`);
        
        const findings: string[] = [];
        const results: any = {};
        
        // Test 1: LDAP enumeration
        try {
          const ldapPort = 389;
          const { stdout: ldapOutput } = await execAsync(`nmap -p ${ldapPort} --script ldap-rootdse ${target}`, { timeout: 60000 });
          results.ldap_enumeration = ldapOutput;
          
          if (ldapOutput.includes('domainFunctionality')) {
            findings.push('Domain Controller detected via LDAP');
          }
          if (ldapOutput.includes('forestFunctionality')) {
            findings.push('Active Directory Forest detected');
          }
        } catch (e) {
          console.error('LDAP enumeration failed:', e);
        }
    
        // Test 2: Kerberos enumeration
        try {
          const { stdout: kerberosOutput } = await execAsync(`nmap -p 88 --script krb5-enum-users ${target}`, { timeout: 60000 });
          results.kerberos_enumeration = kerberosOutput;
          
          if (kerberosOutput.includes('KDC')) {
            findings.push('Kerberos Key Distribution Center detected');
          }
        } catch (e) {
          console.error('Kerberos enumeration failed:', e);
        }
    
        // Test 3: SMB enumeration for DC
        try {
          const { stdout: smbOutput } = await execAsync(`smbclient -L //${target} -N`, { timeout: 60000 });
          results.smb_enumeration = smbOutput;
          
          if (smbOutput.includes('SYSVOL') || smbOutput.includes('NETLOGON')) {
            findings.push('Domain Controller shares detected (SYSVOL/NETLOGON)');
          }
        } catch (e) {
          console.error('SMB enumeration failed:', e);
        }
    
        // Test 4: enum4linux for comprehensive enumeration
        try {
          const { stdout: enum4linuxOutput } = await execAsync(`enum4linux -a ${target}`, { timeout: 180000 });
          results.enum4linux = enum4linuxOutput;
          
          if (enum4linuxOutput.includes('Domain Name:')) {
            const domainMatch = enum4linuxOutput.match(/Domain Name:\s*([^\n]+)/);
            if (domainMatch) {
              findings.push(`Domain Name identified: ${domainMatch[1].trim()}`);
            }
          }
          if (enum4linuxOutput.includes('Users via RID cycling')) {
            findings.push('User enumeration possible via RID cycling');
          }
        } catch (e) {
          console.error('enum4linux failed:', e);
        }
    
        // Test 5: BloodHound data collection (if available)
        if (domain) {
          try {
            const { stdout: bloodhoundOutput } = await execAsync(`bloodhound-python -d ${domain} -u anonymous -p '' -ns ${target} --dns-tcp`, { timeout: 300000 });
            results.bloodhound_collection = bloodhoundOutput;
            
            if (bloodhoundOutput.includes('Resolved collection methods')) {
              findings.push('BloodHound data collection successful');
            }
          } catch (e) {
            console.error('BloodHound collection failed:', e);
          }
        }
    
        // Test 6: Kerberoasting check
        try {
          const { stdout: kerberoastOutput } = await execAsync(`nmap -p 88 --script krb5-enum-users --script-args krb5-enum-users.realm=${domain || target} ${target}`, { timeout: 120000 });
          results.kerberoasting_check = kerberoastOutput;
          
          if (kerberoastOutput.includes('SPN')) {
            findings.push('Service Principal Names detected - potential Kerberoasting targets');
          }
        } catch (e) {
          console.error('Kerberoasting check failed:', e);
        }
    
        return {
          target,
          timestamp: new Date().toISOString(),
          tool: 'active_directory_test',
          results: {
            service: 'Active Directory',
            domain: domain || 'Unknown',
            findings,
            detailed_results: results,
            recommendations: this.getADRecommendations(findings)
          },
          status: 'success'
        };
        
      } catch (error) {
        return {
          target,
          timestamp: new Date().toISOString(),
          tool: 'active_directory_test',
          results: {},
          status: 'error',
          error: error instanceof Error ? error.message : String(error)
        };
      }
    }
  • src/index.ts:365-376 (registration)
    Tool registration in the listTools handler, including name, description, and input schema definition.
    {
      name: "test_active_directory",
      description: "Comprehensive Active Directory penetration testing",
      inputSchema: {
        type: "object",
        properties: {
          target: { type: "string", description: "Domain Controller IP address" },
          domain: { type: "string", description: "Domain name (optional)" }
        },
        required: ["target"]
      }
    },
  • src/index.ts:574-575 (registration)
    Dispatch handler in the callTool switch statement that routes the tool call to the serviceSpecificTools.testActiveDirectory method.
    case "test_active_directory":
      return respond(await this.serviceSpecificTools.testActiveDirectory(args.target, args.domain));
  • Input schema definition for the test_active_directory tool.
    inputSchema: {
      type: "object",
      properties: {
        target: { type: "string", description: "Domain Controller IP address" },
        domain: { type: "string", description: "Domain name (optional)" }
      },
      required: ["target"]
    }
  • Helper method providing security recommendations based on Active Directory test findings.
    private getADRecommendations(findings: string[]): string[] {
      const recommendations: string[] = [];
      
      if (findings.some(f => f.includes('Domain Controller'))) {
        recommendations.push('Ensure Domain Controller is properly hardened');
        recommendations.push('Implement least privilege access controls');
        recommendations.push('Enable Advanced Audit Policy Configuration');
      }
      
      if (findings.some(f => f.includes('SYSVOL') || f.includes('NETLOGON'))) {
        recommendations.push('Secure SYSVOL and NETLOGON shares with proper permissions');
        recommendations.push('Monitor access to domain controller shares');
      }
      
      if (findings.some(f => f.includes('RID cycling'))) {
        recommendations.push('CRITICAL: Implement measures to prevent user enumeration');
        recommendations.push('Consider disabling null session enumeration');
      }
      
      if (findings.some(f => f.includes('Kerberoasting'))) {
        recommendations.push('Review Service Principal Names (SPNs)');
        recommendations.push('Use strong passwords for service accounts');
        recommendations.push('Consider using Group Managed Service Accounts (gMSA)');
      }
      
      recommendations.push('Implement Windows Event Forwarding (WEF)');
      recommendations.push('Deploy Microsoft Defender for Identity');
      recommendations.push('Regular security assessments using BloodHound');
      
      return recommendations;
    }
Behavior2/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. While 'penetration testing' implies potentially intrusive/destructive actions, the description doesn't specify whether this tool actually exploits vulnerabilities, just scans for them, requires special permissions, has rate limits, or produces specific outputs. This is a significant gap for a security testing tool with zero annotation coverage.

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

Conciseness5/5

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

The description is extremely concise - a single phrase that communicates the core function. There's no wasted language or unnecessary elaboration. While it could benefit from more detail, what's present is efficiently packaged.

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?

For a security testing tool with no annotations, no output schema, and potentially complex behavior, the description is inadequate. It doesn't explain what 'comprehensive' means, what specific tests are performed, what results to expect, or safety considerations. Given the context of many sibling security tools, more differentiation and behavioral detail would be expected.

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%, so the schema already documents both parameters (target and domain) adequately. The description adds no additional parameter information beyond what's in the schema - it doesn't explain format requirements, provide examples, or clarify the relationship between target and domain parameters. Baseline 3 is appropriate when 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 'Comprehensive Active Directory penetration testing', which clearly indicates a security testing function. However, it doesn't specify what specific actions it takes (e.g., enumeration, exploitation, vulnerability scanning) or how it differs from sibling tools like 'test_smb_service' or 'directory_scan' that might also interact with Active Directory components.

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 many sibling tools available for security testing (e.g., 'nmap_scan', 'directory_bruteforce', 'test_smb_service'), there's no indication of whether this is a broad-scope tool, when it's appropriate versus more targeted tools, or what prerequisites might be needed for Active Directory testing.

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