DDCTF re1 writeup
The challenge download is a Windows x86 executable named reverse1_final. My first attempt to decompile it in IDA stops with this message:

That looks like a packed executable, so I checked its PE details with PEiD:

The entry point lands in UPX1, which points to UPX. I unpacked the file; the result would no longer run normally, but IDA could at least disassemble it. I found main and renamed the variables to make the flow easier to read:

The input lands in str_in, and the result of a series of operations ends up in v4. Since that value is compared with DDCTF{reverseME}, the transformation is the function I need to understand:

Inside, the function reads the input and looks up values in data. That looks like a substitution table, although its contents are not immediately apparent from the decompilation.
I clicked through to data and found this:

No obvious table yet. A little farther down, though, there is a promising string:

It looks enough like the alphabet to test. I wrote a small program to find the index of each character in the target string:
1 |
|
It prints 58 58 59 42 56 3 12 25 8 25 12 11 25 49 57 1.
Those indices do not look like something I can enter as the answer. I turned to OllyDbg to see how the lookup actually works, but the address was randomized, making the breakpoint awkward to set. PEtools let me disable address-space randomization:


After saving the change, I set a breakpoint at sub_401000 and supplied ABCDEFG as a test input:

1 | loc_401020: |
At this point, the code reads data[eax]; eax comes from the byte addressed by ebx+ecx. The register values show the lookup in action:

The test shows A mapping to ]. I adjusted the C program to account for that offset:
1 |
|
The adjustment is -'='+']'. OllyDbg confirms that the test maps to ] \ [ Z Y X W, so I replaced the test key with DDCTF{reverseME} and checked the resulting input:



That does it—the program reveals the flag!
Celebration! ★,°:.☆( ̄▽ ̄)/$:.°★ 。



