4 # this file was downloaded with this command:
5 # curl https://shellshocker.net/shellshock_test.sh >shellshock_test.sh
8 CVE20146271=$(env 'x=() { :;}; echo vulnerable' 'BASH_FUNC_x()=() { :;}; echo vulnerable' bash -c "echo test" 2>&1 | grep 'vulnerable' | wc -l)
10 echo -n "CVE-2014-6271 (original shellshock): "
11 if [ $CVE20146271 -gt 0 ]; then
12 echo -e "\033[91mVULNERABLE\033[39m"
13 EXITCODE=$((EXITCODE+1))
15 echo -e "\033[92mnot vulnerable\033[39m"
19 # it is fully mitigated by the environment function prefix passing avoidance
20 CVE20146277=$((shellshocker="() { x() { _;}; x() { _;} <<a; }" bash -c date 2>/dev/null || echo vulnerable) | grep 'vulnerable' | wc -l)
22 echo -n "CVE-2014-6277 (segfault): "
23 if [ $CVE20146277 -gt 0 ]; then
24 echo -e "\033[91mVULNERABLE\033[39m"
25 EXITCODE=$((EXITCODE+2))
27 echo -e "\033[92mnot vulnerable\033[39m"
31 CVE20146278=$(shellshocker='() { echo vulnerable; }' bash -c shellshocker 2>/dev/null | grep 'vulnerable' | wc -l)
33 echo -n "CVE-2014-6278 (Florian's patch): "
34 if [ $CVE20146278 -gt 0 ]; then
35 echo -e "\033[91mVULNERABLE\033[39m"
36 EXITCODE=$((EXITCODE+4))
38 echo -e "\033[92mnot vulnerable\033[39m"
42 CVE20147169=$((cd /tmp; rm -f /tmp/echo; env X='() { (a)=>\' bash -c "echo echo nonvuln" 2>/dev/null; [[ "$(cat echo 2> /dev/null)" == "nonvuln" ]] && echo "vulnerable" 2> /dev/null) | grep 'vulnerable' | wc -l)
44 echo -n "CVE-2014-7169 (taviso bug): "
45 if [ $CVE20147169 -gt 0 ]; then
46 echo -e "\033[91mVULNERABLE\033[39m"
47 EXITCODE=$((EXITCODE+8))
49 echo -e "\033[92mnot vulnerable\033[39m"
53 CVE20147186=$((bash -c 'true <<EOF <<EOF <<EOF <<EOF <<EOF <<EOF <<EOF <<EOF <<EOF <<EOF <<EOF <<EOF <<EOF <<EOF' 2>/dev/null || echo "vulnerable") | grep 'vulnerable' | wc -l)
55 echo -n "CVE-2014-7186 (redir_stack bug): "
56 if [ $CVE20147186 -gt 0 ]; then
57 echo -e "\033[91mVULNERABLE\033[39m"
58 EXITCODE=$((EXITCODE+16))
60 echo -e "\033[92mnot vulnerable\033[39m"
64 CVE20147187=$(((for x in {1..200}; do echo "for x$x in ; do :"; done; for x in {1..200}; do echo done; done) | bash || echo "vulnerable") | grep 'vulnerable' | wc -l)
66 echo -n "CVE-2014-7187 (nested loops off by one): "
67 if [ $CVE20147187 -gt 0 ]; then
68 echo -e "\033[91mVULNERABLE\033[39m"
69 EXITCODE=$((EXITCODE+32))
71 echo -e "\033[92mnot vulnerable\033[39m"
75 CVE2014=$(env X=' () { }; echo vulnerable' bash -c 'date' | grep 'vulnerable' | wc -l)
77 echo -n "CVE-2014-//// (exploit 3 on http://shellshocker.net/): "
78 if [ $CVE2014 -gt 0 ]; then
79 echo -e "\033[91mVULNERABLE\033[39m"
80 EXITCODE=$((EXITCODE+64))
82 echo -e "\033[92mnot vulnerable\033[39m"