#!/usr/bin/env bash FILE=BattleBlockTheater MD5_PRE=436e91811d8a38de1918991969347b3d MD5_POST=71eb6519233b21d85c858b39f2b4871f OFFSET=0x24f2b9 PAYLOAD='\x90\x90' function getMD5() { echo $(md5sum "${1}" | cut -d ' ' -f 1) } if [[ ${MD5_PRE} != $(getMD5 ${FILE}) ]] then echo Input has wrong checksum. Already patched? exit 11 fi echo -ne ${PAYLOAD} | dd if=/dev/stdin of="${FILE}" bs=1 conv=notrunc seek=$((${OFFSET})) status=none if [[ $? != 0 ]] then echo Patching binary failed. exit 77 fi if [[ ${MD5_POST} != $(getMD5 ${FILE}) ]] then echo Output has wrong checksum. Expect trouble! exit 22 fi echo Yay... everything went well.