(writeup) bsides-2023
SYS_ROP
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 →
offset 80 + 8(save rbp)
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 →
- based on name of the chall, I think about SYSROP at first
- so we use pwntool named SigreturnFrame to setup these registers
- we also have string '/bin/sh' on binary file
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 think those byte frame we send have too much byte to overwrite
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 →
read 256 byte but we send 360 byte
- so I call read() function one more time to overwrite another address which can r_w section
- arg for read is rax = NULL, rdi = NULL, rsi = rw_address, rdx = size
- because checksec PIE is off so we can use static address
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 →
0x00000000402a00
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 →
- right now we stuck at here
- have a look on register
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 →
maybe $rbp is weird
- in sigframe, we add gadget $rbp at another address (use the same $rsi and minus 8 because after syscall, if we don't minus 8 it will be pop at the same gadget {pop rax})
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 →
- still return at bad address …
- now add more gadget leave_ret
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 →
- method 2: (simplify the problem 🙃)
- have enough gadget –-> ROPchain way
Junior Pwner



- the author give the binary file and libc.so.6, so I pwninit at first
- look at ida, we can see it read in to buf variable and after that, it will print 1 of 3 messages randomly by rand() function
- let see detail:

- otherwise, this program doesn't have any return or exit, will loop forever by while(1)
- so my idea is ow '/bin/sh' and ow system() by puts@GOT
- which mean when it call puts(), we will get shell by execute puts@PLT instead of print 1 of 3 messages
- first we need to leak libc
- because buf only 64 byte, read() 0x48 = 72 byte so we can ow save rbp to change execution flow
- that enough to leak libc
- payload:
at first I want to ow the next addr of messages (+ 0x18) but it can't leak libc (can leak but not always)
- then we ow '/bin/sh' at (messages_addr + 0x40)
- finally ow system() and puts@GOT at address have '/bin/sh'

(writeup) bsides-2024
Can't Give In


main()


analyse
- this challenge is Pwn x Web, which is give us a binary running on a website
- we simply find a bug in read(v8, data, length) if CONTENT_LENGTH is big enough
CONTENT_LENGTH depend on the size we input
- moreover, the description tell us to RCE –-> ret2shellcode
debug
- first, to debug on local, we must have env (environment) of CONTENT_LENGTH to satisfy the function getenv by using this command:
size equal 1000 to easily overflow
- next, there is no canary so base on ida, I can guess the buffer to padding is 0xa8

[rbp-A0h] is 0xA0 to touch $rbp, then +0x8 to ow $rbp, the rest into $rip
- so to ret2shellcode, we need to return to the address which have shellcode
- then I see when it return in main(), the address of stack is on $rdi and $rax is NULL
- I search for gadget and I found some usefull gadgets here
- my idea is move $rdi into $rax, then pop $rdi an offset that point to address shellcode, then just call $rax
- about sending shellcode to a website, I use Burp Suite to genterate a script for python
- I just edit the data from this
into this
because I RCE on local sucessful but fail in server
I guess maybe the return address is wrong due to 'password='
- meanwhile, the payload i will edit like this
- that mean, the offset I have to +9 to bypass 9 bytes of 'password='
get flag

CTF{certified-genuine-instructions}
Can't Give In (secure)

analyse
- in this challenge, similar to above source code but a little different about mechanism security protection
in this case, NX enable
- a little bit tricky restrict execute on stack, but my idea is still ret2shellcode (still RCE)
- to set stack executable, I use _dl_make_stacks_executable()
- before that, we must satisfy some conditions

- first is __stack_prot variable, in default it is 0x1000000

- but it in read_only section 🤡

- so I use mprotect() to set that area has full permission =)))
- then I move 7 into __stack_prot by this gadget

$rdx has value 7 when call mprotect()
just use pop $rsi for __stack_prot
- and for arg1 of _dl_make_stacks_executable(), I use __libc_stack_end variable
- now the rest is shellcode
maybe __libc_stack_end will have an unpredictable stack address so for the offset I will measure simple, then pad the nop
asm code
get flag

CTF{computational-genius-institute}