Skip to content

Instantly share code, notes, and snippets.

@b3dEvilooper
Created January 2, 2019 12:23
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save b3dEvilooper/57a679c05da2c43b2069f58f56411239 to your computer and use it in GitHub Desktop.
Save b3dEvilooper/57a679c05da2c43b2069f58f56411239 to your computer and use it in GitHub Desktop.
Linux simple security cheker
#!/bin/sh
# HISTORY:
# (c) b3, 02/2012 upd 01.03.2013
# https://rdot.org/forum/
# reborn in 25.12.2018 "under construction"
# https://forum.antichat.ru/threads/467600/
####################
PATH=$PATH:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
LANG=C
echo -e "**************************************************"
echo -e "* general information *"
echo -e "* *"
echo -e "**************************************************"
echo -e "[+]id:";id
echo -e "[+]uanme -a:";uname -a
echo -e "\n[+]cat /proc/version:";cat /proc/version
echo -e "\n[+]cat /proc/cpuinfo:";cat /proc/cpuinfo
echo -e "\n[+]cat /etc/issue:";cat /etc/issue
echo -e "\n[+]cat /etc/issue.net:";cat /etc/issue.net
if [ -e "/etc/debian_version" ]; then echo "Debian Version: `cat /etc/debian_version`";fi;
if [ -e "/etc/redhat-release" ]; then echo "Redhat Release: `cat /etc/redhat-release`";fi;
if [ -e "/etc/gentoo-release" ]; then echo "Gentoo Release: `cat /etc/gentoo-release`";fi;
echo -e "\n[+]who online (w):";w
echo -e "\n[+]proccess list wide tree (ps axfuw):";ps axfuw
echo -e "\n[+]mount:";mount
echo -e "\n[+]df -h";df -h
echo -e "\n[+]cat /etc/fstab";cat /etc/fstab
echo -e "**************************************************"
echo -e "* security fails *"
echo -e "* *"
echo -e "**************************************************"
echo -e "[+]mmap_min_addr:";cat /proc/sys/vm/mmap_min_addr
echo -e "[+]Parse /etc for Writeable files"
find /etc -type f -perm -a+w -ls 2>/dev/null
echo -e "[+] check /etc/shadow PERM";ls -lha /etc/shadow
echo -e "[+] check /etc/passwd PERM";ls -lha /etc/passwd
echo -e "[+]FHS root (ls -lha /):";ls -lha /
echo -e "[+]Search core dumps...";find / -type f -regex ".*/core\.[0-9][0-9][0-9][0-9]$" -print 2>/dev/null
which pulseaudio;
#####
#
# Sudo version
#
if [ -x "`which sudo`" ]
then
sudo -V | grep -i version
fi;
#####
#
# /usr/bin/staprun
#
if [ -x "`which staprun`" ]
then
echo "/usr/bin/staprun exist and executable";
echo "http://www.exploit-db.com/exploits/15620/";
fi;
#####
#
# EXIM version
#
if [ -x "`which exim 2>/dev/null`" ]
then
exim -bV 2>/dev/null | grep -i version;
fi;
#####
#
# /proc/sys/net/rds exist
#
if [ -d "/proc/sys/net/rds" ]
then
echo "/proc/sys/net/rds";
echo "http://www.vsecurity.com/resources/advisory/20101019-1/"
fi;
#####
#
# /usr/bin/pkexec date < 2011.04.01
#
if [ -x "`which pkexec`" ]
then
filed="`ls -l /usr/bin/pkexec --full-time | awk '{print $6}' | tr -d '-'`"
if [ "20110401" -gt "$filed" ]
then
echo "/usr/bin/pkexec date < 2011.04.01";
echo "http://git.zx2c4.com/CVE-2011-1485/tree/polkit-pwnage.c";
fi;
fi;
####
# SUID DUMPABLE
# needs to be 1 or 2
# http://www.exploit-db.com/exploits/8369/
if [ `cat /proc/sys/fs/suid_dumpable` -ne "0" ]; then echo "suid_dumpable: `cat /proc/sys/fs/suid_dumpable` http://www.exploit-db.com/exploits/8369/";fi;
echo -e "**************************************************"
echo -e "* av, firewalls *"
echo -e "* *"
echo -e "**************************************************"
whereis chkrootkit
whereis rkhunter
whereis clamav
iptables -L
echo -e "**************************************************"
echo -e "* Usefull *"
echo -e "* *"
echo -e "**************************************************"
echo -e "[+] Python";python -V
echo -e "[+] Php";php -v
echo -e "[+] Perl";perl -v
echo -e "[+]gcc -v";gcc -v
echo -e "[+]Ruby -v";ruby -v
echo -e "**************************************************"
echo -e "* users info *"
echo -e "* *"
echo -e "**************************************************"
echo -e "[+] All users:\n"
cat /etc/passwd
echo -e "\n[+]Chek HOMEs for users with UID>500:\n"
for x in `cat /etc/passwd | cut -d: -f1,3,4,6,7`
do
user_name=`echo $x | awk -F: '{print $1}'`;
user_uid=`echo "$x" | awk -F: '{print $2}'`;
user_gid=`echo $x | awk -F: '{print $3}'`;
user_home=`echo $x | awk -F: '{print $4}'`;
user_shell=`echo $x | awk -F: '{print $5}'`;
if [ "$user_uid" -ge 500 ]
then
echo "[+]check perm $user_name(uid=$user_uid;gid=$user_gid) HOME=$user_home:";
ls -lha $user_home -d --full-time
ls -lha $user_home/.bash_history 2>/dev/null
ls -lha $user_home/.ssh -d 2>/dev/null
ls -lha $user_home/.ssh/ 2>/dev/null
fi;
done;
echo -e "**************************************************"
echo -e "* library info *"
echo -e "* *"
echo -e "**************************************************"
echo -e "[+]LIBC:";
ls -lha /lib/libc-* --full-time | awk '{print $6" "$9}'
echo -e "[+]ALL from /lib /lib64 (sort -u):";
ls -lha /lib/ /lib64/ --full-time | sort -u
echo -e "**************************************************"
echo -e "* crontab info *"
echo -e "* *"
echo -e "**************************************************"
echo -e "[+]List of CRON tabs:"
find /etc/cron* -type f -ls
echo -e "\n[+]List of USER CRON tabs:"
find /var/spool/cron/* -type f -ls
for cr_file in `find /etc/cron* -type f`
do
if test -w $cr_file; then echo -e "\t\t===== FILE HAVE WRITE PERM $cr_file =====";fi;
if test -r $cr_file
then
if test -s $cr_file
then
echo -e "=====================================";
echo -e "== READ cronfile: $cr_file";
cat $cr_file;
echo -e "== end of $cr_file ";
echo -e "=====================================";
else
echo -e "=====================================";
echo -e "== $cr_file EMPTY";
echo -e "=====================================";
fi;
else
echo -e "\t\t ===== File $cr_file dont have READ perm =====";
fi;
done;
echo -e "**************************************************"
echo -e "* FIND suid files *"
echo -e "* *"
echo -e "**************************************************"
find / -type f -perm -4000 -exec ls -lha {} \; 2>/dev/null
########################################################################
echo "[!] ALL JOBS DONE, Have a good day!";
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment