Skip to main content

Overview

The Targeted Pentest API provides focused penetration testing capabilities for specific targets and objectives. Unlike the full workflow, this API allows you to test individual endpoints or features with precise testing goals. Key Features:
  • Focused testing on specific targets
  • Custom testing objectives per target
  • Automatic PoC script generation
  • Finding deduplication across runs
  • Sandbox support for isolated execution
  • Browser automation for complex testing scenarios

runTargetedPentestAgent

Run a targeted penetration test against a specific target with defined objectives. Testing Methodology:
  1. PLAN: State objectives and outline testing approach
  2. VERIFY: Confirm target is reachable and understand baseline behavior
  3. PREPARE: Research payloads and attack techniques
  4. TEST: Execute targeted attacks methodically
  5. EXPLOIT: Create proof-of-concept scripts
  6. DOCUMENT: Document confirmed vulnerabilities
  7. FINISH: Submit final summary
import { runTargetedPentestAgent } from '@pensar/apex/api/targetedPentest';

const result = await runTargetedPentestAgent({
  target: 'https://api.example.com/users',
  objectives: [
    'Test for SQL injection vulnerabilities',
    'Check for authentication bypass',
    'Test for broken access control',
  ],
  model: 'claude-sonnet-4-20250514',
  session: sessionInfo,
});

console.log(`Found ${result.findings.length} vulnerabilities`);

Parameters

input
PentestAgentInput
required
Configuration for the targeted pentest agent

Response

findings
Finding[]
All vulnerability findings discovered during the test
findingsPath
string
Absolute path to the session’s findings directory where JSON reports are stored
pocsPath
string
Absolute path to the session’s POC scripts directory

Usage Examples

import { runTargetedPentestAgent } from '@pensar/apex/api/targetedPentest';
import { createSession } from '@pensar/apex/session';

const session = await createSession({
  name: 'API Security Test',
  targets: ['https://api.example.com'],
});

const result = await runTargetedPentestAgent({
  target: 'https://api.example.com/users',
  objectives: [
    'Test for SQL injection in search parameter',
    'Check for broken access control on user updates',
  ],
  model: 'claude-sonnet-4-20250514',
  session,
});

console.log(`Found ${result.findings.length} vulnerabilities`);
result.findings.forEach((finding) => {
  console.log(`[${finding.severity}] ${finding.title}`);
  console.log(`  PoC: ${finding.pocPath}`);
});

Testing Guidelines

Writing Effective Objectives

Objectives should be specific, actionable, and focused: Good objectives:
  • "Test SQL injection in username parameter on login endpoint"
  • "Check for authentication bypass via JWT token manipulation"
  • "Test for IDOR vulnerabilities on user profile update (PUT /api/users/:id)"
  • "Test XSS in post content and comment fields"
Avoid vague objectives:
  • "Test the API" (too broad)
  • "Find vulnerabilities" (not actionable)
  • "Security test" (no specific target)

Available Testing Capabilities

The agent has access to these testing tools:
  • execute_command: Run shell commands (curl, custom scripts, exploit tools)
  • http_request: Make HTTP requests with custom headers/body
  • browser_navigate: Load pages in a headless browser
  • browser_click: Interact with buttons and links
  • browser_fill: Fill form fields
  • browser_screenshot: Capture visual evidence
  • document_vulnerability: Document confirmed findings
  • create_poc: Generate proof-of-concept exploit scripts

Authentication Handling

If the session has authentication data (from prior auth or manual setup):
  • The agent automatically includes cookies and headers in all requests
  • Authentication is preserved across HTTP requests and browser actions
  • Session expiration is detected and reported

Blackbox Pentest

Full workflow with discovery + exploitation

Attack Surface

Discover targets before testing

Authentication

Authenticate before testing

Patching

Generate patches for findings

Build docs developers (and LLMs) love