Skip to content

Instantly share code, notes, and snippets.

@leonjza
Created September 17, 2014 04:34
Show Gist options
  • Save leonjza/466687aee9a2724a5a68 to your computer and use it in GitHub Desktop.
Save leonjza/466687aee9a2724a5a68 to your computer and use it in GitHub Desktop.
Setup Environment Shell EGG
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
/*
* Setup an ENV EGG with /bin/sh, and find a
* a estimate of where this is located in memory
*
* Compiled with gcc -o setup setup_env.c
*
* # gcc -o setup setup_env.c
* # ./setup
* Setting up environment...
* Estimated address of EGG: 0x804a0a4
*/
int get_env(void)
{
char *ptr = getenv("EGG");
if (ptr != NULL) {
printf("Estimated address of EGG: %p\n", ptr);
return 0;
} else {
printf("Can't find EGG in env\n");
return 1;
}
}
int main( int argc, char **argv )
{
printf("Setting up environment...\n");
setenv("EGG", "/bin/sh", 1);
get_env();
/*execl("/bin/sh", (char *)NULL);*/
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment