L1im1tL355
Problem
Just pwn this program and get a flag. Its also found in /problems/l1im1tl355_3_d7480b654799978caea481ab65d5bbea on the shell server. Source.
Solution
Looking at the source code I notice the
replaceIntegerInArrayAtIndex()
function looks interesting since it is simply a wrapper around the built-in method of changing an element of an array.This program declares an array on the stack, then allows us to write a DWORD to any array index. If we choose an index between
0
and666/4
(DWORD is 4 bytes long), we'll end up writing to the array. There are no checks on the index value for the array, so we should be able to go out of bounds and write anywhere to memory. We can input the address of thewin()
function as the "integer value you want to put in the array" and for the "index in which you want to put the value", we can input the offset from the array to the return address ofreplaceIntegerInArrayAtIndex()
.Layout of stack (source):
The script bruteforces the offset and finds it to be
-5
.Run the script.py
python script.py USER=<username> PASSWORD=<password>
:
Flag
picoCTF{str1nG_CH3353_3fe0db39}
Last updated