From d06fa4585f2d40061d8124cee23c70c1a35deb47 Mon Sep 17 00:00:00 2001 From: otih Date: Sun, 13 Jan 2019 21:37:49 +0100 Subject: [PATCH 1/2] remove coloring optional. This closes #36 --- bashcheck | 45 ++++++++++++++++++++++++++++++++++----------- 1 file changed, 34 insertions(+), 11 deletions(-) diff --git a/bashcheck b/bashcheck index a3245fb..d83484c 100755 --- a/bashcheck +++ b/bashcheck @@ -1,39 +1,62 @@ #!/bin/bash + +color_FAIL="\033[91m" +color_NORM="\033[39m" +color_LightYellow="\033[93m" +color_LightGreen="\033[92m" +color_LightMagenta="\033[95m" +color_LightCyan="\033[96m" + +while :; do + case $1 in + -n|--nocolor) + unset color_FAIL + unset color_NORM + unset color_LightYellow + unset color_LightGreen + unset color_LightMagenta + unset color_LightCyan + ;; + *) break + esac + shift +done + warn() { if [ "$scary" == "1" ]; then - echo -e "\033[91mVulnerable to $1\033[39m" + echo -e "${color_FAIL}Vulnerable to $1${color_NORM}" else - echo -e "\033[93mFound non-exploitable $1\033[39m" + echo -e "${color_LightYellow}Found non-exploitable $1${color_NORM}" fi } good() { - echo -e "\033[92mNot vulnerable to $1\033[39m" + echo -e "${color_LightGreen}Not vulnerable to $1${color_NORM}" } tmpdir=`mktemp -d -t tmp.XXXXXXXX` [ -n "$1" ] && bash=$(which $1) || bash=$(which bash) -echo -e "\033[95mTesting $bash ..." +echo -e "${color_LightMagenta}Testing $bash ..." $bash -c 'echo "Bash version $BASH_VERSION"' -echo -e "\033[39m" +echo -e "${color_NORM}" #r=`a="() { echo x;}" $bash -c a 2>/dev/null` if [ -n "$(env 'a'="() { echo x;}" $bash -c a 2>/dev/null)" ]; then - echo -e "\033[91mVariable function parser active, maybe vulnerable to unknown parser bugs\033[39m" + echo -e "${color_FAIL}Variable function parser active, maybe vulnerable to unknown parser bugs${color_NORM}" scary=1 elif [ -n "$(env 'BASH_FUNC_a%%'="() { echo x;}" $bash -c a 2>/dev/null)" ]; then - echo -e "\033[92mVariable function parser pre/suffixed [%%, upstream], bugs not exploitable\033[39m" + echo -e "${color_LightGreen}mVariable function parser pre/suffixed [%%, upstream], bugs not exploitable${color_NORM}" scary=0 elif [ -n "$(env 'BASH_FUNC_a()'="() { echo x;}" $bash -c a 2>/dev/null)" ]; then - echo -e "\033[92mVariable function parser pre/suffixed [(), redhat], bugs not exploitable\033[39m" + echo -e "${color_LightGreen}Variable function parser pre/suffixed [(), redhat], bugs not exploitable${color_NORM}" scary=0 elif [ -n "$(env '__BASH_FUNC()'="() { echo x;}" $bash -c a 2>/dev/null)" ]; then - echo -e "\033[92mVariable function parser pre/suffixed [__BASH_FUNC<..>(), apple], bugs not exploitable\033[39m" + echo -e "${color_LightGreen}Variable function parser pre/suffixed [__BASH_FUNC<..>(), apple], bugs not exploitable${color_NORM}" scary=0 else - echo -e "\033[92mVariable function parser inactive, bugs not exploitable\033[39m" + echo -e "${color_LightGreen}Variable function parser inactive, bugs not exploitable${color_NORM}" scary=0 fi @@ -68,7 +91,7 @@ $bash -c "`for i in {1..200}; do echo -n "for x$i in; do :;"; done; for i in {1. if [ $? != 0 ]; then warn "CVE-2014-7187 (nested loops off by one)" else - echo -e "\033[96mTest for CVE-2014-7187 not reliable without address sanitizer\033[39m" + echo -e "${color_LightCyan}Test for CVE-2014-7187 not reliable without address sanitizer${color_NORM}" fi $($bash -c "f(){ x(){ _;};x(){ _;}</dev/null) From 334c73eedd9a7b24d38bca4e044192607198d97c Mon Sep 17 00:00:00 2001 From: otih Date: Sun, 13 Jan 2019 22:27:25 +0100 Subject: [PATCH 2/2] typo fix --- bashcheck | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bashcheck b/bashcheck index d83484c..401dfbc 100755 --- a/bashcheck +++ b/bashcheck @@ -47,7 +47,7 @@ if [ -n "$(env 'a'="() { echo x;}" $bash -c a 2>/dev/null)" ]; then echo -e "${color_FAIL}Variable function parser active, maybe vulnerable to unknown parser bugs${color_NORM}" scary=1 elif [ -n "$(env 'BASH_FUNC_a%%'="() { echo x;}" $bash -c a 2>/dev/null)" ]; then - echo -e "${color_LightGreen}mVariable function parser pre/suffixed [%%, upstream], bugs not exploitable${color_NORM}" + echo -e "${color_LightGreen}Variable function parser pre/suffixed [%%, upstream], bugs not exploitable${color_NORM}" scary=0 elif [ -n "$(env 'BASH_FUNC_a()'="() { echo x;}" $bash -c a 2>/dev/null)" ]; then echo -e "${color_LightGreen}Variable function parser pre/suffixed [(), redhat], bugs not exploitable${color_NORM}"