Post

KeyGen Challenge

KeyGen Challenge

Lab Objectives

  • No patching
  • Create a KeyGen
  • Upload a solution + tutorial

Starting

Run the program:

image1

Step 2: Open x64gdb for Analysis

image2

  1. Right Click → Search For → All Modules → String References
  2. Go to the name string
  3. Observe the breakpoint:

image3

  • The instruction cmp eax, dword ptr ss:[ebp-30] is present.
  • Examine the eax register while the program runs.
  • image4
  • This reveals the program’s behavior.
  • View the eax register:
  • image5
  • The input series is stored in the EAX register.
  1. To understand the program, examine the instruction dword ptr ss:[ebp-30]: image6
    • eax is stored at dword ptr ss:[ebp-30].
    • Set a breakpoint at this memory address, run the program, and inspect the EAX register.
    • The serial key is revealed: image7
    • This identifies the target key. To create a key generator, the logic must be derived from the instructions.
  2. At memory address 00401442, a function call is present. Open Ghidra to decompile this function and understand the key generation logic: image8

Step 6: Open Ghidra and Locate the CALL Instruction

  • image9

  • The key generation logic is now understood:

    • len stores the length of the user input.
    • local_34 takes the input length and computes:
      • len(user_input) + 0xcaU ^ 0x3d8d40f

Step 7: Create a Python KeyGen

1
2
3
user_input = input("enter a name : ")
GenKey = len(user_input) + 0xca ^ 0x3d8d40f
print(f"KeyGen is : {GenKey}")

Step 8: Finished

Return to the write-ups for more challenges.

This post is licensed under CC BY 4.0 by the author.

Trending Tags