Akasec CTF 2024
Warm up
Overall
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 →
- No PIE
- No canaryfound
- Give me the address of puts -> leak libc
Bug
Approach
Target: stack pivot + ROP
- As you see, I only have 16 bytes to overwrite from retaddr. If I call system("/bin/sh"), I will need at least 3 quadwords : poprdi_ret, binsh and system.
- So I need to use stack pivot to do my ROP.
- The program disable PIE and name is global variable, so the address of this variable remains unchanged.
- It is a good idea to try to move stack pointer to this.
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 →
Problem
Normally, I try to use method poprdiret, binsh, system; however, it doesn't work here. I try to make rdi, rsi, rcx is zero; it still fails. I don't know exactly the reason for this.
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 →
I used to be stuck and panic for this challenge in one moment. Fortunately, I try with syscall and it works.
Script
Good_trip
Overall
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 →
main
filter

- Banned bytes
- 0F 05: syscall
- 0f 34: sysenter
- cd 80: int 0x80
Approach
Target: leak libc
- Because PIE enable, so I can use got table to leak libc
Script
Bad trip
Overall

main
filter()

- Banned bytes
- 0F 05: syscall
- 0f 34: sysenter
- cd 80: int 0x80
The program gives me 4 bytes at the end of address of puts in libc.
You input shellcode for program run it. However, filter() bans syscall, int 0x80 and sysenter.
Approach 1
Target: libc
-

- r13: contain the address of stack.
- Thus, I can target this to get the libc.
-

Script
Approach 2
Target: libc
- Leak 4 bytes at the end of the address of puts.
- fs: this refers to a special segment register in x86 and x86-64 architectures. Segment registers are used in conjunction with base addresses to locate memory locations. In this case, fs specifically points to a region called Thread-Local Storage (TLS).
- Afterwards, + 4 bytes: I will have the address of libc.
Script
Other approaches
Leak libc depend on: xmm1
excve instead of syscall
Yapping
Overall



main
vuln
win
check_user

- compare user with: admin
Bug
Target: BOF
- This function stores index i for loop in stack.
- Write 8 bytes each input, but loop to 104 with the size of v1: 108. -> Overwrite i
- Afterwards, I have one more time to write 8 bytes to the offset from the address of v1 rely on i. -> Overwrite retaddr.
Approach
Target
-
I need to call win function to get the flag; however, check_user function will check user variable to confirm the privilege.
- write "admin" to user variable -> call win.
-
However, I only one have gadget to overwrite the retaddr.
- The program disable PIE

- If I jump to
sub rsp,0x70
, I will have more space in the stack can be overwrited, include rbp, retaddr…
-
I notice that user variable only can be changed by trigger read to this address of it(this idea is possible because PIE disable -> the address of user variable remains unchanged).

- control rbp -> trigger to write to specified address
Script