Pentesting

From j4flmao/agent-skills · View interactive version

Pentesting is an AI agent skill from the GitHub repository j4flmao/agent-skills. Use when the user asks to scope or manage a penetration test, write rules of engagement, run a bug bounty program, or write and triage a pentest report with CVSS scores. Produces engagement scope, ROE and report templates. Not for testing methodology and techniques (use red-team-pentest-methodology)

How to use this skill

Skill file

Penetration Testing

Purpose

Produce structured penetration testing reports with methodology, severity-classified findings, evidence format, and remediation tracking.

Agent Protocol

Trigger

User request includes: pentest, penetration test, security test, bug bounty, vulnerability assessment, ethical hacking, red team, security assessment.

Input Context

Output Artifact

A markdown document containing:

Response Format

Produce the artifact directly. No preamble. No postamble. No explanations. No filler/hedging/transitions. Compress output — why use many token when few do trick.


Completion Criteria

Max Response Length

4096 tokens

Workflow

Step 1: Define Scope

Document in-scope and out-of-scope targets, testing methodology (black/grey/white box), timeframe, and tools.

Step 2: Execute Tests

Follow OWASP/OSSTMM methodology, covering injection, auth, access control, XSS, SSRF, misconfiguration, crypto, and info leakage.

Step 3: Classify Findings

Score each finding using CVSS v4.0 (or v3.1 where the client's tooling or contract requires it — state the version) and assign severity (Critical/High/Medium/Low/Info).

Step 4: Write Executive Summary

Summarize scope, overall risk rating, key findings count, and business impact for non-technical stakeholders.

Step 5: Document Each Finding

Each finding includes: title, severity, CVSS score, status, location, description, impact, reproduction steps, evidence, recommendation.

Step 6: Assign Remediation

Map each finding to an owner with a fix timeline per severity SLA.

Step 7: Threat Modeling

Perform threat modeling using STRIDE or PASTA before testing. Identify assets, threat agents, attack vectors, and security controls. Prioritize testing based on threat model findings. Map test cases to threats.

Step 8: Reconnaissance and Enumeration

Gather information about targets: DNS enumeration, subdomain discovery, technology fingerprinting, endpoint discovery, directory brute force, parameter discovery. Document all discovered surface area.

Step 9: Vulnerability Analysis

Correlate findings across test types. Eliminate false positives. Chain vulnerabilities to demonstrate realistic impact. Validate each finding manually. Prioritize chained attack paths.

Step 10: Reporting and Remediation Tracking

Generate structured report. Hold findings review with development team. Track remediation in issue tracker. Schedule retesting after fixes. Update risk register.

Framework / Methodologies

Pentest Methodology Comparison

| Aspect | OWASP | PTES | OSSTMM | NIST SP 800-115 |

|--------|-------|------|--------|-----------------|

| Focus | Web applications | Full penetration test | Security metrics | Technical assessment |

| Structure | 12 testing categories | 7 phases | 5 channels (physical, human, wireless, telecom, data) | 4 phases |

| Scoring | Risk rating methodology | CVSS + custom | STAR (Security Test Audit Report) | N/A |

| Best For | Web app pentesting | Comprehensive pentest | Audit/compliance | Government/enterprise |

| Maturity | Highly mature | Moderate | Very mature | Highly mature |

| Industry adoption | Most widely adopted | Common | Less common | Government standard |

Decision Tree: Pentest Type Selection

What is being tested?
  ├── Web application
  │   ├── Internal app → Grey box, OWASP methodology
  │   └── External app → Black box + grey box, OWASP, DAST + manual
  ├── Mobile application
  │   ├── iOS → IPA analysis, runtime manipulation, network interception
  │   └── Android → APK analysis, rooted device testing, intent fuzzing
  ├── API / Microservices
  │   └── Grey box, OpenAPI-based testing, auth testing, injection, rate limiting
  ├── Cloud infrastructure
  │   ├── AWS → IAM analysis, S3 permissions, CloudTrail audit
  │   ├── GCP → IAM, GKE security, Cloud SQL audit
  │   └── Azure → RBAC, Key Vault, App Service, AKS security
  ├── Network infrastructure
  │   ├── Internal → Lateral movement, AD security, network segmentation
  │   └── External → Port scanning, service enumeration, exploit testing
  └── Physical / Social engineering
      └── OSSTMM methodology, physical access testing, phishing simulation

Testing Types Comparison

| Type | Reconnaissance | Access | Knowledge | Accuracy | Coverage | Cost |

|------|---------------|--------|-----------|----------|----------|------|

| Black box | Full | None | None | Medium | Low | High |

| Grey box | Targeted | Some | Architecture | High | Medium | Medium |

| White box | Technical docs | Full access | Full code | Very high | High | Low |

| DAST | None | None | None | High | Medium | Low |

| SAST | Full source | Full code | Full | Medium | High | Low-medium |

| Bug bounty | None | None | None | High | Variable | Pay per finding |

Common Pitfalls

Pitfall 1: Testing Without a Clear Scope

Starting a pentest without clearly documented scope leads to disputes about what was included, missed targets, and wasted effort. Always define in-scope and out-of-scope in writing. Include URL/IP lists and explicit exclusions.

Pitfall 2: Relying Only on Automated Scanners

Automated scanners produce high false-positive rates and miss logic flaws, business logic vulnerabilities, and chained attacks. DAST tools only catch known patterns. Manual testing is essential for high-severity findings.

Pitfall 3: Not Validating Findings

Reporting scanner output without manual validation produces reports full of false positives that teams learn to ignore. Manually validate every finding before including it in the report. Document validation steps in the finding.

Pitfall 4: Incomplete Evidence Documentation

Findings without clear reproduction steps, request/response pairs, or screenshots cannot be reproduced or fixed. Document evidence as you go — recreating evidence later is time-consuming and error-prone.

Pitfall 5: CVSS Without Vector String

Reporting a CVSS score without the vector string makes the score meaningless — it cannot be verified or recalculated if the environment changes. Always include the full vector string.

Pitfall 6: Not Testing Authentication and Authorization Thoroughly

Many testers check basic login/logout but miss IDOR, privilege escalation, session fixation, and JWT vulnerabilities. These are often the highest-impact findings. Dedicate significant testing time to auth and access control.

Pitfall 7: Ignoring Business Logic

Automated scanners don't test business logic — multi-step workflows, approval chains, financial calculations, and user role interactions. Manual business logic testing frequently finds critical vulnerabilities.

Pitfall 8: Reporting Without Remediation Guidance

Finding vulnerabilities without actionable remediation guidance frustrates development teams and delays fixes. Every finding must include specific, actionable recommendation code snippets where possible.

Pitfall 9: Not Sanitizing Evidence

Including live credentials, real customer data, or internal IP addresses in reports creates a secondary security incident. Sanitize all evidence before including it in the report.

Pitfall 10: Missing Retesting After Fixes

Remediation verification is as important as initial testing. Without retesting, you cannot confirm that fixes are effective or that they haven't introduced new issues. Schedule retesting as part of the engagement.

Best Practices

Templates & Tools

Pentest Scope Definition

engagement:
  title: External Web Application Pentest
  client: Acme Corp
  date: 2026-04-15 to 2026-04-26
  methodology: OWASP Web Application Testing Guide v4.2
  testing_type: Grey box
  in_scope:
    targets:
      - https://app.acme.com
      - https://api.acme.com/v2
      - https://admin.acme.com
    testing_allowed:
      - Authentication and session testing
      - Injection testing
      - Business logic testing
      - Access control testing
  out_of_scope:
    - Third-party services (Auth0, Stripe, AWS)
    - Denial of Service attacks
    - Physical security
    - Social engineering
    - Employee accounts (testing accounts provided)
  rules_of_engagement:
    - Testing hours: 08:00 - 18:00 local time only
    - No destructive testing without approval
    - Emergency contact: security@acme.com / +1-555-0123
    - Report critical findings immediately, not in final report
    - Data handling: all data destroyed 30 days after report delivery

Finding Template

finding:
  id: PENTEST-2026-001
  title: SQL Injection in Order Search
  severity: Critical
  cvss: "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H"
  cvss_score: 9.8
  status: Open
  location: "POST /api/v2/orders/search (order-service)"
  discovered: 2026-04-16
  description: |
    The `q` parameter in the order search endpoint is directly concatenated
    into SQL queries without parameterization or sanitization.
  impact: |
    An unauthenticated attacker can extract, modify, or delete all database
    records, including user credentials, payment information, and order data.
  reproduction:
    - Step 1: Intercept request to POST /api/v2/orders/search
    - Step 2: Set payload: q=1' OR '1'='1
    - Step 3: Observe that all orders are returned instead of user's orders
    - Step 4: Extract data using UNION-based injection
  evidence:
    request: "POST /api/v2/orders/search HTTP/1.1\nContent-Type: application/json\n\n{\"q\":\"1' OR '1'='1\"}"
    response: "HTTP/1.1 200 OK\n... (150 orders returned, including orders from other users)"
  recommendation: |
    Replace string concatenation with parameterized queries:
    ```python
    cursor.execute("SELECT * FROM orders WHERE user_id = %s AND search LIKE %s",
                   (user_id, f"%{search_term}%"))
    ```
  remediation:
    owner: team-orders
    due_date: 2026-04-17
    verification: Re-test after deployment to staging
  references:
    - https://owasp.org/www-community/attacks/SQL_Injection
    - https://cheatsheetseries.owasp.org/cheatsheets/SQL_Injection_Prevention_Cheat_Sheet.html

Tool Selection Matrix

| Tool Category | Recommended Tools | Use Case | Cost |

|---------------|-------------------|----------|------|

| Scanner (web) | Burp Suite Professional, OWASP ZAP | Web app scanning | $$ / Free |

| Scanner (network) | Nessus, OpenVAS | Network vulnerabilities | $$ / Free |

| Scanner (cloud) | ScoutSuite, Prowler, CloudSploit | Cloud config review | Free |

| Reconnaissance | Amass, Sublist3r, ffuf, gau, httpx | Subdomain and endpoint discovery | Free |

| Exploitation | Metasploit, Cobalt Strike | Post-exploitation | Free / $$$ |

| Mobile | MobSF, Frida, objection, jadx | Mobile app analysis | Free |

| Wireless | Aircrack-ng, Kismet, Reaver | Wireless security | Free |

| Password | Hashcat, John the Ripper, Hydra | Password cracking | Free |

| OSINT | Maltego, theHarvester, Shodan | Intelligence gathering | Free / $$ |

| DAST | Burp Scanner, Acunetix, Netsparker | Automated web scanning | $$ / $$$ |

| SAST | Semgrep, CodeQL, SonarQube | Source code analysis | Free / $$ |

| API | Postman, Insomnia, Burp | API security testing | Free / $ |

Case Studies (illustrative scenarios — figures are examples, not sourced benchmarks)

Case Study 1: E-Commerce SQL Injection

During a grey-box pentest of an e-commerce platform, the tester found a SQL injection in the order search endpoint. The automated scanner flagged the parameter but the test team validated it manually by extracting database version and table structure. Chaining this with an information disclosure finding (debug endpoint exposed database schema) demonstrated complete database compromise. Remediation: parameterized queries implemented within 4 hours of the finding being reported.

Case Study 2: Cloud Misconfiguration Leading to Data Breach

An infrastructure pentest of an AWS environment using ScoutSuite found 47 S3 buckets with public read access. Manual validation confirmed that 12 buckets contained PII (customer names, emails, purchase history). The finding was escalated to CISO within 24 hours. Remediation: S3 bucket policies updated, CloudTrail enhanced, and automated compliance scanning implemented.

Case Study 3: Business Logic Flaw in Payment Processing

During an API pentest, manual business logic testing revealed that a payment API did not validate that the requesting user owned the order they were paying for. An attacker could change another user's order amount from $100 to $0.01 and pay the reduced amount. No automated scanner would catch this. Remediation: server-side ownership validation was added.

Case Study 4: JWT Authentication Bypass

A mobile app pentest using Frida and runtime manipulation discovered that the app accepted unsigned JWTs with arbitrary user IDs. The finding was validated by creating a JWT with {"sub": "admin", "role": "admin"} and no signature, which the server accepted. Root cause: the server verification library was misconfigured in "debug mode". Remediation: JWT signature verification properly configured, production configs reviewed.

Rules

Report Structure

1. Executive Summary

2. Scope

3. Risk Scoring

| Severity | CVSS score range | Impact | Exploitability | Count |

|----------|----------|--------|----------------|-------|

| Critical | 9.0-10.0 | Complete compromise | Easy, public exploit | # |

| High | 7.0-8.9 | Significant data/access | Moderate | # |

| Medium | 4.0-6.9 | Limited impact | Complex | # |

| Low | 0.1-3.9 | Minimal | Very complex | # |

| Info | 0.0 | No direct risk | N/A | # |

4. Finding Format

Each finding MUST contain:

[CRITICAL] SQL Injection in Order Search

ID: PENTEST-2026-001

Severity: Critical (CVSS 9.8)

Status: Open / Fixed / Accepted / Mitigated

Location: POST /api/v2/orders/search (order-service)

Description

The q parameter is directly concatenated into SQL query without parameterization.

Impact

An attacker can extract, modify, or delete all database records.

Reproduction

  1. Intercept request to POST /api/v2/orders/search
  2. Set payload: q=1' OR '1'='1
  3. Observe that all orders are returned

Evidence

Request: POST /api/orders/search

Payload: q=1' OR '1'='1

Response: 200 OK (150 orders returned, including orders from other users)

Recommendation

Replace string concatenation with parameterized queries.

Remediation

Remediation SLA

| Severity | Fix Timeline | Verification | Escalation |

|----------|-------------|--------------|------------|

| Critical | 24 hours | Re-test required | CISO |

| High | 7 days | Re-test required | Security lead |

| Medium | 30 days | Code review | Engineering manager |

| Low | 90 days | Code review | Team lead |

Common Findings Catalog

| Category | Finding | Typical Severity |

|----------|---------|-----------------|

| Injection | SQL, NoSQL, Command, LDAP injection | Critical/High |

| Auth | Broken authentication, session fixation, weak password policy | Critical/High |

| Access Control | IDOR, privilege escalation, missing function-level access control | High |

| XSS | Stored, Reflected, DOM-based | Medium/High |

| SSRF | Server-side request forgery | High |

| Misconfiguration | Default credentials, debug endpoints, CORS misconfig | Medium |

| Crypto | Weak TLS, hardcoded keys, weak hashing | Medium |

| Info Leakage | Stack traces, error messages, directory listing | Low/Info |

References

Handoff

Hand off to management/security/SKILL.md for vulnerability remediation workflow. Hand off to management/alerting/SKILL.md for detection rule creation.

Architecture Decision Trees

Testing Approach

| Decision Point | Option A | Option B | Decision Criteria |

|---|---|---|---|

| Knowledge level | Black box (realistic external) | White box (thorough coverage) | Budget, compliance requirements |

| Methodology | OWASP WSTG (web-focused) | PTES (comprehensive) | Application type, org maturity |

| Tool selection | Automated scanners (efficient) | Manual testing (deep findings) | Time constraints, finding quality needs |

Scope Definition

Implementation Patterns

Pentest Report Template

`markdown

Pentest Report: {target}

Executive Summary

Critical Findings

{finding title}

Risk Summary

| Risk Level | Count | Examples |

|---|---|---|

| Critical | {n} | {titles} |

| High | {n} | {titles} |

| Medium | {n} | {titles} |

| Low | {n} | {titles} |

`

Vulnerability Reproduction Steps

`markdown

SQL Injection in /api/users endpoint

  1. Login as standard user
  2. Intercept request to GET /api/users?id=1
  3. Modify id parameter: 1 UNION SELECT username,password FROM admin_users
  4. Observe admin credentials in response

Remediation

`

`

Production Considerations

Rules of Engagement

Quality Assurance

Anti-Patterns

| Anti-Pattern | Symptom | Solution |

|---|---|---|

| Scanner-only testing | 50+ false positives, no real findings | Always manually verify scanner findings |

| No retest window | Findings never get validated | Contractually require retest within 30 days |

| Scope creep | Missed critical areas due to unfocused testing | Strictly define scope and stick to it |

| Findings without business context | Management ignores report | Add business impact, regulatory risk, remediation cost |

| No evidence | Cannot reproduce findings | Screenshots, request/response pairs, proof of concept |

Performance Optimization

Efficiency Techniques

Time Management

Security Considerations

Operational Security

Confidentiality

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.