Skip to main content
Glama

adaptive_strategy

Generate penetration testing strategies by analyzing detected services, technologies, and vulnerabilities to create targeted security assessments.

Instructions

Generate adaptive penetration testing strategy based on detected services and OS

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
portsYesArray of open ports and services
technologiesYesArray of detected technologies
existing_vulnsNoArray of existing vulnerabilities (optional)

Implementation Reference

  • Core handler function that executes the adaptive_strategy tool logic: detects OS, profiles services, analyzes attack vectors, plans testing phases, identifies priority targets, and assesses risk based on input ports and technologies.
    async generateStrategy(
      ports: PortScanResult[],
      technologies: TechDetectionResult[],
      existingVulns?: VulnerabilityResult[],
      existingCVEs?: CVEResult[]
    ): Promise<ScanResult> {
      try {
        console.error('🧠 Generating adaptive penetration testing strategy...');
        
        // Phase 1: OS Detection
        const osDetection = this.detectOperatingSystem(ports);
        console.error(`  Detected OS: ${osDetection.os_family} (${osDetection.confidence}% confidence)`);
        
        // Phase 2: Service Profiling
        const serviceProfiles = this.profileServices(ports, osDetection);
        console.error(`  Profiled ${serviceProfiles.length} services`);
        
        // Phase 3: Attack Vector Analysis
        const attackVectors = this.analyzeAttackVectors(ports, technologies, serviceProfiles, osDetection);
        console.error(`  Identified ${attackVectors.length} attack vectors`);
        
        // Phase 4: Testing Phase Planning
        const testingPhases = this.planTestingPhases(attackVectors, serviceProfiles, technologies);
        console.error(`  Planned ${testingPhases.length} testing phases`);
        
        // Phase 5: Priority Target Identification
        const priorityTargets = this.identifyPriorityTargets(serviceProfiles, technologies, existingVulns);
        console.error(`  Identified ${priorityTargets.length} priority targets`);
        
        // Phase 6: Risk Assessment
        const riskAssessment = this.assessRisk(ports, technologies, attackVectors, existingVulns, existingCVEs);
        console.error(`  Overall risk level: ${riskAssessment.overall_risk}`);
        
        const strategy: AdaptiveStrategy = {
          target: 'adaptive_strategy',
          os_detection: osDetection,
          service_profiles: serviceProfiles,
          technology_stack: technologies,
          attack_vectors: attackVectors,
          testing_phases: testingPhases,
          priority_targets: priorityTargets,
          risk_assessment: riskAssessment
        };
        
        return {
          target: 'adaptive_strategy',
          timestamp: new Date().toISOString(),
          tool: 'adaptive_strategy_engine',
          results: {
            strategy,
            execution_plan: this.generateExecutionPlan(strategy),
            estimated_duration: this.calculateEstimatedDuration(testingPhases),
            resource_requirements: this.calculateResourceRequirements(testingPhases),
            success_metrics: this.defineSuccessMetrics(strategy)
          },
          status: 'success'
        };
        
      } catch (error) {
        return {
          target: 'adaptive_strategy',
          timestamp: new Date().toISOString(),
          tool: 'adaptive_strategy_engine',
          results: {},
          status: 'error',
          error: error instanceof Error ? error.message : String(error)
        };
      }
    }
  • Input schema definition for the adaptive_strategy tool, specifying required ports and technologies arrays.
      name: "adaptive_strategy",
      description: "Generate adaptive penetration testing strategy based on detected services and OS",
      inputSchema: {
        type: "object",
        properties: {
          ports: { 
            type: "array", 
            items: { type: "object" },
            description: "Array of open ports and services" 
          },
          technologies: { 
            type: "array", 
            items: { type: "object" },
            description: "Array of detected technologies" 
          },
          existing_vulns: { 
            type: "array", 
            items: { type: "object" },
            description: "Array of existing vulnerabilities (optional)" 
          }
        },
        required: ["ports", "technologies"]
      }
    },
  • src/index.ts:567-572 (registration)
    Tool call dispatch/registration in the main switch handler, invoking AdaptiveStrategyEngine.generateStrategy.
    case "adaptive_strategy":
      return respond(await this.adaptiveStrategy.generateStrategy(
        args.ports, 
        args.technologies, 
        args.existing_vulns
      ));
  • src/index.ts:65-65 (registration)
    Instantiation of AdaptiveStrategyEngine used by the tool handler.
    this.adaptiveStrategy = new AdaptiveStrategyEngine();
  • Helper method for OS detection, key part of strategy generation.
    private detectOperatingSystem(ports: PortScanResult[]): OSDetectionResult {
      const evidence: string[] = [];
      let osFamily: 'windows' | 'linux' | 'unix' | 'mac' | 'unknown' = 'unknown';
      let confidence = 0;
      let osVersion: string | undefined;
      
      // Windows indicators
      const windowsPorts = [135, 139, 445, 3389, 5985, 5986]; // RPC, NetBIOS, SMB, RDP, WinRM
      const windowsServices = ['microsoft-ds', 'msrpc', 'rdp', 'winrm'];
      
      const windowsPortsFound = ports.filter(p => windowsPorts.includes(p.port));
      const windowsServicesFound = ports.filter(p => 
        windowsServices.some(ws => p.service.toLowerCase().includes(ws))
      );
      
      if (windowsPortsFound.length > 0 || windowsServicesFound.length > 0) {
        osFamily = 'windows';
        confidence += windowsPortsFound.length * 20 + windowsServicesFound.length * 25;
        
        if (windowsPortsFound.some(p => p.port === 445)) {
          evidence.push('SMB service detected (port 445)');
        }
        if (windowsPortsFound.some(p => p.port === 3389)) {
          evidence.push('RDP service detected (port 3389)');
        }
        if (windowsPortsFound.some(p => p.port === 135)) {
          evidence.push('RPC endpoint mapper detected (port 135)');
        }
        
        // Try to detect Windows version from service versions
        const smbService = ports.find(p => p.port === 445);
        if (smbService?.version) {
          if (smbService.version.includes('Windows Server 2019')) {
            osVersion = 'Windows Server 2019';
          } else if (smbService.version.includes('Windows Server 2016')) {
            osVersion = 'Windows Server 2016';
          } else if (smbService.version.includes('Windows 10')) {
            osVersion = 'Windows 10';
          } else if (smbService.version.includes('Windows Server 2012')) {
            osVersion = 'Windows Server 2012';
          }
        }
      }
      
      // Linux indicators
      const linuxPorts = [22, 80, 443, 25, 53, 110, 143, 993, 995]; // SSH, HTTP, SMTP, DNS, POP3, IMAP
      const linuxServices = ['openssh', 'apache', 'nginx', 'postfix', 'dovecot', 'bind'];
      
      const linuxPortsFound = ports.filter(p => linuxPorts.includes(p.port));
      const linuxServicesFound = ports.filter(p => 
        linuxServices.some(ls => p.service.toLowerCase().includes(ls) || p.version?.toLowerCase().includes(ls))
      );
      
      if (linuxServicesFound.length > 0) {
        if (osFamily === 'unknown' || confidence < 50) {
          osFamily = 'linux';
          confidence = linuxServicesFound.length * 15 + linuxPortsFound.length * 5;
          
          evidence.push('Linux services detected');
          
          // Try to detect specific distributions
          const sshService = ports.find(p => p.port === 22);
          if (sshService?.version) {
            if (sshService.version.includes('Ubuntu')) {
              osVersion = 'Ubuntu Linux';
              evidence.push('Ubuntu SSH banner detected');
            } else if (sshService.version.includes('Debian')) {
              osVersion = 'Debian Linux';
              evidence.push('Debian SSH banner detected');
            } else if (sshService.version.includes('CentOS') || sshService.version.includes('RHEL')) {
              osVersion = 'RedHat/CentOS Linux';
              evidence.push('RedHat/CentOS SSH banner detected');
            }
          }
        }
      }
      
      // macOS indicators
      const macServices = ['afp', 'apple-filing'];
      const macServicesFound = ports.filter(p => 
        macServices.some(ms => p.service.toLowerCase().includes(ms))
      );
      
      if (macServicesFound.length > 0) {
        osFamily = 'mac';
        confidence = macServicesFound.length * 30;
        evidence.push('Apple Filing Protocol detected');
      }
      
      // Generic Unix indicators
      const unixPorts = [513, 514, 515]; // rsh, syslog, printer
      const unixPortsFound = ports.filter(p => unixPorts.includes(p.port));
      
      if (unixPortsFound.length > 0 && osFamily === 'unknown') {
        osFamily = 'unix';
        confidence = unixPortsFound.length * 20;
        evidence.push('Unix services detected');
      }
      
      // Confidence normalization
      confidence = Math.min(confidence, 95); // Cap at 95%
      
      if (confidence < 30) {
        osFamily = 'unknown';
        evidence.push('Insufficient evidence for OS detection');
      }
      
      return {
        os_family: osFamily,
        os_version: osVersion,
        confidence,
        evidence
      };
    }
Behavior2/5

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

With no annotations provided, the description carries full burden but only states what the tool does, not how it behaves. It doesn't disclose whether this is a read-only analysis, if it modifies systems, requires specific permissions, has rate limits, or what the output format might be. This leaves critical behavioral traits undefined for a tool in a security testing context.

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 a single, efficient sentence that gets straight to the point with no wasted words. It's appropriately sized for the tool's complexity and front-loads the core functionality without unnecessary elaboration.

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 tool with 3 parameters, no annotations, and no output schema in a complex penetration testing domain, the description is inadequate. It doesn't explain what constitutes a 'strategy', what format it returns, how it adapts, or any behavioral constraints. Given the rich sibling toolset and security context, more completeness is needed.

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 all three parameters. The description mentions 'detected services and OS' which loosely maps to 'ports' and 'technologies', but adds no meaningful semantic context beyond what the schema provides. The baseline of 3 is appropriate given the comprehensive schema coverage.

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

Purpose4/5

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

The description clearly states the action ('generate') and the resource ('adaptive penetration testing strategy'), specifying it's based on detected services and OS. It distinguishes from siblings like 'suggest_next_steps' by focusing on strategy generation rather than general recommendations, but doesn't explicitly differentiate from all tools.

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 like 'suggest_next_steps' or 'generate_report'. It mentions the input basis but offers no context about prerequisites, timing, or exclusions relative to other penetration testing tools in the sibling list.

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