Skip to content

Instantly share code, notes, and snippets.

@shmam
Last active May 4, 2018 10:04
Show Gist options
  • Select an option

  • Save shmam/07c83b70e6660aa7e581451eb7689a06 to your computer and use it in GitHub Desktop.

Select an option

Save shmam/07c83b70e6660aa7e581451eb7689a06 to your computer and use it in GitHub Desktop.
Simple exploit of the dangerous stdlib.h system() function in C99 to make a replicating and auto-compiling program. I haven't run the full thing yet because it is probably bad. I really have to study now but I plan on updating this and adding to it after my exam.
#include <stdio.h>
#include <stdlib.h>
int main(int argc, char *argv[]) {
system(" rm -f spam2.c spam2.o spam2");
system(" touch spam2.c");
system(" hexdump -ve \'1/1 \"%.2x\"\' spam.c | xxd -r -p > spam2.c");
system(" gcc -Wall -std=c99 spam2.c -o spam2");
system(" echo STOP ME :) ");
// uncomment this to run the file! :0
// system(" ./spam2");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment