Skip to content

Latest commit

 

History

History
59 lines (45 loc) · 1.57 KB

README.md

File metadata and controls

59 lines (45 loc) · 1.57 KB

Simplified LLVM StackProtector

This is a simplified llvm Stackprotector which can only run on the x86_64 machine, if you want to build this project on your own machine, you can follow the following steps:

  1. You should make sure that llvm is properly built on your machine. The tuotorial can be found from the link

  2. First, clone the git repository into your workspace

git clone https://github.com/bin2415/llvm-stack-guard.git
  1. Second, mkdir a dirtory named build and cmake in it
mkdir build && cd ./build
cmake ../
make
  1. Then, you can find a .so file in /build/SSPPass/

  2. In test folder, you can find the test file named stack_example.c

  3. Compile it through clang

clang -S -emit-llvm -o stack_example.ll stack_example.c
  1. Use the pass to protect stack.
opt -load ../build/SSPPass/libSSPass.so -SSPPass stack_example.ll -S -o stack_example_protect.ll
  1. Use the llc tool to generate .o file
llc -filetype=obj stack_example_protect.ll -o stack_example_protect.o
  1. Use clang to generate a binary file
clang -o stack_example_llvm stack_example_protect.o
  1. Run the example file and input 111111111111111111111111 to corrupt the program
./stack_example_llvm
111111111111111111111111111111111

And the result is shown as belows:

corrupt

  1. You can disassemble the binary to find code that implement the stack smashing protect
objdump -S stack_example_llvm > stack_example_llvm.s
vi stack_example_llvm.s

disassemble code

Enjoy doing it!