Skip to content

Commit

Permalink
Merge pull request #21 from perror/master
Browse files Browse the repository at this point in the history
Adding a script to handle command line in a nicer way
  • Loading branch information
perror committed Feb 6, 2015
2 parents 1c6a708 + c316da0 commit b17e41c
Showing 1 changed file with 66 additions and 0 deletions.
66 changes: 66 additions & 0 deletions triton
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
#!/bin/sh

# Get the path to the script ROOT
ROOT="$(cd "$(dirname "$0")" && pwd)"

usage ()
{
echo "Triton binary analyzer usage: triton MODE [MODE_ARGS] EXEC [EXEC_ARGS]\n"
echo "Available modes are:"
echo " -startAnalysis <func_name> Start the analysis the scope of the function"
echo " -detectFormatString Enable the format string detection analysis"
}

check_argument ()
{
if [ -z "${MODE_ARGS}" ]; then
echo "triton: error: missing argument for the ${MODE} mode"
usage
exit 1
fi
}

# Getting Triton arguments
MODE=$1
MODE_ARGS=$2
EXEC=$3
EXEC_ARGS=$4

# Check the mode and the arguments
case ${MODE} in
"")
echo "triton: error: no mode given"
usage
exit 1;;

"-startAnalysis")
check_argument
;;

"-detectFormatString")
;;

"-h" | "-help" | "--help")
usage
exit 0;;
*)
echo "triton: error: unknown mode '${MODE}'"
usage
exit 1;;
esac

# Check the executable file
if [ ! -f ${EXEC} ]; then
echo "triton: error: '${EXEC}' not found"
usage
exit 1
fi

if [ ! -x ${EXEC} ]; then
echo "triton: error: '${EXEC}' is not an executable"
usage
exit 1
fi

# Running Triton
${ROOT}/../../../pin -t ${ROOT}/triton.so ${MODE} ${MODE_ARGS} -- ${EXEC} ${EXEC_ARGS} || usage

0 comments on commit b17e41c

Please sign in to comment.