Reverse Engineer: A Beginner’s Guide to Debugging with x64dbg

Welcome, fellow hackers and tinkerers! Today, we are diving into the fascinating world of Assembly Language and Reverse Engineering. We will be walking through a classic "CrackMe" challenge.

Our goal? To take a compiled Windows executable, peek under the hood, and understand exactly how it works using Detect It Easy (DIE) and x64dbg.

Let’s get started!

The Tools of the Trade

Before we begin, make sure you have:

  1. The Target: Untitled1.exe (located in the C:\crackme\01-mexican directory).

  2. Detect It Easy (DIE): For quick static analysis.

  3. x64dbg: Our dynamic debugger of choice.

Step 1: Initial Reconnaissance

First, let’s see what the program actually does. Open your command prompt, navigate to the folder, and run the executable.

As you can see in the screenshot, the program runs and simply outputs:
try harder

Not very helpful! Let's figure out what language it was written in and where it starts. Open Untitled1.exe in Detect It Easy (DIE). DIE will give us the File Type (PE32) and, most importantly, the Entry Point (EP)—the exact memory address where our program begins execution.

In this case, DIE tells us the Entry Point is 4014E0.


Step 2: Setting Up Our Debugger

Open the executable in x64dbg. Before we start stepping through the code, we need to tweak a few settings to make our lives easier.

  1. Go to Options > Preferences > Events.

  2. Uncheck TLS Callbacks. (TLS callbacks can sometimes trigger before our actual entry point and confuse beginners).

  3. Next, go to the Exceptions tab. We want the debugger to ignore standard system errors so it doesn't pause constantly. Click Ignore Range and set the Start to 00000000 and End to ffffffff.


💡 Pro-Tip: Make sure to save these settings!

Step 3: Understanding the x64dbg Interface

Before we press play, let's decode the main window. It can look overwhelming, but it’s actually broken down into five logical sections:

  1. Graphical View (Left): Shows how instructions visually jump from one location to another.

  2. RAM Memory Address (Left Column): The physical memory locations of the instructions.

  3. OPCODE (Middle Column): The actual machine code (e.g., 55, 8B EC). This is what the CPU actually reads.

  4. Assembly Code (Middle-Right): The human-readable x86/x64 instructions (e.g., push ebp, mov ebp, esp). This is what the OPCODE translates to.

  5. Comments (Right Column): Sometimes the debugger adds helpful hints here.

Step 4: Stepping Through the Code

Remember the Entry Point we found in DIE? Press F9 (Run) in x64dbg to run the program until it hits that exact starting address (4014E0).


Now, how do we move through the code?

  • F9 (Run): Runs the program until it hits a breakpoint or the end.

  • F8 (Step Over): This is your best friend. It executes one line of assembly code at a time. Press F8 repeatedly, and you will see the highlighted line move down the screen sequentially.

Step 5: Jumps, Jumps, and More Jumps

As you press F8, you will notice arrows flying around the screen. These are Jumps.

  • Conditional Jumps: Look at the instruction jne (Jump if Not Equal) or test. If the condition is met, the line turns RED, and the arrow will follow the jump. If the condition is not met, it ignores the jump and moves to the next line down.

  • Unconditional Jumps: Look for jmp. This one doesn't care about conditions. It will always jump directly to the specified location.

  • Loops: Have you ever seen an arrow pointing UP? That is a loop! The program is jumping backward to repeat a block of code until a specific condition is finally met.




By carefully stepping through these jumps, you can trace the exact path the program takes to print out "try harder".

Conclusion

Reverse engineering is a puzzle. By learning how to read OPCODEs, setting up your debugger correctly, and understanding the flow of conditional and unconditional jumps, you are well on your way to mastering x64dbg.

Keep practicing, keep stepping over instructions, and soon, those assembly instructions will read like a book.






Popular Posts