3 ms·
a much simpler way to execute an executable on linux without writing it to disk is to use fexecve, though i'm not sure if that existed in 02014
by kragen 3y ago
a much simpler way to execute an executable on linux without writing it to disk is to use fexecve, though i'm not sure if that existed in 02014
- grugq 3y agoIt is actually from 2004. :)
- baam 3y agofexecve is just a wrapper of execve using "/proc/self/fd/3" as binary location. (with fd=3 pointing to a mmapped binary) In 2014 you could still use a tmpfs location exec from it and unlink binary, but it generate a lot of artifacts. With linux kernel > 3.16 you can use memfd_* syscalls to achieve same thing in cleaner way. You can look at this rootkit https://github.com/io-tl/degu-lib https://github.com/io-tl/degu-lib that uses theses tricks for stealth executions of binaries
- kragen 3y agoapparently since glibc 2.27 fexecve() uses execveat() instead of /proc if possible, but otherwise i agree