本文へスキップ
Skillpedia
セキュリティ35k · #8193

performing-binary-exploitation-analysis

できること

このツールは、攻撃者がコマンドを実行できてしまう可能性のある、コンピュータープログラム(ELFファイル)のセキュリティ上の欠陥を見つけるためのものです。バッファオーバーフローの脆弱性を探し、その問題を示すための小さなプログラム(エクスプロイト)を作成します。

使う場面

  • ✓許可を得て、プログラムのセキュリティをテストするとき。
  • ✓セキュリティ競技会(CTF)に参加するとき。
  • ✓プログラムの攻撃対策が機能しているかを確認するとき。

スキルのリンク

https://github.com/mukul975/Anthropic-Cybersecurity-Skills/blob/main/skills/performing-binary-exploitation-analysis/SKILL.md

コピーしてAI(Claude、ChatGPT、Cursor)に貼り付け、指示に従うよう頼んでください。

使い方

いちばん簡単な方法:メッセージをコピーしてAIに貼り付けるだけ。AIがスキルを読んで指示に従います。

貼り付け用メッセージ

このスキルを使って手伝ってください:https://github.com/mukul975/Anthropic-Cybersecurity-Skills/blob/main/skills/performing-binary-exploitation-analysis/SKILL.md このリンクのSKILL.mdファイルを読んで、私の作業でその指示に従ってください。
こういうスキルを、AIが自分で見つけてくれたら?無料のSkillpedia MCPをインストール。1行で、作業の前に15,000+のスキルから探してくれます。1分でインストール →

AIへの頼み方の例

“「このプログラムを分析してセキュリティ上の欠陥を見つけ、それを悪用する例を作成してください。」”

毎週5つの新しいスキル。1分で読めます。

仕組み

`checksec` などのユーティリティでプログラムの保護機能を確認し、`pwntools` で攻撃用のコードを作成します。プログラムがどこで失敗するかを特定し、その欠陥を利用してコマンドを実行するコードを作ります。

技術的な内容(元のSKILL.md)

作者による元のテキスト(英語)をGitHubからそのまま表示しています。

Performing Binary Exploitation Analysis

For authorized security testing and CTF challenges only.

Analyze ELF binaries for exploitation vectors using checksec, ROPgadget, and pwntools for buffer overflow and ROP chain development.

When to Use

  • Analyzing ELF binaries during authorized penetration tests to identify memory corruption vulnerabilities
  • Solving binary exploitation challenges in CTF competitions
  • Evaluating the effectiveness of compiler mitigations (NX, ASLR, stack canaries, PIE, RELRO) on target binaries
  • Developing proof-of-concept exploits for vulnerability reports to demonstrate impact
  • Training security engineers in exploit development techniques for defensive awareness
  • Validating that security patches for buffer overflow vulnerabilities are effective

Do not use against systems without explicit written authorization. Binary exploitation techniques can cause system instability and must only be applied in controlled environments (lab VMs, CTF platforms, authorized pentests with scope documents).

Prerequisites

  • Linux system (Ubuntu/Debian recommended) for exploit development
  • Python 3.8+ with pwntools (pip install pwntools)
  • GDB with pwndbg or GEF plugin for enhanced debugging
  • ROPgadget for ROP chain gadget discovery (pip install ROPgadget)
  • checksec (included with pwntools or standalone via apt install checksec)
  • Target vulnerable binary compiled for testing (e.g., from pwnable.kr, ROP Emporium, or custom test binaries)
  • Basic understanding of x86/x86_64 calling conventions and stack layout

Workflow

Step 1: Install the Exploitation Toolkit

# Install pwntools and dependencies
pip install pwntools ROPgadget

# Install GDB with pwndbg plugin
git clone https://github.com/pwndbg/pwndbg
cd pwndbg && ./setup.sh

# Alternatively, install GEF (GDB Enhanced Features)
# bash -c "$(curl -fsSL https://gef.blah.cat/sh)"

# Install supporting tools
sudo apt install -y gdb nasm gcc-multilib libc6-dbg

# Verify installation
python3 -c "from pwn import *; print('pwntools version:', version)"
checksec --version
ROPgadget --version

Step 2: Analyze Binary Protections with checksec

Before writing any exploit, enumerate the security mitigations compiled into the binary:

from pwn import *

# Load the target binary
binary_path = "./vulnerable_server"
elf = ELF(binary_path)

# checksec output explains what mitigations are in place
print(f"Architecture: {elf.arch}")
print(f"Bits: {elf.bits}")
print(f"Endianness: {elf.endian}")
print()

# Key security properties
# RELRO: Full = GOT is read-only, Partial = GOT header read-only, No = writable GOT
# Stack Canary: Detects stack buffer overflows via random canary value
# NX (No-eXecute): Prevents executing code on the stack (DEP)
# PIE: Position Independent Executable, randomizes base address
# ASLR: OS-level address randomization (check /proc/sys/kernel/randomize_va_space)

# Also available via command line:
# checksec --file=./vulnerable_server
# Command-line checksec output example:
checksec --file=./vulnerable_server
# RELRO           STACK CANARY      NX            PIE
# Partial RELRO   No canary found   NX disabled   No PIE

# Check ASLR status on the system
cat /proc/sys/kernel/randomize_va_space
# 0 = disabled, 1 = conservative, 2 = full randomization

Step 3: Find the Buffer Overflow Offset

Determine exactly how many bytes are needed to overwrite the return address:

from pwn import *

context.binary = ELF("./vulnerable_server")
context.log_level = "info"

# Method 1: Use cyclic pattern to find exact offset
# Generate a unique cyclic pattern
pattern_length = 200
pattern = cyclic(pattern_length)
print(f"Generated cyclic pattern of length {pattern_length}")

# Send the pattern to the binary
p = process("./vulnerable_server")
p.sendline(pattern)
p.wait()

# After the crash, read the value in RIP/EIP from core dump or GDB
# Then find the offset:
# For 64-bit: crashed_value = p.corefile.fault_addr
# Or manually from GDB: "info registers rip" after crash
crashed_rip = 0x6161616c  # Example value from crash
offset = cyclic_find(crashed_rip)
print(f"Offset to return address: {offset} bytes")

# Method 2: Use GDB with pwndbg to find offset interactively
# In GDB:
#   pwndbg> cyclic 200
#   pwndbg> run < <(python3 -c "from pwn import *; print(cyclic(200).decode())")
#   pwndbg> cyclic -l $rsp   (or cyclic -l <value in RIP>)

…

よくある質問

ELFファイルとは何ですか?

LinuxやUnixシステムで一般的に使われる実行形式のファイルです。パソコンで実行するプログラムと同じように動作するものです。

「バッファオーバーフロー」とは何ですか?

プログラムが、格納できる容量を超えるデータをメモリ領域に書き込もうとする欠陥です。重要な情報を上書きしてしまい、悪意あるコードの実行を許す可能性があります。

ROP(Return-Oriented Programming)とは何ですか?

プログラムに直接のコード実行を防ぐ保護機能がある場合に使われる高度な手法です。代わりに、プログラム内に既にある小さなコードの断片を「連結」して、目的の動作を実現します。

詳細

作者による元の説明

Analyze ELF binaries for memory-corruption vulnerabilities and build proof-of-concept exploits using pwntools, checksec, and ROPgadget for buffer overflows and ROP chains. Use when a penetration test or CTF challenge requires evaluating compiler mitigations (NX, ASLR, stack canaries, PIE, RELRO) or developing a working exploit to demonstrate impact. '

repo: mukul975/Anthropic-Cybersecurity-Skills

人気

GitHubのスター
35k
ランキング
#8193
ライセンス
Apache-2.0
更新日
2026/8/31

このスキルは役に立ちますか?

0

ログイン して投票しましょう。

コメント

  • …

このリポジトリの他のスキル

似ているスキル