$ cat writeup.md…
$ cat writeup.md…
HackTheBox
The task provides a Windows executable file (Bypass.exe) — a .NET assembly requiring authentication bypass.
"The Client is in full control. Bypass the authentication and read the key to get the Flag."
The task provides a Windows executable file (Bypass.exe) — a .NET assembly requiring authentication bypass.
$ file Bypass.exe Bypass.exe: PE32 executable (console) Intel 80386 Mono/.Net assembly, for MS Windows
The file is a .NET assembly, which means IL code can be disassembled.
Used monodis to obtain the IL code:
monodis --output=bypass.il Bypass.exe
The binary contains two checks:
1. Login Check (Method '0'::'1')
false regardless of inputIL_0043: ldc.i4.0 // push 0 (false) IL_0044: ret // return
2. Secret Key Check (Method '0'::'2')
string::op_Equalitybrfalse.s to jump to "Wrong Key" if comparison failsstring::ConcatUsed Python to patch two locations:
#!/usr/bin/env python3 """ Bypass.exe patcher Patches authentication checks in .NET binary """ with open('Bypass.exe', 'rb') as f: data = bytearray(f.read()) # Patch 1: Bypass Login Check # Location: Offset 0x2bf # Change: ldc.i4.0 (0x16) -> ldc.i4.1 (0x17) # Effect: Login function now always returns true data[0x2bf] = 0x17 # Patch 2: Bypass Key Check # Location: Offset 0x2f5 # Change: brfalse.s (0x2c) -> brtrue.s (0x2d) # Effect: Inverted conditional - shows flag when key is WRONG data[0x2f5] = 0x2d with open('Bypass_patched.exe', 'wb') as f: f.write(data) print("Patched successfully!")
| Opcode | Hex | Description |
|---|---|---|
ldc.i4.0 | 0x16 | Push 0 (false) onto stack |
ldc.i4.1 | 0x17 | Push 1 (true) onto stack |
brfalse.s | 0x2c | Branch if false (short form) |
brtrue.s | 0x2d | Branch if true (short form) |
$ echo -e "test\ntest\nwrongkey" | mono Bypass_patched.exe Enter a username: Enter a password: Please Enter the secret Key: Nice here is the Flag:HTB{REDACTED}
ldc.i4.0 to ldc.i4.1 or inverting a conditional branch$ cat /etc/motd
Liked this one?
Pro unlocks every complete writeup and expanded API access. $9/mo.
$ grep --similar