hstocks/gcchijack: Tool to backdoor binaries compiled by gcc/g++ by hijacking their temporary files
2019-07-03 22:27:00 Author: github.com(查看原文) 阅读量:221 收藏

A PoC tool to backdoor binaries compiled by gcc/g++ by hijacking their temporary files.

How it works

When gcc and g++ compile source to a binary, they first write the generated assembly to a temporary file (usually /tmp/<random_string>.s). The compiler then invokes the GAS assembler to assemble this file into an object file, e.g. with /usr/bin/as --64 -o /tmp/ccKdFjq0.o /tmp/ccQIzZ3y.s.

Therefore it is possible for us to modify the generated assembly to insert our own code before the assembler has been invoked, if we do it quickly. This project achieves this by setting up an inotify watch on /tmp/, then when any .s files are created the code will open them, if main: is found then an assembly snippet will be inserted directly after it.

Disclaimer

This is a quick hack which doesn't do anything too exciting. If you want to do something more exciting or target a binary which isnt x86_64 then just change the backdoor assembly snippet at the top of the file.


文章来源: https://github.com/hstocks/gcchijack
如有侵权请联系:admin#unsafe.sh