Reverse Engineering

Challenge
Link

Free Play (495 points)

Free Play (495 points)

Description

-

Solution

  • At initial, we try to decompile using ghidra plugin but it fail, also we can't do decompile and converting to wat using wasm2c and wasm2wat

  • We found the solution , we set --enable-threads to convert the file to wat

  • There is a binary that can convert wat to wasm, so using this approach we try to patch some instruction so we can compiel the wat to wasm and decompile it using ghidra plugin/wasm2c/wasm-decompile

  • There are some instruction that can't be converted , so my approach is trying to replacing the instruction and then compile again

  • here is the patched main.wat arrow-up-right

  • After that just open it on ghidra , here is the example of opening checkFlag function on ghidra

  • During the competition we use chrome to do dynamic analysis , such as inspecting the value on memory, stack , and register value.

  • Here is an example when we try to inspecting the value on stack/argument for func46 which is address of memory

  • Here is when we try to inspecting value on address 63984

  • Last part before creating the solver, we try to reconstruct the algorithm in python. Here is reconstructed algorithm in python

  • After reconstructing the process the last step is solving it using z3, but in this case we failed to find the flag and the algorithm is weird because its only check partial of value not all.

  • But after opening ticket we found that there is an issue from the challenge, so by changing the loop to check all the values we got the flag.

  • Here is the final script we used

  • Flag : HackTM{bee3dc52aabec5c1b673d8d2beaeef64fbbf94fbbfe3f7ebcf716e465bd7af2a609a0be0717f6bcbed7c33dcfc95aadaae2f3e046a3b1ee42dbfb7da3687d77fbece4d957b48c3c3fa00d77da8aeffdedbe823bbc89678ded4bfe9f71fdcbf8c9cbd8b84ebffb118eb68b39bee0bfeccd07efbf8cd530b2dadbff4af}

Last updated