Skip to content

Instantly share code, notes, and snippets.

@cyberheartmi9
Last active October 11, 2020 09:57
Show Gist options
  • Select an option

  • Save cyberheartmi9/500d32810998f6f324ed48a2282185c1 to your computer and use it in GitHub Desktop.

Select an option

Save cyberheartmi9/500d32810998f6f324ed48a2282185c1 to your computer and use it in GitHub Desktop.
audit script for linux servers
#!/bin/bash
cat <<EOF
m " mmmmmm
# mmm m mm m m m m # m mm m m mmmmm
# # #" # # # #m# #mmmmm #" # # # # # #
# # # # # # m#m # # # # # # # #
#mmmmm mm#mm # # "mm"# m" "m #mmmmm # # "mm"# # # #
@intx0x80
EOF
echo -e "\n[+] System info \n"
uname -a
function userlist(){
echo "[+] Enum Users & home Dir & shell type "
#sleep 5
user=$(cat /etc/passwd|cut -d ":" -f 1,6,7)
for i in $user
do
echo $i|tr ":" " | "
done
}
function sudolist(){
echo "[+] sudoer file "
list=$(cat /etc/passwd|cut -d ":" -f 1)
for i in $list
do
sudo -U $i -l |grep -v "not allowed to run sudo"
done
}
function hostnetwork(){
echo -e "\n[+] List open communication\n"
lsof -i
echo -e "\n[+] List Open ports \n"
netstat -antup
echo -e "\n[+] Routing traffic \n"
route -nee
}
function filesys(){
echo -e "\n[+] check for writable config file by [ anyone ] \n"
ls -aRl /etc/ | awk '$1 ~ /^.*w.*/' 2>/dev/null
echo -e "\n[+] check for writable config file by [ owner ] \n"
ls -aRl /etc/ | awk '$1 ~ /^..w/' 2>/dev/null
echo -e "\n[+] check for writable config file by [ group ] \n"
ls -aRl /etc/ | awk '$1 ~ /^.....w/' 2>/dev/null
echo -e "\n[+] check for writable config file by [ other ] \n"
ls -aRl /etc/ | awk '$1 ~ /w.$/' 2>/dev/null
}
function fileperm(){
echo -e "\n[+] List sticky bit only for dir [owner ] \n"
find / -perm -1000 -type d 2>/dev/null
echo -e "\n[+] List sticky bit only for file [group ] \n"
find / -perm -g=s -type f 2>/dev/null
echo -e "\n[+] List sticky bit only for file [owner ] \n"
find / -perm -u=s -type f 2>/dev/null
echo -e "\n[+] List suid & gid only for files\n"
find / -perm -g=s -o -perm -u=s -type f 2>/dev/null
echo -e "\n[+] List writable Dir \n"
find / -writable -type d 2>/dev/null
echo -e "\n[+] List Executable Dir \n"
find / -perm -o x -type d 2>/dev/null
}
function groups() {
grpinfo=`for i in $(cut -d":" -f1 /etc/passwd 2>/dev/null);do id $i;done 2>/dev/null`
if [ "$grpinfo" ]; then
echo -e "\e[00;31m[-] Group memberships:\e[00m\n$grpinfo"
echo -e "\n"
fi
}
function sudousers() {
sudoers=`grep -v -e '^$' /etc/sudoers 2>/dev/null |grep -v "#" 2>/dev/null`
if [ "$sudoers" ]; then
echo -e "\e[00;31m[-] Sudoers configuration (condensed):\e[00m$sudoers"
echo -e "\n"
fi
}
userlist
sudousers
#sudolist
#fileperm
#filesys
#hostnetwork
echo -e "\n Finish ..........\n"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment