write4
write4 32bit
Solution
The string "/bin/cat flag.txt" is not present in the binary, so the method used in "split" won't work here.
We are given a function print_file and our task is to call print_file("flag.txt"). There is no "flag.txt" string in the binary either, so we have to input this string and store it somewhere, for example, the .bss segment.
As the instruction suggests, we should look for a gadget mov [reg], reg:

The idea is:
Store the string
"flag"inebp.Store the address of
bssinedi.Use the gadget
mov dword ptr [edi], ebp ; retto pass the stringflagto the.bsssegment.Repeat step 1 to 3 to pass the string
".txt"tobss + 4.Call
print_file(bss)
Exploit
write4 64bit
Solution
Again, the 64-bit case is even simpler. The idea is the same, except we can pass the string "flag.txt" in one round because we are dealing with 64-bit registers.
Exploit
Last updated