Communitygithub.com

SamuelChien/mega-skills-collection

AFL++는 향상된 퍼징 성능과 고급 기능을 제공하는 AFL의 포크입니다. C/C++ 프로젝트의 멀티코어 퍼징에 사용됩니다.

mega-skills-collection란 무엇인가요?

이 스킬은 AFL 퍼저의 포크인 **AFL++**를 사용하여 C/C++ 프로젝트를 퍼징하는 방법을 설명합니다. AFL++는 멀티코어 퍼징, 다양한 변이 전략, 성숙한 도구 지원을 제공하여 libFuzzer보다 대규모 퍼징에 더 적합합니다. 이 스킬은 퍼징 캠페인을 시작하고 실행하는 전체 워크플로를 다루며, 다음을 포함합니다: 하네스 작성 규칙, Clang/GCC/LTO 컴파일 모드 사용, 시드 코퍼스 관리 및 최소화, AddressSanitizer(ASan) 및 UndefinedBehaviorSanitizer(UBSan)와 같은 샌타이저 통합, 다중 인스턴스 멀티코어 캠페인 실행, CMPLOG/RedQueen 경로 제약 해결 메커니즘, 표준 입력/파일 입력/인자 퍼징. 또한 실시간 통계를 해석하는 방법, `afl-plot`으로 커버리지 추세를 시각화하는 방법, `afl-cmin`으로 코퍼스를 최소화하는 방법을 설명합니다. 주요 특징으로는 Debian/Ubuntu 패키지, Docker 이미지(Apple Silicon 지원), 소스에서 빌드 등 다양한 설치 방법; `./afl++` 래퍼 스크립트를 통한 편리한 퍼징; and 시스템 구성 및 보안 경고에 대한 명확한 지침이 포함됩니다. 이 스킬은 Claude Code, Cursor, Codex에서 사용하도록 설계되었으며, 퍼징 워크플로를 안내하는 실용적인 멀티 에이전트 시스템 역할을 합니다.

지원 대상~Claude Code~Codex CLI~Cursor
npx skills add https://github.com/SamuelChien/mega-skills-collection/tree/HEAD/aflpp

즐겨 사용하는 AI에게 물어보기

이 에이전트 스킬이 미리 로드된 새 채팅을 엽니다.

문서

AFL++

AFL++는 원본 AFL 퍼저의 포크로, 안정성을 유지하면서 더 나은 퍼징 성능과 고급 기능을 제공합니다. libFuzzer에 비해 AFL++의 주요 이점은 멀티코어에서 퍼징 캠페인을 안정적으로 실행할 수 있어 대규모 퍼징 작업에 이상적입니다.

사용 시기

퍼저최적 용도복잡도
AFL++멀티코어 퍼징, 다양한 변이, 성숙한 프로젝트중간
libFuzzer빠른 설정, 단일 스레드, 간단한 하네스낮음
LibAFL맞춤형 퍼저, 연구, 고급 사용 사례높음

다음과 같은 경우 AFL++를 선택하세요:

  • 처리량을 극대화하기 위해 멀티코어 퍼징이 필요한 경우
  • 프로젝트를 Clang 또는 GCC로 컴파일할 수 있는 경우
  • 다양한 변이 전략과 성숙한 도구를 원하는 경우
  • libFuzzer가 정체되어 더 많은 커버리지가 필요한 경우
  • 병렬 실행의 이점을 얻을 수 있는 프로덕션 코드베이스를 퍼징하는 경우

빠른 시작

extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
    // 퍼저가 제공한 데이터로 코드 호출
    check_buf((char*)data, size);
    return 0;
}

컴파일 및 실행:

# 먼저 AFL++ 래퍼 스크립트 설정 (설치 참조)
./afl++ docker afl-clang-fast++ -DNO_MAIN=1 -O2 -fsanitize=fuzzer harness.cc main.cc -o fuzz
mkdir seeds && echo "aaaa" > seeds/minimal_seed
./afl++ docker afl-fuzz -i seeds -o out -- ./fuzz

설치

AFL++에는 LLVM, Python, Rust를 포함한 많은 종속성이 있습니다. AFL++로 퍼징하려면 최신 Debian 또는 Ubuntu 배포판을 사용하는 것이 좋습니다.

방법사용 시기지원되는 컴파일러
Ubuntu/Debian 저장소최신 Ubuntu, 기본 기능만Ubuntu 23.10: Clang 14 & GCC 13Debian 12: Clang 14 & GCC 12
Docker (Docker Hub에서)특정 AFL++ 버전, Apple Silicon 지원4.35c 기준: Clang 19 & GCC 11
Docker (소스에서)릴리스되지 않은 기능 테스트, 패치 적용Dockerfile에서 구성 가능
소스에서Docker 회피, 특정 패치 필요LLVM_CONFIG env var를 통해 조정 가능

Ubuntu/Debian

afl++을 설치하기 전에 apt-cache show afl++로 패키지의 clang 버전 종속성을 확인하고 일치하는 lld 버전(예: lld-17)을 설치하세요.

apt install afl++ lld-17

Docker (Docker Hub에서)

docker pull aflplusplus/aflplusplus:stable

Docker (소스에서)

git clone --depth 1 --branch stable https://github.com/AFLplusplus/AFLplusplus
cd AFLplusplus
docker build -t aflplusplus .

소스에서

Ubuntu 버전 요구 사항 및 종속성은 Dockerfile을 참조하세요. LLVM_CONFIG를 설정하여 Clang 버전(예: llvm-config-18)을 지정하세요.

래퍼 스크립트 설정

호스트 또는 Docker에서 AFL++를 실행하는 래퍼 스크립트를 만듭니다:

cat <<'EOF' > ./afl++
#!/bin/sh
AFL_VERSION="${AFL_VERSION:-"stable"}"
case "$1" in
   host)
        shift
        bash -c "$*"
        ;;
    docker)
        shift
        /usr/bin/env docker run -ti \
            --privileged \
            -v ./:/src \
            --rm \
            --name afl_fuzzing \
            "aflplusplus/aflplusplus:$AFL_VERSION" \
            bash -c "cd /src && bash -c \"$*\""
        ;;
    *)
        echo "Usage: $0 {host|docker}"
        exit 1
        ;;
esac
EOF
chmod +x ./afl++

보안 경고: afl-system-config 및 afl-persistent-config 스크립트는 루트 권한이 필요하며 OS 보안 기능을 비활성화합니다. 프로덕션 시스템이나 개발 환경에서 퍼징하지 마세요. 대신 전용 VM을 사용하세요.

시스템 구성

재부팅 후 초당 최대 15% 더 많은 실행을 위해 다음을 실행하세요:

./afl++ <host/docker> afl-system-config

최대 성능을 위해 커널 보안 완화를 비활성화합니다(grub 부트로더 필요, Docker에서는 지원되지 않음):

./afl++ host afl-persistent-config
update-grub
reboot
./afl++ <host/docker> afl-system-config

cat /proc/cmdline으로 확인 - 출력에 mitigations=off가 포함되어야 합니다.

하네스 작성

하네스 구조

AFL++는 libFuzzer 스타일의 하네스를 지원합니다:

#include <stdint.h>
#include <stddef.h>

extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
    // 1. 필요한 경우 입력 크기 검증
    if (size < MIN_SIZE || size > MAX_SIZE) return 0;

    // 2. 퍼즈 데이터로 대상 함수 호출
    target_function(data, size);

    // 3. 0 반환 (0이 아닌 값은 향후 사용을 위해 예약됨)
    return 0;
}

하네스 규칙

할 것하지 말 것
실행 간에 전역 상태 재설정이전 실행의 상태에 의존
예외 상황을 정상적으로 처리잘못된 입력에서 종료
하네스를 결정론적으로 유지난수 생성기 사용
할당된 메모리 해제메모리 누수 생성
입력 크기 검증무제한 입력 처리

참고: 상세한 하네스 작성 기술, 복잡한 입력 처리 패턴 및 고급 전략은 fuzz-harness-writing 기술 스킬을 참조하세요.

컴파일

AFL++는 다양한 트레이드오프가 있는 여러 컴파일 모드를 제공합니다.

컴파일 모드 결정 트리

컴파일 모드를 선택하세요:

  • LTO 모드 (afl-clang-lto): 최상의 성능 및 계측. 먼저 시도하세요.
  • LLVM 모드 (afl-clang-fast): LTO 컴파일 실패 시 대체.
  • GCC 플러그인 (afl-gcc-fast): GCC가 필요한 프로젝트용.

기본 컴파일 (LLVM 모드)

./afl++ <host/docker> afl-clang-fast++ -DNO_MAIN=1 -O2 -fsanitize=fuzzer harness.cc main.cc -o fuzz

GCC 컴파일

./afl++ <host/docker> afl-g++-fast -DNO_MAIN=1 -O2 -fsanitize=fuzzer harness.cc main.cc -o fuzz

중요: GCC 버전은 AFL++ GCC 플러그인을 컴파일하는 데 사용된 버전과 일치해야 합니다.

샌타이저 사용

./afl++ <host/docker> AFL_USE_ASAN=1 afl-clang-fast++ -DNO_MAIN=1 -O2 -fsanitize=fuzzer harness.cc main.cc -o fuzz

참고: 상세한 샌타이저 구성, 일반적인 문제 및 고급 플래그는 address-sanitizer 및 undefined-behavior-sanitizer 기술 스킬을 참조하세요.

빌드 플래그

-g는 필요하지 않습니다. AFL++ 컴파일러에서 기본적으로 추가됩니다.

플래그목적
-DNO_MAIN=1libFuzzer 하네스 사용 시 main 함수 건너뛰기
-O2프로덕션 최적화 수준 (퍼징에 권장)
-fsanitize=fuzzerlibFuzzer 호환 모드 활성화 및 실행 파일 링크 시 퍼저 런타임 추가
-fsanitize=fuzzer-no-link퍼저 런타임 연결 없이 계측 (정적 라이브러리 및 오브젝트 파일용)

코퍼스 관리

초기 코퍼스 생성

AFL++는 최소한 하나의 비어 있지 않은 시드 파일이 필요합니다:

mkdir seeds
echo "aaaa" > seeds/minimal_seed

실제 프로젝트의 경우 대표적인 입력을 수집하세요:

  • 퍼징하려는 형식의 예제 파일 다운로드
  • 프로젝트 테스트 스위트에서 테스트 케이스 추출
  • 파일 형식에 대한 최소 유효 입력 사용

코퍼스 최소화

캠페인 후 고유 커버리지만 유지하도록 코퍼스를 최소화합니다:

./afl++ <host/docker> afl-cmin -i out/default/queue -o minimized_corpus -- ./fuzz

참고: 코퍼스 생성 전략, 사전 및 시드 선택에 대해서는 fuzzing-corpus 기술 스킬을 참조하세요.

캠페인 실행

기본 실행

./afl++ <host/docker> afl-fuzz -i seeds -o out -- ./fuzz

환경 변수 설정

./afl++ <host/docker> AFL_FAST_CAL=1 afl-fuzz -i seeds -o out -- ./fuzz

출력 해석

AFL++ UI는 실시간 퍼징 통계를 보여줍니다:

출력의미
execs/sec실행 속도 - 높을수록 좋음
cycles done완료된 큐 통과 횟수
corpus count큐의 고유 테스트 케이스 수
saved crashes발견된 고유 충돌 수
stability안정적인 에지의 % (100%에 가까워야 함)

출력 디렉토리 구조

out/default/
├── cmdline          # SUT가 어떻게 호출되었는가?
├── crashes/         # SUT를 충돌시키는 입력
│   └── id:000000,sig:06,src:000002,time:286,execs:13105,op:havoc,rep:4
├── hangs/           # SUT를 중단시키는 입력
├── queue/           # 최종 퍼저 상태를 재현하는 테스트 케이스
│   ├── id:000000,time:0,execs:0,orig:minimal_seed
│   └── id:000001,src:000000,time:0,execs:8,op:havoc,rep:6,+cov
├── fuzzer_stats     # 캠페인 통계
└── plot_data        # 플롯 데이터

결과 분석

라이브 캠페인 통계 보기:

./afl++ <host/docker> afl-whatsup out

커버리지 플롯 생성:

apt install gnuplot
./afl++ <host/docker> afl-plot out/default out_graph/

테스트 케이스 재실행

./afl++ <host/docker> ./fuzz out/default/crashes/<test_case>

퍼저 옵션

옵션목적
-G 4000최대 테스트 입력 길이 (기본값: 1048576 바이트)
-t 1000각 테스트 케이스에 대한 시간 제한 (밀리초) (기본값: 1000ms)
-m 1000메모리 제한 (메가바이트) (기본값: 0 = 무제한)
-x ./dict.dict변이를 안내하는 사전 파일 사용

멀티코어 퍼징

AFL++는 두 가지 주요 이점으로 멀티코어 퍼징에 탁월합니다:

  1. 초당 더 많은 실행 (물리적 코어에 선형적으로 확장)
  2. 비대칭 퍼징 (예: 하나의 ASan 작업, 나머지는 샌타이저 없음)

캠페인 시작

기본 퍼저 시작 (백그라운드):

./afl++ <host/docker> afl-fuzz -M primary -i seeds -o state -- ./fuzz 1>primary.log 2>primary.error &

보조 퍼저 시작 (코어 수만큼):

./afl++ <host/docker> afl-fuzz -S secondary01 -i seeds -o state -- ./fuzz 1>secondary01.log 2>secondary01.error &
./afl++ <host/docker> afl-fuzz -S secondary02 -i seeds -o state -- ./fuzz 1>secondary02.log 2>secondary02.error &

멀티코어 캠페인 모니터링

실행 중인 모든 작업 나열:

jobs

실시간 통계 보기 (1초마다 업데이트):

./afl++ <host/docker> watch -n1 --color afl-whatsup state/

모든 퍼저 중지

kill $(jobs -p)

커버리지 분석

AFL++는 에지 계측을 통해 커버리지를 자동으로 추적합니다. 커버리지 정보는 fuzzer_stats 및 plot_data에 저장됩니다.

커버리지 측정

afl-plot을 사용하여 시간 경과에 따른 커버리지를 시각화합니다:

./afl++ <host/docker> afl-plot out/default out_graph/

커버리지 개선

  • 형식 인식 퍼징을 위해 사전 사용
  • 더 긴 캠페인 실행 (cycles_wo_finds는 정체기를 나타냄)
  • 멀티코어 퍼징으로 다양한 변이 전략 시도
  • 커버리지 격차 분석 및 타겟 시드 입력 추가

참고: 상세한 커버리지 분석 기술, 커버리지 격차 식별 및 체계적인 커버리지 개선에 대해서는 coverage-analysis 기술 스킬을 참조하세요.

CMPLOG

CMPLOG/RedQueen는 모든 퍼저에서 사용 가능한 최고의 경로 제약 해결 메커니즘입니다. 이를 활성화하려면 퍼즈 대상이 이에 대해 계측되어야 합니다. 퍼징 대상을 빌드하기 전에 환경 변수를 설정하세요:

./afl++ <host/docker> AFL_LLVM_CMPLOG=1 make

하네스 컴파일 및 링크에는 특별한 작업이 필요하지 않습니다.

CMPLOG 계측된 퍼징 대상으로 퍼저 인스턴스를 실행하려면 명령줄 인수에 -c0을 추가하세요:

./afl++ <host/docker> afl-fuzz -c0 -S cmplog -i seeds -o state -- ./fuzz 1>secondary02.log 2>secondary02.error &

샌타이저 통합

샌타이저는 즉시 충돌을 일으키지 않는 메모리 손상 버그를 찾는 데 필수적입니다.

AddressSanitizer (ASan)

./afl++ <host/docker> AFL_USE_ASAN=1 afl-clang-fast++ -DNO_MAIN=1 -O2 -fsanitize=fuzzer harness.cc main.cc -o fuzz

참고: 메모리 제한 (-m)은 20TB 가상 메모리 예약으로 인해 ASan에서 지원되지 않습니다.

UndefinedBehaviorSanitizer (UBSan)

./afl++ <host/docker> AFL_USE_UBSAN=1 afl-clang-fast++ -DNO_MAIN=1 -O2 -fsanitize=fuzzer,undefined harness.cc main.cc -o fuzz

일반적인 샌타이저 문제

문제해결책
ASan으로 인해 퍼징 속도 저하멀티코어 설정에서 ASan 작업을 1개만 사용
스택 고갈ASAN_OPTIONS=stack_size=...로 스택 증가
GCC 버전 불일치시스템 GCC가 AFL++ 플러그인 버전과 일치하는지 확인

참고: 포괄적인 샌타이저 구성 및 문제 해결에 대해서는 address-sanitizer 기술 스킬을 참조하세요.

고급 사용법

팁과 요령

팁도움이 되는 이유
가능하면 LLVMFuzzerTestOneInput 하네스 사용퍼징 캠페인의 안정성이 85% 이상이면 이것이 가장 효율적인 퍼징 스타일입니다. 그렇지 않으면 표준 입력 또는 파일 입력 퍼징 시도
사전 사용퍼저가 형식별 키워드와 매직 바이트를 발견하는 데 도움
현실적인 타임아웃 설정시스템 부하로 인한 거짓 양성 방지
입력 크기 제한더 큰 입력이 반드시 더 많은 공간을 탐색하는 것은 아님
안정성 모니터링낮은 안정성은 비결정적 동작을 나타냄

표준 입력 퍼징

AFL++는 libFuzzer 하네스 없이 stdin에서 읽는 프로그램을 퍼징할 수 있습니다:

./afl++ <host/docker> afl-clang-fast++ -O2 main_stdin.c -o fuzz_stdin
./afl++ <host/docker> afl-fuzz -i seeds -o out -- ./fuzz_stdin

이것은 영구 모드보다 느리지만 하네스 코드가 필요하지 않습니다.

파일 입력 퍼징

파일을 읽는 프로그램의 경우 @@ 자리 표시자를 사용하세요:

./afl++ <host/docker> afl-clang-fast++ -O2 main_file.c -o fuzz_file
./afl++ <host/docker> afl-fuzz -i seeds -o out -- ./fuzz_file @@

더 나은 성능을 위해 fmemopen을 사용하여 메모리에서 파일 디스크립터를 만드세요.

인자 퍼징

argv-fuzz-inl.h를 사용하여 명령줄 인자를 퍼징합니다:

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#ifdef __AFL_COMPILER
#include "argv-fuzz-inl.h"
#endif

void check_buf(char *buf, size_t buf_len) {
    if(buf_len > 0 && buf[0] == 'a') {
        if(buf_len > 1 && buf[1] == 'b') {
            if(buf_len > 2 && buf[2] == 'c') {
                abort();
            }


…

[번역을 위해 잘림]

Individual skills in this repo

This repo contains 20 individual skills — each has its own dedicated page.

SamuelChien/mega-skills-collection

Security audit, hardening, threat modeling (STRIDE/PASTA), Red/Blue Team, OWASP checks, code review, incident response, and infrastructure security for any project.

SamuelChien/mega-skills-collection

Arquitecto de Soluciones Principal y Consultor Tecnológico de Andru.ia. Diagnostica y traza la hoja de ruta óptima para proyectos de IA en español.

SamuelChien/mega-skills-collection

Ingeniero de Sistemas de Andru.ia. Diseña, redacta y despliega nuevas habilidades (skills) dentro del repositorio siguiendo el Estándar de Diamante.

SamuelChien/mega-skills-collection

Estratega de Inteligencia de Dominio de Andru.ia. Analiza el nicho específico de un proyecto para inyectar conocimientos, regulaciones y estándares únicos del sector. Actívalo tras definir el nicho.

SamuelChien/mega-skills-collection

2D game development principles. Sprites, tilemaps, physics, camera.

SamuelChien/mega-skills-collection

3D game development principles. Rendering, shaders, physics, cameras.

SamuelChien/mega-skills-collection

Expert in building 3D experiences for the web - Three.js, React Three Fiber, Spline, WebGL, and interactive 3D scenes. Covers product configurators, 3D portfolios, immersive websites, and bringing depth to web experiences.

SamuelChien/mega-skills-collection

Accessibility audit skill for scanning, fixing, and verifying WCAG 2.2 Level A and AA compliance across React, Next.js, Vue, Angular, Svelte, and plain HTML codebases. Use when auditing accessibility, fixing a11y violations, checking color contrast, generating compliance reports, or integrating accessibility checks into CI/CD pipelines.

SamuelChien/mega-skills-collection

Ab Test Analyzer - Auto-activating skill for Data Analytics. Triggers on: ab test analyzer, ab test analyzer Part of the Data Analytics skill category.

SamuelChien/mega-skills-collection

A B Test Config Creator - Auto-activating skill for ML Deployment. Triggers on: a b test config creator, a b test config creator Part of the ML Deployment skill category.

SamuelChien/mega-skills-collection

When the user wants to plan, design, or implement an A/B test or experiment. Also use when the user mentions "A/B test," "split test," "experiment," "test this change," "variant copy," "multivariate test," "hypothesis," "conversion experiment," "statistical significance," or "test this." For tracking implementation, see analytics-tracking.

SamuelChien/mega-skills-collection

Acceptance Criteria Creator - Auto-activating skill for Enterprise Workflows. Triggers on: acceptance criteria creator, acceptance criteria creator Part of the Enterprise Workflows skill category.

SamuelChien/mega-skills-collection

Use when a coding task should be driven end-to-end from issue intake through implementation, review, deployment, and acceptance verification with minimal human re-intervention.

SamuelChien/mega-skills-collection

Accessibility Audit Runner - Auto-activating skill for Frontend Development. Triggers on: accessibility audit runner, accessibility audit runner Part of the Frontend Development skill category.

SamuelChien/mega-skills-collection

You are an accessibility expert specializing in WCAG compliance, inclusive design, and assistive technology compatibility. Conduct audits, identify barriers, and provide remediation guidance.

SamuelChien/mega-skills-collection

Web accessibility patterns for WCAG 2.2 compliance including ARIA, keyboard navigation, screen readers, and testing

SamuelChien/mega-skills-collection

Manage Discord channel access — approve pairings, edit allowlists, set DM/group policy. Use when the user asks to pair, approve someone, check who's allowed, or change policy for the Discord channel.

SamuelChien/mega-skills-collection

Create unified specification packages across Business, Development, and Design teams. Staged elaboration (L0 Vision → L1 Requirements → L2 Team Detail → L3 Acceptance Criteria) to build shared understanding. Does not write code.

SamuelChien/mega-skills-collection

Research a company or person and get actionable sales intel. Works standalone with web search, supercharged when you connect enrichment tools or your CRM. Trigger with "research [company]", "look up [person]", "intel on [prospect]", "who is [name] at [company]", or "tell me about [company]".

SamuelChien/mega-skills-collection

Validate messaging consistency across website, GitHub repos, and local documentation generating read-only discrepancy reports. Use when checking content alignment or finding mixed messaging. Trigger with phrases like "check consistency", "validate documentation", or "audit messaging".

관련 스킬