Skip to main content
skill Claude Code CX Codex Cursor GitHub Copilot

ctf-ai-ml — Claude Code skill: what it does, how to install

Provides AI and machine learning attack techniques for CTF competitions, from adversarial examples to LoRA weight inspection and prompt injection.

Install into Claude Code · Skills CLI (Vercel) All methods and platforms ↓
npx skills add ljagiello/ctf-skills --skill ctf-ai-ml -a claude-code
Open on GitHub

What ctf-ai-ml does

The skill equips the agent with one-liners and structured workflows for AI security challenges. It covers adversarial sample generation via FGSM, PGD, and C&W, model inversion with gradient descent, LoRA adapter merging, and membership inference. For language models, it provides direct and indirect prompt injection patterns along with token smuggling tricks.

Execution requires Python 3 alongside torch, transformers, safetensors, and scikit-learn. If a challenge turns into reverse-engineering compiled TensorRT or ONNX binaries, the reference instructs the agent to pivot to reverse-engineering tools. Without local PyTorch libraries, the model inspection commands will fail immediately.

What it helps with

  • inspect and diff model weights in .safetensors and .pt files
  • craft adversarial inputs using FGSM, PGD, and C&W algorithms
  • bypass LLM guardrails via prompt injection and token smuggling
  • invert model outputs to recover private training samples

Example prompts for the agent

  • Inspect challenge.pt and find anomalous weight differences against original.pt
  • Craft an adversarial example against this image classifier using PGD
  • Test the target chat API endpoint for prompt injection and token smuggling

How to install ctf-ai-ml

1Skills CLI (Vercel)

npx skills add ljagiello/ctf-skills --skill ctf-ai-ml -a claude-code

2Manually: put the files in place

~/.claude/skills/ctf-ai-ml/SKILL.md

Copy the whole skill folder; for one project use .claude/skills/ctf-ai-ml/

From the same set11

The whole set →
ctf-reverse ljagiello A reverse engineering reference for CTF challenges: guides coding agents through binary inspection, anti-debug bypass, and virtual machine analysis. Claude Code CX Codex Cursor +1 10,100installs ctf-web ljagiello Routes and guides agents through web CTF challenges, covering everything from SQL injection and SSTI to auth bypasses and SSRF. Claude Code CX Codex Cursor +1 9,700installs ctf-pwn ljagiello Binary exploitation guide for CTF challenges. Helps turn memory corruption bugs into code execution and shell access. Claude Code CX Codex Cursor +1 9,400installs ctf-crypto ljagiello A skill for solving crypto CTF challenges, covering RSA, AES, hashes, signatures, PRNG, ZKP, and mathematical attacks. Claude Code CX Codex Cursor +1 9,200installs ctf-osint ljagiello A field guide to public-source research for CTF challenges, from username and DNS checks to image searches and geolocation. Useful when clues point beyond the challenge files. Claude Code CX Codex Cursor +1 9,100installs ctf-forensics ljagiello Digital forensics and signal analysis techniques for CTF challenges: disk images, memory dumps, PCAP files, steganography, Windows artifacts, and side-channel attacks. Claude Code CX Codex Cursor +1 9,000installs solve-challenge ljagiello Runs first-pass CTF triage, identifies the likely challenge category, and routes work to a specialized ctf-* skill. Use it when you have files, a remote service, or only a short prompt. Claude Code CX Codex Cursor +1 8,900installs ctf-misc ljagiello Provides reference techniques and payloads for miscellaneous CTF challenges like sandbox escapes, exotic encodings, and signal analysis. Claude Code CX Codex Cursor +1 8,800installs

Similar

setup-api-key calesthio A skill that checks whether an ElevenLabs API key is configured and working, then walks the user through obtaining and saving a new key if needed. Claude Code CX Codex Cursor +1 1,000installs cso garrytan Audits code and infrastructure for security findings, with reproduction and repair candidates in comprehensive mode. Use it when reviewing a project. Claude Code CX Codex Cursor +1 405installs nestjs-expert https://github.com/Jeffallan A skill for designing and building NestJS backends in TypeScript: modules, services, controllers, validation, authentication and testing. Use it when building REST APIs or GraphQL services with enterprise patterns. Claude Code CX Codex Cursor +1 5,900installs cli-keys cheaper-inference Manages OmniRoute API keys and provider OAuth flows from your terminal. Handy when configuring model access and usage policies. Claude Code CX Codex Cursor +1 1,000installs differential-review trailofbits Reviews code changes for security issues using Git history and test coverage. Use it for commits, diffs, and pull requests that need a written review report. Claude Code CX Codex Cursor +1 8,800installs git-guardrails-claude-code Matt Pocock This skill adds a Claude Code hook that stops risky Git commands before they run. Use it when an agent must not push or discard working-tree changes. Claude Code 499,069installs ponytail-review DietrichGebert ponytail-review reviews a change beyond the diff, checking connected code, bugs, risks, load, tests, speed, and unnecessary code. Use it for PRs and commits. Claude Code CX Codex Cursor +1 56,300installs ponytail-audit DietrichGebert It audits a repository and ranks bugs, risks, and redundant code in a one-shot report. Use it when you need a review without code changes. Claude Code CX Codex Cursor +1 44,800installs

Questions about ctf-ai-ml

How to install ctf-ai-ml in Claude Code?

Run npx skills add ljagiello/ctf-skills --skill ctf-ai-ml -a claude-code. The configuration is saved to ~/.claude/skills/ctf-ai-ml/SKILL.md.

What does ctf-ai-ml do?

It provides quick-reference commands and methods for solving ML CTF challenges, covering adversarial attacks, weight perturbation negation, and LLM exploitation.

What dependencies are required for ctf-ai-ml?

You need Python 3, python3-dev (or Homebrew python@3), and pip packages including torch, transformers, safetensors, scikit-learn, scipy, numpy, and Pillow.

Source text

SKILL.md · MIT
---
name: ctf-ai-ml
description: Provides AI and machine learning techniques for CTF challenges. Use when attacking ML models, crafting adversarial examples, performing model extraction, prompt injection, membership inference, training data poisoning, fine-tuning manipulation, neural network analysis, LoRA adapter exploitation, LLM jailbreaking, or solving AI-related puzzles.
license: MIT
compatibility: Requires filesystem-based agent (Claude Code or similar) with bash, Python 3, and internet access for tool installation.
allowed-tools: Bash Read Write Edit Glob Grep Task WebFetch WebSearch
metadata:
  user-invocable: "false"
---

# CTF AI/ML

Quick reference for AI/ML CTF challenges. Each technique has a one-liner here; see supporting files for full details.

## Prerequisites

**Python packages (all platforms):**
```bash
pip install torch transformers numpy scipy Pillow safetensors scikit-learn
```

**Linux (apt):**
```bash
apt install python3-dev
```

**macOS (Homebrew):**
```bash
brew install python@3
```

## Additional Resources

- [model-attacks.md](model-attacks.md) - Model weight perturbation negation, model inversion via gradient descent, neural network encoder collision, LoRA adapter weight merging, model extraction via query API, membership inference attack
- [adversarial-ml.md](adversarial-ml.md) - Adversarial example generation (FGSM, PGD, C&W), adversarial patch generation, evasion attacks on ML classifiers, data poisoning, backdoor detection in neural networks
- [llm-attacks.md](llm-attacks.md) - Prompt injection (direct/indirect), LLM jailbreaking, token smuggling, context window manipulation, tool use exploitation

---

## When to Pivot

- If the challenge becomes pure math, lattice reduction, or number theory with no ML component, switch to `/ctf-crypto`.
- If the task is reverse engineering a compiled ML model binary (ONNX loader, TensorRT engine, custom inference binary), switch to `/ctf-reverse`.
- If the challenge is a game or puzzle that merely uses ML as a wrapper (e.g., Python jail inside a chatbot), switch to `/ctf-misc`.

## Quick Start Commands

```bash
# Inspect model file format
file model.*
python3 -c "import torch; m = torch.load('model.pt', map_location='cpu'); print(type(m)); print(m.keys() if hasattr(m, 'keys') else dir(m))"

# Inspect safetensors model
python3 -c "from safetensors import safe_open; f = safe_open('model.safetensors', framework='pt'); print(f.keys()); print({k: f.get_tensor(k).shape for k in f.keys()})"

# Inspect HuggingFace model
python3 -c "from transformers import AutoModel, AutoTokenizer; m = AutoModel.from_pretrained('./model_dir'); print(m)"

# Inspect LoRA adapter
python3 -c "from safetensors import safe_open; f = safe_open('adapter_model.safetensors', framework='pt'); print([k for k in f.keys()])"

# Quick weight comparison between two models
python3 -c "
import torch
a = torch.load('original.pt', map_location='cpu')
b = torch.load('challenge.pt', map_location='cpu')
for k in a:
    if not torch.equal(a[k], b[k]):
        diff = (a[k] - b[k]).abs()
        print(f'{k}: max_diff={diff.max():.6f}, mean_diff={diff.mean():.6f}')
"

# Test prompt injection on a remote LLM endpoint
curl -X POST http://target:8080/api/chat \
  -H 'Content-Type: application/json' \

# Check for adversarial robustness
python3 -c "
import torch, torchvision.transforms as T
from PIL import Image
img = T.ToTensor()(Image.open('input.png')).unsqueeze(0)
print(f'Shape: {img.shape}, Range: [{img.min():.3f}, {img.max():.3f}]')
"
```

## Model Weight Analysis

- **Weight perturbation negation:** Fine-tuned model suppresses behavior; recover by computing `2*W_orig - W_chal` to negate the fine-tuning delta. See [model-attacks.md](model-attacks.md#ml-model-weight-perturbation-negation-dicectf-2026).
- **LoRA adapter merging:** Merge LoRA adapter `W_base + alpha * (B @ A)` and inspect activations or generate output with merged weights. See [model-attacks.md](model-attacks.md#lora-adapter-weight-merging-apoorvctf-2026).
- **Model inversion:** Optimize random input tensor to minimize distance between model output and known target via gradient descent. See [model-attacks.md](model-attacks.md#ml-model-inversion-via-gradient-descent-bsidessf-2025).
- **Neural network collision:** Find two distinct inputs that produce identical encoder output via joint optimization. See [model-attacks.md](model-attacks.md#neural-network-encoder-collision-rootaccess2026).

## Adversarial Examples

- **FGSM:** Single-step attack: `x_adv = x + eps * sign(grad_x(loss))`. Fast but less effective than iterative methods. See [adversarial-ml.md](adversarial-ml.md#adversarial-example-generation-fgsm-pgd-cw).
- **PGD:** Iterative FGSM with projection back to epsilon-ball each step. Standard benchmark attack. See [adversarial-ml.md](adversarial-ml.md#adversarial-example-generation-fgsm-pgd-cw).
- **C&W:** Optimization-based attack that minimizes perturbation norm while achieving misclassification. See [adversarial-ml.md](adversarial-ml.md#adversarial-example-generation-fgsm-pgd-cw).
- **Adversarial patches:** Physical-world patches that cause misclassification when placed in a scene. See [adversarial-ml.md](adversarial-ml.md#adversarial-patch-generation).
- **Data poisoning:** Injecting backdoor triggers into training data so model learns attacker-chosen behavior. See [adversarial-ml.md](adversarial-ml.md#data-poisoning-foundational).

## LLM Attacks

- **Prompt injection:** Overriding system instructions via user input; both direct injection and indirect via retrieved documents. See [llm-attacks.md](llm-attacks.md#prompt-injection-foundational).
- **Jailbreaking:** Bypassing safety filters via DAN, role play, encoding tricks, multi-turn escalation. See [llm-attacks.md](llm-attacks.md#llm-jailbreaking-foundational).
- **Token smuggling:** Exploiting tokenizer splits so filtered words pass through as subword tokens. See [llm-attacks.md](llm-attacks.md#token-smuggling-foundational).
- **Tool use exploitation:** Abusing function calling in LLM agents to execute unintended actions. See [llm-attacks.md](llm-attacks.md#tool-use-exploitation-foundational).

## Model Extraction & Inference

- **Model extraction:** Querying a model API with crafted inputs to reconstruct its parameters or decision boundary. See [model-attacks.md](model-attacks.md#model-extraction-via-query-api).
- **Membership inference:** Determining whether a specific sample was in the training data based on confidence score distribution. See [model-attacks.md](model-attacks.md#membership-inference-attack).

## Gradient-Based Techniques

- **Gradient-based input recovery:** Using model gradients to reconstruct private training data from shared gradients (federated learning attacks). See [model-attacks.md](model-attacks.md#ml-model-inversion-via-gradient-descent-bsidessf-2025).
- **Activation maximization:** Optimizing input to maximize a specific neuron's activation, revealing what the network has learned.

© ljagiello · MIT · ljagiello/ctf-skills

See also

Project sponsors

Companies that keep this analytics open
Gold sponsor

Impressions, clicks and code copies — open statistics. We keep the numbers public for the same reason NeBlask itself is public. Become a sponsor