Last active
September 27, 2018 21:18
-
-
Save ansemjo/816098f0227ad830e6644bd82e9d2c28 to your computer and use it in GitHub Desktop.
wrapper for slimm609/checksec.sh which displays nicer-formatted output
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
#!/usr/bin/env bash | |
# wrapper script for slimm609/checksec.sh for nicer output format | |
# download https://github.com/slimm609/checksec.sh/blob/master/checksec to PATH | |
# further requires jq and objdump in PATH | |
CHECKSEC=checksec | |
set -e | |
# version information | |
$CHECKSEC --version | |
box() { printf ' [\033[1;%dm%s\033[0m] %s\n' "$1" "$2" "$3"; } | |
res() { | |
{ [[ $1 == yes ]] && box "32" "+" "$2"; } || \ | |
{ [[ $1 == partial ]] && box "33" "*" "$3"; } || \ | |
box "31" "-" "$4"; } | |
get() { jq -r ".file.$1"; } | |
inv() { [[ $(get "$1") == no ]] && echo yes || echo no; } | |
sec() { | |
# run test and receive json results | |
printf '\033[1mfile: %q\033[0m\n' "${1:?filename required}" | |
box "34" "i" "$(objdump -f "$1" | sed -n 's/.*file format //p')" | |
JSON=$($CHECKSEC --output json --file "$1") | |
# display results | |
echo $JSON | res "$(get relro)" {Full,Partial,No}\ RELRO | |
echo $JSON | res "$(get canary)" {,?,No\ }Canary\ found | |
echo $JSON | res "$(get nx)" NX\ {enabled,?,disabled} | |
echo $JSON | res "$(get pie)" PIE\ {enabled,?,disabled} | |
echo $JSON | res "$(inv rpath)" {No\ RUNPATH,?,RUNPATH\ present} | |
echo $JSON | res "$(inv symtables)" {No\ Symbols,?,Symbols\ found} | |
echo $JSON | res "$(get fortify_source)" {Fortify,?,Not\ fortified} | |
echo | |
} | |
for arg in "$@"; do | |
sec "$arg" | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
output sample