-
Notifications
You must be signed in to change notification settings - Fork 522
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #21 from perror/master
Adding a script to handle command line in a nicer way
- Loading branch information
Showing
1 changed file
with
66 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |