Skip to content

Commit

Permalink
Improvements for syscalls.sh contib file
Browse files Browse the repository at this point in the history
Fixed the identation for copy/past problems and added a console character that returns the console to it's original colour after the SYSCALLS_OUTPUT_FILE param is printed.
  • Loading branch information
avilum committed Apr 9, 2020
1 parent f12ba66 commit 2a3f61b
Showing 1 changed file with 17 additions and 21 deletions.
38 changes: 17 additions & 21 deletions contrib/syscalls.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,26 +8,22 @@ SYSCALLS_OUTPUT_FILE="$(pwd)/syscalls.txt"

if [ $# -eq 0 ]
then
echo
echo " *** No program specified!!! ***"
echo
echo -e "Make this file executable and execute it as:\\n"
echo -e "\\e[96m syscalls.sh /full/path/to/program\\n"
echo -e "\\e[39mif you saved this script in a directory in your PATH (e.g., in ${HOME}/bin), otherwise as:\\n"
echo -e "\\e[96m ./syscalls.sh /full/path/to/program\\n"
echo -e "\\e[39mUse the full path to the respective program to avoid executing it sandboxed with Firejail\\n(if a Firejail profile for it already exits and 'sudo firecfg' was executed earlier)\\nin order to determine the necessary system calls."
echo
exit 0

echo
echo " *** No program specified!!! ***"
echo
echo -e "Make this file executable and execute it as:\\n"
echo -e "\\e[96m syscalls.sh /full/path/to/program\\n"
echo -e "\\e[39mif you saved this script in a directory in your PATH (e.g., in ${HOME}/bin), otherwise as:\\n"
echo -e "\\e[96m ./syscalls.sh /full/path/to/program\\n"
echo -e "\\e[39mUse the full path to the respective program to avoid executing it sandboxed with Firejail\\n(if a Firejail profile for it already exits and 'sudo firecfg' was executed earlier)\\nin order to determine the necessary system calls."
echo
exit 0
else

strace -cfo "$STRACE_OUTPUT_FILE" "$@" && awk '{print $NF}' "$STRACE_OUTPUT_FILE" | sed '/syscall\|-\|total/d' | sort -u | awk -vORS=, '{ print $1 }' | sed 's/,$/\n/' > "$SYSCALLS_OUTPUT_FILE"
echo
echo -e "\e[39mThese are the sorted syscalls:\n\e[93m"
cat "$SYSCALLS_OUTPUT_FILE"
echo
echo -e "\e[39mThe sorted syscalls were saved to:\n\n\e[96m$SYSCALLS_OUTPUT_FILE"
echo
exit 0

strace -cfo "$STRACE_OUTPUT_FILE" "$@" && awk '{print $NF}' "$STRACE_OUTPUT_FILE" | sed '/syscall\|-\|total/d' | sort -u | awk -vORS=, '{ print $1 }' | sed 's/,$/\n/' > "$SYSCALLS_OUTPUT_FILE"
echo
echo -e "\e[39mThese are the sorted syscalls:\n\e[93m"
cat "$SYSCALLS_OUTPUT_FILE"
echo
echo -e "\e[39mThe sorted syscalls were saved to:\n\e[96m$SYSCALLS_OUTPUT_FILE\n\e[39m"
exit 0
fi

0 comments on commit 2a3f61b

Please sign in to comment.