[Phoenix] Net zero

2022. 10. 13. 17:51·Wargame/Exploit Education
728x90
반응형

1. intro

2. code 및 분석

2.1.  C code

/*
 * phoenix/net-zero, by https://exploit.education
 *
 * What did the fish say when he swam head first into a wall?
 * Dam!
 */

#include <err.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/random.h>
#include <sys/types.h>
#include <unistd.h>

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

int main(int argc, char **argv) {
  uint32_t i, j;

  setvbuf(stdout, NULL, _IONBF, 0);
  setvbuf(stderr, NULL, _IONBF, 0);
  printf("%s\n", BANNER);

  if (getrandom((void *)&i, sizeof(i), 0) != sizeof(i)) {
    errx(1, "unable to getrandom(%d bytes)", sizeof(i));
  }

  printf("Please send '%u' as a little endian, 32bit integer.\n", i);

  if (read(0, (void *)&j, sizeof(j)) != sizeof(j)) {
    errx(1, "unable to read %d bytes from stdin", sizeof(j));
  }

  if (i == j) {
    printf("You have successfully passed this level, well done!\n");
  } else {
    printf("Close - you sent %u instead\n", j);
  }

  return 0;
}

 

2.2. 분석

사실상 pwntools를 사용하라는 의미의 문제라고 생각한다.

랜덤 값을 i 변수에 받고 j 값을 입력받은 다음 둘을 비교한다.

다만 j 값은 string으로 입력받기 때문에 hex 값을 삽입해줘야 한다.

 

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

3.1. 취약점

별도 취약점은 없다.

 

3.2. 공격 준비

특별히 준비할 것 없이 pwntools를 이용해서 공격 코드를 작성하자.

 

4. exploit

from pwn import *

p = remote ('localhost', 64000)

p.recvuntil('\'')
i = int(p.recvuntil('\'')[:-1])
p.recvline()

print(i)
print(hex(i))

p.send(p32(i))
print(p.recvline())

 

user@phoenix-amd64:~$ python /tmp/a.py
[+] Opening connection to localhost on port 64000: Done
1927523823
0x72e3adef
You have successfully passed this level, well done!

 

728x90
반응형
저작자표시 비영리 변경금지 (새창열림)

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

[Phoenix] Net two  (0) 2022.10.13
[Phoenix] Net one  (0) 2022.10.13
[Phoenix] Heap three  (0) 2022.10.06
[Phoenix] Heap two  (0) 2022.10.06
[Phoenix] Heap one  (0) 2022.10.04
'Wargame/Exploit Education' 카테고리의 다른 글
  • [Phoenix] Net two
  • [Phoenix] Net one
  • [Phoenix] Heap three
  • [Phoenix] Heap two
wyv3rn
wyv3rn
아저씨의 흔한 취미. wyv3rn#1249
  • wyv3rn
    think storage
    wyv3rn
  • 전체
    오늘
    어제
    • 분류 전체보기 (502)
      • To do list (7)
        • Doing (1)
        • Complete (6)
      • Diary (35)
      • Tips & theory (73)
      • 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 (41)
        • Solved (39)
        • Unsolved (2)
      • Script (0)
      • RubiyaLap (0)
  • 블로그 메뉴

    • 홈
    • 방명록
  • 링크

  • 공지사항

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

  • 태그

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

  • 최근 글

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

티스토리툴바