Post

Assembly Exercise

Assembly Exercise

Executive Summary

This exercise demonstrates bypassing the cmp instruction to obtain the flag. The most efficient method I found was through patching.


Sample Information

AttributeValue
File Nameexercise1.exe
File Size400 KB
File TypeApplication Executable (EXE)
MD59427e326732b6c4b674229e9ebcf2a34
SHA13cc42b5dfdd4b49d63fc1d5d0ccc45796df498e4

Case-Specific Requirements

Machine

  • Environment: Windows

Tools Used

  • IDA

Static Analysis

When the program is executed, it doesn’t display much at first, as shown below:

img

The program checks the computer’s hostname. If it matches "DESKTOP-TRAINING", it prompts the user for a password. If the password is "awesome_training@1337", the program performs a simple XOR operation on an array of data and prints the result. If either the hostname doesn’t match or the password is incorrect, the program exits with an error message. It also handles errors in retrieving the computer’s hostname.

img

Instead of bypassing the password check, I decided to jump directly to the encryption routine:

img

By following the jump if zero (jz) address:

img

Navigate to Edit > Patch Program > Assemble:

img

Change the instruction at this address:

img

To jump not zero (jnz) with the updated address:

img

You’ll notice the program’s behavior has now changed:

img

Now go to Edit > Patch Program > Apply Patches to Input File…:

img

A confirmation dialog will appear—just click OK:

img

Run the file again, and you’ll see the flag:

img


Additional Notes

  • Password for the Challenge: awesome_training@1337
  • Flag: flag{n1c3_on3_r3vers3r_k33p_1t_up}
This post is licensed under CC BY 4.0 by the author.