Adapted from slyth11907 / Cheatsheets / Cheatsheet_QuickCShell.
It’s actually trivial to write a C program that loads up a shell.
Alternate approach:
Compile with:
Note that this is almost identical to the LD_PRELOAD trick; the primary differences are:
- Use
main()
instead of_init()
as our entry point. - Compile without
-shared
and-nostartfiles
.
A simple binary like this is useful for exploiting SUID/SGID applications that call other executables from part of the PATH that we control.
Using Metasploit
How to use msfvenom to generate a binary that launches any command as root
Metasploit’s msfvenom tool can generate binaries that launch any command as root (useful for exploiting SUID/SGID applications that call other executables from part of the PATH that we control).
Link to original