dor1s / libfuzzer-workshop Goto Github PK
View Code? Open in Web Editor NEWRepository for materials of "Modern fuzzing of C/C++ Projects" workshop.
License: Apache License 2.0
Repository for materials of "Modern fuzzing of C/C++ Projects" workshop.
License: Apache License 2.0
README in lesson 11 is writen 10 :)
Hello.
In lesson 8, I can not compile fuzzer.
I extracted libxml2 and make it.
Next step, I compile fuzzer but it fail.
clang++ -std=c++11 xml_read_memory_fuzzer.cc -O2 -fno-omit-frame-pointer -g -fsanitize=address,fuzzer -v \
-fsanitize-coverage=edge,indirect-calls,trace-cmp,trace-div,trace-gep -I libxml2/include \
-lz -llzma\
-o xml_read_memory_fuzzer
Ubuntu clang version 14.0.0-1ubuntu1
Target: x86_64-pc-linux-gnu
Thread model: posix
InstalledDir: /usr/bin
Found candidate GCC installation: /usr/bin/../lib/gcc/x86_64-linux-gnu/11
Found candidate GCC installation: /usr/bin/../lib/gcc/x86_64-linux-gnu/12
Selected GCC installation: /usr/bin/../lib/gcc/x86_64-linux-gnu/12
Candidate multilib: .;@m64
Selected multilib: .;@m64
"/usr/lib/llvm-14/bin/clang" -cc1 -triple x86_64-pc-linux-gnu -emit-obj --mrelax-relocations -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name xml_read_memory_fuzzer.cc -mrelocation-model pic -pic-level 2 -pic-is-pie -mframe-pointer=all -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -mllvm -treat-scalable-fixed-error-as-warning -debug-info-kind=constructor -dwarf-version=5 -debugger-tuning=gdb -v -fcoverage-compilation-dir=/home/user/fuzzing/libfuzzer-workshop/lessons/08 -resource-dir /usr/lib/llvm-14/lib/clang/14.0.0 -I libxml2/include -internal-isystem /usr/bin/../lib/gcc/x86_64-linux-gnu/12/../../../../include/c++/12 -internal-isystem /usr/bin/../lib/gcc/x86_64-linux-gnu/12/../../../../include/x86_64-linux-gnu/c++/12 -internal-isystem /usr/bin/../lib/gcc/x86_64-linux-gnu/12/../../../../include/c++/12/backward -internal-isystem /usr/lib/llvm-14/lib/clang/14.0.0/include -internal-isystem /usr/local/include -internal-isystem /usr/bin/../lib/gcc/x86_64-linux-gnu/12/../../../../x86_64-linux-gnu/include -internal-externc-isystem /usr/include/x86_64-linux-gnu -internal-externc-isystem /include -internal-externc-isystem /usr/include -O2 -std=c++11 -fdeprecated-macro -fdebug-compilation-dir=/home/user/fuzzing/libfuzzer-workshop/lessons/08 -ferror-limit 19 -fsanitize-coverage-type=3 -fsanitize-coverage-indirect-calls -fsanitize-coverage-trace-cmp -fsanitize-coverage-trace-div -fsanitize-coverage-trace-gep -fsanitize-coverage-inline-8bit-counters -fsanitize-coverage-pc-table -fsanitize-coverage-stack-depth -fsanitize=address,fuzzer,fuzzer-no-link -fsanitize-system-ignorelist=/usr/lib/llvm-14/lib/clang/14.0.0/share/asan_ignorelist.txt -fsanitize-address-use-after-scope -fno-assume-sane-operator-new -fno-builtin-bcmp -fno-builtin-memcmp -fno-builtin-strncmp -fno-builtin-strcmp -fno-builtin-strncasecmp -fno-builtin-strcasecmp -fno-builtin-strstr -fno-builtin-strcasestr -fno-builtin-memmem -fgnuc-version=4.2.1 -fcxx-exceptions -fexceptions -fcolor-diagnostics -vectorize-loops -vectorize-slp -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /tmp/xml_read_memory_fuzzer-f8ac34.o -x c++ xml_read_memory_fuzzer.cc
clang -cc1 version 14.0.0 based upon LLVM 14.0.0 default target x86_64-pc-linux-gnu
ignoring nonexistent directory "/usr/bin/../lib/gcc/x86_64-linux-gnu/12/../../../../x86_64-linux-gnu/include"
ignoring nonexistent directory "/include"
#include "..." search starts here:
#include <...> search starts here:
libxml2/include
/usr/bin/../lib/gcc/x86_64-linux-gnu/12/../../../../include/c++/12
/usr/bin/../lib/gcc/x86_64-linux-gnu/12/../../../../include/x86_64-linux-gnu/c++/12
/usr/bin/../lib/gcc/x86_64-linux-gnu/12/../../../../include/c++/12/backward
/usr/lib/llvm-14/lib/clang/14.0.0/include
/usr/local/include
/usr/include/x86_64-linux-gnu
/usr/include
End of search list.
"/usr/bin/ld" -pie -z relro --hash-style=gnu --build-id --eh-frame-hdr -m elf_x86_64 -dynamic-linker /lib64/ld-linux-x86-64.so.2 -o xml_read_memory_fuzzer /lib/x86_64-linux-gnu/Scrt1.o /lib/x86_64-linux-gnu/crti.o /usr/bin/../lib/gcc/x86_64-linux-gnu/12/crtbeginS.o -L/usr/bin/../lib/gcc/x86_64-linux-gnu/12 -L/usr/bin/../lib/gcc/x86_64-linux-gnu/12/../../../../lib64 -L/lib/x86_64-linux-gnu -L/lib/../lib64 -L/usr/lib/x86_64-linux-gnu -L/usr/lib/../lib64 -L/usr/lib/llvm-14/bin/../lib -L/lib -L/usr/lib --whole-archive /usr/lib/llvm-14/lib/clang/14.0.0/lib/linux/libclang_rt.fuzzer-x86_64.a --no-whole-archive -lstdc++ --whole-archive /usr/lib/llvm-14/lib/clang/14.0.0/lib/linux/libclang_rt.asan_static-x86_64.a --no-whole-archive --whole-archive /usr/lib/llvm-14/lib/clang/14.0.0/lib/linux/libclang_rt.asan-x86_64.a --no-whole-archive --dynamic-list=/usr/lib/llvm-14/lib/clang/14.0.0/lib/linux/libclang_rt.asan-x86_64.a.syms --whole-archive /usr/lib/llvm-14/lib/clang/14.0.0/lib/linux/libclang_rt.asan_cxx-x86_64.a --no-whole-archive --dynamic-list=/usr/lib/llvm-14/lib/clang/14.0.0/lib/linux/libclang_rt.asan_cxx-x86_64.a.syms /tmp/xml_read_memory_fuzzer-f8ac34.o -lz -llzma -lstdc++ -lm --no-as-needed -lpthread -lrt -lm -ldl -lgcc_s -lgcc -lc -lgcc_s -lgcc /usr/bin/../lib/gcc/x86_64-linux-gnu/12/crtendS.o /lib/x86_64-linux-gnu/crtn.o
/usr/bin/ld: /usr/bin/ld: DWARF error: invalid or unhandled FORM value: 0x23
/tmp/xml_read_memory_fuzzer-f8ac34.o: in function `LLVMFuzzerTestOneInput':
xml_read_memory_fuzzer.cc:(.text.LLVMFuzzerTestOneInput[LLVMFuzzerTestOneInput]+0x2f): undefined reference to `xmlSetGenericErrorFunc'
/usr/bin/ld: xml_read_memory_fuzzer.cc:(.text.LLVMFuzzerTestOneInput[LLVMFuzzerTestOneInput]+0x46): undefined reference to `xmlReadMemory'
/usr/bin/ld: xml_read_memory_fuzzer.cc:(.text.LLVMFuzzerTestOneInput[LLVMFuzzerTestOneInput]+0x5a): undefined reference to `xmlFreeDoc'
clang: error: linker command failed with exit code 1 (use -v to see invocation)
How do I get the fuzzer to compile properly?
Hello, the author, I encountered this problem when Implementing libfuzzer in MAC OS system:
Ld: file not found: / Applications/Xcode. The app/Contents/Developer/Toolchains/XcodeDefault xctoolchain/usr/lib/clang 12.0.0 / lib/Darwin/libclang_rt fuzzer_osx. A
clang: error: linker command failed with exit code 1 (use -v to see invocation)
I wonder if you have any solution. Thank you very much
hello author,I am so interesting in libfuzzer.I want to know can I run libfuzzer on a MAC?
Hi, Dor1s, is there some tutorial about using libfuzzer in android? can you give some advice?
thanks.
when I install LLVM for Libfuzzer, someting is wrong.
when i run "checkout_build_install_llvm.sh" , and return some wrongs, it say that "Git.llvm.org Excessive redirection times."
and i check checkout_build_install_llvm.sh, and found the code
"
cd $WORK_DIR/src && git clone --depth 1 http://llvm.org/git/llvm.git
cd $WORK_DIR/src/llvm/tools && git clone --depth 1 http://llvm.org/git/clang.git
cd $WORK_DIR/src/llvm/projects && git clone --depth 1 http://llvm.org/git/compiler-rt.git
cd $WORK_DIR/src/llvm/projects && git clone --depth 1 http://llvm.org/git/libcxx.git
cd $WORK_DIR/src/llvm/projects && git clone --depth 1 http://llvm.org/git/libcxxabi.git
"
then i visit the "http://llvm.org/git/xxx.git" in my browser,and also can't visit successfully.
May I ask whether this is my operation error or this website has updated these urls?
The workshop uses a hardcoded libFuzzer version which is pretty old these days. Would be nice to update it and check that the instructions are still applicable.
i used this instrcution below to compile it :
clang++ -g -std=c++11 -fsanitize=address -fsanitize-coverage=trace-pc-guard first_fuzzer.cc ../../libFuzzer/libFuzzer.a -o first_fuzzer
then i runed
./first_fuzzer corpus1
but it shows :
-fsanitize-coverage=trace-pc-guard is no longer supported by libFuzzer.
Please either migrate to a compiler that supports -fsanitize=fuzzer
or use an older version of libFuzzer
i use clang-7 clnag-9 cloang-10 to recompile but it is still show the following error.
by the way , i download llvm bin file directly through github ,and setup env. so i didn't use your automatic build srcipt
could you please help me ?
when i run xml_read_memory_fuzzer in lesson 08 , i got error like this:
'''
08$ ./xml_read_memory_fuzzer -max_total_time=300 -print_final_stats=1 corpus1
INFO: Seed: 1486712041
INFO: Loaded 0 modules (0 guards):
Loading corpus dir: corpus1
INFO: -max_len is not provided, using 64
INFO: A corpus is not provided, starting from an empty corpus
#0 READ units: 1
#1 INITED exec/s: 0 rss: 31Mb
ERROR: no interesting inputs were found. Is the code instrumented for coverage? Exiting.
'''
did i missed something?
any suggestion?
I successfully compiled libfuzzer.lib on the windows platform with vs2019. The msvc compiler supports "-fsanitize-coverage=trace-pc", and I successfully use libfuzzer to deploy exe and lib projects, but the msvc compiler does not support "-fsanitize= fuzzer-no-link", which prevents me from deploying dll projects with libfuzzer.lib, what should I do?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.