Sandbox 1 | redmask CTF 2020 Final
today 13 december 2020, my team is qualified for the final of redmask ctf 2020, I solve some rev and pwn challenge. in this post I will cover Sandbox 1 Challenge from redmask CTF 2020 final. it’s really cool challenge, i love it so much thanks to kyraa for this cool challenge.
Info files
we were given 2 elf file, user
, sandbox
it’s 64bit linux elf, and there’s bof bug on the user
binary, and we can also controll %rax
, %rdi
, %rsi
, %rdx
via
helper
function
the sandbox binary is also intresting, it’s look like a rust binary with unicorn emulation.
the main
function is only call 2 function first is the setup
function (just a normal binary ctf setup) and the run
function
this is the run
function
in this challenge we will focus on handle_syscall
function. here is the handle_syscall
function
as you can see, there is a dummy flag, our goal is to print that flag on the server, after an hours debugging the sandbox, I found that we can easily print out the flag
by using uc_mem_write
, according to the docs
this function is used to copy data from the sandbox to the running binary
, and on this section from handle_syscall
function
this function is used to copy the flag to the running process user
binary. and as you can see here, it’s copied the flag
and after doing dynamic analysis, I found that we can control the destination address via %rsi
register
now we can just print the flag without setting up the %rsi
register, so the flag will be send to a memory region on user
binary, then we use
write
syscall to print our flag, this is my exploit to solve this challenge
FLAG: redmask{ez_pz__lem0n_squeezY_fix3fix3fix3fix7}