Skip to content

Instantly share code, notes, and snippets.

@jimneath
Forked from omgitsads/rails-check.sh
Last active December 10, 2015 23:29
Show Gist options
  • Save jimneath/4510168 to your computer and use it in GitHub Desktop.
Save jimneath/4510168 to your computer and use it in GitHub Desktop.
for i in `find /data -maxdepth 1 -type d ! -name "monit.d" ! -name "nginx" ! -name "lost+found" ! -name "homedirs" ! -name "data"`;
do
appname=`echo ${i} | awk -F/ '{print $3}'`
version=''
if [ -f $i/current/Gemfile.lock ];
then
version=`egrep "^ *rails \([0-9\.]+\)" $i/current/Gemfile.lock | egrep -o "[0-9\.]+"`
else
version=`gem list | egrep -o "^rails \([^,\)]+" | egrep -o "[0-9\.]+"`
fi
if [[ $version != 3.2.11 && $version != 3.1.10 && $version != 3.0.19 && $version != 2.3.15 ]]
then
if [[ -d "$i/current/config/initializers" ]];
then
grep -q "ActiveSupport::XmlMini::PARSING.delete" $i/current/config/initializers/*
patched=$?
if [ $patched != 0 ];
then
echo -e "\033[31mApp: ${appname} - Rails Version: ${version} - Vulnerability Possible"
else
echo -e "\033[33mApp: ${appname} - Rails Version: ${version} - CVE-2013-0156 Looks to be patched"
fi
else
echo -e "\033[33mApp: ${appname} - Rails Version: ${version} - No Initializers dir, may not be a rails app"
fi
else
echo -e "\033[32mApp: ${appname} - Rails Version: ${version} - CVE-2013-0156 Patched"
fi
done
App: ths - Rails Version: 2.3.15 - Vulnerability Possible
App: sphinx-0.9.8.1 - Rails Version: 2.3.15 - No Initializers dir, may not be a rails app
App: thehairstyler - Rails Version: 2.3.15 - No Initializers dir, may not be a rails app
App: ssmtp - Rails Version: 2.3.15 - No Initializers dir, may not be a rails app
app_master i-0f149b7e ~ #
App: bruschetta - Rails Version: 3.1.0 - CVE-2013-0156 Looks to be patched
solo i-2cf3fd49 ~ #
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment