diff --git a/triton b/triton new file mode 100755 index 000000000..e9641a6a1 --- /dev/null +++ b/triton @@ -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 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