Anti Flag
Anti Flag
Platform: HackTheBox | Category: Reversing | Difficulty: N/A | Author: D3v0o0Nu11 | Date: 2026-02-10
Description
Flag? What's a flag?
Solution Approach
Core idea: Identify the weakness from source review or fingerprinting first. Iterate with incremental payloads instead of guessing.
Steps
-
First, unzip the
.zipfile given. -
Next, check type of file we got.
-
Run the binary.
-
Hmm.. let us decompile the binary.
-
Looks like i found the main function.
-
Found something that could be our interest.
-
Could be this is an encrypted flag??
-
And this is the key?
-
But i don't know what encryption algorithm used.
-
Let us user another approach with patching the binary.
-
After analyzing the
main()function, actually we can change the intruction for this offset tojmpto0x1525. -
Now export the binary and run it.
-
Got the flag!
ALTERNATE SOLUTION
-
Also we can solve it dynamically with gdb.
-
As we know the binary protection for PIE is enabled.
-
So to solve it dynamically we need to identify the piebase to do a jump (dynamically).
-
Before that i realize ghidra removes uncreachable code which we can undo that by doing this at ghidra:
edit -> tool options -> analysis -> "do uncheck" for eliminate reachable code
-
Then click apply.
-
As you can see we got another logic validations at the middle, which we can bypass by simply change to true, then we can get the flag easily (for static).
-
For dynamic, since the binary is stripped, we can't just set a breakpoint there:
-
Because we don't now the base address for the offset we want and we can't see the address.
-
But we can start breakpoint by ran
starti. With this we can jump to the flag decode function to get the flag.
OUR INTEREST OFFSET TO JUMP (THE FLAG DECODE FUNCTION) --> 0x1525
- We can run
piebase 0x1525to get the piebase for that offset then jump to the piebase we got. - But we can't just do that, it shall gave us SEGMENTATION FAULT.
- We need to breakrva first at the first check (first if statement), then hit continue and grab the piebase for 0x1525 to jump there.
SET BREAKPOINT AT 0x14f4 (first breakpoint) and hti continue
HIT CONTINUE
GET PIEBASE for 0x1525 and JUMP there.
- Got the flag!
Flag
REDACTED
Lessons Learned
- Identify the weakness from source review or fingerprinting first.
- Iterate with incremental payloads instead of guessing.
- Reuse the same pattern in future engagements.