diff options
Diffstat (limited to 'batch/old')
-rwxr-xr-x | batch/old/bindiff.sh | 12 | ||||
-rwxr-xr-x | batch/old/genShellcode.sh | 61 | ||||
-rwxr-xr-x | batch/old/genhex.sh | 18 |
3 files changed, 91 insertions, 0 deletions
diff --git a/batch/old/bindiff.sh b/batch/old/bindiff.sh new file mode 100755 index 0000000..e598c6b --- /dev/null +++ b/batch/old/bindiff.sh @@ -0,0 +1,12 @@ +#!/bin/bash + + +if [ "x$1" = "x" ] || [ "x$2" = "x" ]; then + echo "$0: [FILE1] [FILE2]" + exit 1 +fi + +xxd "$1" > "$1.hex" +xxd "$2" > "$2.hex" +diff -du "$1.hex" "$2.hex" 2>&1 | less +rm -f "$1.hex" "$2.hex" diff --git a/batch/old/genShellcode.sh b/batch/old/genShellcode.sh new file mode 100755 index 0000000..bf0327a --- /dev/null +++ b/batch/old/genShellcode.sh @@ -0,0 +1,61 @@ +#!/bin/bash + +set -e + +OBJDUMP="$(dirname $0)/../deps/sysroot/bin/i686-w64-mingw32-objdump" +OBJDUMP_ARGS="-z -D" +TMPFILE="$(mktemp)" + + +if [ ! -x ${OBJDUMP} ]; then + echo "$0: ${OBJDUMP} not found!" + false +fi + +if [ "x$1" != "x" -a "x$2" != "x" -a "x$3" != "x" -a "x$4" != "x" ]; then + echo "$0: create tmpfile ${TMPFILE}" + OBJECTFILE="${1}" + OUTPUT="${2}" + DEFINE="${3}" + OBJDUMP_ARGS="${OBJDUMP_ARGS} -j ${4}" + + DO_APPEND=0 + if [ "x$5" != "x" ]; then + echo "$5" | egrep -qi 'append.*=.*true' && DO_APPEND=1 || true + fi + + if [ ! -r ${OBJECTFILE} ]; then + echo "$0: ${OBJECTFILE} not found or not readable" + false + fi + + echo "$0: objdump command: \`${OBJDUMP} ${OBJDUMP_ARGS} ${OBJECTFILE}\`" + export SIZE=0 + if [ ${DO_APPEND} -eq 1 ]; then + echo "$0: APPENDING to ${OUTPUT}" + cp ${OUTPUT} ${TMPFILE} + echo >> ${TMPFILE} + echo '#undef '"${DEFINE}" >> ${TMPFILE} + else + echo '#undef '"${DEFINE}" > ${TMPFILE} + fi + echo -n '#define '"${DEFINE}"' "' >> ${TMPFILE} + # TODO: use objdump -s to show everything (-d shows only valid opcodes) + for i in $(${OBJDUMP} ${OBJDUMP_ARGS} ${OBJECTFILE} |grep "^ " |cut -f2); do + echo -n '\x'$i >>${TMPFILE} + SIZE=$(expr $SIZE + 1) + done + if [ $SIZE -eq 0 ]; then + echo "$0: Whoops! Something went wrong (SIZE=0)." + echo "$0: Check output manually with: \`${OBJDUMP} ${OBJDUMP_ARGS} ${OBJECTFILE}\`" + false + fi + echo '"' >>${TMPFILE} + echo '#undef '"${DEFINE}"'_SIZE' >> ${TMPFILE} + echo '#define '"${DEFINE}"'_SIZE '"${SIZE}" >> ${TMPFILE} + mv ${TMPFILE} ${OUTPUT} + echo "$0: moved ${TMPFILE} to ${OUTPUT}" +else + echo "usage: $0 [OBJECT-FILE or STATIC-LIB] [OUTPUT-HEADER] [OUTPUT-DEFINE] [LOADER-SECTION] [DO-APPEND=[TRUE|FALSE]]" + exit 1 +fi diff --git a/batch/old/genhex.sh b/batch/old/genhex.sh new file mode 100755 index 0000000..114ea34 --- /dev/null +++ b/batch/old/genhex.sh @@ -0,0 +1,18 @@ +#!/bin/bash + +if [ -z "$1" ]; then + DPATH="$(pwd)" +else + DPATH="$1" +fi + +echo "$0: generate *.hex files in $(ls ${DPATH})" +for file in $(ls ${DPATH}); do + [ -d ${file} ] && continue + FLEN=$((${#file}-4)) + FSUFFIX=${file:$FLEN:4} + if [ "$FSUFFIX" != ".hex" ]; then + xxd "${file}" > "${file}.hex" + fi +done + |