basic_exploitation_002
·
Wargame/Dreamhack
#include #include #include #include void alarm_handler() { puts("TIME OUT"); exit(-1); } void initialize() { setvbuf(stdin, NULL, _IONBF, 0); setvbuf(stdout, NULL, _IONBF, 0); signal(SIGALRM, alarm_handler); alarm(30); } void get_shell() { system("/bin/sh"); } int main(int argc, char *argv[]) { char buf[0x80]; initialize(); read(0, buf, 0x80); printf(buf); exit(0); } 32 bit format string bug 문제이..
basic_rop_x86
·
Wargame/Dreamhack
#include #include #include #include void alarm_handler() { puts("TIME OUT"); exit(-1); } void initialize() { setvbuf(stdin, NULL, _IONBF, 0); setvbuf(stdout, NULL, _IONBF, 0); signal(SIGALRM, alarm_handler); alarm(30); } int main(int argc, char *argv[]) { char buf[0x40] = {}; initialize(); read(0, buf, 0x400); write(1, buf, sizeof(buf)); return 0; } 32bit rop 문제이다. 앞선 문제에서 설명한 것과 같이 64 bit와의 차이는..
ssp_001
·
Wargame/Dreamhack
이번 문제는 SSP 방어기법, 즉 canary가 보호기법으로 걸려있는 문제이다. 이를 우회하기위해서는 memory leak이 발생한다면 이를 활용해서 canary를 확인하는 방법이 최선이며, 그게 아니라면 브루트포싱해야한다. 코드를 조금 분석해보자. #include #include #include #include void alarm_handler() { puts("TIME OUT"); exit(-1); } void initialize() { setvbuf(stdin, NULL, _IONBF, 0); setvbuf(stdout, NULL, _IONBF, 0); signal(SIGALRM, alarm_handler); alarm(30); } void get_shell() { system("/bin/sh");..
basic_exploitation_001
·
Wargame/Dreamhack
#include #include #include #include void alarm_handler() { puts("TIME OUT"); exit(-1); } void initialize() { setvbuf(stdin, NULL, _IONBF, 0); setvbuf(stdout, NULL, _IONBF, 0); signal(SIGALRM, alarm_handler); alarm(30); } void read_flag() { system("cat /flag"); } int main(int argc, char *argv[]) { char buf[0x80]; initialize(); gets(buf); return 0; } 앞선 문제와 다르게 이번에는 gets로 문자열을 입력받는다. 또한 read_flag ..
basic_exploitation_000
·
Wargame/Dreamhack
서버에 접속해서 실제로 값을 넣어보면 접속 시마다 buf의 주소가 변경되는 것을 보아 ASLR 즉, 랜덤 스택 보호 기법이 걸려있음을 알 수 있다. ┌──(kali㉿kali)-[~/Downloads/1] └─$ nc host3.dreamhack.games 13445 buf = (0xfff4d778) a ┌──(kali㉿kali)-[~/Downloads/1] └─$ nc host3.dreamhack.games 13445 buf = (0xffa4f748) a 코드를 보면 #include #include #include #include void alarm_handler() { puts("TIME OUT"); exit(-1); } void initialize() { setvbuf(stdin, NULL, _ION..
[App-System] ELF x86 - Stack buffer overflow basic 6
·
Wargame/Root me
1. intro 2. code 및 분석 2.1. code #include #include #include #include int main (int argc, char ** argv){ char message[20]; if (argc != 2){ printf ("Usage: %s \n", argv[0]); return -1; } setreuid(geteuid(), geteuid()); strcpy (message, argv[1]); printf ("Your message: %s\n", message); return 0; } 2.2. 분석 argv[1]을 message 변수에 복사하고 이를 출력한다. 3. 취약점 확인 및 공격 준비 3.1. 취약점 argv[1]의 크기를 체크하지 않아 overflow가 발생..
[App-System] ELF x86 - Stack buffer overflow basic 4
·
Wargame/Root me
1. intro 2. code 및 분석 2.1. code #include #include #include #include struct EnvInfo { char home[128]; char username[128]; char shell[128]; char path[128]; }; struct EnvInfo GetEnv(void) { struct EnvInfo env; char *ptr; if((ptr = getenv("HOME")) == NULL) { printf("[-] Can't find HOME.\n"); exit(0); } strcpy(env.home, ptr); if((ptr = getenv("USERNAME")) == NULL) { printf("[-] Can't find USERNAME.\n..
[App-System] ELF x86 - BSS buffer overflow
·
Wargame/Root me
1. intro 2. code 및 분석 2.1. code #include #include char username[512] = {1}; void (*_atexit)(int) = exit; void cp_username(char *name, const char *arg) { while((*(name++) = *(arg++))); *name = 0; } int main(int argc, char **argv) { if(argc != 2) { printf("[-] Usage : %s \n", argv[0]); exit(0); } cp_username(username, argv[1]); printf("[+] Running program with username : %s\n", username); _atexit(..
[App-System] ELF x86 - Use After Free - basic
·
Wargame/Root me
1. intro 2. code 및 분석 2.1. code #include #include #include #include #define BUFLEN 64 struct Dog { char name[12]; void (*bark)(); void (*bringBackTheFlag)(); void (*death)(struct Dog*); }; struct DogHouse{ char address[16]; char name[8]; }; int eraseNl(char* line){ for(;*line != '\n'; line++); *line = 0; return 0; } void bark(){ int i; for(i = 3; i > 0; i--){ puts("UAF!!!"); sleep(1); } } void b..
[App-System] ELF x86 - Format string bug basic 2
·
Wargame/Root me
1. intro 2. code 및 분석 2.1. code #include #include #include #include int main( int argc, char ** argv ) { int var; int check = 0x04030201; char fmt[128]; if (argc 239 - 0x56 + 1 = 239 - 86 + 1 = 154 be => be - ef => 1be - ef = 446 - 239 = 207 ad => ad - be => 1ad - be = 429 - 190 = 239 de => de - ad = 222 - 173 = 49 가 된다. 다시 한번 페이로드를 변경해서 시도하면 ./ch14 `perl -e 'print "\xa8\xfa\xff\xbf","BBBB","\xa..