Phantom

[Giant] giant -> assassin 풀이 본문

Pwnable/[Wargame]Load of Bof

[Giant] giant -> assassin 풀이

Ph4nt0m_ 2015. 1. 8. 16:17
반응형


Colored By Color Scripter

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
29
30
31
32
33
34
35
36
/*
        The Lord of the BOF : The Fellowship of the BOF
        - assassin
        - no stack, no RTL
*/
 
#include <stdio.h>
#include <stdlib.h>
 
main(int argc, char *argv[])
{
    char buffer[40];
 
    if(argc < 2){
        printf("argv error\n");
        exit(0);
    }
 
    if(argv[1][47] == '\xbf')
    {
        printf("stack retbayed you!\n");
        exit(0);
    }
 
        if(argv[1][47] == '\x40')
        {
                printf("library retbayed you, too!!\n");
                exit(0);
        }
 
    strcpy(buffer, argv[1]); 
    printf("%s\n", buffer);
 
        // buffer+sfp hunter
        memset(buffer, 0, 44);
}




이번 단계는 No stack, No RTL이다

RTL도 막혔고 일반적인 오버플로우도 사용할 수 없다


쉘 획득 과정 페이로드



그리고 buffer와 SFP 초기화까지... 오직 RET만 덮을 수 있다

여기서 멘붕이 왔다

뭘 어떻게 해야 할까


만약 RET를 한번 더 덮은다면 어떻게 될까?

차례대로 명령어 코드가 실행되고 RET주소를 RET에 다시한번 덮어쓰게 되면 esp+4가 됨으로써 system을 호출 할 수 있게 된다 


스택에 다음과 같이 입력할 것이다


 NOP

RET's address 

system 

exit 

/bin/sh 

먼저 ret의 주소를 찾는다




그리고 system, exit,/bin/sh의 주소를 찾는다



1
2
3
4
5
6
7
8
9
10
findsh.c
 
#include <stdio.h>
 
int main(int argc, char *argv[]){
        long shell;
        shell = 0x40058ae0;
        while(memcmp((void *)shell, "/bin/sh", 8)) shell++;
        printf("\"/bin/sh\" is at [ %#x ]\n",shell);
}

                                        






명령문 작성하기

 


이로써 assassin의 권한을 얻었다


반응형

'Pwnable > [Wargame]Load of Bof' 카테고리의 다른 글

zombie_assassin  (0) 2017.01.05
assassin -> zombie_assassin  (0) 2017.01.04
[Bugbear] bugbear -> giant 풀이  (0) 2015.01.07
[Darkknight] darkknight -> bugbear 풀이  (0) 2015.01.06
[Golem] golem -> darkknight 풀이  (0) 2015.01.05
Comments