Skip to content

Instantly share code, notes, and snippets.

@oliverchang
Created December 22, 2014 08:40
Show Gist options
  • Save oliverchang/8f0bb6bf92ae17378678 to your computer and use it in GitHub Desktop.
Save oliverchang/8f0bb6bf92ae17378678 to your computer and use it in GitHub Desktop.
catalyst_patch_load_extension.sh
#!/bin/sh
LOAD_EXTENSION_OFF=$(printf "%d" 0x`objdump -d $1 | grep -m1 '<LoadExtension@plt>:' | cut -d' ' -f1`)
LOAD_EXTENSION_LIST_OFF=$(printf "%d" 0x`objdump -d $1 | grep -m1 '<LoadExtensionList@plt>:' | cut -d' ' -f1`)
DIFF=$((LOAD_EXTENSION_LIST_OFF - LOAD_EXTENSION_OFF))
cat << EOF > patch$$.asm
BITS 64
mov rsi, rdx
xor rsi, rsi
inc rsi
jmp $((DIFF))
EOF
nasm -o patch$$.bin patch$$.asm
dd conv=notrunc if=patch.bin bs=1 count=14 seek=$LOAD_EXTENSION_OFF of=$1
rm patch$$.bin
rm patch$$.asm
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment