From cedf414da537cc308f4e5a909266ad2555ecfb86 Mon Sep 17 00:00:00 2001 From: curiosity-seeker Date: Fri, 14 Jun 2019 12:49:21 +0200 Subject: Create syscalls file (#2754) * Create syscalls file A little script to determine the necessary syscalls for a program. --- contrib/syscalls.sh | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 contrib/syscalls.sh (limited to 'contrib') diff --git a/contrib/syscalls.sh b/contrib/syscalls.sh new file mode 100644 index 000000000..9ab6acf5b --- /dev/null +++ b/contrib/syscalls.sh @@ -0,0 +1,30 @@ +#!/bin/bash + +STRACE_OUTPUT_FILE="$(pwd)/strace_output.txt" +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 + +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 + +fi -- cgit v1.2.3-54-g00ecf