FUZZING FOR BEGINNERS (KUGG teaches STÖK American fuzzy lop)

STÖK
11 May 202025:56

Summary

TLDRIn this video, Stick teams up with Christopher, aka Cook, to delve into the basics of fuzzing using AFL (American Fuzzy Lop). Christopher explains the process of using AFL to find bugs in binary programs through automated testing. They discuss the importance of compiling programs with instrumentation, setting up the environment, and running AFL on an HTTP server. The video demonstrates how to identify and analyze crashes, offering insights into bug hunting and reporting. Additionally, they highlight the value of fuzzing for various parsers and the potential for exploiting vulnerabilities.

Takeaways

  • 😀 Introduction to Fuzzing: The script introduces fuzzing as a method to find bugs in binary programs by sending numerous requests into a system.
  • 🔧 AFL Tool Overview: AFL (American Fuzzy Lop) is highlighted as a fast testing tool used for fuzzing, which can automate the process of finding bugs.
  • 🛠️ Compilation with AFL: The script explains how to compile a program using AFL by replacing the GCC with AFL-GCC and setting the CC environment variable.
  • 🔬 Instrumentation: AFL's instrumentation feature allows for tracking the internal state of a program during execution, which is useful for identifying when specific code paths are reached.
  • 🔄 Synchronization in Multi-core Systems: AFL can synchronize output across multiple cores or machines, which is beneficial for large-scale fuzzing operations.
  • 📁 Output Directory Importance: The output directory in AFL is crucial for syncing results, storing crashes, and managing the fuzzing queue.
  • 🚫 SSD Fuzzing Caution: The script advises against running fuzzing on SSDs due to the high volume of writes, suggesting the use of RAM-based storage like tmpfs instead.
  • 🔄 Fuzzing Automation: AFL automatically mutates input data to discover new paths within the program, learning from each iteration.
  • 🛑 Handling Crashes: The script discusses how to handle crashes found during fuzzing, using tools like gdb to analyze and understand the cause of the crash.
  • 🔑 Security Implications: Fuzzing can reveal serious security vulnerabilities, such as privilege escalation and denial of service, which can be critical in systems running as root.
  • 🔍 Debugging and Exploitation: The process of using gdb to debug a program post-crash is outlined, which is essential for creating proof-of-concept exploits.
  • 🌐 Community and Resources: The script mentions the availability of web casts and the F-Secure Lab channel on YouTube as community resources for learning more about fuzzing.

Q & A

  • What is AFL and what does it stand for?

    -AFL stands for American Fuzzy Lop, but in the context of this script, it refers to a fast testing tool used for finding bugs in binary programs by sending a lot of requests into something.

  • How does fuzzing work in the context of AFL?

    -Fuzzing involves sending a lot of random inputs into a program to see how it behaves. AFL takes an original input and transforms it in each iteration, running thousands of iterations every second to test the program's response to various inputs.

  • What is the role of GCC in AFL?

    -GCC is a compiler used in Linux for compiling software. In AFL, you replace GCC with AF-GCC, which compiles the program with built-in instrumentation, allowing AFL to understand what's happening inside the program during execution.

  • What is instrumentation in the context of AFL?

    -Instrumentation in AFL refers to the process of modifying the code being built so that every time the program reaches a certain state, it is registered by the instrumentation. This helps AFL understand the program's internal workings and behavior.

  • Why is it recommended to not run AFL on SSD drives?

    -SSD drives are not always ready to handle the high volume of writes that AFL generates, which can be harmful and wear them out quickly. Instead, using tmpfs, which is a temporary file storage in RAM, is recommended for the output directory to avoid excessive writes to SSD.

  • What does the output directory in AFL contain?

    -The output directory in AFL contains the results of the fuzzing process, including crashes, hangs, bitmaps, statistics, and other data. It is also used for synchronization between multiple machines or cores running AFL.

  • What is the purpose of the queue data in AFL?

    -The queue data in AFL shows the original file in the queue where it started and its current position. It helps AFL learn from each iteration and adjust its approach, flipping bits and learning what type of data the program wants or doesn't want.

  • How does AFL handle synchronization in a multi-core or multi-machine setup?

    -AFL uses the output directory to synchronize multiple slaves in a multi-core or multi-machine setup. The master process gives the slaves a queue of tasks to do, ensuring they always have work to do until the master updates the queue.

  • What is the significance of finding crashes during fuzzing?

    -Finding crashes during fuzzing is significant because it indicates potential vulnerabilities in the program. These crashes can be the starting point for further analysis and exploitation, leading to the discovery of serious bugs or security issues.

  • How can the crashes found by AFL be used for further analysis?

    -The crashes found by AFL can be analyzed using tools like gdb to understand the program's behavior at the time of the crash. This can help in identifying the cause of the crash, such as a segmentation fault or memory corruption, and potentially lead to the creation of a proof-of-concept exploit.

  • What is the role of gdb in analyzing crashes found by AFL?

    -Gdb (GNU Debugger) is a tool used for debugging programs. It can be used to analyze crashes found by AFL by running the program with the problematic input and observing the behavior, stack trace, and register states at the time of the crash, which can help in understanding and exploiting the vulnerability.

Outlines

00:00

😀 Introduction to AFL Fuzzing

In this introductory segment, Stick and Christopher (also known as Cook) discuss the basics of fuzzing and AFL (American Fuzzy Lop). Cook explains that AFL is a fast testing tool designed to find bugs in binary programs by sending numerous requests into a system. The process involves taking an original input and transforming it through thousands of iterations per second. Cook demonstrates how to set up AFL by replacing the GCC compiler with AF-GCC and setting the CC environment variable. This enables the compilation of programs with built-in instrumentation, which allows AFL to monitor the program's state and detect when it reaches points of interest, such as breakpoints.

05:02

🔍 Fuzzing an HTTP Server Configuration File

The second paragraph delves into the specifics of fuzzing an HTTP server's configuration file. Cook discusses the importance of fuzzing the configuration file parser, especially when an attacker might have arbitrary write access. The goal is to potentially crash the process and exploit the memory overwrite. The input for AFL in this case is the configuration file, and the output is a directory where AFL syncs its findings. Cook also mentions the importance of not running AFL on SSD drives due to the high number of write operations, which can wear out SSDs. Instead, using tmpfs (temporary file storage in RAM) is recommended. The discussion also touches on the ability to synchronize fuzzing efforts across multiple machines or a cluster.

10:02

🚀 AFL Fuzzing in Action and Finding Crashes

In this segment, the focus is on running AFL to fuzz an HTTP server and observing the results. Cook demonstrates how AFL quickly identifies crashes, which are the starting point for further analysis. The discussion includes the scalability of AFL, which can be run on multiple cores to increase the number of attempts per second, potentially leading to the discovery of more bugs. Cook also explains that AFL can be run in the cloud or on multiple cores to speed up the process. The output directory is highlighted as a crucial component, containing information about crashes, hangs, and the queue of inputs being tested. The segment ends with a look at the crashes directory, which contains the configuration files that caused the crashes.

15:04

🐛 Analyzing Crashes and Using GDB

This paragraph discusses the analysis of crashes found during fuzzing. Cook explains that the output directory contains a 'crashes' directory with files that caused the crashes, as well as a README file that provides information on how the bug was found. The discussion moves to using GDB (GNU Debugger) to further investigate the crashes. GDB is highlighted as a valuable tool for security research and CTF competitions. Cook demonstrates how to run GDB on the HTTP server and analyze the crash by setting breakpoints and examining the program's behavior. The goal is to understand why the program crashes and potentially exploit the vulnerability.

20:08

🔎 Exploring the Impact of Fuzzing and Reporting Bugs

In this segment, Cook and Stick discuss the implications of fuzzing and the process of reporting bugs. They mention that fuzzing can lead to the discovery of denial of service vulnerabilities and privilege escalation issues. Cook shares his experience of reporting a bug to an HTTP server vendor, providing details on how the bug was found and the stack trace obtained using GDB. The conversation also touches on the potential for fuzzing to uncover bugs in various file formats and parsers, which can be exploited for different purposes. The importance of responsible disclosure in bug bounties and penetration testing is emphasized.

25:10

🌐 Community and Resources for Fuzzing

The final paragraph wraps up the discussion by highlighting the community aspect of fuzzing. Cook mentions setting up webcasts to help people get started with fuzzing and provide a platform for live interaction and support. The F-Secure Lab channel on YouTube is introduced as a resource for those interested in fuzzing. The conversation concludes with an appreciation for the learning experience and an invitation for viewers to join the fuzzing community and explore the potential of AFL and fuzzing techniques.

Mindmap

Keywords

💡Fuzzing

Fuzzing is an automated software testing technique that involves providing random, invalid, or unexpected data to a program in order to observe how it handles the input. In the context of the video, fuzzing is used to find bugs in binary programs by sending numerous requests to test the program's robustness and uncover potential vulnerabilities. The script discusses the use of AFL (American Fuzzy Lop), a fuzzing tool, to perform this testing.

💡AFL (American Fuzzy Lop)

AFL is an open-source fuzzing tool designed to discover bugs in binary programs by automatically generating input data and observing the program's behavior. It is central to the video's theme, as the tutorial focuses on using AFL to fuzz an HTTP server and find potential crashes or vulnerabilities. The script mentions using AFL with GCC (GNU Compiler Collection) to compile programs with instrumentation for fuzzing.

💡Instrumentation

In the context of fuzzing, instrumentation refers to the process of modifying a program's code to collect runtime information about its execution. This allows the fuzzer to understand the internal state of the program and identify paths taken during execution. The video script explains that AFL compiles programs with built-in instrumentation to track the program's behavior during fuzzing.

💡GCC (GNU Compiler Collection)

GCC is a collection of compilers for various programming languages, including C and C++. In the script, it is mentioned that AFL replaces GCC with 'AFL-GCC' to compile programs with instrumentation, which is a crucial step in preparing a program for fuzzing with AFL.

💡Configuration File Parser

A configuration file parser is a component of a program that reads and interprets configuration files. In the video, the focus is on fuzzing the parser of an HTTP server's configuration file, assuming an attacker has write access to this file. The goal is to find input that causes the parser to crash or behave unexpectedly.

💡Crashes

In the context of the video, crashes refer to the instances where the fuzzed program encounters an error and terminates unexpectedly. The script describes finding crashes as a significant outcome of fuzzing, as they indicate potential vulnerabilities that can be further investigated and exploited.

💡SSD (Solid-State Drive)

SSDs are storage devices that use flash memory to store data. The script mentions that running fuzzing, which involves a high number of writes, on an SSD can be harmful due to the limited write cycles of flash memory. It suggests using 'tmpfs', a temporary filesystem stored in RAM, to mitigate this issue.

💡tmpfs

tmpfs is a temporary filesystem in Unix-like operating systems that resides in volatile memory (RAM). The script recommends using tmpfs for the output directory of fuzzing tools like AFL to avoid the wear and tear on SSDs caused by the high volume of writes during fuzzing.

💡GDB (GNU Debugger)

GDB is a debugger tool used to analyze and debug programs written in C, C++, and other languages. In the script, GDB is used to analyze crashes found by AFL, allowing the user to understand the cause of the crash and potentially develop an exploit. The video mentions using GDB to investigate a segmentation fault in the fuzzed HTTP server.

💡Segmentation Fault

A segmentation fault is a specific kind of error caused by accessing memory that the program is not allowed to access. In the video, a segmentation fault is identified as a result of fuzzing the HTTP server, indicating a serious vulnerability that could potentially be exploited for privilege escalation.

💡Privilege Escalation

Privilege escalation refers to the act of exploiting a bug or vulnerability to gain higher levels of access or permissions in a system. The script discusses the potential for a segmentation fault caused by fuzzing to lead to privilege escalation, allowing an unprivileged user to gain root access.

Highlights

Introduction to using AFL (American Fuzzy Lop) for beginners as a fast testing tool to find bugs in binary programs.

Fuzzing is the process of sending numerous requests into a system to find vulnerabilities.

AFL works by taking an original input and transforming it through thousands of iterations per second.

The importance of automation in fuzzing to ensure efficiency.

Setting up AFL involves using a compiler like GCC with an environment variable CC.

Compiling with AFL involves instrumenting the code to track program states.

Instrumentation allows AFL to understand and learn from the program's behavior during execution.

AFL can be run on multiple CPUs with tuning options for performance.

The discovery of a vulnerability in an HTTP server during fuzzing sessions.

Explanation of how fuzzing an HTTP server's configuration file can lead to crashes.

The use of an output directory for AFL to synchronize findings across multiple processes or machines.

Avoiding SSD drives for the AFL output directory due to high write operations that can wear out SSDs.

AFL's ability to mutate input data to discover what type of data a program wants or rejects.

AFL's use of a queue system to manage input data and mutations.

Finding crashes with AFL and the significance of these crashes for vulnerability discovery.

Using GDB (GNU Debugger) to analyze crashes and understand the underlying code issues.

The process of reporting a discovered vulnerability responsibly to the affected vendor.

AFL's continuous learning and mutation process until it exhausts the search space.

The potential for fuzzing to be applied to various file formats and parsers in security research.

The value of fuzzing in bug bounty programs and penetration testing.

Upcoming webcasts on fuzzing to help beginners get started and troubleshoot issues.

F-Secure Lab's initiative to create a community around fuzzing to increase its adoption.

Transcripts

play00:00

hi I'm stick and today I'm gonna learn

play00:04

something new and for this reason I

play00:07

brought on Christopher yeah also known

play00:10

as cook to help me understand the

play00:14

beginner's guide to fussing or a mean

play00:18

audience in a beginner's guide but it's

play00:20

gonna be an introduction to using AFL

play00:22

thank you so far

play00:24

hi I'm cook hi cook cook instead show

play00:28

yeah so we you and I outside of this

play00:33

camera

play00:34

situation has had been has been playing

play00:37

around a little bit with fussing and I

play00:39

kind convince you to get on here and

play00:43

teach me and others how this actually

play00:45

works and talk a little bit about

play00:46

fussing so without any further ado

play00:49

please take it away

play00:51

all right so today we're gonna play with

play00:53

AFL AFL is fast testing tool and it's a

play00:59

method to find bugs in binary programs

play01:03

fussing is sending a lot of like

play01:05

requests into something right is that

play01:08

the idea yeah so you have an original

play01:12

input in a dictionary of possible inputs

play01:15

and then it's taking that original thing

play01:18

and transforming it every time it runs a

play01:21

new iteration and it runs thousands of

play01:24

iterations every second so this is

play01:27

automation yeah definitely you have to

play01:29

automate it otherwise it won't work okay

play01:34

show us how you did it okay so

play01:38

essentially when you want to do this

play01:40

when you want to run AFL you have to use

play01:43

a compiler so compiling software you do

play01:49

it with in Linux you do it with GCC

play01:52

normally and GCC is by the compiler

play01:57

program called make or make file sis is

play02:00

define an environment variable called CC

play02:02

so CC equals GCC is an environment

play02:06

variable that's automatically assumed

play02:07

every

play02:08

you do a compilation and compiling

play02:11

programs means to take all that C code

play02:13

and turn it into turn it into a binary

play02:18

program cool with AFL you're going to

play02:21

replace GCC with with your thing so our

play02:26

thing is AF - GCC and setting that

play02:33

environment variable we can now compile

play02:36

the program with something called

play02:39

instrumentation built-in and that means

play02:41

that it's changing the code that you're

play02:43

building so that every time it comes the

play02:46

program turns into a certain state then

play02:49

that's registered by something called

play02:50

the instrumentation instrument or the

play02:52

instrumentation state oh cool right so

play02:55

having instrumentation means that you

play02:59

can know what's going on inside of the

play03:01

program when you run it and this is a

play03:03

really nice feature with a FL that other

play03:06

Foster's aren't that good at and that

play03:09

means that if al can understand when you

play03:12

have reached into a point that you're

play03:15

interested in reaching say you want to

play03:18

you want to break a certain point in a

play03:21

certain place than a FL will know if you

play03:23

are there so it's some kind of break

play03:25

points so taking its just measuring all

play03:28

the time like where are you in the code

play03:30

and if something breaks breaks it's

play03:32

gonna know instantly yeah yeah it's

play03:34

definitely like a break point I think

play03:37

this is more more what you could call a

play03:39

function hook where you take a regular

play03:41

function you put yourself in a place of

play03:43

it and and that's something that it can

play03:46

put into some kind of a live

play03:48

documentation that it's understanding

play03:51

and learning from that so it's a sort of

play03:53

a self learning program cool so once you

play03:57

have compiled your program you can start

play04:00

it using the AFL foster that looks a bit

play04:04

like this AFL fuss is name of the

play04:07

program you want to run efl by the way

play04:09

is a program that you can download using

play04:11

apt-get install AFL that's it

play04:14

so it's it's super easy to set up just

play04:17

get started and yeah now you're up and

play04:19

running on different CPUs you have some

play04:22

different tuning options that you want

play04:24

to set and those tuning options is

play04:26

something that AFL will tell you what to

play04:29

do with so you can adapt to multiple

play04:31

cores and you can do different things

play04:33

but it depends on your architecture

play04:35

we've already done this but if I will

play04:37

tell you exactly what you need to do for

play04:39

your CPU cool so the - I argument it

play04:45

gives you the inputs to the program and

play04:48

we're gonna take a look at the input to

play04:50

this program because we are today

play04:52

fussing HTTP server no I got cool and

play04:55

the HTTP server we are fussing we did

play04:58

one more take with this last week and we

play05:01

are ready to publish it when we realize

play05:03

that we have found this here today and

play05:04

we had to report it and that meant that

play05:06

we couldn't really publish it at that

play05:08

time right so this is the second

play05:10

recording for that obviously yeah when

play05:13

you financier days do during your

play05:16

fussing sessions it's a good thing to

play05:19

report those yeah so we're gonna show

play05:22

you how we found that Saturday but we're

play05:23

not going to show you what program it's

play05:25

in but it's a HTTP server we'll give you

play05:27

that much so if you look it into the

play05:31

input directory I have a default

play05:33

configuration file that sort of looks a

play05:35

bit this is this a fake configuration

play05:38

folder I wrote it's this similar to the

play05:41

default file where the domain domain

play05:44

name is f-secure comm which is my my

play05:47

employer the the configuration file is

play05:49

pretty straightforward we are today

play05:53

going to fuss the configuration file

play05:55

parser and the reason why we want to

play05:58

fastest parser is because we are

play06:00

assuming that an attacker has arbitrary

play06:03

write access but once the escalator

play06:06

privileges to root or get access to

play06:09

whatever that server is is doing and

play06:12

since you have write access if you write

play06:14

to that configuration file something

play06:16

arbitrary and bad

play06:17

then maybe you can make the process

play06:19

crash and if the process crashes then

play06:22

you can overwrite this memory and that's

play06:23

what we're gonna try to do or already

play06:25

used wait for it let's say that we had a

play06:27

malicious conferral that we created and

play06:30

uh well we would use do is to either use

play06:33

crash the daemon itself right or or just

play06:36

wait for it to reboot and then hopefully

play06:38

you know nobody's noticing what's going

play06:40

on in wala suddenly we have root axes

play06:43

yeah exactly

play06:45

and in this case the input to a FL is

play06:49

that configuration file so the default

play06:53

the default configuration file is pretty

play06:57

much what we need as an input as an

play07:01

output output in this case is a

play07:03

directory where a FL is syncing whatever

play07:06

it's doing with other processes so if

play07:09

you run this with multiple course you

play07:11

can synchronize that output using the

play07:13

output directory and this is something

play07:16

that you can synchronize between

play07:18

multiple machines even so if you're

play07:20

having a cluster running it and you want

play07:22

all these machines to know what's going

play07:25

on

play07:25

that's good things just meant can you

play07:28

map this over network or is that not

play07:30

recommended yeah you can so what what

play07:34

the master process does is it

play07:36

synchronizes multiple slaves using the

play07:39

output directory and then it gives the

play07:41

slaves a queue of things to do so if

play07:44

there is a certain lag between the

play07:46

machines that queue will sort of work

play07:49

itself out so as long as the lag is not

play07:51

longer than the queue then the slaves

play07:53

will have something to do to do until

play07:55

the master realizes that this is where

play07:58

we want to go with with the fussing so

play08:01

all the directory is pretty important it

play08:03

also contains wherever our like crashes

play08:07

and things that we found out during the

play08:09

this attempt is going to end up in the

play08:10

output directory

play08:11

oh cool I got a question though and I

play08:14

know last time we talked a little bit

play08:15

about it we and it didn't really strike

play08:19

me self out for me but you've mentioned

play08:20

that it would be a good idea to not run

play08:23

this on SSD drives right so the output

play08:26

directory is some directory that is

play08:29

written to a lot of times so it's

play08:31

written for every single instance in my

play08:34

case is writing 2000 times every second

play08:38

and that means a lot of Rights and for

play08:41

an SSD that can be a bit harmful SSDs

play08:44

are are not always ready to handle that

play08:46

much data and it can wear them out

play08:48

quickly and therefore there is something

play08:50

called tmpfs which is like what do you

play08:53

have in /tmp in your machine where you

play08:55

can write as many times as you like

play08:57

because it's on the RAM and it's all

play08:59

very quick so so we have the input which

play09:02

is the config file actually we can have

play09:04

a directory full of inputs so if we had

play09:06

a bunch of other bunch of other config

play09:10

files there that would be fine and that

play09:12

gives a file inspiration to how to

play09:15

destroy things oh okay so it's fetching

play09:18

all this other stuff as well and yes

play09:20

thinks about maybe this you can put

play09:22

random data in there and you can put

play09:24

legitimate data in there eventually AFL

play09:28

will figure out what type of data this

play09:30

program wants

play09:32

so it's or doesn't want so the next

play09:34

argument for AFL is to type in hd-dvd

play09:38

and that's the name of the server that

play09:41

we are fussing and there C is the

play09:46

arguments for a config file and then we

play09:48

type in at-at-at that is the variable

play09:50

where EFL will input the forcing

play09:54

mechanism so this is where it will go

play09:55

and attack so if we run this it's going

play09:58

to initiate by trying to find basic

play10:02

paths into the program and just try to

play10:05

understand the program and now it's

play10:06

started and even like in the first

play10:10

second here we found a crash and when

play10:12

this turns red and it says one unique

play10:14

crash then we have essentially we have

play10:17

the beginning of a CRT

play10:19

because this is yeah and that's not the

play10:24

time it takes to sometimes there's the

play10:26

second one

play10:28

and so now we're running in two thousand

play10:32

attempts a second you can I mean you can

play10:35

scale this as much as you want to if you

play10:37

have more course you can scale this much

play10:39

much faster and if you do that then you

play10:42

can find more bugs basically and if you

play10:46

are pressed with time let's say that

play10:49

you're a developer and you want to test

play10:50

your own software then maybe you want to

play10:52

do this in the cloud or you run it on

play10:54

multiple cores and you get it up to

play10:56

maybe thirty thousand twice a second

play10:58

because that's gonna take the tax base

play11:01

or make it much shorter absolutely it's

play11:05

like if you can run this like not just

play11:08

one time faster like ten or twenty times

play11:10

faster yeah horse you're gonna save like

play11:12

a lot of time where it yeah isn't it

play11:14

gonna be like very CPU intensive and

play11:16

very expensive that if you let's say

play11:19

you're putting it in a cloud storage

play11:20

somewhere yeah I mean it uses only CPU

play11:23

so if you have a story solution where

play11:27

where CPU is cheap and the rest is

play11:29

expensive then that's fine

play11:31

but but it's using a lot of CPU and

play11:34

somewhat a bit of network if you have it

play11:37

networked but but it's only using as

play11:41

much as you allow it to use so you can

play11:43

make it make it crash and hang in

play11:45

different different ways

play11:47

damn it that means that I'm gonna have

play11:50

to buy back all my old rack servers now

play11:52

again yeah yeah so CPU cost nothing if

play11:56

you own the server if you have your own

play11:58

servers and this is what they're for

play11:59

right used abuse for cracking and CPUs

play12:02

for fussing yeah oh man oh man so right

play12:06

now we're running on 12% of the CPU that

play12:10

means in this case that we're running on

play12:12

bond core only which is enough for our

play12:14

example and in another caste we can show

play12:17

maybe how to increase that number

play12:19

because if you use more than or up to a

play12:22

hundred percent of the CPU that means

play12:24

all course then you can then you can

play12:28

make a lot of damage

play12:30

hey let's do that that would be exciting

play12:33

but and it's this ever going to stop

play12:38

though or or it doesn't ever feel like

play12:42

I'm done now this this never exhausts

play12:45

because it actually has ways of muting

play12:50

the output and coming up with new ideas

play12:51

until forever so I think this can pretty

play12:55

much go on forever in this case but you

play12:59

can exhaust the search space for a given

play13:02

input so imagine you have you know that

play13:05

a program only takes true or false as an

play13:07

argument then that search space will be

play13:11

exhausted pretty quickly and the program

play13:13

will just run on hot fuse basically cool

play13:16

so we we currently have two crashes what

play13:22

does that really mean like what do one

play13:24

simply do with the crashes yeah so now I

play13:27

interrupted the program typing control-c

play13:29

and it says we're done have a nice day

play13:31

thanks and I'm done too right so now we

play13:34

have the output directory let's take a

play13:35

look at that so in the output directory

play13:38

you can see the crashes directory the

play13:40

first bitmap that gives an information

play13:42

about where in RAM are we at this point

play13:45

statistics hangs that's an option to

play13:48

crashes so the hang is when a program

play13:50

doesn't finish in a given certain time

play13:52

so you put a timeout on a program you

play13:55

can assume that it's not supposed to

play13:57

hang until this or that or it's supposed

play13:59

to finish before that's the particular

play14:01

time and and every input that exceeds

play14:04

that ends up in hang block data don't

play14:08

know the queue is where the next input

play14:11

is queued let's look at the queue yet

play14:13

for now because this is pretty pretty

play14:15

interesting so looking at what it's

play14:17

doing it shows the original file in the

play14:20

queue where it started and then it shows

play14:21

where it's at so right now this queue

play14:24

data here is on position 25 and it's

play14:26

flipping one bit and

play14:29

we can look at what that looks like it

play14:31

pretty much looks like a shorter version

play14:33

of the previous file it's flip flip flip

play14:36

they stopped what it did previously and

play14:38

every time it does this it learns that

play14:41

parsing the config file at this point

play14:44

gave that output and config parsing the

play14:46

config file it and another point Kay

play14:48

gave something else in terms of of we're

play14:51

in the matheletes ending up let's move

play14:54

into the crashes directory because

play14:56

that's what you wanted to see right

play14:57

whoopsie yep

play14:58

so there is a readme file and this

play15:01

readme file is pretty good the readme

play15:03

file shows what you actually ran to find

play15:06

this bug and that's something that you

play15:10

can give to a to a organization that the

play15:15

dust is testing so that they can

play15:17

actually know what's going on I mean if

play15:20

they want to reproduce this bug then

play15:22

then it's good to have that command line

play15:24

saved so this entire directory is

play15:27

relevant for anyone who wants to

play15:28

reproduce it cool inside of here we have

play15:33

the config file that caused the crash so

play15:37

this is a config file that has a

play15:38

character called 8a in it and that's

play15:43

like a non ASCII character maybe that's

play15:45

the reason white crashed maybe there is

play15:47

another reason it says that the log

play15:49

access file is called hard bracket that

play15:52

looks kind of weird as well and the doc

play15:55

index has bracket as well maybe that's

play15:57

not it we don't know exactly but we can

play16:00

find out eventually we can look at the

play16:02

other file for now so this is two files

play16:05

representing two different crashes

play16:09

all right so this is a weird one and

play16:12

weird is good the weirder the better

play16:15

yeah so now it's actually advantage to

play16:18

produce this kind of a string here where

play16:20

it says TMM Vernis whatever that means

play16:23

yeah and that's yes the the machine

play16:26

talking and in other cases woman when I

play16:30

did fussing with with pictures before I

play16:32

started with basically an empty file and

play16:34

it actually managed to produce in a few

play16:37

days it managed to produce a valid JPEG

play16:41

header by us looking at the reaction

play16:43

from the programs like if I want to get

play16:45

a step further I have to type in this in

play16:47

this position oh cool so here it's

play16:50

actually created the image for you yeah

play16:53

yeah and that's built it up yeah that's

play16:56

the definition of mutation right cool so

play17:01

this is a configuration file that also

play17:04

causes a crash and there's also non

play17:06

ASCII characters in a comment on the

play17:09

last line maybe that has something to do

play17:11

with it I'm not exactly sure yet so I'm

play17:13

gonna back out to this directory where

play17:17

the HTTP server was yeah and now I'm

play17:20

gonna run gdb and gdb sounds for annuity

play17:23

bugger it's if you are into CTF or any

play17:30

type of security research gdb is a good

play17:32

tool to know it's older than me and it

play17:35

has a lot of good plugins for its that

play17:39

can enable you to write exploits later

play17:41

cool so we're gonna run gdb on httpd

play17:46

which is the name of the server and

play17:48

right now I didn't compile it with the

play17:51

bug symbol so it's not super easy to

play17:53

find out what I what's going on but if I

play17:55

have debug symbols on it's going to tell

play17:57

me on what line in the code the bug

play18:00

exists which is pretty nice sorry I'm

play18:03

gonna set up an argument which is - see

play18:09

this is the configuration I do for the

play18:12

programs I typeset args - C and then

play18:16

output crashes and then I paste in the

play18:19

name of that file the second file that

play18:21

cost a problem for us

play18:24

so this is now the configuration file of

play18:27

the program at this point I can set up a

play18:30

breakpoint myself if I happen to know

play18:32

what I'm going for if there's something

play18:34

in particular I'm interested in but yet

play18:36

right now I don't know so now I can run

play18:38

some people put the breakpoint on main

play18:40

for instance which is usually a function

play18:43

that starts initially in the pro in the

play18:45

program in this case I know there is no

play18:47

main function so it's not gonna work the

play18:49

main function doesn't work necessarily

play18:51

the way I wanted to but you can put the

play18:53

breakpoint on either and offset into the

play18:55

file or into a function that you think

play18:58

caused the crash this is much easier to

play19:00

do if you have debug symbols on so if I

play19:04

type on run right now then you'll see

play19:08

that there is a segmentation fault and

play19:10

this is not supposed to happen normally

play19:12

like a program is not supposed to seg

play19:14

fault every time it reads the cosmic

play19:16

file then you have a serious

play19:18

vulnerability in this case this is a

play19:21

vulnerability where we are running as an

play19:23

unprivileged user writing to a config

play19:25

file right and the service is reading

play19:29

that config file and it's corrupting

play19:31

memory causing a seg fault somehow yes

play19:35

and it's doing it as root because root

play19:37

is needed to start this service and bind

play19:40

port 80 and this is running as root

play19:42

initially and then when it's running

play19:45

it's it's crashing and I have Minkoff

play19:48

all of the memory so that's a privilege

play19:50

escalation on the kind of suite and and

play19:55

here we can do a back trace

play19:56

oops sorry a back trace where it shows

play20:03

the states of of the program and you can

play20:07

look into the info about the registers

play20:10

that you're dealing with right now

play20:14

no idea

play20:16

I'm sorry about that there are more

play20:18

tutorials that can go into depth and

play20:20

show how to do this the exploitation and

play20:23

proof of concept state because what we

play20:25

have right now is a crash right we have

play20:27

a denial of service vulnerability that's

play20:29

local by the way but it's still

play20:31

something after this point in time we

play20:34

start figuring out why is the return

play20:36

winter here at this point why is it

play20:38

there what happened how did it secure if

play20:42

we do that using gdb we can start

play20:45

figuring out writing a proof-of-concept

play20:48

exploit have you done osip by the way

play20:51

the buffer overflow part is very much

play20:53

like this right so this is exactly

play20:56

that's that you have to do at this point

play20:59

you can you can input a certain pattern

play21:01

into the program see if that pattern

play21:04

reoccurs and if you do that you can see

play21:06

where this is a memory and what you were

play21:08

able to overwrite using the original

play21:10

config file that we looked at and this

play21:13

is pretty much how you say a file that's

play21:16

amazing so the whole idea with AFL is

play21:18

for us to by automation and a little bit

play21:21

of and I wouldn't called ai but at least

play21:23

a little bit of learning that it learns

play21:26

what's going on in the process and then

play21:28

when it crashes its try to replicate it

play21:30

and see what happens again again again

play21:32

again until you know whatever kind of

play21:34

break it then this happens and it

play21:37

outputs that file and that's where the

play21:38

exploitation creation begins right yeah

play21:42

we're we're people this is where when

play21:44

people write exploits this is what they

play21:46

do

play21:46

yeah and this is how you this is how you

play21:49

find a bug and and this is something

play21:52

that I already in this point

play21:54

reported to the vendors I told the HTTP

play21:58

server vendor what the bug was about how

play22:00

it was found what the stack looked like

play22:03

by using gdb and gave the core dump file

play22:06

to them so they could reproduce that bug

play22:08

in their local environment and see that

play22:09

this is a problem that's very

play22:11

responsible of you I'm I'm very proud in

play22:15

bug bounty do you think this is useful

play22:18

for you maybe it's not this situation

play22:21

because in bug bounties you don't if you

play22:26

get this far you report it and get out

play22:29

right you can touch just a part of it

play22:33

this that's that's game over you've done

play22:35

your work you don't privilege escalate

play22:38

further on you might just be doing it in

play22:40

pen testing my buddy bounties you don't

play22:42

do it but I see other areas where this

play22:45

can be very interesting like there's

play22:47

file formats there's

play22:49

different other servers parsers and

play22:52

things that are being used by our

play22:54

industry that if you can find an exploit

play22:57

or something that breaks that that could

play22:59

turn into I don't know a DOS or some

play23:02

kind of other this configuration

play23:04

happening maybe I don't know maybe even

play23:06

a little bit of memory leak if you're

play23:07

lucky right so I mean if you have an

play23:10

input like a sip file or a JavaScript

play23:13

parser or something where you can upload

play23:15

maybe a HTML document that's key

play23:17

getting parsed or CSS getting parsed or

play23:21

maybe maybe a video file or something

play23:24

mm-hmm there's there's all these parsers

play23:28

out there that that's gonna have to deal

play23:30

with and I know you and I have been

play23:33

goons and reaches research on this and

play23:35

eventually yeah I would recommend anyone

play23:39

to to you at least started to doing a

play23:41

little bit of fussing I think it's super

play23:43

super fun and and so rewarding when you

play23:46

see that crashes sign coming up you're

play23:48

like yeah so I mean it's it's so easy to

play23:52

get started with and the types of bugs

play23:54

you find you can use them on the large

play23:58

scale for much longer time because this

play24:01

low-level level programs are reused

play24:03

identically on multiple platforms I mean

play24:07

so imagine that you we were playing with

play24:09

a media transformation for Matt I found

play24:12

the bug the other week and that's

play24:14

something you can reproduce forever you

play24:16

know like it's reported and all and they

play24:19

don't seem to want to fix it because

play24:20

it's just a hang and not a crash I was

play24:23

like okay fine so then you can use that

play24:26

to identify this media transformer tool

play24:28

well all this is super interesting but

play24:31

could you've been you've been doing this

play24:33

for a while and I know you got some aces

play24:36

up your sleeve can you tell us a little

play24:38

bit more about that so we're setting up

play24:40

we're setting up in web casts where you

play24:43

can follow along and live answer and ask

play24:46

questions how to get a get started with

play24:49

fussing and if you have getting got

play24:52

stuck recently with it you can get help

play24:54

there in the web cast and it's on a

play24:56

secure Labs where me my colleagues

play24:59

publish lots of talks of

play25:02

we're doing basically that's amazing so

play25:05

so it's going to be a community-based

play25:07

thing that if security is doing to get

play25:10

more people into fussing yes so this is

play25:12

the f-secure lab channel on youtube and

play25:14

it's it's available to anyone who wants

play25:17

to wash it that's amazing

play25:20

god damn it I learned something new

play25:21

today as well and and I'm gonna be a

play25:24

huge fan of the channel of course I'm

play25:26

gonna glue myself to that so thank you

play25:29

very much for taking your time and

play25:31

learning me or teach me about AFL thanks

play25:35

for for joining in guys so this is it's

play25:37

really fun to teach and thank you stuck

play25:40

for having me appreciate it

play25:41

awesome a my bike

play25:44

[Music]

play25:54

[Music]

Rate This

5.0 / 5 (0 votes)

関連タグ
AFL FuzzingBug HuntingBinary ProgramsSecurity TestingAutomationGCC CompilerInstrumentationCrash AnalysisGDB DebuggerVulnerability Reporting
英語で要約が必要ですか?