Skip to content

Instantly share code, notes, and snippets.

@nelhage
Created March 2, 2010 02:57
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nelhage/319075 to your computer and use it in GitHub Desktop.
Save nelhage/319075 to your computer and use it in GitHub Desktop.
/* gcc -o nostdlib nostdlib.c -m32 -z execstack -nostdlib */
/* Who needs libc or asm() when you can abuse the ABI in horrible ways?*/
typedef int (*sc_fun)(int,int,int,int,int,int,int);
void _start(void) {
char syscall[] = "\x60\x83\xc4\x24\x58\x5b\x59\x5a\x5e\x5f\x5d\xcd\x80\x83\xec\x40\x61\xc3";
((sc_fun)syscall)(4, 0, "Hello, World\n", 13, 0, 0, 0);
((sc_fun)syscall)(1, 0, 0, 0, 0, 0, 0);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment