Security/System Security

[System Security] 기말고사 정리

잉숭 2021. 6. 7. 23:34

ASLR 해제 명령

더보기

sudo sysctl kernel.randomize_va_space=0 (default=2)

 

gcc 디버깅 정보 추가 옵션

더보기

gcc -o stackbof stackbof.c -fno-stack-protector -mpreferred-stack-boundary=2 -g

 

stackexploit1

더보기

1. ./stackexploit1 512

2. Heap에 512만큼 (NOP sled + shell code) 작성

3. stack에 (12*A + 추측한 주소) 작성

4. execl("./stackbof1, stackbof1, 스택버퍼, 힙버퍼, NULL)

 

1. 스택버퍼로 받은 인자를 스택에 저장

2. 출력

3. main return시 조작된 주소로 return

 

heapexploit1

더보기

1. ./heapexploit1 512

2. Heap에 512만큼 (NOP sled + shell code) 작성

3. stack에 (64*A + 추측한 주소) 작성

4. execl("./heapbof1, heapbof1, 스택버퍼, 힙버퍼, NULL)

 

1. 스택버퍼로 받은 인자를 스택에 저장 (strncpy)

2. 함수 호출하면 조작된 주소(스택)로 호출

 

heapexploit2

더보기

1. ./heapexploit1 512

2. Heap에 512만큼 (NOP sled + shell code) 작성

3. stack에 (64*A + 추측한 주소) 작성

4. execl("./heapbof2, heapbof2, 스택버퍼, 힙버퍼, NULL)

 

1. 스택버퍼로 받은 인자를 힙에 저장

2. 함수 호출하면 조작된 주소(힙)로 return

 

fmtstr

더보기

1. eggshell 실행

2. 위와 동일

 

컴파일시 NX 스택 기능 해제

더보기

gcc -o stackbof stackbof.c -fno-stack-protector -mpreferred-stack-boundary=2 -W1,-z,execstack

 

Canary 해제

더보기

gcc -o stackbof stackbof.c -fno-stack-protector 

 

소스코드 Fortify + 최적화

더보기

gcc -D_fortify_source=2 -O2

 

소스코드 Format String 에러 방지

더보기

gcc -Wformat-security

gcc -Wno-format-security : 해제

gcc -Werror=fomat-security

 

ASLR 기술 2가지

더보기

sudo sysctl kernal.randomize_va_space=2

gcc -o sample sample.c -fPIE -pie

 

gdb 옵션 정리

더보기

-q : quite, 조용히

-g : 디버깅 정보 추가

 

 

gdb 명령어 정리

더보기

list : 소스코드 출력

b # : #라인에 Break

r AAAAAAA : AAAAAAA 입력하고 계속하기

p &buffer : buffer의 주소를 출력

info reg $esp : esp 값을 출력

x/8wx $esp : esp주소부터 word 8개 출력