Skip to main content
Challenges Format-string vulnerability: memory leak via %x
PWN Medium Format string Solves: 7

Format-string vulnerability: memory leak via %x

Author: CyberSamSU
Points
35

If the program calls the user-inputted text directly as printf(user_input) (without providing the format string itself!), the attacker can "read" any value on the program's STACK using special characters like %x, %N$x — even without providing any actual arguments.

def printf_sim(pos, reg_args, stack_args):
    """Haqiqiy printf(fmt, ...) ning %N$x semantikasi:
    N-argument (1-indeksli) — agar N <= 5 bo'lsa registrdan
    (reg_args[N-1]), aks holda stekdan (stack_args[N-6]) olinadi."""
    if pos <= 5:
        return reg_args[pos - 1]
    return stack_args[pos - 6]

In x86-64, the FIRST 5 variadic arguments are placed in registers (N=1..5), and starting from the 6th, they are placed on the stack. Below is the state when this program was called:

N (1..5)Value (in register)
117533
244976
338226
431624
537594
N (6+i)stack_args index (i)Value
608452831
715038768
825410035
9313821324
10415106394
1157796144
1266237517
1372438921

The attacker sent the format string "%12$x". What (hex) value will be output to the screen?

Submit the answer in the format BAYROQ{PWN_LEAK_<hex qiymat, katta harflarda>}.

Hints 3
Opening a hint reduces the points you get for solving this challenge.
Hint 1 −3 pts Log in
Hint 2 −7 pts Log in
Hint 3 −10 pts Log in
To submit a flag, log in.

First solvers

1. Stiv_084100 11.09.2026
2. W.o.X 17.09.2026
3. Mirjaxon Qaxxarov 27.10.2026
4. Odam 04.11.2026
5. Mahfuza 11.11.2026
6. arcanum 11.11.2026
7. Furqat Turayev 11.11.2026