Skip to main content
Challenges Final chain: leak + canary + ROP
PWN Expert Full exploit chain Solves: 14

Final chain: leak + canary + ROP

Author: CyberSamSU
Points
220

The final challenge combines ALL the techniques learned in this section: leaking via format-string, correctly placing the stack canary and calling a 2-argument function via a ROP chain.

For simplicity, in ALL examples in this section, addresses/registers are considered to be 4-byte (32-bit), little-endian — in real 64-bit systems they are usually 8 bytes, but the idea itself (offset, ROP, canary, GOT...) remains the same.

Stage 1: leaking the canary

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]

The attacker sent "%11$x". The table below lists the arguments — ONE of them is actually the canary value itself (in decimal):

N (6+i)Value (one is the CANARY!)
612340179
714147159
84886957
92855826
1014419694
1110649761
124010238
135731670

The canary is always 4 bytes and its LAST byte is 0x00 (little-endian: at the position of the MOST significant byte).

Stage 2: full payload

Buffer size: 12 bytes. After the canary comes a 4-byte saved register (value is not important), and then instead of the return address — the ROP chain begins.

The "calling convention" in this challenge is a simple model invented for educational purposes: the function takes its first argument from the R0 register, the second from R1, and if needed the third from R2 (in the real x86-64 System V ABI this happens via rdi, rsi, rdx — the idea is the same, the names are simplified).

Goal: to call maxfiy_funksiya(R0=178, R1=247) (address 0x00403086). Gadgets:

AddressInstruction (gadget)
0x00401910POP R2; RET
0x00401DF8RET
0x00401208POP R3; RET
0x004014B0POP R1; RET
0x00401FE0NOP; RET
0x004018F8POP R0; RET

Construct the full payload in the following order: 'A'*buffer + canary(1-bosqichdan, 4 bayt, kichik-endian) + 4 bayt ixtiyoriy + ROP zanjiri (gadget_R0, R0-qiymat, gadget_R1, R1-qiymat, maqsad_manzil — har biri 4 bayt).

Submit the answer in the format BAYROQ{PWN_FINAL_<to'liq payload, uzluksiz hex satr>}.

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

First solvers

1. Stiv_084100 10.09.2026
2. Абдул 15.09.2026
3. Лазиз 01.10.2026
4. perseidavr 02.10.2026
5. BlackCipher 04.10.2026
6. bunyod 05.10.2026
7. Raumdeuter 09.10.2026
8. testrejim 09.10.2026
9. Mirjaxon Qaxxarov 26.10.2026
10. anonym 29.10.2026