-
Notifications
You must be signed in to change notification settings - Fork 27
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
AFL filename formats #11
Merged
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
68debf3
fix filename format mismatches
cponcelets d867ec4
add format conversion functions into utils.py
cponcelets 4cffbe7
build llvm Release version
cponcelets 4a80ead
add simple example
cponcelets 0991fbb
[README] update example output
cponcelets c093f8d
Update Makefile
cponcelets 8b2e285
Delete .savior_sanitizer_combination
cponcelets 9a77604
Delete .afl_coverage_combination
cponcelets ac553ca
remove .example.o .example.o.bc and update Makefile
cponcelets File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
## Variable storing paths | ||
SAVIOR_PATH=${HOME}/work/savior | ||
|
||
all: seed_folder | ||
|
||
example : example.c | ||
LLVM_COMPILER=clang wllvm -fsanitize=integer,bounds,shift -g -o example example.c | ||
|
||
example.bc : example | ||
extract-bc example | ||
|
||
# and labelmap.csv locmap.csv paired_edges.csv | ||
savior-example : example.bc | ||
${SAVIOR_PATH}/AFL/afl-clang-fast example.bc -o savior-example -lubsan -lm | ||
|
||
# and savior-example.dma example.reach.bug example.edge | ||
savior-example.bc : savior-example | ||
${SAVIOR_PATH}/svf/SVF/Release-build/bin/dma -fspta savior-example.bc -savior-label-only -o example.reach.bug -edge example.edge | ||
|
||
savior-example.dma.bc : savior-example.bc | ||
opt -load ${SAVIOR_PATH}/svf/InsertBugPotential/build/insertpass/libInsertBugPass.so -InsertBug -i example.reach.bug savior-example.bc -o savior-example.dma.bc | ||
|
||
example.conf : savior-example.dma.bc | ||
./set-configuration.sh | ||
|
||
seed_folder : example.conf | ||
mkdir -p "seed_folder" && echo "a" > seed_folder/seed1.txt | ||
|
||
# and run: python ../coordinator/moriarty.py -t $(pwd) -c $(pwd)/example.conf | ||
|
||
clean: | ||
rm example .example* *.bc savior-example savior-example.dma example.conf example.edge example.reach.bug labelmap.csv locmap.csv paired_edges.csv .savior_sanitizer_combination .afl_coverage_combination |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# Savior simple example | ||
|
||
The example simply checks a magic number value big enough to prevent AFL from generating testcases covering the true branch. | ||
|
||
Run `make` to: | ||
- build the SAVIOR instrumented binaries, | ||
- create a seed into `seed_folder`, | ||
- set a default configuration file (`example.conf`). | ||
|
||
Verify the example behavior by running a testcase passing the magic number check: | ||
|
||
``` | ||
./savior-example < test.in | ||
Magic number passed | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
#include <stdio.h> | ||
#include <unistd.h> | ||
|
||
long AFL_STOP = 0x41464c5f53544f50; | ||
|
||
int main(int argc, char *argv[]) { | ||
int a,nb; | ||
long magic; | ||
|
||
nb = read(0, &magic, sizeof(long)); | ||
if (nb == 0) return 1; | ||
if (nb < sizeof(long)) return 1; //add coverage if good size | ||
|
||
if (magic != AFL_STOP) return 1; | ||
|
||
puts("Magic number passed"); | ||
|
||
nb = read(0, &a, sizeof(int)); | ||
a = a - 12; | ||
|
||
return 0; | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
|
||
|
||
## Variable storing paths | ||
SAVIOR_PATH=$HOME/work/savior | ||
SYNC_FOLDER=@target/output_folder | ||
SEED_FOLDER=@target/seed_folder | ||
# target directory: $(pwd) | ||
|
||
sed s/PROG/example/g $SAVIOR_PATH/coordinator/fuzz.cfg.template | \ | ||
#sed s/inputtype=stdin/inputtype=symfile/g | \ | ||
#sed "s|target_bin=@target/savior-fuzzer|target_bin=$AFL_CMD|g" | \ | ||
#sed "s|target_bc=@target/savior-fuzzer.dma.bc|target_bc=$KLEE_CMD|g" | \ | ||
sed "s|sync_dir=@target/out|sync_dir=$SYNC_FOLDER|g" | \ | ||
sed "s,in_dir=@target/in,in_dir=$SEED_FOLDER,g" | \ | ||
sed "s|heuristics=san-guided|heuristics=san-guided:sequential:bug-potential:avg-bug-potential|g" | \ | ||
sed "s|SAVIOR|$SAVIOR_PATH|g" > example.conf | ||
|
||
## Note: to use uncov-edge-bug generates code_reach_map by running the dma pass without -savior-label-only option | ||
## ref: https://github.com/evanmak/savior-source/blob/b419c868e3dd966e77bb2707a7901e6f1872fb92/coordinator/README.md |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
POTS_LFA2 |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why is there a case when there will be multiple entries return by
glob
given a unique name?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ah never mind, glob.glob returns a list,
can we add an assert here to ensure the list len is 1?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think an assert is too strong since a file can be removed by AFL on the fly.
Time to time AFL calls a routine to polish the queue (a cmin similar function if you want), this is briefly mentionned here as a part of afl-fuzz algorithm.
Unfortunately, it may raise the assertion if the file savior wants to read has been removed by AFL.
I preferred the way you chose here and simply continue if a problem occurred.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The problem here is the use of
edge_san_first_seen[i]
storing only the id of the first testcase covering a branch. I have not seen a simple way to print back the full filename in the standard format. A solution would be to store the full name but it does not sound like a simpler way.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmmm, I got your point, reading the code again we use the seed names in the
input_id_map
for SE converter, so it needs to be a full match.Thanks for the discussion btw, my concern was keeping a mixed scheme will make the code logic more convoluted, being able to modified KLEE seems like a more straightforward approach but we don't have source.
@DanielGuoVT maybe you could consider release another klee version before fully open source. But until then we can use the solution in this PR.