Time's Up, For the Last Time!
Problem
You've solved things fast. You've solved things faster! Now do the impossible. times-up-one-last-time, located in the directory at /problems/time-s-up--for-the-last-time-_5_b2df97b433878873b16cff47337769d6.
Solution
Running the program and inputting a newline character (
\n
) with bash is not fast enough.Running previous challenges in this way produced
Solution? Nope!
:However, this challenge does not even register the input since the alarm triggers so fast:
The time for the alarm to trigger is now 10 microseconds (10 uSections). It is unlikely that any script will solve this if we can't even get any input into the program. Decompile the binary file using Ghidra (cheat sheet).
main()
function (Ghidra was not able to determine names):There are also weird new operators. Going into the source code we find the function that appears to solve the expression generated (comments are ascii conversions added by me):
We can reverse this functionality and implement it into our script later.
We should try blocking the
SIGALRM
. However, this cannot be done using a debugger (GDB
) like was possible in "Need For Speed" since we need the elevated permissions from SETUID to be able tocat
theflag.txt
file. The zardus/preeny project will not work here for the same reason, but it could be useful for future projects.We can open a session with the challenge file in which the
SIGALRM
is ignored with the following C program:The above file runs the challenge using the absolute path on the shell server. Create a file called
no_sigalrm.c
in your home directory. Compile it with:gcc -g no_sigalrm.c -o no_sigalrm
(output name is important since the script.py is hardcoded to use that name). Make sure to mark it as executable withchmod +x no_sigalrm
.Above script as a file (calls the
times-up-one-last-time
in the present directory): no_sigalrm.c (compiled version: no_sigalrm)Let's write a script to solve the equation, now that we have bypassed the time restriction. Searching for "custom python operators" yields this hack for infix operators linked to from this blog and this StackOverflow answer.
We actually only have two custom operators: return the left value and return the right value, there are just many names for these operators in the produced equation.
We replace the operators in the program output with our new operators:
The script.py only works in
python2
since the infix operator hack only works properly in that version. Make sure to change the script location directory to your home folder. You should compile theno_sigalrm
file on the shell server and place it in your home folder. Then, in script.py change the text<username>
to your username.Run exploit:
python2 script.py USER=<username> PASSWORD=<password>
:Warning: The script might fail, but it has approximately a 3/4 success rate.
Flag
picoCTF{And now you can hack time! #0e9c1f05}
Last updated