본문 바로가기

root-me5

ELF x64 - Stack buffer overflow - PIE 64bit bof문제인데 PIE 보호기법이 걸려 있는거 같다. PIE가 걸려 있어 메모리 영역이 랜덤으로 매핑이 되서 주소가 일정하지 않을 것이고 NX enable로 인해 실행 권한이 없고 ASLR이 걸려있다. 소스 코드 #include #include // Instructions // // gcc -o chall chall.c -Wl,-z,norelro -fno-stack-protector (on the app-systeme-ch61 server for instance, but the goal is to enable NX and PIE) void Winner() { printf("Access granted!\n"); FILE *fp; int c; fp = fopen(".passwd", "r"); if .. 2021. 3. 28.
ELF x86 - Stack buffer overflow basic 3 ELFx86 BOF 문제이다. GOT Overwrite 가능하고 실행 권한이 없다. 소스 코드 #include #include #include #include #include void shell(void); int main() { char buffer[64]; int check; int i = 0; int count = 0; printf("Enter your name: "); fflush(stdout); while(1) { if(count >= 64) printf("Oh no...Sorry !\n"); if(check == 0xbffffabc) shell(); else { read(fileno(stdin),&i,1); switch(i) { case '\n': printf("\a"); break; case.. 2021. 3. 28.
ELF x64 - Stack buffer overflow - basic 64bit BOF 문제이다. Mitigation은 Full RELRO NX enabled ASLR ON이다. GOT Overwrite는 불가능 하다. 소스 코드를 보면 256 바이트 만큼 선언되어있고 scanf로부터 입력을 받는데 길이에 대한 검증이 없어서 여기서 BOF가 일어난다. 일반적인 BOF이기 때문에 리턴 주소를 callMeMaybe로 조작하면 된다. 64bit는 32bit와 다르게 8 바이트기 때문이에 이점을 유의하자. buffer의 길이는 rbp - 0x110 = 272이다. payload는 dummy(272) + sfp(8) + ret으로 구성하면 된다. callMeMaybe의 주소이다. exploit from pwn import * user = 'app-systeme-ch35' host .. 2021. 3. 28.
ELF x86 - Format string bug basic 1 이번 문제는 포멧스트링 문제이다. #include #include int main(int argc, char *argv[]){ FILE *secret = fopen("/challenge/app-systeme/ch5/.passwd", "rt"); char buffer[32]; fgets(buffer, sizeof(buffer), secret); printf(argv[1]); fclose(secret); return 0; } 이번 문제의 소스 코드이다. fopen 함수가 위 경로의 .passwd 파일은 텍스트로 읽어오고 fgets로 buffer에 입력을 받는다. 그리고 printf 에서 형식 지정자를 쓰지않아 포멧 스트링 취약점이 일어난다. from pwn import * user = 'app-systeme.. 2021. 3. 27.