Created
March 9, 2020 14:51
-
-
Save ellcs/9849d98638b397d9f820ceda8ca34d73 to your computer and use it in GitHub Desktop.
Override method in compiled file
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Step 1) gcc -fpic -shared -o execve.so execve_overload.c | |
#ifndef foo_h__ | |
#define foo_h__ | |
#include <stdio.h> | |
#include "stdlib.h" | |
int execve(const char *filename, char *const argv[], char *const envp[]) { | |
puts("Overwritten. Bye!"); | |
exit(0); | |
} | |
#endif // foo_h__ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Step 2) gcc main.c | |
// Step 3) LD_PRELOAD=./execve.so ./a.out | |
int main() { | |
execve("/bin/bash"); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment