Skip to content

Instantly share code, notes, and snippets.

@pmauduit
Last active August 29, 2015 14:11
Show Gist options
  • Save pmauduit/0bd3cd8ea44c8119b25c to your computer and use it in GitHub Desktop.
Save pmauduit/0bd3cd8ea44c8119b25c to your computer and use it in GitHub Desktop.
My first shellcode
#include <stdio.h>
#include <stdlib.h>
/**
*
* ba 0b 00 00 00 ; mov ?, 0b (write ?)
* be 01 00 00 00 ; mov ?,1 (stdout)
* bf cb 06 40 00 ; mov edi, 0x00 40 06 cb (char * helloworld)
* e8 bb fe ff ff ; call fwrite
* 5d
* c3
*
* - fwrite position is not known
* - char * helloworld position is not known either :(
*
*/
char * sc = "\xba\x0b\x00\x00\x00\xbe\x01\x00\x00\x00\xbf\xcb\x06\x50\x00\xe8\xbb\xfe\xff\xff\x5d\xc3";
char * helloworld = "helloworld\n";
int main(void) {
char * blah = NULL;
blah = 0x4006cb;
fprintf(stdout, "0x%x\n", helloworld);
fprintf(stdout, "%s", blah);
void * (* ret)() = (void * (*)()) sc;
ret();
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment