Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 11 additions & 9 deletions src/AI/AI-Assisted-Fuzzing-and-Vulnerability-Discovery.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
{{#include ../banners/hacktricks-training.md}}

## Overview
Large-language models (LLMs) can super-charge traditional vulnerability-research pipelines by generating semantically rich inputs, evolving grammars, reasoning over crash data, and even proposing multi-bug patches. This page collects the most effective patterns observed during DARPA’s AI Cyber Challenge (AIxCC) finals and other public research.
Large-language models (LLMs) can super-charge traditional vulnerability-research pipelines by generating semantically rich inputs, evolving grammars, reasoning over crash data, and even proposing multi-bug patches. This page collects the most effective patterns observed during DARPA’s AI Cyber Challenge (AIxCC) finals and other public research.<sup>[[4]](#references)[[5]](#references)</sup>

What follows is not a description of one specific competition system, but an abstraction of the techniques so you can reproduce them in your own workflows.

Expand Down Expand Up @@ -135,7 +135,7 @@ Implement a queue where confirmed PoV-validated patches and *speculative* patche

## 6. Deterministic File-by-File AI Code Review

A frequent failure mode in AI-assisted review is asking one agent to inspect a whole repository and hoping it chooses the right files and grep terms. A more reliable pattern is to **force repository coverage**:
A frequent failure mode in AI-assisted review is asking one agent to inspect a whole repository and hoping it chooses the right files and grep terms. A more reliable pattern is to **force repository coverage**:<sup>[[1]](#references)</sup>

1. Enumerate source files.
2. Send **one file at a time** plus minimal context (entrypoint, imports, nearby routes/callers).
Expand All @@ -152,8 +152,8 @@ This is token-heavy and noisy, but it is very effective at surfacing **simple hi

### Two practical bug classes this method finds well

- **PHP controller-dispatch LFI/RCE**: if a request-controlled controller name is concatenated into `require_once()` with no allowlist/path normalisation, traversal sequences such as `../` can make PHP include an unintended local `.php` file. If the attacker can point the include at a planted or otherwise useful PHP file, the LFI becomes code execution. See [File Inclusion / Path Traversal](../pentesting-web/file-inclusion/README.md).
- **Authenticated command injection in hosting/admin panels**: if account-management fields such as usernames are embedded into shell commands, a low-privileged authenticated user may turn a normal create/delete action into RCE. The impact increases when the panel executes the command as a more privileged service account. See [Command Injection](../pentesting-web/command-injection.md).
- **PHP controller-dispatch LFI/RCE**: if a request-controlled controller name is concatenated into `require_once()` with no allowlist/path normalisation, traversal sequences such as `../` can make PHP include an unintended local `.php` file. If the attacker can point the include at a planted or otherwise useful PHP file, the LFI becomes code execution. See [File Inclusion / Path Traversal](../pentesting-web/file-inclusion/README.md).<sup>[[1]](#references)</sup>
- **Authenticated command injection in hosting/admin panels**: if account-management fields such as usernames are embedded into shell commands, a low-privileged authenticated user may turn a normal create/delete action into RCE. The impact increases when the panel executes the command as a more privileged service account. See [Command Injection](../pentesting-web/command-injection.md).<sup>[[1]](#references)</sup>

### Practical review notes

Expand Down Expand Up @@ -183,9 +183,11 @@ graph TD
---

## References
* [Project Black - Local AI for Cyber Security: Finding phpIPAM LFI and myVesta Authenticated RCE](https://projectblack.io/blog/local-ai-for-cyber-security)
* [Strix](https://github.com/usestrix/strix)
* [GitHub Copilot community security-review skill](https://github.com/github/awesome-copilot/blob/main/skills/security-review/SKILL.md)
* [Trail of Bits – AIxCC finals: Tale of the tape](https://blog.trailofbits.com/2025/08/07/aixcc-finals-tale-of-the-tape/)
* [CTF Radiooo AIxCC finalist interviews](https://www.youtube.com/@ctfradiooo)

- [1] [Project Black - Local AI for Cyber Security: Finding phpIPAM LFI and myVesta Authenticated RCE](https://projectblack.io/blog/local-ai-for-cyber-security)
- [2] [Strix](https://github.com/usestrix/strix)
- [3] [GitHub Copilot community security-review skill](https://github.com/github/awesome-copilot/blob/main/skills/security-review/SKILL.md)
- [4] [Trail of Bits – AIxCC finals: Tale of the tape](https://blog.trailofbits.com/2025/08/07/aixcc-finals-tale-of-the-tape/)
- [5] [CTF Radiooo AIxCC finalist interviews](https://www.youtube.com/@ctfradiooo)

{{#include ../banners/hacktricks-training.md}}
26 changes: 13 additions & 13 deletions src/AI/AI-Burp-MCP.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

## Overview

Burp's **MCP Server** extension can expose intercepted HTTP(S) traffic to MCP-capable LLM clients so they can **reason over real requests/responses** for passive vulnerability discovery and report drafting. The intent is evidence-driven review (no fuzzing or blind scanning), keeping Burp as the source of truth.
Burp's **MCP Server** extension can expose intercepted HTTP(S) traffic to MCP-capable LLM clients so they can **reason over real requests/responses** for passive vulnerability discovery and report drafting. The intent is evidence-driven review (no fuzzing or blind scanning), keeping Burp as the source of truth.<sup>[[1]](#references)</sup>

## Architecture

Expand All @@ -17,15 +17,15 @@ Burp's **MCP Server** extension can expose intercepted HTTP(S) traffic to MCP-ca

### 1) Install Burp MCP Server

Install **MCP Server** from the Burp BApp Store and verify it is listening on `127.0.0.1:9876`.
Install **MCP Server** from the Burp BApp Store and verify it is listening on `127.0.0.1:9876`.<sup>[[3]](#references)</sup>

### 2) Extract the proxy JAR

In the MCP Server tab, click **Extract server proxy jar** and save `mcp-proxy.jar`.

### 3) Configure an MCP client (Codex example)

Point the client to the proxy JAR and Burp's SSE endpoint:
Point the client to the proxy JAR and Burp's SSE endpoint:<sup>[[1]](#references)</sup>

```toml
# ~/.codex/config.toml
Expand All @@ -43,7 +43,7 @@ codex

### 4) Fix strict Origin/header validation with Caddy (if needed)

If the MCP handshake fails due to strict `Origin` checks or extra headers, use a local reverse proxy to normalize headers (this matches the workaround for the Burp MCP strict validation issue).
If the MCP handshake fails due to strict `Origin` checks or extra headers, use a local reverse proxy to normalize headers (this matches the workaround for the Burp MCP strict validation issue).<sup>[[1]](#references)[[4]](#references)</sup>

```bash
brew install caddy
Expand Down Expand Up @@ -81,7 +81,7 @@ codex

### Gemini CLI

The **burp-mcp-agents** repo provides launcher helpers:
The **burp-mcp-agents** repo provides launcher helpers:<sup>[[2]](#references)</sup>

```bash
source /path/to/burp-mcp-agents/gemini-cli/burpgemini.sh
Expand All @@ -105,7 +105,7 @@ Example local models and approximate VRAM needs:

## Prompt pack for passive review

The **burp-mcp-agents** repo includes prompt templates for evidence-driven analysis of Burp traffic:
The **burp-mcp-agents** repo includes prompt templates for evidence-driven analysis of Burp traffic:<sup>[[2]](#references)</sup>

- `passive_hunter.md`: broad passive vulnerability surfacing.
- `idor_hunter.md`: IDOR/BOLA/object/tenant drift and auth mismatches.
Expand Down Expand Up @@ -133,7 +133,7 @@ Replace: User-Agent: $1 BugBounty-Username

## Burp AI Agent (AI-assisted triage + MCP tools)

**Burp AI Agent** is a Burp extension that couples local/cloud LLMs with passive/active analysis (62 vulnerability classes) and exposes 53+ MCP tools so external MCP clients can orchestrate Burp. Highlights:
**Burp AI Agent** is a Burp extension that couples local/cloud LLMs with passive/active analysis (62 vulnerability classes) and exposes 53+ MCP tools so external MCP clients can orchestrate Burp. Highlights:<sup>[[5]](#references)</sup>

- **Context-menu triage**: capture traffic via Proxy, open **Proxy > HTTP History**, right-click a request → **Extensions > Burp AI Agent > Analyze this request** to spawn an AI chat bound to that request/response.
- **Backends** (selectable per profile):
Expand All @@ -153,14 +153,14 @@ JAVA_HOME=/path/to/jdk-21 ./gradlew clean shadowJar
# load build/libs/Burp-AI-Agent-<version>.jar via Burp Extensions > Add (Java)
```

Operational cautions: cloud backends may exfiltrate session cookies/PII unless privacy mode is enforced; MCP exposure grants remote orchestration of Burp so restrict access to trusted agents and monitor the integrity-hashed audit log.
Operational cautions: cloud backends may exfiltrate session cookies/PII unless privacy mode is enforced; MCP exposure grants remote orchestration of Burp so restrict access to trusted agents and monitor the integrity-hashed audit log.<sup>[[5]](#references)</sup>

## References

- [Burp MCP + Codex CLI integration and Caddy handshake fix](https://pentestbook.six2dez.com/others/burp)
- [Burp MCP Agents (workflows, launchers, prompt pack)](https://github.com/six2dez/burp-mcp-agents)
- [Burp MCP Server BApp](https://portswigger.net/bappstore/9952290f04ed4f628e624d0aa9dccebc)
- [PortSwigger MCP server strict Origin/header validation issue](https://github.com/PortSwigger/mcp-server/issues/34)
- [Burp AI Agent](https://github.com/six2dez/burp-ai-agent)
- [1] [Burp MCP + Codex CLI integration and Caddy handshake fix](https://pentestbook.six2dez.com/others/burp)
- [2] [Burp MCP Agents (workflows, launchers, prompt pack)](https://github.com/six2dez/burp-mcp-agents)
- [3] [Burp MCP Server BApp](https://portswigger.net/bappstore/9952290f04ed4f628e624d0aa9dccebc)
- [4] [PortSwigger MCP server strict Origin/header validation issue](https://github.com/PortSwigger/mcp-server/issues/34)
- [5] [Burp AI Agent](https://github.com/six2dez/burp-ai-agent)

{{#include ../banners/hacktricks-training.md}}
7 changes: 4 additions & 3 deletions src/AI/AI-llm-architecture/1.-tokenizing.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

## Tokenizing

**Tokenizing** is the process of breaking down data, such as text, into smaller, manageable pieces called _tokens_. Each token is then assigned a unique numerical identifier (ID). This is a fundamental step in preparing text for processing by machine learning models, especially in natural language processing (NLP).
**Tokenizing** is the process of breaking down data, such as text, into smaller, manageable pieces called _tokens_. Each token is then assigned a unique numerical identifier (ID). This is a fundamental step in preparing text for processing by machine learning models, especially in natural language processing (NLP).<sup>[[1]](#references)</sup>

> [!TIP]
> The goal of this initial phase is very simple: **Divide the input in tokens (ids) in some way that makes sense**.
Expand Down Expand Up @@ -73,7 +73,7 @@ While the basic tokenizer works well for simple texts, it has limitations, espec

## Code Example

Let's understand this better from a code example from [https://github.com/rasbt/LLMs-from-scratch/blob/main/ch02/01_main-chapter-code/ch02.ipynb](https://github.com/rasbt/LLMs-from-scratch/blob/main/ch02/01_main-chapter-code/ch02.ipynb):
Let's understand this better from a code example from [https://github.com/rasbt/LLMs-from-scratch/blob/main/ch02/01_main-chapter-code/ch02.ipynb](https://github.com/rasbt/LLMs-from-scratch/blob/main/ch02/01_main-chapter-code/ch02.ipynb):<sup>[[2]](#references)</sup>

```python
# Download a text to pre-train the model
Expand All @@ -96,7 +96,8 @@ print(token_ids[:50])

## References

- [https://www.manning.com/books/build-a-large-language-model-from-scratch](https://www.manning.com/books/build-a-large-language-model-from-scratch)
- [1] [Build a Large Language Model (From Scratch)](https://www.manning.com/books/build-a-large-language-model-from-scratch)
- [2] [LLMs-from-scratch - ch02 tokenizer notebook](https://github.com/rasbt/LLMs-from-scratch/blob/main/ch02/01_main-chapter-code/ch02.ipynb)


{{#include ../../banners/hacktricks-training.md}}
14 changes: 7 additions & 7 deletions src/AI/AI-llm-architecture/2.-data-sampling.md
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ Using the same tokenized text and `max_length` of 4:

## Code Example

Let's understand this better from a code example from [https://github.com/rasbt/LLMs-from-scratch/blob/main/ch02/01_main-chapter-code/ch02.ipynb](https://github.com/rasbt/LLMs-from-scratch/blob/main/ch02/01_main-chapter-code/ch02.ipynb):
Let's understand this better from a code example from [https://github.com/rasbt/LLMs-from-scratch/blob/main/ch02/01_main-chapter-code/ch02.ipynb](https://github.com/rasbt/LLMs-from-scratch/blob/main/ch02/01_main-chapter-code/ch02.ipynb):<sup>[[1]](#references)</sup>

```python
# Download the text to pre-train the LLM
Expand Down Expand Up @@ -248,7 +248,7 @@ p(i) = \frac{w_i^{\alpha}}{\sum_j w_j^{\alpha}}
• *w<sub>i</sub>* – raw token percentage of corpus *i*
• *α* ("temperature") – a value in (0,1]. α < 1 flattens the distribution, giving more weight to smaller high-quality corpora.

Llama 2 used α = 0.7 and showed that decreasing α boosted evaluation scores on knowledge-heavy tasks while keeping the training mix stable. The same trick is adopted by Mistral (2023) and Claude 3.
Llama 2 used α = 0.7 and showed that decreasing α boosted evaluation scores on knowledge-heavy tasks while keeping the training mix stable.<sup>[[2]](#references)</sup> The same trick is adopted by Mistral (2023) and Claude 3.

```python
from collections import Counter
Expand Down Expand Up @@ -277,12 +277,12 @@ Repeated passages cause memorization and provide an easy channel for data-poison
2. Filter documents whose perplexity under a small reference model is > µ + 3σ (noisy OCR, garbled HTML).
3. Block-list documents that contain PII or CWE keywords using regex & spaCy NER.

The Llama 2 team deduplicated with 8-gram MinHash and removed ~15 % of CommonCrawl before sampling. OpenAI’s 2024 "Deduplicate Everything" paper demonstrates ≤0.04 duplicate ratio reduces over-fitting and speeds convergence.
The Llama 2 team deduplicated with 8-gram MinHash and removed ~15 % of CommonCrawl before sampling.<sup>[[2]](#references)</sup> OpenAI’s 2024 "Deduplicate Everything" paper demonstrates ≤0.04 duplicate ratio reduces over-fitting and speeds convergence.

## Security & Privacy Considerations During Sampling

### Data-Poisoning / Backdoor Attacks
Researchers showed that inserting <1 % backdoored sentences can make a model obey a hidden trigger ("PoisonGPT", 2023). Recommended mitigations:
Researchers showed that inserting <1 % backdoored sentences can make a model obey a hidden trigger ("PoisonGPT", 2023).<sup>[[3]](#references)</sup> Recommended mitigations:

* **Shuffled mixing** – make sure adjacent training examples originate from different sources; this dilutes gradient alignment of malicious spans.
* **Gradient similarity scoring** – compute cosine similarity of example gradient to batch average; outliers are candidates for removal.
Expand All @@ -300,8 +300,8 @@ Practical recommendations:

## References

- [Build a Large Language Model from Scratch (Manning, 2024)](https://www.manning.com/books/build-a-large-language-model-from-scratch)
- [Llama 2: Open Foundation and Fine-Tuned Chat Models (2023)](https://arxiv.org/abs/2307.09288)
- [PoisonGPT: Assessing Backdoor Vulnerabilities in Large Language Models (BlackHat EU 2023)](https://arxiv.org/abs/2308.12364)
- [1] [Build a Large Language Model from Scratch (Manning, 2024)](https://www.manning.com/books/build-a-large-language-model-from-scratch)
- [2] [Llama 2: Open Foundation and Fine-Tuned Chat Models (2023)](https://arxiv.org/abs/2307.09288)
- [3] [PoisonGPT: Assessing Backdoor Vulnerabilities in Large Language Models (BlackHat EU 2023)](https://arxiv.org/abs/2308.12364)

{{#include ../../banners/hacktricks-training.md}}
13 changes: 6 additions & 7 deletions src/AI/AI-llm-architecture/3.-token-embeddings.md
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ For how token and positional embeddings are combined inside the model, see [the

Recent work shows that context length is often limited by the positional encoding scheme rather than the token embedding matrix itself.

- **Position Interpolation (PI):** Rescales position indices so longer sequences map into the range seen during training, enabling extension with minimal fine-tuning. Example:
- **Position Interpolation (PI):** Rescales position indices so longer sequences map into the range seen during training, enabling extension with minimal fine-tuning. Example:<sup>[[2]](#references)</sup>

```python
# Position Interpolation (PI) intuition
Expand All @@ -194,11 +194,11 @@ new_ctx = 8192
scaled_pos = pos * (orig_ctx / new_ctx)
```

- **YaRN:** A compute-efficient RoPE extension strategy that modifies RoPE scaling/interpolation to extrapolate to longer contexts with fewer additional training steps.
- **YaRN:** A compute-efficient RoPE extension strategy that modifies RoPE scaling/interpolation to extrapolate to longer contexts with fewer additional training steps.<sup>[[3]](#references)</sup>

## Code Example

Following with the code example from [https://github.com/rasbt/LLMs-from-scratch/blob/main/ch02/01_main-chapter-code/ch02.ipynb](https://github.com/rasbt/LLMs-from-scratch/blob/main/ch02/01_main-chapter-code/ch02.ipynb):
Following with the code example from [https://github.com/rasbt/LLMs-from-scratch/blob/main/ch02/01_main-chapter-code/ch02.ipynb](https://github.com/rasbt/LLMs-from-scratch/blob/main/ch02/01_main-chapter-code/ch02.ipynb):<sup>[[1]](#references)</sup>

```python
# Use previous code...
Expand Down Expand Up @@ -239,9 +239,8 @@ print(input_embeddings.shape) # torch.Size([8, 4, 256])

## References

- [https://www.manning.com/books/build-a-large-language-model-from-scratch](https://www.manning.com/books/build-a-large-language-model-from-scratch)
- [1] [Build a Large Language Model from Scratch (Manning)](https://www.manning.com/books/build-a-large-language-model-from-scratch)
- [2] [Extending Context Window of Large Language Models via Positional Interpolation](https://arxiv.org/abs/2306.15595)
- [3] [YaRN: Efficient Context Window Extension of Large Language Models](https://arxiv.org/abs/2309.00071)


- [https://arxiv.org/abs/2306.15595](https://arxiv.org/abs/2306.15595)
- [https://arxiv.org/abs/2309.00071](https://arxiv.org/abs/2309.00071)
{{#include ../../banners/hacktricks-training.md}}
Loading