We expect a high standard of professionalism from you at all times while you are taking any of our courses. We expect all students to act in good faith at all times
TLDR: Don’t be a dick jerk
attempts to reconstruct the source code
right-click >
there’s multiple ways to display the information
allows you to modify the binary during execution
how to get started
att 1234 # attach to running process 1234
b 0x1337 # break at address 1337
break *(main) # break at the first instruction in main()
break *(main+12) # break at the address 12 bytes after main
c # continue until next breakpoint/end program
si # step by a single instruction
fin # go until end of current function
changing the flow of the application
x 0x1337 # examine at 0x1337
x/20wx 0x1337 # examine 20 words from 0x1337
x/s 0x1337 # examine string at 0x1337
set $reg=value # set register = value ie: set $ebx=1
set *(int *)($ebp + 0xX)=value # set a local variable
jump *(0x1234) # jump to 0x1234 (e.g. start executing there)
jump *(main) # jump to main
a python library to interact with binaries (remotely?)
you interact as if it were a python object
from pwn import *
p = remote('abc.com', 1234) # connect to a remote server
p = process('./vuln') # or run a local binary
# do stuff with the binary
pause() #
p.interactive() # drops you into an interactive shell
p.close() # oh man, idk
how do we interact with the program?
p.recvline() # reads one line from the process
p.recvuntil('line') # read input from p until 'line'
p.sendline(line) # sends the line to the program
p.sendlineafter(until, line) # combines recvuntil() and sendline()
binaries like ints & bytes, not strings
p32(0x12345678) # packs a 32-bit hex number (b'\x78\x56\x34\x12')
u32(b'\x78\x56\x34\x12') # unpacks a 32-bit (little-endian) number.
hex(x) #
bytes(x) #
int(x, 16)
f''.encode() #
b''.decode() #
how do I grab the function pointers automatically?
p = process('./program')
e = ELF('./program')
e = p.elf
e.symbols['win'] # get the address of "function_name"
e.got['printf'] # dw about this yet
e.address = 0x1234 # set the binary base address (for aslr)
you can launch gdb from within pwntools to debug
# https://docs.pwntools.com/en/stable/gdb.html
context.arch = 'i386'
context.terminal = ['urxvt', '-e', 'sh', '-c']
gdb_command = '''
break *main
si
'''
gdb.attach(p, cmd) # attach to an existing process
gdb.debug('./vuln', cmd) # spin up a debugger process, stopped at the first instruction
if the window it spawns is ugly a hell, check out this