write-up/pwnable
[LOB] level 1: gate
목차
The Lord Of BOF: level 1
![[LOB] level 1: gate [LOB] level 1: gate](http://t1.daumcdn.net/tistory_admin/static/images/no-image-v1.png)
- bash에서는 \xff를 NULL로 인식할 수 있어서 쉘 코드를 돌릴 때 segmentation fault가 일어날 수 있다.
★ 문제 분석
![[LOB] level 1: gate [LOB] level 1: gate](http://t1.daumcdn.net/tistory_admin/static/images/no-image-v1.png)
argc가 2개 이상이어야 함
buffer 배열 크기 256byte
★ gdb로 소스코드 분석
![[LOB] level 1: gate [LOB] level 1: gate](http://t1.daumcdn.net/tistory_admin/static/images/no-image-v1.png)
- main+3: stack에 공간 256byte 할당
>> buffer[256]
![[LOB] level 1: gate [LOB] level 1: gate](http://t1.daumcdn.net/tistory_admin/static/images/no-image-v1.png)
![[LOB] level 1: gate [LOB] level 1: gate](http://t1.daumcdn.net/tistory_admin/static/images/no-image-v1.png)
- [ebp+8]과 1을 비교
같으면 <main+38>로 JMP
같지 않으면,
>> printf("argv ~ ")
>> exit(0)
![[LOB] level 1: gate [LOB] level 1: gate](http://t1.daumcdn.net/tistory_admin/static/images/no-image-v1.png)
![[LOB] level 1: gate [LOB] level 1: gate](http://t1.daumcdn.net/tistory_admin/static/images/no-image-v1.png)
- main+54:
>> strcpy([ebp-256])
- main+74:
>> printf("%s\n", [ebp-256])
★ 공격
buffer[256] |
SFP |
RET |
buffer[256] + SFP[4] = 260byte 덮은 후 RET 주소 변조하면 될 것이다.
- 변조할 주소 찾기
![[LOB] level 1: gate [LOB] level 1: gate](http://t1.daumcdn.net/tistory_admin/static/images/no-image-v1.png)
strcpy(buffer) 까지 bp를 건 후,
A 200개를 넣고 실행시킨다.
buffer 시작 주소: 0xbffff948
RET 변조 주소는 0xbffff960
☆ 페이로드
NOP[200] + SHELL CODE[24] + NOP[36] + RET 주소
![[LOB] level 1: gate [LOB] level 1: gate](http://t1.daumcdn.net/tistory_admin/static/images/no-image-v1.png)
level2: gremlin
password: hello bof world
'write-up > pwnable' 카테고리의 다른 글
[pwnable.kr] fd (0) | 2019.09.23 |
---|---|
[LOB] LOB TIP (0) | 2019.09.15 |
[ftz] level 20: we are just regular guys (0) | 2019.08.27 |
[ftz] level 19: swimming in pink (0) | 2019.08.27 |
[ftz] level 18: why did you do it (0) | 2019.08.27 |
댓글