Skip to content

简化版本llvm的stackprotector策略,将其包装成一个pass,对程序的stack进行保护

Notifications You must be signed in to change notification settings

zhilongwang/llvm-stack-guard

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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!

About

简化版本llvm的stackprotector策略,将其包装成一个pass,对程序的stack进行保护

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Assembly 62.3%
  • C++ 18.2%
  • LLVM 15.1%
  • CMake 2.9%
  • C 1.5%