(writeup) LIT CTF 2024
w4dup 2de
Image Not Showing
Possible Reasons
- The image was uploaded to a note which you don't have access to
- The note which the image was originally uploaded to has been deleted
Learn More →
Image Not Showing
Possible Reasons
- The image was uploaded to a note which you don't have access to
- The note which the image was originally uploaded to has been deleted
Learn More →
Image Not Showing
Possible Reasons
- The image was uploaded to a note which you don't have access to
- The note which the image was originally uploaded to has been deleted
Learn More →
analyse
- PIE tĩnh, file chỉ có 1 hàm –-> ret2dlresolved
- có thể dùng tool python để generate dlresolve nhưng hên xui lắm
- ở đây sẽ chơi "fong kách" khác
- kết hợp csu với lại resolve
Image Not Showing
Possible Reasons
- The image was uploaded to a note which you don't have access to
- The note which the image was originally uploaded to has been deleted
Learn More →
Image Not Showing
Possible Reasons
- The image was uploaded to a note which you don't have access to
- The note which the image was originally uploaded to has been deleted
Learn More →
- chỉ cần $rbp mình là got đến libc với $ebx là offset, sẽ tuỳ ý có được địa chỉ libc mình muốn mà không cần leak
- có sẵn gadget $rdi và $rsi, bị filter execve nên system hay one_gadget là không thể –> ret2shellcode
Image Not Showing
Possible Reasons
- The image was uploaded to a note which you don't have access to
- The note which the image was originally uploaded to has been deleted
Learn More →
Image Not Showing
Possible Reasons
- The image was uploaded to a note which you don't have access to
- The note which the image was originally uploaded to has been deleted
Learn More →
- flow như script là: pop_rdx (change size) -> sys_ret (call read for payload 2) -> pop_rax (0xa) -> pop_rdx (0x7) -> sys_ret (call mprotect) -> pop_rax (0) -> pop_rdx (change size) -> sys_ret (call read shellcode) -> pop_rax (shell_addr) -> jmp_rax
- shellcode là openat và sendfile, với "flag.txt" là địa chỉ tương đối
không xài ORW được vì seccomp nó xét fd phải = 0 khi read
- hơi dài =))) (hoặc dùng tool Ret2dlresolved luôn cũng dịu)
getflag
Image Not Showing
Possible Reasons
- The image was uploaded to a note which you don't have access to
- The note which the image was originally uploaded to has been deleted
Learn More →
How to Raise a Boring Vuln Flat
Image Not Showing
Possible Reasons
- The image was uploaded to a note which you don't have access to
- The note which the image was originally uploaded to has been deleted
Learn More →
Image Not Showing
Possible Reasons
- The image was uploaded to a note which you don't have access to
- The note which the image was originally uploaded to has been deleted
Learn More →
analyse
Image Not Showing
Possible Reasons
- The image was uploaded to a note which you don't have access to
- The note which the image was originally uploaded to has been deleted
Learn More →
Image Not Showing
Possible Reasons
- The image was uploaded to a note which you don't have access to
- The note which the image was originally uploaded to has been deleted
Learn More →
- ở đây sẽ tận dụng 1 là got@printf để fmtstr, 2 là dùng got@scanf để làm được nhiều thứ hơn
- với index
-7
, là -8 = -7 -1
trỏ got@scanf, ta có thể khiến qsort() đó thực hiện plt@scanf nhiều lần ứng với số nums ta nhập từ đầu
–-> arbitrary write
- và để leak libc chỉ còn cách fmtstr
%X$s
với X
là offset trên stack đến _IO_2_1_stdout

payload : b"%171" + b" " + b"$s\0\0" + b" "
(convert về int -> u32)
- Ta ow _flags đến write_base với write_ptr
- leak xong sẽ end –-> tận dụng lần nhập scanf tiếp theo ow ret của scanf thành
_start
(brute 1 byte–> chance 1/16)

main+314: call qsort
return: main+319
- nhưng vấn đề là chain tương tự như z thì bị lỗi trong quá trình qsort()
lấy số này đắp số kia, bị nối chuỗi, %s ở stack k phải là 1 địa chỉ khác, …
- nên sẽ chain đệm thêm fmtstr không gây ảnh hưởng gì ("$s")
b"$s\0\0" + b" "
- gọi fmtstr ow stdout là A, fmtstr ow ret là B
- ban đầu A + đệm + B bị fail
- nhưng chèn như thế sẽ bị thay đổi offset, DEBUG nhiều lần và thấy để đệm "$s" đầu tiên thì lại smooth (đệm + A + B) nên tính offset lại:


- nên lấy stack trước ret value để ow hơn 8 byte, cụ thể là 10 byte cho 2 byte ow brute –> "$10c" (take exactly 10 byte)
- nhưng trong quá trình debug thì thấy tồn tại 1 byte "\n" từ trước nên chỉ padding 7 byte rồi 2 byte ow
- sau khi loop, ta tiếp tục fmtstr scanf để chain ROP

- local with parameter NOASLR

getflag
- 2 bytes ow (brute 1/16) lấy mẫu cho NOASLR làm cho REMOTE vẫn được
