본문 바로가기
정보보안/fuzzing

AFL 설치 및 실습

by meanjung 2022. 1. 8.

https://wogh8732.tistory.com/272

 

AFL fuzzer 설명 및 사용방법

1. AFL 퍼저 원리 afl 퍼저는 instrumentation-guided genetic algorithm 과 결합된 퍼저이다. 브푸트포스로 입력을 받지만, 거기서 끝나는게 아니라, 커버리지를 넓혀가며 프로그램 제어 흐름에 대한 변경사항

wogh8732.tistory.com

 

AFL 설치

wget http://lcamtuf.coredump.cx/afl/releases/afl-latest.tgz
tar -xvf afl-latest.tgz
cd afl-2.52b/
make
sudo make install

 

 

퍼징할 프로그램 dact 설치

https://fossies.org/linux/privat/old/dact-0.8.42.tar.gz/cloc.html

tar -xvf dact-0.8.42.tar.gz
make clean (맨처음 실행하면 이건 안해도 됨)
CC=[afl folder]/afl-2.52b/afl-gcc ./configure (컴파일을 afl-gcc로 하겠다)
make 

 

input 데이터 만들어서 퍼징하기

echo hello > hello.txt
./dact hello.txt (hello.txt.dct 생성됨)

mkdir input
mv hello.txt.dct input/

 

sysctl -w kernel.core_pattern=core

[afl folder]/afl-fuzz -i input -o output -- ./dact -dcf (압축해제하는 기능 기준으로 퍼징)

 

퍼징 결과 파악하기

퍼징을 하면 /output/crashes에 여러 파일들이 저장된다.xxd로 확인해보면 퍼징할 때 input으로 넣었던 hello.txt.dct와 비슷한 꼴임을 알 수 있다.

 

압축된 형태인 것 같으니까 dact명령어로 그냥 압축해제 시도

그랬더니 퍼징할 때의 에러를 표시하는 것 같다...

 

 

AFL output 디렉터리

  • crashes : 실제 seg fault 등이 나왔을 때의 unique input 파일
  • queue : 각 path별 입력값들
  • hangs : 지정된 시간을 지났을 때까지 멈췄었던 input 데이터 케이스를 확인할 수 있다. 

 

llvm_mode 사용하기(ASAN과 관련있는 것 같은데 추후 추가할 것)

  • llvm mode로 컴파일하는 목적
    • 성능 향상

 

# vi /etc/apt/sources.list 에다가 아래 내용 추가

deb http://apt.llvm.org/xenial/ llvm-toolchain-xenial-4.0 main
deb-src http://apt.llvm.org/xenial/ llvm-toolchain-xenial-4.0 main

 

wget -O - http://apt.llvm.org/llvm-snapshot.gpg.key|sudo apt-key add -

sudo apt install clang

 

cd ./llvm_mode
sudo ln -s /usr/bin/llvm-config-4.0 /usr/local/bin/llvm-config
sudo ln -s /usr/bin/clang-4.0 /usr/local/bin/clang
sudo ln -s /usr/bin/clang++-4.0 /usr/local/bin/clang++

 

export AFL_USE_ASAN=1

export PATH=/usr/lib/llvm-10/bin:$PATH

make clean all

 

cd dact-0.8.42/

CC=../AFL/afl-2.52b/afl-clang-fast ./configure (configure가 있는/ test하려는 프로그램 소스 디렉터리로 가서 해야함)

make

sudo make install

 

 

 

 

 

 

https://wogh8732.tistory.com/272

 

AFL fuzzer 설명 및 사용방법

1. AFL 퍼저 원리 afl 퍼저는 instrumentation-guided genetic algorithm 과 결합된 퍼저이다. 브푸트포스로 입력을 받지만, 거기서 끝나는게 아니라, 커버리지를 넓혀가며 프로그램 제어 흐름에 대한 변경사항

wogh8732.tistory.com


읽어볼거리

https://medium.com/@ayushpriya10/fuzzing-applications-with-american-fuzzy-lop-afl-54facc65d102

 

Fuzzing Applications with American Fuzzy Lop (AFL)

What is Fuzzing?

medium.com

https://cpuu.postype.com/post/3419500

 

[논문리뷰] Fuzzing: Art, Science, and Engineering - Part 1

KAIST CSRC(사이버보안연구센터)의 VALENTIN J.M. MANÈS 연구원과, 소프트웨어보안 연구실 소속(출신) 학생들, 그리고 차상길 교수님과 MAVERICK WOO 등 Fuzzing 분야의 기라성과 같은 거장 교수님들이 참여하

cpuu.postype.com

 

댓글