├── README
├── QuickStartGuide.txt
├── dsa
├── lib
│ ├── DSA
│ │ ├── test.cpp
│ │ ├── Makefile.org
│ │ ├── README
│ │ ├── Makefile
│ │ ├── AddressTakenAnalysis.cpp
│ │ ├── LICENSE.TXT
│ │ └── Basic.cpp
│ └── AssistDS
│ │ ├── Makefile.org
│ │ ├── Makefile
│ │ ├── FuncSimplify.cpp
│ │ ├── SimplifyLoad.cpp
│ │ └── LICENSE.TXT
├── README.md
├── include
│ ├── assistDS
│ │ ├── SimplifyLoad.h
│ │ ├── SimplifyExtractValue.h
│ │ ├── SimplifyInsertValue.h
│ │ ├── FuncSimplify.h
│ │ ├── MergeGEP.h
│ │ ├── StructReturnToPointer.h
│ │ ├── GEPExprArgs.h
│ │ ├── SimplifyGEP.h
│ │ ├── IndCloner.h
│ │ ├── ArgCast.h
│ │ ├── FuncSpec.h
│ │ ├── Int2PtrCmp.h
│ │ ├── LoadArgs.h
│ │ ├── TypeChecksOpt.h
│ │ ├── DSNodeEquivs.h
│ │ ├── Devirt.h
│ │ └── LICENSE.TXT
│ └── dsa
│ │ ├── super_set.h
│ │ ├── stl_util.h
│ │ ├── AddressTakenAnalysis.h
│ │ ├── EntryPointAnalysis.h
│ │ ├── Steensgaard.hh
│ │ ├── AllocatorIdentification.h
│ │ ├── CallTargets.h
│ │ ├── TypeSafety.h
│ │ └── LICENSE.TXT
└── LICENSE.TXT
├── testcases
├── others
│ ├── text
│ │ └── hello_world.txt
│ ├── js
│ │ └── small_script.js
│ ├── xml
│ │ └── small_document.xml
│ ├── rtf
│ │ └── small_document.rtf
│ ├── elf
│ │ └── small_exec.elf
│ ├── sql
│ │ └── simple_queries.sql
│ ├── pcap
│ │ └── small_capture.pcap
│ └── pdf
│ │ └── small.pdf
├── images
│ ├── bmp
│ │ └── not_kitty.bmp
│ ├── gif
│ │ └── not_kitty.gif
│ ├── ico
│ │ └── not_kitty.ico
│ ├── jp2
│ │ └── not_kitty.jp2
│ ├── jxr
│ │ └── not_kitty.jxr
│ ├── png
│ │ ├── not_kitty.png
│ │ ├── not_kitty_icc.png
│ │ ├── not_kitty_alpha.png
│ │ └── not_kitty_gamma.png
│ ├── jpeg
│ │ └── not_kitty.jpg
│ ├── tiff
│ │ └── not_kitty.tiff
│ └── webp
│ │ └── not_kitty.webp
├── multimedia
│ └── h264
│ │ └── small_movie.mp4
├── archives
│ ├── common
│ │ ├── xz
│ │ │ └── small_archive.xz
│ │ ├── bzip2
│ │ │ └── small_archive.bz2
│ │ ├── cab
│ │ │ └── small_archive.cab
│ │ ├── cpio
│ │ │ └── small_archive.cpio
│ │ ├── gzip
│ │ │ └── small_archive.gz
│ │ ├── lzo
│ │ │ └── small_archive.lzo
│ │ ├── rar
│ │ │ └── small_archive.rar
│ │ ├── zip
│ │ │ └── small_archive.zip
│ │ ├── compress
│ │ │ └── small_archive.Z
│ │ ├── ar
│ │ │ └── small_archive.a
│ │ └── tar
│ │ │ └── small_archive.tar
│ └── exotic
│ │ ├── arj
│ │ └── small_archive.arj
│ │ ├── lha
│ │ └── small_archive.lha
│ │ ├── lrzip
│ │ └── small_archive.lrz
│ │ ├── lzip
│ │ └── small_archive.lz
│ │ ├── lzma
│ │ └── small_archive.lzma
│ │ ├── rzip
│ │ └── small_archive.rz
│ │ └── zoo
│ │ └── small_archive.zoo
└── README.testcases
├── docs
├── vuln_samples
│ ├── bash-cmd-exec.var
│ ├── sqlite-null-ptr4.sql
│ ├── bash-uninit-mem.var
│ ├── sqlite-null-ptr10.sql
│ ├── sqlite-null-ptr11.sql
│ ├── sqlite-null-ptr3.sql
│ ├── sqlite-null-ptr5.sql
│ ├── sqlite-null-ptr2.sql
│ ├── sqlite-null-ptr7.sql
│ ├── sqlite-bad-ptr.sql
│ ├── sqlite-null-ptr8.sql
│ ├── sqlite-stack-exhaustion.sql
│ ├── sqlite-null-ptr1.sql
│ ├── sqlite-null-ptr12.sql
│ ├── sqlite-null-ptr13.sql
│ ├── sqlite-unint-mem.sql
│ ├── jxrlib-crash.jxr
│ ├── libxml2-bad-read.xml
│ ├── jxrlib-crash2.jxr
│ ├── jxrlib-crash3.jxr
│ ├── jxrlib-crash4.jxr
│ ├── msie-dht-leak.jpg
│ ├── msie-zlib-dos.png
│ ├── firefox-bmp-leak.bmp
│ ├── firefox-gif-leak.gif
│ ├── firefox-gif-leak2.gif
│ ├── libjpeg-sos-leak.jpg
│ ├── libtiff-bad-write.tif
│ ├── msie-jxr-mem-leak.jxr
│ ├── msie-png-mem-leak.png
│ ├── openssl-null-ptr.der
│ ├── openssl-null-ptr2.der
│ ├── sqlite-null-ptr6.sql
│ ├── sqlite-null-ptr9.sql
│ ├── sqlite-oob-read.sql
│ ├── file-fpu-exception.elf
│ ├── firefox-chrome-leak.jpg
│ ├── libtiff-uninit-mem.tif
│ ├── libtiff-uninit-mem2.tif
│ ├── libtiff-uninit-mem3.tif
│ ├── libtiff-uninit-mem4.tif
│ ├── msie-tiff-mem-leak.tif
│ ├── photoshop-mem-leak.jpg
│ ├── sqlite-bad-free.sql
│ ├── strings-bfd-badptr.elf
│ ├── strings-bfd-badptr2.elf
│ ├── strings-stack-overflow
│ ├── tcpdump-arp-crash.pcap
│ ├── tcpdump-ppp-crash.pcap
│ ├── ffmpeg-h264-bad-read.mp4
│ ├── libjpeg-turbo-dht-leak.jpg
│ ├── strings-unchecked-ctr.elf
│ ├── unrtf-arbitrary-read.rtf
│ ├── unzip-t-mem-corruption.zip
│ ├── ffmpeg-h264-bad-ptr-800m.mp4
│ ├── lesspipe-cpio-bad-write.cpio
│ ├── ffmpeg-h264-call-stack-overflow.mp4
│ ├── sqlite-bad-ptr2.sql
│ ├── sqlite-stack-buf-overflow.sql
│ ├── sqlite-null-ptr15.sql
│ ├── sqlite-bad-ptr3.sql
│ ├── sqlite-heap-overflow.sql
│ ├── sqlite-use-after-free.sql
│ ├── sqlite-oob-write.sql
│ ├── sqlite-null-ptr14.sql
│ └── sqlite-negative-memset.sql
├── visualization
│ └── afl_gzip.png
└── QuickStartGuide.txt
├── afl-fuzz
├── gllvm
├── examples
│ ├── issue19
│ │ ├── test.c
│ │ └── Makefile
│ ├── linux-kernel
│ │ ├── convert-thin-archive.sh
│ │ ├── make-script.sh
│ │ ├── make-script-clang.sh
│ │ ├── bootable-kernel.sh
│ │ ├── bash_profile
│ │ ├── install-kernel.sh
│ │ ├── build_linux_wllvm_git.sh
│ │ ├── build_linux_wllvm_tarball.sh
│ │ ├── build_linux_gllvm_git.sh
│ │ ├── build_linux_gllvm_tarball.sh
│ │ ├── bootstrap.sh
│ │ ├── Vagrantfile
│ │ ├── build_linux_gllvm.sh
│ │ ├── init_script.sh
│ │ ├── full-script.sh
│ │ ├── parse-bi.py
│ │ ├── handle-bi.sh
│ │ ├── copy-native-bi.sh
│ │ ├── copy-missing-o.sh
│ │ └── copy.sh
│ ├── README.md
│ └── tor_and_its_dependencies
│ │ └── Makefile
├── ians-notes.txt
├── LICENSE
├── cmd
│ ├── gsanity-check
│ │ └── main.go
│ ├── get-bc
│ │ └── main.go
│ ├── gclang++
│ │ └── main.go
│ └── gclang
│ │ └── main.go
└── shared
│ ├── constants.go
│ └── utils.go
├── python_libs
├── __init__.py
├── c2s.py
├── logger.py
├── storage.py
└── statistics.py
├── clang_rewriters
├── common.h
└── Makefile
├── dictionaries
├── gif.dict
├── webp.dict
├── jpeg.dict
├── json.dict
├── png.dict
├── tiff.dict
├── xml.dict
├── README.dictionaries
└── js.dict
├── experimental
├── libpng_no_checksum
│ └── libpng-nocrc.patch
├── README.experiments
├── clang_asm_normalize
│ └── as
├── bash_shellshock
│ └── shellshock-fuzz.diff
├── argv_fuzzing
│ └── argv-fuzz-inl.h
├── distributed_fuzzing
│ └── sync_script.sh
├── persistent_demo
│ └── persistent_demo.c
└── crash_triage
│ └── triage_crashes.sh
├── afl-config.sh
├── test-instr.c
├── llvm_mode
├── testcases.txt
└── afl-llvm-pass-parent.h
├── qemu_mode
└── patches
│ ├── cpu-exec.diff
│ ├── syscall.diff
│ └── elfload.diff
├── libtokencap
├── Makefile
└── README.tokencap
├── utils.h
├── libdislocator
├── Makefile
└── README.dislocator
├── make_autodict.sh
├── setup-aflc-gclang.sh
├── library.sh
├── aflc-link-bc
├── hash.h
├── types.h
├── backup.py
├── plotone2one.py
└── clang_format_fixes
└── clang
└── License.txt
/README:
--------------------------------------------------------------------------------
1 | docs/README
--------------------------------------------------------------------------------
/QuickStartGuide.txt:
--------------------------------------------------------------------------------
1 | docs/QuickStartGuide.txt
--------------------------------------------------------------------------------
/dsa/lib/DSA/test.cpp:
--------------------------------------------------------------------------------
1 | int foo() { return 3; }
2 |
--------------------------------------------------------------------------------
/testcases/others/text/hello_world.txt:
--------------------------------------------------------------------------------
1 | hello
2 |
--------------------------------------------------------------------------------
/testcases/others/js/small_script.js:
--------------------------------------------------------------------------------
1 | if (1==1) eval('1');
--------------------------------------------------------------------------------
/testcases/others/xml/small_document.xml:
--------------------------------------------------------------------------------
1 | d
2 |
--------------------------------------------------------------------------------
/docs/vuln_samples/bash-cmd-exec.var:
--------------------------------------------------------------------------------
1 | () { _; } >_[$($())] { id; }
--------------------------------------------------------------------------------
/docs/vuln_samples/sqlite-null-ptr4.sql:
--------------------------------------------------------------------------------
1 | select n()AND+#00;
2 |
--------------------------------------------------------------------------------
/testcases/others/rtf/small_document.rtf:
--------------------------------------------------------------------------------
1 | {\rtf1\pard Test\par}
--------------------------------------------------------------------------------
/afl-fuzz:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Samsung/afl_cc/HEAD/afl-fuzz
--------------------------------------------------------------------------------
/docs/vuln_samples/bash-uninit-mem.var:
--------------------------------------------------------------------------------
1 | () { x() { _; }; x() { _; } <
2 | int main(void) {
3 | printf("test\n");
4 | }
5 |
--------------------------------------------------------------------------------
/docs/visualization/afl_gzip.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Samsung/afl_cc/HEAD/docs/visualization/afl_gzip.png
--------------------------------------------------------------------------------
/docs/vuln_samples/sqlite-null-ptr12.sql:
--------------------------------------------------------------------------------
1 | PRAGMA e;select lower(0);select lower(0)"a",""GROUP BY a ORDER BY a;
2 |
--------------------------------------------------------------------------------
/docs/vuln_samples/sqlite-null-ptr13.sql:
--------------------------------------------------------------------------------
1 | WITH x AS(SELECT*FROM t)SELECT""EXCEPT SELECT 0 ORDER BY 0 COLLATE"";
2 |
--------------------------------------------------------------------------------
/docs/vuln_samples/sqlite-unint-mem.sql:
--------------------------------------------------------------------------------
1 | REATE VIRTUAL TABLE t0 USING fts4(prefix=0);INSERT INTO t0 VALUES(0);
2 |
--------------------------------------------------------------------------------
/docs/vuln_samples/jxrlib-crash.jxr:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Samsung/afl_cc/HEAD/docs/vuln_samples/jxrlib-crash.jxr
--------------------------------------------------------------------------------
/docs/vuln_samples/libxml2-bad-read.xml:
--------------------------------------------------------------------------------
1 | O));insert into t0
2 | select randomblob(0)-trim(0);
3 |
--------------------------------------------------------------------------------
/docs/vuln_samples/strings-bfd-badptr.elf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Samsung/afl_cc/HEAD/docs/vuln_samples/strings-bfd-badptr.elf
--------------------------------------------------------------------------------
/docs/vuln_samples/strings-bfd-badptr2.elf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Samsung/afl_cc/HEAD/docs/vuln_samples/strings-bfd-badptr2.elf
--------------------------------------------------------------------------------
/docs/vuln_samples/strings-stack-overflow:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Samsung/afl_cc/HEAD/docs/vuln_samples/strings-stack-overflow
--------------------------------------------------------------------------------
/docs/vuln_samples/tcpdump-arp-crash.pcap:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Samsung/afl_cc/HEAD/docs/vuln_samples/tcpdump-arp-crash.pcap
--------------------------------------------------------------------------------
/docs/vuln_samples/tcpdump-ppp-crash.pcap:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Samsung/afl_cc/HEAD/docs/vuln_samples/tcpdump-ppp-crash.pcap
--------------------------------------------------------------------------------
/testcases/images/png/not_kitty_alpha.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Samsung/afl_cc/HEAD/testcases/images/png/not_kitty_alpha.png
--------------------------------------------------------------------------------
/testcases/images/png/not_kitty_gamma.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Samsung/afl_cc/HEAD/testcases/images/png/not_kitty_gamma.png
--------------------------------------------------------------------------------
/testcases/multimedia/h264/small_movie.mp4:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Samsung/afl_cc/HEAD/testcases/multimedia/h264/small_movie.mp4
--------------------------------------------------------------------------------
/testcases/others/pcap/small_capture.pcap:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Samsung/afl_cc/HEAD/testcases/others/pcap/small_capture.pcap
--------------------------------------------------------------------------------
/docs/vuln_samples/ffmpeg-h264-bad-read.mp4:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Samsung/afl_cc/HEAD/docs/vuln_samples/ffmpeg-h264-bad-read.mp4
--------------------------------------------------------------------------------
/docs/vuln_samples/libjpeg-turbo-dht-leak.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Samsung/afl_cc/HEAD/docs/vuln_samples/libjpeg-turbo-dht-leak.jpg
--------------------------------------------------------------------------------
/docs/vuln_samples/strings-unchecked-ctr.elf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Samsung/afl_cc/HEAD/docs/vuln_samples/strings-unchecked-ctr.elf
--------------------------------------------------------------------------------
/docs/vuln_samples/unrtf-arbitrary-read.rtf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Samsung/afl_cc/HEAD/docs/vuln_samples/unrtf-arbitrary-read.rtf
--------------------------------------------------------------------------------
/docs/vuln_samples/unzip-t-mem-corruption.zip:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Samsung/afl_cc/HEAD/docs/vuln_samples/unzip-t-mem-corruption.zip
--------------------------------------------------------------------------------
/gllvm/examples/linux-kernel/convert-thin-archive.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | for lib in $*;
3 | do ar -t $lib |xargs ar rvs $lib.new;
4 | done
--------------------------------------------------------------------------------
/python_libs/__init__.py:
--------------------------------------------------------------------------------
1 | import os, pkgutil
2 | __all__ = list(module for _, module, _ in pkgutil.iter_modules([os.path.dirname(__file__)]))
--------------------------------------------------------------------------------
/docs/vuln_samples/ffmpeg-h264-bad-ptr-800m.mp4:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Samsung/afl_cc/HEAD/docs/vuln_samples/ffmpeg-h264-bad-ptr-800m.mp4
--------------------------------------------------------------------------------
/docs/vuln_samples/lesspipe-cpio-bad-write.cpio:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Samsung/afl_cc/HEAD/docs/vuln_samples/lesspipe-cpio-bad-write.cpio
--------------------------------------------------------------------------------
/testcases/archives/common/xz/small_archive.xz:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Samsung/afl_cc/HEAD/testcases/archives/common/xz/small_archive.xz
--------------------------------------------------------------------------------
/testcases/archives/common/bzip2/small_archive.bz2:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Samsung/afl_cc/HEAD/testcases/archives/common/bzip2/small_archive.bz2
--------------------------------------------------------------------------------
/testcases/archives/common/cab/small_archive.cab:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Samsung/afl_cc/HEAD/testcases/archives/common/cab/small_archive.cab
--------------------------------------------------------------------------------
/testcases/archives/common/cpio/small_archive.cpio:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Samsung/afl_cc/HEAD/testcases/archives/common/cpio/small_archive.cpio
--------------------------------------------------------------------------------
/testcases/archives/common/gzip/small_archive.gz:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Samsung/afl_cc/HEAD/testcases/archives/common/gzip/small_archive.gz
--------------------------------------------------------------------------------
/testcases/archives/common/lzo/small_archive.lzo:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Samsung/afl_cc/HEAD/testcases/archives/common/lzo/small_archive.lzo
--------------------------------------------------------------------------------
/testcases/archives/common/rar/small_archive.rar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Samsung/afl_cc/HEAD/testcases/archives/common/rar/small_archive.rar
--------------------------------------------------------------------------------
/testcases/archives/common/zip/small_archive.zip:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Samsung/afl_cc/HEAD/testcases/archives/common/zip/small_archive.zip
--------------------------------------------------------------------------------
/testcases/archives/exotic/arj/small_archive.arj:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Samsung/afl_cc/HEAD/testcases/archives/exotic/arj/small_archive.arj
--------------------------------------------------------------------------------
/testcases/archives/exotic/lha/small_archive.lha:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Samsung/afl_cc/HEAD/testcases/archives/exotic/lha/small_archive.lha
--------------------------------------------------------------------------------
/testcases/archives/exotic/lrzip/small_archive.lrz:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Samsung/afl_cc/HEAD/testcases/archives/exotic/lrzip/small_archive.lrz
--------------------------------------------------------------------------------
/testcases/archives/exotic/lzip/small_archive.lz:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Samsung/afl_cc/HEAD/testcases/archives/exotic/lzip/small_archive.lz
--------------------------------------------------------------------------------
/testcases/archives/exotic/lzma/small_archive.lzma:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Samsung/afl_cc/HEAD/testcases/archives/exotic/lzma/small_archive.lzma
--------------------------------------------------------------------------------
/testcases/archives/exotic/rzip/small_archive.rz:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Samsung/afl_cc/HEAD/testcases/archives/exotic/rzip/small_archive.rz
--------------------------------------------------------------------------------
/testcases/archives/exotic/zoo/small_archive.zoo:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Samsung/afl_cc/HEAD/testcases/archives/exotic/zoo/small_archive.zoo
--------------------------------------------------------------------------------
/testcases/archives/common/compress/small_archive.Z:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Samsung/afl_cc/HEAD/testcases/archives/common/compress/small_archive.Z
--------------------------------------------------------------------------------
/docs/vuln_samples/ffmpeg-h264-call-stack-overflow.mp4:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Samsung/afl_cc/HEAD/docs/vuln_samples/ffmpeg-h264-call-stack-overflow.mp4
--------------------------------------------------------------------------------
/docs/vuln_samples/sqlite-bad-ptr2.sql:
--------------------------------------------------------------------------------
1 | PRAGMA foreign_keys=1;CREATE TABLE t1("""0"PRIMARY KEy REFERENCES t1 ON DELETE SET NULL);REPLACE INTO t1 SELECT(0);
2 |
--------------------------------------------------------------------------------
/docs/vuln_samples/sqlite-stack-buf-overflow.sql:
--------------------------------------------------------------------------------
1 | SELECT printf('%*.*f',90000||006000000&6600000000,00000000000000000909000000000000.0000000000000000)""WHERE"">"";
2 |
--------------------------------------------------------------------------------
/gllvm/examples/linux-kernel/make-script.sh:
--------------------------------------------------------------------------------
1 | #to avoid random missing files errors when building
2 | while [ ! -e "vmlinux" ]; do
3 | make vmlinux CC=gclang HOSTCC=gclang
4 | done
--------------------------------------------------------------------------------
/gllvm/examples/linux-kernel/make-script-clang.sh:
--------------------------------------------------------------------------------
1 | #to avoid random missing files errors when building with clang
2 | while [ ! -e "vmlinux" ]; do
3 | make vmlinux CC=clang HOSTCC=clang
4 | done
--------------------------------------------------------------------------------
/testcases/others/pdf/small.pdf:
--------------------------------------------------------------------------------
1 | %PDF-1.0
2 | 1 0 obj<>endobj 2 0 obj<>endobj 3 0 obj<>endobj trailer<>
--------------------------------------------------------------------------------
/docs/vuln_samples/sqlite-null-ptr15.sql:
--------------------------------------------------------------------------------
1 | CREATE VIRTUAL TABLE t4 USING fts4(0,b,c,notindexed=0);INSERT INTO t4 VALUES('','','0');BEGIN;INSERT INTO t4 VALUES('','','0');INSERT INTO t4(t4)VALUES('integrity-check');
2 |
--------------------------------------------------------------------------------
/dsa/README.md:
--------------------------------------------------------------------------------
1 | # llvm-dsa #
2 |
3 | DSA fork for SeaHorn.
4 | Based on the DSA for in [SMACK](https://github.com/smackers/smack).
5 | Originally from [PoolAlloc](https://llvm.org/svn/llvm-project/poolalloc/).
6 | LLVM version is 3.8.
7 |
--------------------------------------------------------------------------------
/gllvm/examples/linux-kernel/bootable-kernel.sh:
--------------------------------------------------------------------------------
1 | cd $HOME
2 | tar xf linux-4.14.39.tar.xz
3 | mv linux-4.14.39 bootable-linux
4 |
5 | cp /vagrant/make-script-clang.sh bootable-linux/
6 | cd bootable-linux
7 | bash make-script-clang.sh
8 |
--------------------------------------------------------------------------------
/docs/vuln_samples/sqlite-bad-ptr3.sql:
--------------------------------------------------------------------------------
1 | create table t(l);PRAGMA writable_schema=ON;
2 | UPDATE sqlite_master SET sql='0 0000000000000000000000000000000000000000000000000000000000000000000000000000000[%S';PRAGMA t;SAVEPOINT x;ROLLBACK;VACUUM;
3 |
--------------------------------------------------------------------------------
/docs/vuln_samples/sqlite-heap-overflow.sql:
--------------------------------------------------------------------------------
1 | DROP TABLE IF EXISTS t;CREATE VIRTUAL TABLE t0 USING fts4();insert into t0 select zeroblob(0);SAVEPOINT O;insert into t0
2 | select(0);SAVEPOINT E;insert into t0 SELECT 0 UNION SELECT 0'x'ORDER BY x;
3 |
--------------------------------------------------------------------------------
/docs/vuln_samples/sqlite-use-after-free.sql:
--------------------------------------------------------------------------------
1 | create table t(s);PRAGMA writable_schema=ON;UPDATE sqlite_master SET sql='ANALYZE;CREATE VIRTUAL TABLE t USING fts3;DROP TABLE t;DROP TABLE EXISTS t';PRAGMA r;SAVEPOINT T;ANALYZE;ROLLBACK;SAVEPOINT E;DROP TABLE IF EXISTS t;
2 |
--------------------------------------------------------------------------------
/docs/vuln_samples/sqlite-oob-write.sql:
--------------------------------------------------------------------------------
1 | CREATE VIRTUAL TABLE t0 USING fts4(x,order=DESC);
2 | INSERT INTO t0(docid,x)VALUES(-1E0,'0(o');
3 | INSERT INTO t0 VALUES('');
4 | INSERT INTO t0 VALUES('');
5 | INSeRT INTO t0 VALUES('o');
6 | SELECT docid FROM t0 WHERE t0 MATCH'"0*o"';
7 |
--------------------------------------------------------------------------------
/gllvm/examples/README.md:
--------------------------------------------------------------------------------
1 | # Examples of using GLLVM
2 |
3 |
4 | A simple set of instructions for building apache in a vagrant Ubuntu 14.04 can be found
5 | [here,](tutorial.md) and for Ubuntu 16.04 [here.](tutorial-ubuntu-16.04.md)
6 |
7 | The big example here though is the [linux kernel.](linux-kernel)
8 |
9 |
--------------------------------------------------------------------------------
/clang_rewriters/common.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | #include
4 | #include
5 |
6 | #define __FILENAME__ (strrchr(__FILE__, '/') ? strrchr(__FILE__, '/') + 1 : __FILE__)
7 | #define ASSERT(x) if (!(x)) {errs() << "assert( " << #x << " ) failed in file " << __FILENAME__ << " at line " << __LINE__ << "\n"; exit(-1); }
--------------------------------------------------------------------------------
/docs/vuln_samples/sqlite-null-ptr14.sql:
--------------------------------------------------------------------------------
1 | CREATE VIRTUAL TABLE x USING fts4();VALUES(0,0),(0,0),(0,0),(0,0);PRAGMA writable_schema=ON;UPDATE sqlite_master SET sql=''WHERE name='';UPDATE sqlite_master SET sql='CREATE table t(d CHECK(T(#0)';SAVEPOINT K;SAVEPOINT T;SAVEPOINT T;ANALYZE;ROLLBACK;SAVEPOINT E;DROP TABLE IF EXISTS t;
2 |
--------------------------------------------------------------------------------
/testcases/archives/common/ar/small_archive.a:
--------------------------------------------------------------------------------
1 | !
2 | limerick/ 1415337776 500 500 100640 191 `
3 | There was a young man from Japan
4 | Whose limericks never would scan.
5 | When asked why that was,
6 | He replied "It's because
7 | I always try to cram as many words into the last line as I possibly can."
8 |
9 |
--------------------------------------------------------------------------------
/gllvm/examples/issue19/Makefile:
--------------------------------------------------------------------------------
1 |
2 | all: test
3 |
4 | #one:
5 | # ${CC} test.c -dead_strip -fsanitize=address -o test
6 |
7 |
8 | test.o:
9 | ${CC} -c test.c -fsanitize=address
10 |
11 |
12 | test: test.o
13 | ${CC} test.o -dead_strip -fsanitize=address -o test
14 |
15 |
16 |
17 | clean:
18 | rm -f test.o test .test* *~
19 |
--------------------------------------------------------------------------------
/dictionaries/gif.dict:
--------------------------------------------------------------------------------
1 | #
2 | # AFL dictionary for GIF images
3 | # -----------------------------
4 | #
5 | # Created by Michal Zalewski
6 | #
7 |
8 | header_87a="87a"
9 | header_89a="89a"
10 | header_gif="GIF"
11 |
12 | marker_2c=","
13 | marker_3b=";"
14 |
15 | section_2101="!\x01\x12"
16 | section_21f9="!\xf9\x04"
17 | section_21fe="!\xfe"
18 | section_21ff="!\xff\x11"
19 |
--------------------------------------------------------------------------------
/gllvm/examples/linux-kernel/bash_profile:
--------------------------------------------------------------------------------
1 | #### /vagrant/bash_profile
2 |
3 | #### llvm
4 | export LLVM_HOME=/usr/lib/llvm-5.0
5 | export GOPATH=/vagrant/go
6 |
7 | ######## gllvm/wllvm configuration #############
8 |
9 | export LLVM_COMPILER=clang
10 | export WLLVM_OUTPUT_LEVEL=WARNING
11 | export WLLVM_OUTPUT_FILE=/vagrant/wrapper-logs/wrapper.log
12 | export PATH=${GOPATH}/bin:${LLVM_HOME}/bin:${PATH}
13 |
--------------------------------------------------------------------------------
/gllvm/examples/linux-kernel/install-kernel.sh:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | ### Copy vmlinux into the bootable linux folder and install the new kernel
4 | cp $HOME/standalone-build/vmlinux $HOME/linux-stable/
5 |
6 | cd $HOME/linux-stable
7 |
8 | scripts/sortextable vmlinux
9 | nm -n vmlinux | grep -v '\( [aNUw] \)\|\(__crc_\)\|\( \$[adt]\)\|\( .L\)' > System.map
10 | make CC=gclang HOSTCC=gclang
11 | sudo make modules_install install
12 |
--------------------------------------------------------------------------------
/python_libs/c2s.py:
--------------------------------------------------------------------------------
1 | import os, sys, inspect
2 | currentdir = os.path.dirname(os.path.abspath(inspect.getfile(inspect.currentframe())))
3 | parentdir = os.path.dirname(currentdir)
4 | sys.path.insert(0, parentdir)
5 |
6 | import storage
7 |
8 | def read(fn):
9 | d = dict()
10 | lines = storage.read_file(fn, True)
11 | for line in lines:
12 | edgeid = int(line.split("=")[0])
13 | d[edgeid] = line[:-1].split("=")[1].split(",")
14 | return d
--------------------------------------------------------------------------------
/gllvm/examples/linux-kernel/build_linux_wllvm_git.sh:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | ### building from a git clone with wllvm
4 |
5 | sudo pip install wllvm
6 |
7 | cd ${HOME}
8 | git clone git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable.git
9 |
10 | cd linux-stable
11 | git checkout tags/v4.14.39
12 | cp /vagrant/tinyconfig64 .config
13 |
14 |
15 | make CC=wllvm HOSTCC=wllvm
16 |
17 | extract-bc -m -b built-in.o
18 | extract-bc -m vmlinux
19 |
--------------------------------------------------------------------------------
/gllvm/examples/linux-kernel/build_linux_wllvm_tarball.sh:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | ### building from a tarball with wllvm
4 |
5 | sudo pip install wllvm
6 |
7 | cd ${HOME}
8 | wget https://cdn.kernel.org/pub/linux/kernel/v4.x/linux-4.14.39.tar.xz
9 | tar xvf linux-4.14.39.tar.xz
10 | cd linux-4.14.39
11 |
12 | cp /vagrant/tinyconfig64 .config
13 |
14 |
15 | make CC=wllvm HOSTCC=wllvm
16 |
17 | extract-bc -m -b built-in.o
18 | extract-bc -m vmlinux
19 |
--------------------------------------------------------------------------------
/dictionaries/webp.dict:
--------------------------------------------------------------------------------
1 | #
2 | # AFL dictionary for WebP images
3 | # ------------------------------
4 | #
5 | # Created by Michal Zalewski
6 | #
7 |
8 | header_RIFF="RIFF"
9 | header_WEBP="WEBP"
10 |
11 | section_ALPH="ALPH"
12 | section_ANIM="ANIM"
13 | section_ANMF="ANMF"
14 | section_EXIF="EXIF"
15 | section_FRGM="FRGM"
16 | section_ICCP="ICCP"
17 | section_VP8="VP8 "
18 | section_VP8L="VP8L"
19 | section_VP8X="VP8X"
20 | section_XMP="XMP "
21 |
--------------------------------------------------------------------------------
/gllvm/examples/linux-kernel/build_linux_gllvm_git.sh:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | ### building from a git clone with gllvm
4 |
5 | go get github.com/SRI-CSL/gllvm/cmd/...
6 |
7 | cd ${HOME}
8 | git clone git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable.git
9 |
10 | cd linux-stable
11 | git checkout tags/v4.14.39
12 | cp /vagrant/tinyconfig64 .config
13 |
14 | make CC=gclang HOSTCC=gclang
15 |
16 | get-bc -m -b built-in.o
17 | get-bc -m vmlinux
18 |
--------------------------------------------------------------------------------
/gllvm/examples/linux-kernel/build_linux_gllvm_tarball.sh:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | ### building from a tarball with gllvm
4 |
5 | go get github.com/SRI-CSL/gllvm/cmd/...
6 |
7 | cd ${HOME}
8 | wget https://cdn.kernel.org/pub/linux/kernel/v4.x/linux-4.14.39.tar.xz
9 | tar xvf linux-4.14.39.tar.xz
10 | cd linux-4.14.39
11 |
12 | cp /vagrant/tinyconfig64 .config
13 |
14 | make CC=gclang HOSTCC=gclang
15 |
16 | get-bc -m -b built-in.o
17 | get-bc -m vmlinux
18 |
--------------------------------------------------------------------------------
/python_libs/logger.py:
--------------------------------------------------------------------------------
1 | import os, sys, inspect
2 | currentdir = os.path.dirname(os.path.abspath(inspect.getfile(inspect.currentframe())))
3 | parentdir = os.path.dirname(currentdir)
4 | sys.path.insert(0, parentdir)
5 |
6 | import logging
7 | logging.basicConfig(format='%(levelname)s:\t%(message)s')
8 |
9 | # https://docs.python.org/2/howto/logging-cookbook.html
10 | def get(name):
11 | logger = logging.getLogger(name)
12 | logger.setLevel(logging.INFO)
13 | return logger
--------------------------------------------------------------------------------
/gllvm/examples/linux-kernel/bootstrap.sh:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | # vagrant bootstrapping file
4 |
5 | sudo apt-get update
6 |
7 | sudo apt-get install -y emacs24 dbus-x11
8 | sudo apt-get install -y git
9 | sudo apt-get install -y llvm-5.0 libclang-5.0-dev clang-5.0
10 | sudo apt-get install -y python-pip golang-go
11 | sudo apt-get install -y flex bison bc libncurses5-dev
12 | sudo apt-get install -y libelf-dev libssl-dev
13 |
14 | echo ". /vagrant/bash_profile" >> /home/vagrant/.bashrc
15 |
--------------------------------------------------------------------------------
/gllvm/examples/linux-kernel/Vagrantfile:
--------------------------------------------------------------------------------
1 | # -*- mode: ruby -*-
2 | # vi: set ft=ruby :
3 |
4 |
5 | Vagrant.configure("2") do |config|
6 |
7 | config.vm.box = "ubuntu/xenial64"
8 | config.vm.provision :shell, path: "bootstrap.sh"
9 |
10 | config.vm.provider "virtualbox" do |vb|
11 | vb.memory = "4096"
12 | vb.customize ["modifyvm", :id, "--ioapic", "on"]
13 | vb.customize ["modifyvm", :id, "--memory", "4096"]
14 | vb.customize ["modifyvm", :id, "--cpus", "2"]
15 | end
16 |
17 | end
--------------------------------------------------------------------------------
/gllvm/ians-notes.txt:
--------------------------------------------------------------------------------
1 | To edit the code locally use the repository here:
2 |
3 | ~/go/src/github.com/SRI-CSL/gllvm
4 |
5 | Then do:
6 |
7 | go install github.com/SRI-CSL/gllvm/cmd/...
8 |
9 |
10 | To format for the badge:
11 |
12 | gofmt -s -w shared/*.go cmd/*/*.go
13 |
14 |
15 | For linting:
16 |
17 | https://github.com/alecthomas/gometalinter
18 |
19 | gometalinter.v2 ./...
20 |
21 |
22 | For keeping up with the Jones:
23 |
24 | clang -cc1 --help
25 |
26 | https://clang.llvm.org/docs/ClangCommandLineReference.html
27 |
--------------------------------------------------------------------------------
/experimental/libpng_no_checksum/libpng-nocrc.patch:
--------------------------------------------------------------------------------
1 | --- pngrutil.c.orig 2014-06-12 03:35:16.000000000 +0200
2 | +++ pngrutil.c 2014-07-01 05:08:31.000000000 +0200
3 | @@ -268,7 +268,11 @@
4 | if (need_crc != 0)
5 | {
6 | crc = png_get_uint_32(crc_bytes);
7 | - return ((int)(crc != png_ptr->crc));
8 | +
9 | + if (crc != png_ptr->crc)
10 | + fprintf(stderr, "NOTE: CRC in the file is 0x%08x, change to 0x%08x\n", crc, png_ptr->crc);
11 | +
12 | + return ((int)(1 != 1));
13 | }
14 |
15 | else
16 |
--------------------------------------------------------------------------------
/gllvm/examples/linux-kernel/build_linux_gllvm.sh:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | ### building from a tarball with gllvm
4 |
5 | go get github.com/SRI-CSL/gllvm/cmd/...
6 |
7 | cd ${HOME}
8 | wget https://cdn.kernel.org/pub/linux/kernel/v4.x/linux-4.14.39.tar.xz
9 | tar xf linux-4.14.39.tar.xz
10 | mv linux-4.14.39 linux-stable
11 | cd linux-stable
12 |
13 | cp /vagrant/link-vmlinux.sh scripts/ #to retain a copy of kallsyms.o
14 | cp /vagrant/parse-bi.py .
15 | cp /vagrant/make-script.sh .
16 |
17 | make defconfig
18 | bash make-script.sh
19 |
--------------------------------------------------------------------------------
/docs/vuln_samples/sqlite-negative-memset.sql:
--------------------------------------------------------------------------------
1 | SELECT*from(select"",zeroblob(0),zeroblob(1E9),zeroblob(0),zeroblob(150000000),zeroblob(0),zeroblob(0),zeroblob(0),zeroblob(0),zeroblob(1E9),zeroblob(0),zeroblob(0),zeroblob(0),zeroblob(0),zeroblob(0)),(select"",zeroblob(1E9),zeroblob(0),zeroblob(0),zeroblob(0),zeroblob(0),zeroblob(0),zeroblob(0),zeroblob(1E9),(0),zeroblob(150000000),(0),zeroblob(0),(0)EXCEPT select zeroblob(0),zeroblob(0),zeroblob(0),zeroblob(0),zeroblob(0),zeroblob(0),(0),zeroblob(0),zeroblob(0),zeroblob(0),zeroblob(0),zeroblob(0),zeroblob(0),zeroblob(0));
2 |
--------------------------------------------------------------------------------
/dictionaries/jpeg.dict:
--------------------------------------------------------------------------------
1 | #
2 | # AFL dictionary for JPEG images
3 | # ------------------------------
4 | #
5 | # Created by Michal Zalewski
6 | #
7 |
8 | header_jfif="JFIF\x00"
9 | header_jfxx="JFXX\x00"
10 |
11 | section_ffc0="\xff\xc0"
12 | section_ffc2="\xff\xc2"
13 | section_ffc4="\xff\xc4"
14 | section_ffd0="\xff\xd0"
15 | section_ffd8="\xff\xd8"
16 | section_ffd9="\xff\xd9"
17 | section_ffda="\xff\xda"
18 | section_ffdb="\xff\xdb"
19 | section_ffdd="\xff\xdd"
20 | section_ffe0="\xff\xe0"
21 | section_ffe1="\xff\xe1"
22 | section_fffe="\xff\xfe"
23 |
--------------------------------------------------------------------------------
/dsa/lib/AssistDS/Makefile.org:
--------------------------------------------------------------------------------
1 | ##===- lib/AssistDS/Makefile -------------------------------*- Makefile -*-===##
2 | #
3 | # The LLVM Compiler Infrastructure
4 | #
5 | # This file was developed by the LLVM research group and is distributed under
6 | # the University of Illinois Open Source License. See LICENSE.TXT for details.
7 | #
8 | ##===----------------------------------------------------------------------===##
9 |
10 | LEVEL = ../..
11 | LIBRARYNAME = AssistDS
12 | BUILD_ARCHIVE=1
13 |
14 | include $(LEVEL)/Makefile.common
15 |
16 | CFlags += -Wno-deprecated
17 |
--------------------------------------------------------------------------------
/dsa/lib/DSA/Makefile.org:
--------------------------------------------------------------------------------
1 | ##===- lib/DSA/Makefile ------------------------------------*- Makefile -*-===##
2 | #
3 | # The LLVM Compiler Infrastructure
4 | #
5 | # This file was developed by the LLVM research group and is distributed under
6 | # the University of Illinois Open Source License. See LICENSE.TXT for details.
7 | #
8 | ##===----------------------------------------------------------------------===##
9 |
10 | LEVEL = ../..
11 | LIBRARYNAME = LLVMDataStructure
12 | BUILD_ARCHIVE=1
13 |
14 | include $(LEVEL)/Makefile.common
15 |
16 | CFlags += -Wno-deprecated
17 |
18 |
--------------------------------------------------------------------------------
/dictionaries/json.dict:
--------------------------------------------------------------------------------
1 | #
2 | # AFL dictionary for JSON
3 | # -----------------------
4 | #
5 | # Just the very basics.
6 | #
7 | # Inspired by a dictionary by Jakub Wilk
8 | #
9 |
10 | "0"
11 | ",0"
12 | ":0"
13 | "0:"
14 | "-1.2e+3"
15 |
16 | "true"
17 | "false"
18 | "null"
19 |
20 | "\"\""
21 | ",\"\""
22 | ":\"\""
23 | "\"\":"
24 |
25 | "{}"
26 | ",{}"
27 | ":{}"
28 | "{\"\":0}"
29 | "{{}}"
30 |
31 | "[]"
32 | ",[]"
33 | ":[]"
34 | "[0]"
35 | "[[]]"
36 |
37 | "''"
38 | "\\"
39 | "\\b"
40 | "\\f"
41 | "\\n"
42 | "\\r"
43 | "\\t"
44 | "\\u0000"
45 | "\\x00"
46 | "\\0"
47 | "\\uD800\\uDC00"
48 | "\\uDBFF\\uDFFF"
49 |
50 | "\"\":0"
51 | "//"
52 | "/**/"
53 |
--------------------------------------------------------------------------------
/afl-config.sh:
--------------------------------------------------------------------------------
1 | if [ -z "$LLVM_CONFIG" ]; then
2 | fatal "LLVM_CONFIG not defined"
3 | fi
4 |
5 | OPT=`$LLVM_CONFIG --bindir`/opt
6 | LLVM_AS=`$LLVM_CONFIG --bindir`/llvm-as
7 | LLVM_AR=`$LLVM_CONFIG --bindir`/llvm-ar
8 | LLVM_LINK=`$LLVM_CONFIG --bindir`/llvm-link
9 |
10 | OPT_ARGS="-internalize -internalize-public-api-list=main -globaldce -deadargelim -dse -die -argpromotion -disable-simplify-libcalls -inline -instcombine -loop-deletion -loop-unswitch -lowerswitch -memcpyopt -mem2reg -mergereturn"
11 | OPT_ARGS_ARCHIVE="-globaldce -deadargelim -dse -die -argpromotion -disable-simplify-libcalls -inline -instcombine -loop-deletion -loop-unswitch -lowerswitch -memcpyopt -mem2reg -mergereturn"
12 |
--------------------------------------------------------------------------------
/dsa/lib/DSA/README:
--------------------------------------------------------------------------------
1 | DSA is changed since PLDI07 in (at least) the following ways:
2 |
3 | 1) DSA tracks types per offset.
4 | 2) DSA does not assume that all clients will want to collapse a node if types
5 | conflict. Many clients don't care that an offset is used as an int or a
6 | double, they just care about the points-to result.
7 |
8 | In Progress:
9 |
10 | 1) DSA handles multiple entry points in a module.
11 | 2) Optional assumption that only legal targets are called at indirect call sites
12 | 3) Positional arguments, rather than pointer relative arguments. This handles
13 | the case where pointer and ints are assumed compatible and function pointers
14 | containing them are cast freely.
15 |
16 |
--------------------------------------------------------------------------------
/dsa/include/assistDS/SimplifyLoad.h:
--------------------------------------------------------------------------------
1 | //===--------------- SimplifyLoad.cpp - Simplify load insts ---------------===//
2 | //
3 | // The LLVM Compiler Infrastructure
4 | //
5 | // This file is distributed under the University of Illinois Open Source
6 | // License. See LICENSE.TXT for details.
7 | //
8 | //===----------------------------------------------------------------------===//
9 | //
10 | // Derived from InstCombine
11 | //
12 | //===----------------------------------------------------------------------===//
13 |
14 | #include "llvm/IR/Instructions.h"
15 | #include "llvm/IR/Module.h"
16 | #include "llvm/Pass.h"
17 |
18 | namespace llvm {
19 | //
20 | // Class: SimplifyLoad
21 | //
22 | class SimplifyLoad : public ModulePass {
23 | public:
24 | static char ID;
25 | SimplifyLoad() : ModulePass(ID) {}
26 | virtual bool runOnModule(Module& M);
27 | };
28 | }
29 |
30 |
--------------------------------------------------------------------------------
/testcases/README.testcases:
--------------------------------------------------------------------------------
1 | =======================
2 | AFL starting test cases
3 | =======================
4 |
5 | (See ../docs/README for the general instruction manual.)
6 |
7 | The archives/, images/, multimedia/, and others/ subdirectories contain small,
8 | standalone files that can be used to seed afl-fuzz when testing parsers for a
9 | variety of common data formats.
10 |
11 | There is probably not much to be said about these files, except that they were
12 | optimized for size and stripped of any non-essential fluff. Some directories
13 | contain several examples that exercise various features of the underlying format.
14 | For example, there is a PNG file with and without a color profile.
15 |
16 | Additional test cases are always welcome.
17 |
18 | In addition to well-chosen starting files, many fuzzing jobs benefit from a
19 | small and concise dictionary. See ../dictionaries/README.dictionaries for more.
20 |
--------------------------------------------------------------------------------
/gllvm/examples/linux-kernel/init_script.sh:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | ### creating the folder architecture necessary for the kernel build
4 |
5 | cd $HOME
6 | mkdir standalone-build
7 | sudo cp /vagrant/convert-thin-archive.sh /usr/bin/
8 |
9 | cd standalone-build
10 | cp /vagrant/copy-missing-o.sh .
11 | cp /vagrant/copy-native-bi.sh .
12 | cp /vagrant/handle-bi.sh .
13 | cp /vagrant/copy.sh .
14 |
15 | mkdir -p arch/x86/lib
16 | mkdir -p arch/x86/kernel
17 |
18 | mkdir -p built-ins/objects/lib_assembly_objects
19 | mkdir -p built-ins/objects/arch_assembly_objects
20 | mkdir -p built-ins/objects/xlib_assembly_objects
21 | mkdir -p built-ins/objects/pow_assembly_objects
22 | mkdir -p built-ins/objects/ker_objects
23 | mkdir -p built-ins/objects/libx_objects
24 |
25 | mkdir -p built-ins/fs/objects
26 |
27 | mkdir lib/
28 |
29 | bash /vagrant/build_linux_gllvm.sh
30 |
31 | bash copy.sh
32 |
33 | #bash /vagrant/bootable-kernel.sh
34 |
--------------------------------------------------------------------------------
/dsa/include/assistDS/SimplifyExtractValue.h:
--------------------------------------------------------------------------------
1 | //===-- SimplifyExtractValue.cpp - Remove extraneous extractvalue insts----===//
2 | //
3 | // The LLVM Compiler Infrastructure
4 | //
5 | // This file is distributed under the University of Illinois Open Source
6 | // License. See LICENSE.TXT for details.
7 | //
8 | //===----------------------------------------------------------------------===//
9 | //
10 | // Simplify extractvalue
11 | //
12 | // Derived from InstCombine
13 | //
14 | //===----------------------------------------------------------------------===//
15 |
16 | #include "llvm/IR/Instructions.h"
17 | #include "llvm/IR/Module.h"
18 | #include "llvm/Pass.h"
19 |
20 | namespace llvm {
21 | //
22 | // Class: SimplifyEV
23 | //
24 | class SimplifyEV : public ModulePass {
25 | public:
26 | static char ID;
27 | SimplifyEV() : ModulePass(ID) {}
28 | virtual bool runOnModule(Module& M);
29 | };
30 | }
31 |
32 |
--------------------------------------------------------------------------------
/dictionaries/png.dict:
--------------------------------------------------------------------------------
1 | #
2 | # AFL dictionary for PNG images
3 | # -----------------------------
4 | #
5 | # Just the basic, standard-originating sections; does not include vendor
6 | # extensions.
7 | #
8 | # Created by Michal Zalewski
9 | #
10 |
11 | header_png="\x89PNG\x0d\x0a\x1a\x0a"
12 |
13 | section_IDAT="IDAT"
14 | section_IEND="IEND"
15 | section_IHDR="IHDR"
16 | section_PLTE="PLTE"
17 | section_bKGD="bKGD"
18 | section_cHRM="cHRM"
19 | section_fRAc="fRAc"
20 | section_gAMA="gAMA"
21 | section_gIFg="gIFg"
22 | section_gIFt="gIFt"
23 | section_gIFx="gIFx"
24 | section_hIST="hIST"
25 | section_iCCP="iCCP"
26 | section_iTXt="iTXt"
27 | section_oFFs="oFFs"
28 | section_pCAL="pCAL"
29 | section_pHYs="pHYs"
30 | section_sBIT="sBIT"
31 | section_sCAL="sCAL"
32 | section_sPLT="sPLT"
33 | section_sRGB="sRGB"
34 | section_sTER="sTER"
35 | section_tEXt="tEXt"
36 | section_tIME="tIME"
37 | section_tRNS="tRNS"
38 | section_zTXt="zTXt"
39 |
--------------------------------------------------------------------------------
/dsa/include/assistDS/SimplifyInsertValue.h:
--------------------------------------------------------------------------------
1 | //===-- SimplifyInsertValue.cpp - Remove extraneous insertvalue insts------===//
2 | //
3 | // The LLVM Compiler Infrastructure
4 | //
5 | // This file is distributed under the University of Illinois Open Source
6 | // License. See LICENSE.TXT for details.
7 | //
8 | //===----------------------------------------------------------------------===//
9 | //
10 | // Simplify insertvalue
11 | // Replace insertvalue by storess where possible
12 | //
13 | //===----------------------------------------------------------------------===//
14 |
15 | #include "llvm/IR/Instructions.h"
16 | #include "llvm/IR/Module.h"
17 | #include "llvm/Pass.h"
18 |
19 | namespace llvm {
20 | //
21 | // Class: SimplifyIV
22 | //
23 | class SimplifyIV : public ModulePass {
24 | public:
25 | static char ID;
26 | SimplifyIV() : ModulePass(ID) {}
27 | virtual bool runOnModule(Module& M);
28 | };
29 | }
30 |
31 |
--------------------------------------------------------------------------------
/dsa/include/assistDS/FuncSimplify.h:
--------------------------------------------------------------------------------
1 | //===-------- ArgCast.cpp - Cast Arguments to Calls -----------------------===//
2 | //
3 | // The LLVM Compiler Infrastructure
4 | //
5 | // This file is distributed under the University of Illinois Open Source
6 | // License. See LICENSE.TXT for details.
7 | //
8 | //===----------------------------------------------------------------------===//
9 | //===----------------------------------------------------------------------===//
10 |
11 | #include "llvm/IR/Instructions.h"
12 | #include "llvm/IR/Module.h"
13 | #include "llvm/Pass.h"
14 |
15 | namespace llvm {
16 | //
17 | // Class: FuncSimplify
18 | //
19 | // Description:
20 | // Replace all internal aliases with the
21 | // aliasee value
22 | //
23 | class FuncSimplify : public ModulePass {
24 | public:
25 | static char ID;
26 | FuncSimplify() : ModulePass(ID) {}
27 | virtual bool runOnModule(Module& M);
28 | };
29 | }
30 |
31 |
--------------------------------------------------------------------------------
/dsa/include/assistDS/MergeGEP.h:
--------------------------------------------------------------------------------
1 | //===-- MergeGEP.cpp - Merge GEPs for indexing in arrays ------------------===//
2 | //
3 | // The LLVM Compiler Infrastructure
4 | //
5 | // This file is distributed under the University of Illinois Open Source
6 | // License. See LICENSE.TXT for details.
7 | //
8 | //===----------------------------------------------------------------------===//
9 | //
10 | // Merge chained GEPs; Specially useful for arrays inside structs
11 | //
12 | //===----------------------------------------------------------------------===//
13 |
14 | #include "llvm/IR/DataLayout.h"
15 | #include "llvm/IR/Instructions.h"
16 | #include "llvm/IR/Module.h"
17 | #include "llvm/Pass.h"
18 |
19 | namespace llvm {
20 | //
21 | // Class: MergeArrayGEP
22 | //
23 | class MergeArrayGEP : public ModulePass {
24 | public:
25 | static char ID;
26 | MergeArrayGEP() : ModulePass(ID) {}
27 | virtual bool runOnModule(Module& M);
28 | };
29 | }
30 |
31 |
--------------------------------------------------------------------------------
/dsa/include/assistDS/StructReturnToPointer.h:
--------------------------------------------------------------------------------
1 | //===-------- StructReturnToPointer.cpp ------------------------------------===//
2 | //
3 | // The LLVM Compiler Infrastructure
4 | //
5 | // This file is distributed under the University of Illinois Open Source
6 | // License. See LICENSE.TXT for details.
7 | //
8 | //===----------------------------------------------------------------------===//
9 | //
10 | // For functions that return structures,
11 | // transform them to return a pointer to the structure instead.
12 | //
13 | //===----------------------------------------------------------------------===//
14 |
15 | #include "llvm/IR/Instructions.h"
16 | #include "llvm/IR/Module.h"
17 | #include "llvm/Pass.h"
18 |
19 | namespace llvm {
20 | //
21 | // Class: StructRet
22 | //
23 | class StructRet : public ModulePass {
24 | public:
25 | static char ID;
26 | StructRet() : ModulePass(ID) {}
27 | virtual bool runOnModule(Module& M);
28 | };
29 | }
30 |
31 |
--------------------------------------------------------------------------------
/dsa/include/assistDS/GEPExprArgs.h:
--------------------------------------------------------------------------------
1 |
2 | //
3 | // The LLVM Compiler Infrastructure
4 | //
5 | // This file is distributed under the University of Illinois Open Source
6 | // License. See LICENSE.TXT for details.
7 | //
8 | //===----------------------------------------------------------------------===//
9 | //
10 | // Identify GEPs used as arguments to call sites.
11 | //
12 | //===----------------------------------------------------------------------===//
13 |
14 | #include "llvm/IR/Instructions.h"
15 | #include "llvm/IR/Module.h"
16 | #include "llvm/Pass.h"
17 |
18 | namespace llvm {
19 | //
20 | // Class: GEPExprArgs
21 | //
22 | // Description:
23 | // Implement an LLVM pass that clones functions which are passed GEPs
24 | // as an argument
25 | //
26 | //
27 | class GEPExprArgs : public ModulePass {
28 | public:
29 | static char ID;
30 | GEPExprArgs() : ModulePass(ID) {}
31 | virtual bool runOnModule(Module& M);
32 | };
33 | }
34 |
35 |
--------------------------------------------------------------------------------
/test-instr.c:
--------------------------------------------------------------------------------
1 | /*
2 | american fuzzy lop - a trivial program to test the build
3 | --------------------------------------------------------
4 |
5 | Written and maintained by Michal Zalewski
6 |
7 | Copyright 2014 Google Inc. All rights reserved.
8 |
9 | Licensed under the Apache License, Version 2.0 (the "License");
10 | you may not use this file except in compliance with the License.
11 | You may obtain a copy of the License at:
12 |
13 | http://www.apache.org/licenses/LICENSE-2.0
14 |
15 | */
16 |
17 | #include
18 | #include
19 | #include
20 | #include
21 | uint32_t __afl_area_size;
22 |
23 | int main(int argc, char** argv) {
24 |
25 | char buf[8];
26 |
27 | if (read(0, buf, 8) < 1) {
28 | printf("Hum?\n");
29 | exit(1);
30 | }
31 |
32 | if (buf[0] == '0')
33 | printf("Looks like a zero to me!\n");
34 | else
35 | printf("A non-zero value? How quaint!\n");
36 |
37 | exit(0);
38 |
39 | }
40 |
--------------------------------------------------------------------------------
/dsa/include/dsa/super_set.h:
--------------------------------------------------------------------------------
1 | /*
2 | * File: super_set.h
3 | * Author: andrew
4 | *
5 | * Created on March 10, 2010, 2:04 PM
6 | */
7 |
8 | #ifndef _SUPER_SET_H
9 | #define _SUPER_SET_H
10 |
11 | #include "dsa/svset.h"
12 | #include
13 |
14 | // Contains stable references to a set
15 | // The sets can be grown.
16 |
17 | template
18 | class SuperSet {
19 | //std::set provides stable iterators, and that matters a lot
20 | typedef svset InnerSetTy;
21 | typedef std::set OuterSetTy;
22 | OuterSetTy container;
23 | public:
24 | typedef const typename OuterSetTy::value_type* setPtr;
25 |
26 | setPtr getOrCreate(svset& S) {
27 | if (S.empty()) return 0;
28 | return &(*container.insert(S).first);
29 | }
30 |
31 | setPtr getOrCreate(setPtr P, Ty t) {
32 | svset s;
33 | if (P)
34 | s.insert(P->begin(), P->end());
35 | s.insert(t);
36 | return getOrCreate(s);
37 | }
38 | };
39 |
40 |
41 |
42 | #endif /* _SUPER_SET_H */
43 |
44 |
--------------------------------------------------------------------------------
/llvm_mode/testcases.txt:
--------------------------------------------------------------------------------
1 | - mem2reg should work
2 | - array {} of any size *not* 1,2,4,8 should be added to dictionary if followed by memcmp/strcmp/etc
3 | - array {} of size 1,2,4,8 should work
4 | example: unsigned char arr[] = {0xAA, 0xAA, 0xCC, 0xDD, 0xEE, 0xFF, 0x00 };
5 | if ( !memcmp(hello, arr, sizeof(arr)) )
6 |
7 | -> handled in strcompare-to-unit.so.cc
8 |
9 | - 0,1 magic values should not be broken down into small comparison for equalities
10 | - 0,1,-1 should not be broekn blabla for ine and call results
11 | - u8 a == 0xCC
12 | -> dictionary should have 1-byte value, not 4 bytes because of integer promotion
13 | handled by -instcombine
14 | -> should not be broken down because of integer prmotion
15 | handle by -instcombine
16 | - switch statement
17 | handled by -lowerswitch
18 | - libs strcat, etc should be able to *not* be added to dictionary
19 | handled in strcompare-to-unit.so.cc
20 | handled by -disable-simplify-libcalls to not optimize this into memcpy()
21 | TODO: add memcmpy() ad test again
--------------------------------------------------------------------------------
/qemu_mode/patches/cpu-exec.diff:
--------------------------------------------------------------------------------
1 | --- qemu-2.10.0-rc3-clean/accel/tcg/cpu-exec.c 2017-08-15 11:39:41.000000000 -0700
2 | +++ qemu-2.10.0-rc3/accel/tcg/cpu-exec.c 2017-08-22 14:34:55.868730680 -0700
3 | @@ -36,6 +36,8 @@
4 | #include "sysemu/cpus.h"
5 | #include "sysemu/replay.h"
6 |
7 | +#include "../patches/afl-qemu-cpu-inl.h"
8 | +
9 | /* -icount align implementation. */
10 |
11 | typedef struct SyncClocks {
12 | @@ -144,6 +146,8 @@
13 | int tb_exit;
14 | uint8_t *tb_ptr = itb->tc_ptr;
15 |
16 | + AFL_QEMU_CPU_SNIPPET2;
17 | +
18 | qemu_log_mask_and_addr(CPU_LOG_EXEC, itb->pc,
19 | "Trace %p [%d: " TARGET_FMT_lx "] %s\n",
20 | itb->tc_ptr, cpu->cpu_index, itb->pc,
21 | @@ -365,6 +369,7 @@
22 | if (!tb) {
23 | /* if no translated code available, then translate it now */
24 | tb = tb_gen_code(cpu, pc, cs_base, flags, 0);
25 | + AFL_QEMU_CPU_SNIPPET1;
26 | }
27 |
28 | mmap_unlock();
29 |
--------------------------------------------------------------------------------
/dsa/include/assistDS/SimplifyGEP.h:
--------------------------------------------------------------------------------
1 | //===--------------- SimplifyGEP.cpp - Simplify GEPs types ---------------===//
2 | //
3 | // The LLVM Compiler Infrastructure
4 | //
5 | // This file is distributed under the University of Illinois Open Source
6 | // License. See LICENSE.TXT for details.
7 | //
8 | //===----------------------------------------------------------------------===//
9 | //
10 | // Simplify GEPs with bitcasts (mostly cloned from InstCombine)
11 | //
12 | //===----------------------------------------------------------------------===//
13 |
14 | #include "llvm/IR/DataLayout.h"
15 | #include "llvm/IR/Instructions.h"
16 | #include "llvm/IR/Module.h"
17 | #include "llvm/Pass.h"
18 |
19 | namespace llvm {
20 | //
21 | // Class: SimplifyGEP
22 | //
23 | class SimplifyGEP : public ModulePass {
24 | private:
25 | const DataLayout * TD;
26 | public:
27 | static char ID;
28 | SimplifyGEP() : ModulePass(ID) {}
29 | virtual bool runOnModule(Module& M);
30 | virtual void getAnalysisUsage(AnalysisUsage &AU) const {}
31 | };
32 | }
33 |
34 |
--------------------------------------------------------------------------------
/dsa/include/assistDS/IndCloner.h:
--------------------------------------------------------------------------------
1 | //===-- IndCloner.h - Clone Indirectly Called Functions -------------------===//
2 | //
3 | // The LLVM Compiler Infrastructure
4 | //
5 | // This file is distributed under the University of Illinois Open Source
6 | // License. See LICENSE.TXT for details.
7 | //
8 | //===----------------------------------------------------------------------===//
9 | //
10 | // This code defines a pass which clones functions which could potentially be
11 | // used in indirect function calls.
12 | //
13 | //===----------------------------------------------------------------------===//
14 |
15 | #include "llvm/IR/Instructions.h"
16 | #include "llvm/IR/Module.h"
17 | #include "llvm/Pass.h"
18 |
19 | namespace llvm {
20 | //
21 | // Class: IndClone
22 | //
23 | // Description:
24 | // Implement an LLVM pass that clones functions which could be used for
25 | // indirect function calls.
26 | //
27 | class IndClone : public ModulePass {
28 | public:
29 | static char ID;
30 | IndClone() : ModulePass(ID) {}
31 | virtual bool runOnModule(Module& M);
32 | };
33 | }
34 |
35 |
--------------------------------------------------------------------------------
/qemu_mode/patches/syscall.diff:
--------------------------------------------------------------------------------
1 | --- qemu-2.10.0-rc3-clean/linux-user/syscall.c 2017-08-15 11:39:41.000000000 -0700
2 | +++ qemu-2.10.0-rc3/linux-user/syscall.c 2017-08-22 14:34:03.193088186 -0700
3 | @@ -116,6 +116,8 @@
4 |
5 | #include "qemu.h"
6 |
7 | +extern unsigned int afl_forksrv_pid;
8 | +
9 | #ifndef CLONE_IO
10 | #define CLONE_IO 0x80000000 /* Clone io context */
11 | #endif
12 | @@ -11688,8 +11690,21 @@
13 | break;
14 |
15 | case TARGET_NR_tgkill:
16 | - ret = get_errno(safe_tgkill((int)arg1, (int)arg2,
17 | - target_to_host_signal(arg3)));
18 | +
19 | + {
20 | + int pid = (int)arg1,
21 | + tgid = (int)arg2,
22 | + sig = (int)arg3;
23 | +
24 | + /* Not entirely sure if the below is correct for all architectures. */
25 | +
26 | + if(afl_forksrv_pid && afl_forksrv_pid == pid && sig == SIGABRT)
27 | + pid = tgid = getpid();
28 | +
29 | + ret = get_errno(safe_tgkill(pid, tgid, target_to_host_signal(sig)));
30 | +
31 | + }
32 | +
33 | break;
34 |
35 | #ifdef TARGET_NR_set_robust_list
36 |
--------------------------------------------------------------------------------
/dsa/include/assistDS/ArgCast.h:
--------------------------------------------------------------------------------
1 | //===-------- ArgCast.cpp - Cast Arguments to Calls -----------------------===//
2 | //
3 | // The LLVM Compiler Infrastructure
4 | //
5 | // This file is distributed under the University of Illinois Open Source
6 | // License. See LICENSE.TXT for details.
7 | //
8 | //===----------------------------------------------------------------------===//
9 | // Convert
10 | // call(bitcast (.., T1 arg, ...)F to(..., T2 arg, ...))(..., T2 val, ...)
11 | // to
12 | // val1 = bitcast T2 val to T1
13 | // call F (..., T1 val1, ...)
14 | //===----------------------------------------------------------------------===//
15 |
16 | #include "llvm/IR/Instructions.h"
17 | #include "llvm/IR/Constants.h"
18 | #include "llvm/IR/Module.h"
19 | #include "llvm/Pass.h"
20 |
21 | namespace llvm {
22 | //
23 | // Class: ArgCast
24 | //
25 | // Description:
26 | // Implement an LLVM pass that cleans up call sites that take casted args
27 | //
28 | class ArgCast : public ModulePass {
29 | public:
30 | static char ID;
31 | ArgCast() : ModulePass(ID) {}
32 | virtual bool runOnModule(Module& M);
33 | };
34 | }
35 |
36 |
--------------------------------------------------------------------------------
/libtokencap/Makefile:
--------------------------------------------------------------------------------
1 | #
2 | # american fuzzy lop - libtokencap
3 | # --------------------------------
4 | #
5 | # Written by Michal Zalewski
6 | #
7 | # Copyright 2016 Google Inc. All rights reserved.
8 | #
9 | # Licensed under the Apache License, Version 2.0 (the "License");
10 | # you may not use this file except in compliance with the License.
11 | # You may obtain a copy of the License at:
12 | #
13 | # http://www.apache.org/licenses/LICENSE-2.0
14 | #
15 |
16 | PREFIX ?= /usr/local
17 | HELPER_PATH = $(PREFIX)/lib/afl
18 |
19 | VERSION = $(shell grep '^\#define VERSION ' ../config.h | cut -d '"' -f2)
20 |
21 | CFLAGS ?= -O3 -funroll-loops
22 | CFLAGS += -Wall -D_FORTIFY_SOURCE=2 -g -Wno-pointer-sign
23 |
24 | all: libtokencap.so
25 |
26 | libtokencap.so: libtokencap.so.c ../config.h
27 | $(CC) $(CFLAGS) -shared -fPIC $< -o $@ $(LDFLAGS)
28 |
29 | .NOTPARALLEL: clean
30 |
31 | clean:
32 | rm -f *.o *.so *~ a.out core core.[1-9][0-9]*
33 | rm -f libtokencap.so
34 |
35 | install: all
36 | install -m 755 libtokencap.so $${DESTDIR}$(HELPER_PATH)
37 | install -m 644 README.tokencap $${DESTDIR}$(HELPER_PATH)
38 |
39 |
--------------------------------------------------------------------------------
/dsa/include/assistDS/FuncSpec.h:
--------------------------------------------------------------------------------
1 | //===-- FuncSpec.cpp - Clone Functions With Constant Function Ptr Args ----===//
2 | //
3 | // The LLVM Compiler Infrastructure
4 | //
5 | // This file is distributed under the University of Illinois Open Source
6 | // License. See LICENSE.TXT for details.
7 | //
8 | //===----------------------------------------------------------------------===//
9 | //
10 | // This pass clones functions that take constant function pointers as arguments
11 | // from some call sites. It changes those call sites to call cloned functions.
12 | //
13 | //===----------------------------------------------------------------------===//
14 |
15 | #include "llvm/IR/Instructions.h"
16 | #include "llvm/IR/Module.h"
17 | #include "llvm/Pass.h"
18 |
19 | namespace llvm {
20 | //
21 | // Class: FuncSpec
22 | //
23 | // Description:
24 | // Implement an LLVM pass that clones functions which are passed
25 | // as an argument
26 | //
27 | //
28 | class FuncSpec : public ModulePass {
29 | public:
30 | static char ID;
31 | FuncSpec() : ModulePass(ID) {}
32 | virtual bool runOnModule(Module& M);
33 | };
34 | }
35 |
36 |
--------------------------------------------------------------------------------
/dsa/include/assistDS/Int2PtrCmp.h:
--------------------------------------------------------------------------------
1 | //===-- Int2PtrCmp.cpp - Merge inttoptr/ptrtoint --------------------------===//
2 | //
3 | // The LLVM Compiler Infrastructure
4 | //
5 | // This file is distributed under the University of Illinois Open Source
6 | // License. See LICENSE.TXT for details.
7 | //
8 | //===----------------------------------------------------------------------===//
9 | //
10 | // Remove unnecessary inttoptr casts
11 | // Specially ones used in just compares
12 | // Most cases derived from InstCombine
13 | //
14 | //===----------------------------------------------------------------------===//
15 |
16 | #include "llvm/IR/DataLayout.h"
17 | #include "llvm/IR/Instructions.h"
18 | #include "llvm/IR/Module.h"
19 | #include "llvm/Pass.h"
20 |
21 |
22 | namespace llvm {
23 | //
24 | // Class: Int2PtrCmp
25 | //
26 | //
27 | class Int2PtrCmp : public ModulePass {
28 | private:
29 | const DataLayout * TD;
30 | public:
31 | static char ID;
32 | Int2PtrCmp() : ModulePass(ID) {}
33 | virtual bool runOnModule(Module& M);
34 | virtual void getAnalysisUsage(AnalysisUsage &AU) const {}
35 |
36 | };
37 | }
38 |
39 |
--------------------------------------------------------------------------------
/dsa/include/assistDS/LoadArgs.h:
--------------------------------------------------------------------------------
1 | //===-- LoadArgs.cpp - Promote args if they came from loads ---------------===//
2 | //
3 | // The LLVM Compiler Infrastructure
4 | //
5 | // This file is distributed under the University of Illinois Open Source
6 | // License. See LICENSE.TXT for details.
7 | //
8 | //===----------------------------------------------------------------------===//
9 | //
10 | // Identify calls, that are passed arguemtns that are LoadInsts.
11 | // Pass the original pointer instead. Helps improve some
12 | // context sensitivity.
13 | //
14 | //===----------------------------------------------------------------------===//
15 |
16 | #include "llvm/IR/Instructions.h"
17 | #include "llvm/IR/Module.h"
18 | #include "llvm/Pass.h"
19 |
20 | namespace llvm {
21 | //
22 | // Class: LoadArgs
23 | //
24 | // Description:
25 | // Implement an LLVM pass that clones functions which are passed loads
26 | // as an argument
27 | //
28 | //
29 | class LoadArgs : public ModulePass {
30 | public:
31 | static char ID;
32 | LoadArgs() : ModulePass(ID) {}
33 | virtual bool runOnModule(Module& M);
34 | };
35 | }
36 |
37 |
--------------------------------------------------------------------------------
/utils.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | #ifdef AFL_LLVM_RT
4 | # define __FILENAME__ (strrchr(__FILE__, '/') ? strrchr(__FILE__, '/') + 1 : __FILE__)
5 | # define ASSERT(x) if (!(x)) { printf("assert( " #x " ) failed in file %s at line %u\n", __FILENAME__, __LINE__); exit(-1); }
6 | #endif
7 |
8 | static inline u32 get_bbmap_size(u32 size) {
9 | return (((size - 1) / 8) + 1);
10 | }
11 |
12 | static inline u32 get_map_size(u32 size) {
13 | ASSERT(size);
14 | size = (((size - 1) / 8) + 1);
15 | ASSERT((size <= (u32)(-1) / 8) && "Map size too large");
16 | return size * 8;
17 | }
18 |
19 | static inline void set_bit_from_bb_id(u8 * bb_trace_map, u32 trace_map_size, u32 bb_id) {
20 | u32 byte_n = bb_id / 8;
21 | u32 bit = (bb_id & 7);
22 | ASSERT(byte_n < trace_map_size); /* Sanity check things work as expected... */
23 | bb_trace_map[byte_n] |= (1 << bit);
24 | }
25 |
26 | static inline u8 get_bit_from_bb_id(u8 * bb_trace_map, u32 trace_map_size, u32 bb_id) {
27 | u32 byte_n = bb_id / 8;
28 | u32 bit = (bb_id & 7);
29 | ASSERT(byte_n < trace_map_size); /* Sanity check things work as expected... */
30 | return !!(bb_trace_map[byte_n] & (1 << bit));
31 | }
32 |
--------------------------------------------------------------------------------
/libdislocator/Makefile:
--------------------------------------------------------------------------------
1 | #
2 | # american fuzzy lop - libdislocator
3 | # ----------------------------------
4 | #
5 | # Written by Michal Zalewski
6 | #
7 | # Copyright 2016 Google Inc. All rights reserved.
8 | #
9 | # Licensed under the Apache License, Version 2.0 (the "License");
10 | # you may not use this file except in compliance with the License.
11 | # You may obtain a copy of the License at:
12 | #
13 | # http://www.apache.org/licenses/LICENSE-2.0
14 | #
15 |
16 | PREFIX ?= /usr/local
17 | HELPER_PATH = $(PREFIX)/lib/afl
18 |
19 | VERSION = $(shell grep '^\#define VERSION ' ../config.h | cut -d '"' -f2)
20 |
21 | CFLAGS ?= -O3 -funroll-loops
22 | CFLAGS += -Wall -D_FORTIFY_SOURCE=2 -g -Wno-pointer-sign
23 |
24 | all: libdislocator.so
25 |
26 | libdislocator.so: libdislocator.so.c ../config.h
27 | $(CC) $(CFLAGS) -shared -fPIC $< -o $@ $(LDFLAGS)
28 |
29 | .NOTPARALLEL: clean
30 |
31 | clean:
32 | rm -f *.o *.so *~ a.out core core.[1-9][0-9]*
33 | rm -f libdislocator.so
34 |
35 | install: all
36 | install -m 755 libdislocator.so $${DESTDIR}$(HELPER_PATH)
37 | install -m 644 README.dislocator $${DESTDIR}$(HELPER_PATH)
38 |
39 |
--------------------------------------------------------------------------------
/qemu_mode/patches/elfload.diff:
--------------------------------------------------------------------------------
1 | --- qemu-2.10.0-rc3-clean/linux-user/elfload.c 2017-08-15 11:39:41.000000000 -0700
2 | +++ qemu-2.10.0-rc3/linux-user/elfload.c 2017-08-22 14:33:57.397127516 -0700
3 | @@ -20,6 +20,8 @@
4 |
5 | #define ELF_OSABI ELFOSABI_SYSV
6 |
7 | +extern abi_ulong afl_entry_point, afl_start_code, afl_end_code;
8 | +
9 | /* from personality.h */
10 |
11 | /*
12 | @@ -2085,6 +2087,8 @@
13 | info->brk = 0;
14 | info->elf_flags = ehdr->e_flags;
15 |
16 | + if (!afl_entry_point) afl_entry_point = info->entry;
17 | +
18 | for (i = 0; i < ehdr->e_phnum; i++) {
19 | struct elf_phdr *eppnt = phdr + i;
20 | if (eppnt->p_type == PT_LOAD) {
21 | @@ -2118,9 +2122,11 @@
22 | if (elf_prot & PROT_EXEC) {
23 | if (vaddr < info->start_code) {
24 | info->start_code = vaddr;
25 | + if (!afl_start_code) afl_start_code = vaddr;
26 | }
27 | if (vaddr_ef > info->end_code) {
28 | info->end_code = vaddr_ef;
29 | + if (!afl_end_code) afl_end_code = vaddr_ef;
30 | }
31 | }
32 | if (elf_prot & PROT_WRITE) {
33 |
--------------------------------------------------------------------------------
/make_autodict.sh:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 |
3 | # objdump -d "${1}" | grep -Eo '\$0x[0-9a-f]+' | cut -c 2- | sort -u | while read const; do echo $const | python -c 'import sys, struct; sys.stdout.write("".join(struct.pack(" testcases/$const; done
4 | # i=0; strings "${1}"| while read line; do echo -n "$line" > testcases/string_${i} ; i=$[ $i + 1 ] ; done
5 |
6 | if [ "$#" -ne 1 ]; then
7 | echo "Illegal number of parameters"
8 | echo "$0 /path/to/executable"
9 | echo "Example: $0 /bin/ls"
10 | exit 1
11 | fi
12 |
13 | EXE="$1"
14 | DICT=$EXE-auto.dict
15 | rm $DICT 2>/dev/null
16 |
17 |
18 | L=$(objdump -d $EXE | grep -Eo '\$0x[0-9a-f]+' | cut -c 2- | sort -u)
19 |
20 | echo "length:" $(echo $L | wc -w) ... Be patient
21 | i=0
22 |
23 | # this adds a 0 in front if the value is does not contain an even number of characters
24 | # it also transforms 0x into \x
25 | for v in $L
26 | do
27 | v=$(echo $v | sed "s/0x//g")
28 | length=$(echo -n $v | wc -c)
29 | if [ $((length%2)) -eq 1 ]; then
30 | v="0${v}"
31 | fi
32 |
33 | v="\\x${v}"
34 | echo auto_value=\"$v\" >> $DICT
35 |
36 | i=$((i+1))
37 | i=$(expr $i % 1000)
38 | if [ $i -eq 0 ]; then
39 | echo -n .
40 | fi
41 | done
42 |
43 |
--------------------------------------------------------------------------------
/gllvm/examples/linux-kernel/full-script.sh:
--------------------------------------------------------------------------------
1 | export home=/home/pn/perso/bcfull
2 | export ker=/home/pn/perso/linux-stable
3 |
4 | cd $ker
5 | python parse-bi.py fs/built-in.o fs/out.sh ../bcfull/instrfs 999
6 |
7 | cd $home
8 | bash copy.sh
9 |
10 | ld --build-id -T ./arch/x86/kernel/vmlinux.lds --whole-archive built-ins/sep_objs/ker_objects/head_64.o \
11 | built-ins/sep_objs/ker_objects/head64.o built-ins/sep_objs/ker_objects/ebda.o built-ins/sep_objs/ker_objects/platform-quirks.o\
12 | built-ins/inibibc.o built-ins/sep_objs/ker_objects/initramfs_data.o built-ins/arcbibc.o built-ins/sep_objs/arch_assembly_objects/* \
13 | built-ins/kerbibc.o built-ins/mmbibc.o \@instrfs built-ins/ipcbibc.o built-ins/secbibc.o built-ins/cptbibc.o built-ins/blkbibc.o \
14 | built-ins/libbibc.o built-ins/sep_objs/lib_assembly_objects/* built-ins/xlibbibc.o built-ins/sep_objs/xlib_assembly_objects/* \
15 | built-ins/dribi.o built-ins/sndbibc.o built-ins/pcibibc.o built-ins/powbibc.o built-ins/sep_objs/pow_assembly_objects/* \
16 | built-ins/vidbibc.o built-ins/netbibc.o --no-whole-archive --start-group lib/lib.a.o arch/x86/lib/lib.a.o \
17 | built-ins/sep_objs/libx_objects/* .tmp_kallsyms2.o --end-group -o vmlinux
18 |
19 | cp vmlinux ../linux-stable-clang/
20 | cd ../linux-stable-clang
21 | ./install.sh
22 | sudo reboot
23 |
--------------------------------------------------------------------------------
/dictionaries/tiff.dict:
--------------------------------------------------------------------------------
1 | #
2 | # AFL dictionary for TIFF images
3 | # ------------------------------
4 | #
5 | # Just the basic, standard-originating sections; does not include vendor
6 | # extensions.
7 | #
8 | # Created by Michal Zalewski
9 | #
10 |
11 | header_ii="II*\x00"
12 | header_mm="MM\x00*"
13 |
14 | section_100="\x00\x01"
15 | section_101="\x01\x01"
16 | section_102="\x02\x01"
17 | section_103="\x03\x01"
18 | section_106="\x06\x01"
19 | section_107="\x07\x01"
20 | section_10D="\x0d\x01"
21 | section_10E="\x0e\x01"
22 | section_10F="\x0f\x01"
23 | section_110="\x10\x01"
24 | section_111="\x11\x01"
25 | section_112="\x12\x01"
26 | section_115="\x15\x01"
27 | section_116="\x16\x01"
28 | section_117="\x17\x01"
29 | section_11A="\x1a\x01"
30 | section_11B="\x1b\x01"
31 | section_11C="\x1c\x01"
32 | section_11D="\x1d\x01"
33 | section_11E="\x1e\x01"
34 | section_11F="\x1f\x01"
35 | section_122="\"\x01"
36 | section_123="#\x01"
37 | section_124="$\x01"
38 | section_125="%\x01"
39 | section_128="(\x01"
40 | section_129=")\x01"
41 | section_12D="-\x01"
42 | section_131="1\x01"
43 | section_132="2\x01"
44 | section_13B=";\x01"
45 | section_13C="<\x01"
46 | section_13D="=\x01"
47 | section_13E=">\x01"
48 | section_13F="?\x01"
49 | section_140="@\x01"
50 | section_FE="\xfe\x00"
51 | section_FF="\xff\x00"
52 |
--------------------------------------------------------------------------------
/dsa/include/dsa/stl_util.h:
--------------------------------------------------------------------------------
1 | #ifndef _DSA_STL_UTIL_H_
2 | #define _DSA_STL_UTIL_H_
3 |
4 | #include "llvm/ADT/ilist.h"
5 | #include
6 | #include