Skip to main content

Pride - Kinnaird CTF

Writeup: Pride Challenge (Reverse Engineering)

Challenge Overview

Pride is a multi-layered Windows reverse engineering challenge. It requires the researcher to navigate through a protective "shell" (UPX), bypass environmental checks (Anti-Debugging/Anti-VM), and eventually reverse-engineer a custom Virtual Machine (VM) architecture to extract the hidden flag fragment.


1. Initial Analysis & Unpacking

The binary initially presents a decoy flag. Analysis with PEiD or Detect It Easy (DIE) reveals the executable is compressed with UPX.

Manual Unpacking

While a standard upx -d pride.exe is the first step, this challenge utilizes a modified UPX header. To unpack manually:

  1. Load the binary in x64dbg.

  2. Look for the POPAD instruction followed by a large JMP—this is the jump to the Original Entry Point (OEP).

  3. Use Scylla to dump the process and fix the IAT (Import Address Table).


2. Anti-Analysis Bypassing

Once unpacked, the binary performs several checks to ensure it is not being monitored.

TechniqueMechanismBypass Strategy
PEB CheckInspects BeingDebugged flag in the PEB.Patch the MOV EAX, [FS:30h] result or use ScyllaHide.
Timing CheckUses rdtsc to measure execution time between instructions.Patch the conditional jump (JZ/JNZ) following the delta comparison.
Hardware CheckQueries CPUID for hypervisor strings (e.g., "VMware", "VBox").Manually edit the EAX/EBX/ECX/EDX return values in the debugger.
Parent CheckVerifies if the parent process is explorer.exe.Patch the check or start the process via a shell.

3. Virtual Machine Architecture

The core logic resides in a custom VM. To reconstruct the flag, we must understand the instruction set architecture (ISA).

Instruction Set (ISA)

The VM utilizes 16 registers (R0-R15) and a stack-based memory model.

  • 0x01 (MOV_IMM): Loads a constant into a register.

  • Arithmetic: ADD, SUB, XOR, AND, OR.

  • Bitwise: ROL (Rotate Left), ROR (Rotate Right), SHL/SHR (Shifts).

  • Control Flow: JUMP, JZ (Jump if Zero), JNZ (Jump if Not Zero).

  • Lifecycle: 0x00 (HALT) terminates the VM.


4. Bytecode Reversal & Flag Extraction

The "Pride" fragment is not stored in plaintext. It is reconstructed at runtime through a series of transformations:

  1. Initialization: Registers R0-R7 are loaded with obfuscated constants.

  2. Key Injection: Registers R8-R15 are loaded with the XOR key: PRIDE_F_}.

  3. Transformation:

    • Bytecode performs a loop where R[i] = (R[i] XOR R[i+8]).

    • A secondary pass applies a ROR by 3 bits and an ADD operation with a static salt.

  4. Reconstruction: The VM writes the resulting bytes into a memory buffer, which forms the final string.

Flag Fragment

By tracing the VM state at the OP_HALT instruction or statically emulating the bytecode in Python, we retrieve the hex-encoded fragment:

Final Flag:

SkelerCTF{PRIDE_FRAGMENT_9F3A7E2B1C8D4A6F}


Key Learning Points

Tools Used: x64dbg, IDA Pro, Scylla, Python (for emulation).





By SkelerSecurity

Comments

Popular posts from this blog

DVWA CHEAT SHEET

“If you’re waiting for permission to break the system, you’re already too late.” What You’re Actually Dealing With DVWA isn’t random vulnerable code. It’s a deliberately broken system designed to teach how real applications fail — SQL injection, XSS, command execution, file inclusion, all of it ( edgenexus.io ) Multiple difficulty levels exist for one reason: To show you how weak defenses evolve into real ones. 0. Core Principle You don’t memorize payloads. You understand flow. Input → Application Logic → Output If you control input, you control logic. If you control logic, the rest is just execution. 1. SQL Injection “You don’t bypass authentication. You redefine it.” Break the query ' Error means the application is exposing its internal structure. Take control ' OR '1'='1 # You’re not logging in. You’re forcing the query to return true. Map columns ' ORDER BY 1-- ' ORDER BY 2-- You’re learning how the database thinks. Extract data ' UNION SELECT datab...

Greed - Kinnaird CTF

Greed Challenge — RSA Low-Exponent Write-Up Overview This challenge revolves around a classic RSA weakness: using a small public exponent (e = 3) without proper padding . Under the right conditions, this allows direct recovery of the plaintext by taking an integer cube root of the ciphertext. The task is to identify the real encrypted flag among several decoys and exploit this mathematical flaw. Key Observations RSA Parameters Public exponent: e = 3 (Narratively hinted as the warden’s “three kingdoms”) Modulus size: ~254 bits Candidate ciphertext: 0x1aadb93ce9a5704a83345e00 Critical Hint “Sometimes the treasure is so light that it never touches the vault walls.” This implies the plaintext m is small enough that: m³ < N When this happens, RSA encryption becomes: c = m³ instead of: c = m³ mod N No modular reduction occurs — which is exactly what enables the attack. Cryptographic Background RSA encryption is defined as: c = m^e mod N If m^e < N , then: c = m^e For e = 3 , recove...