Skip to content

Instantly share code, notes, and snippets.

@psifertex
Created January 12, 2024 04:07
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 psifertex/33a0236f70867423b9b5c658269b0144 to your computer and use it in GitHub Desktop.
Save psifertex/33a0236f70867423b9b5c658269b0144 to your computer and use it in GitHub Desktop.
Open Ghidra with default analysis options
#!/bin/bash
GHIDRAPATH=~/Downloads/ghidra
# https://stackoverflow.com/posts/23002317/revisions
function abspath() {
# generate absolute path from relative path
# $1 : relative filename
# return : absolute path
if [ -d "$1" ]; then
# dir
(cd "$1"; pwd)
elif [ -f "$1" ]; then
# file
if [[ $1 = /* ]]; then
echo "$1"
elif [[ $1 == */* ]]; then
echo $(cd "${1%/*}"; pwd)/${1##*/}
else
echo "$(pwd)/$1"
fi
fi
}
FILE=$(abspath $1)
FILENAME="${FILE##*/}"
pushd $GHIDRAPATH
./support/analyzeHeadless /tmp tmp -import "$FILE" && ./support/GhidraGo/ghidraGo "ghidra:///tmp//tmp?/$FILENAME"
popd
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment