Code Monkey home page Code Monkey logo

afl-training's Introduction

Fuzzing with AFL workshop

Materials of the "Fuzzing with AFL" workshop by Michael Macnair (@michael_macnair).

This workshop introduces fuzzing and how to make the most of using American Fuzzy Lop, a popular and powerful fuzzer, through a series of challenges where you rediscover real vulnerabilities in popular open source projects.

The first public version of this workshop was presented at SteelCon 2017 and it was revised for each of BSides London 2019, BSides Bristol 2019, and GrayHat 2020 (most notable change in this revision was a switch to afl++).

Presentation

Via Google slides and as a PDF. There is extra information in the speaker notes.

GrayHat published a recording of a remote version of the workshop on YouTube - this was created for a real-time workshop audience, but you can follow along at your own pace as long as you don't mind skipping a few pauses and ignoring references to Discord.

The presentation suggests when to attempt the different challenges in this repository, and the video provides a walk-through of quickstart and harness.

Pre-requisites

  • 3-4 hours (more to complete all the challenges)
  • Linux machine
  • Basic C and command line experience - ability to modify and compile C programs.
  • Docker, or the dependencies described in quickstart.

Contents

  • quickstart - Do this first! A tiny sample program to get started with fuzzing, including instructions on how to setup your machine.
  • harness - the basics of creating a test harness. Do this if you have any doubts about the "plumbing" between afl-fuzz and the target code.
  • challenges - a set of known-vulnerable programs with fuzzing hints
  • docker - Instructions and Dockerfile for preparing a suitable environment, and hosting it on GCP if you wish. A prebuilt image can be pulled from ghcr.io/mykter/fuzz-training.

See the other READMEs for more information.

Challenges

Challenges, roughly in recommended order, with any specific aspects they cover:

  • libxml2 - an ideal target, using ASAN and persistent mode.
  • heartbleed - infamous bug, using ASAN.
  • sendmail/1301 - parallel fuzzing
  • ntpq - fuzzing a network client; coverage analysis and increasing coverage
  • date - fuzzing environment variable input
  • cyber-grand-challenge - an easy vuln and an example of a hard to find vuln using afl
  • sendmail/1305 - persistent mode difficulties

The challenges have HINTS.md and ANSWERS.md files - these contain useful information about fuzzing different targets even if you're not going to attempt the challenge.

Most of the challenges also have an ANSWERS-libFuzzer.md file, for if you want to try out using LLVM's libFuzzer. These are brief descriptions of the differences for libFuzzer, and should be read alongside the afl docs (.md files).

All of the challenges use real vulnerabilities from open source projects (the CVEs are identified in the descriptions), with the exception of the Cyber Grand Challenge extract, which is a synthetic vulnerability.

The chosen bugs are all fairly well isolated, and (except where noted) are very amenable to fuzzing. This means that you should be able to discover the bugs with a relatively small amount of compute time - these won't take core-days, most of them will take core-minutes. That said, fuzz testing is by definition a random process, so there's no guarantee how long it will take to find a particular bug, just a probability distribution.

Links

afl-training's People

Contributors

mykter avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

afl-training's Issues

Presentation doesn't have speaker notes

In readme there is a line "There is extra information in the speaker notes". But actually it has only slides. And there is no option to open speaker notes.

How long time does it need to detect the heartbleed vul?

Hi,
I have done the experiment as the tutorial, but only about 78 paths detected after 24 hours fuzzing, neither does the heartbleed vulnerability.
The process is as follow:

  1. git clone https://github.com/openssl/openssl.git
  2. git checkout Checkout at tag OpenSSL_1_0_1f
  3. export CC=/afl/afl-clang-fast export CXX=afl/afl-clang-fast++
  4. in openssl dir, ./config && AFL_USE_ASAN=1 make
  5. build the handshake binary
    AFL_USE_ASAN=1 /afl/afl-clang-fast++ -g handshake.cc openssl/libssl.a openssl/libcrypto.a -o handshake -I openssl/include -ldl
  6. set "AAAAAAAAAA" as the seed
  7. run the AFL
    /afl/afl-fuzz -i /seed -o /out -m none -- //handshake

Regards,
xiaosatianyu

Add a QEMU / dyninst challenge

There isn't time to cover it in the typical 4hr format, but people might find it valuable to have in the materials to work on after or if they're doing it offline.

In harness section, for arbitary input formats harness, how to write a file input test harness

If write harness as example https://github.com/mykter/afl-training/tree/main/harness#arbitrary-input-formats
the harness can tell which case to run based on the 1st parameter.
In this circumstances, how to make the harness read from input file? if we write the "echo" and "mul" in seed file, the AFL will mutate the "echo" and "mul" as well. if we just write the parameters in seed file, how the harness know whether lib_echo or mul be called?

Examples that AFL cannot support

Hello @mykter! Really amazing collection in this repo!

I was wondering if you also have any examples and (most importantly) programs that have some kind of file IO, or they change their environment, that prohibits AFL of finding bugs?

I'm working on an isolation framework around AFL to checkpoint application files in case they have changed. So when the AFL forkserver spawns a new process, all files are reverted to their initial condition.

compile handshake.cc error

when compile target in heartbleed by

AFL_USE_ASAN=1 afl-clang-fast++ -g handshake.cc openssl/libssl.a openssl/libcrypto.a -o handshake -I openssl/include -ldl

I got
image
I looked at the source code of handshake.cc, there does not exist identifier data or size.
How can I do to fix this?

ASan cgroups limit_memory script not working

I'm trying to complete the heartbleed challenge and the limit_memory.sh script doesn't work as the ASNWERS.md file suggests.

First of all, the script is located in the ~/AFLplusplus/utils/asan_cgroups/ directory, and not ~/AFLplusplus/examples/asan_cgroups/, like the answers file suggests.

Second of all, when you do try to run the script, then it fails:

sudo ~/AFLplusplus/utils/asan_cgroups/limit_memory.sh -u fuzzer afl-fuzz -i in -o out ./handshake

cgcreate: libcgroup initialization failed: Cgroup is not mounted

I also tried running it in the official AFL++ docker image, but ran into the same problem.

I don't know too much about cgroups, so I'm not sure what's going wrong. I'm running AFL++ from a privileged docker container, from inside a Virtualbox VM, if it makes any difference.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.