I participated in LACTF with Project Sekai
and secure 1st place in the open division. I managed to solve glottem
and flipma
and here are my writeups for them.
glottem
Discription
Category: Rev
Points: 455
Solves: 89
Solve
This challenge provided a shell script,embeded with js and python scripts.
1 | #!/bin/sh |
This script asks for a flag, then checks if the flag is correct. It runs itself with the flag as an argument against both node and python.
Here is the simplified python script:
1 | d = 0 |
and js script:
1 | d = 0 |
It may appear unsolvable at first glance, but upon examining the array e
, we would notice that all its elements lie within the range of 10 to 17. Furthermore, the sum of all 26 elements amounts to 260. Consequently, the elements we select must necessarily be multiples of 10.
For deeper analysis, we observe that the x-coordinate of the current element corresponds to the y-coordinate of the preceding element. This insight enables us to identify all possible paths consisting of 10s with a length of 26. Subsequently, we can validate each of these paths using JavaScript’s logic checking mechanism. Below is the solving script for this approach.
1 | e = [...] |
flipma
Discription
Category: PWN
Points: 492
Solves: 19
Analysis
This is a simple 64-bit binary with all protection on.
1 | Arch: amd64-64-little |
The logic behind this program is straightforward: continue flipping the bit until the number of flips is no longer positive. The initial value of flips is set to 4, allowing us four opportunities to flip a bit.
1 | int __fastcall main(int argc, const char **argv, const char **envp) |
The base addr of our flip is stdin which is on libc
and the offset can be negative since v1
is signed. Also, if input is invalid, it will just output and return.
1 | int flip() |
With only four flips available, our options are severely limited. However, without access to the program’s codebase, we must devise a strategy to manipulate the flips value. Fortunately, we can exploit the program’s stdout to leak information about the codebase and the libc base. By altering _flags
and write_base
within _IO_2_1_stdout_
, we can trigger a write operation between write_base
and write_ptr
.
Once the setup is complete, sending an invalid input can provoke the puts function, allowing us to leak the codebase and libc base. With this information, we can manipulate the flips value, granting us infinite flip chances and establishing an arbitrary address write primitive.
Utilizing this primitive, we can achieve Remote Code Execution (RCE) through various methods. In this exploit, I choose house of apple
. Below is the full exploit script.
1 | # %% |
Comments