Skip to content

Instantly share code, notes, and snippets.

@CLOVIS-AI
Created January 5, 2019 18:22
Show Gist options
  • Save CLOVIS-AI/b038b9e8dacc66be34a86601fb81c58d to your computer and use it in GitHub Desktop.
Save CLOVIS-AI/b038b9e8dacc66be34a86601fb81c58d to your computer and use it in GitHub Desktop.
#!/bin/bash
GREEN="\033[0;32m"
NOCOLOR="\033[0m"
BLUE="\033[0;34m"
GRAY="\033[0;37m"
DQ='"'
RED="\033[0;31m"
echo && echo && echo
echo -e " ${GREEN}-------------------"
echo "/ \\"
echo -e "| ${NOCOLOR}SYSTEM STATISTICS${GREEN} |"
echo "\\ /"
echo -e " -------------------${NOCOLOR}"
echo && echo -e "${BLUE}------ USAGE ------${NOCOLOR}"
w
echo && echo -e "${BLUE}------ SIZE ------${NOCOLOR}"
df -h
echo && echo -e "${BLUE}------ FILES ------${NOCOLOR}"
lsof | head -1
lsof -i | grep ESTABLISHED
echo && echo -e "${BLUE}------ SERVERS ------${NOCOLOR}"
echo "$ service --status-all"
echo "$ service [NAME] status"
service --status-all | grep -e apache2 -e proftpd -e ssh -e fail2ban -e cron -e mysql -e sendmail | grep -E --color '\-|'
echo && echo -e "${BLUE}------ SUCCESSFUL LOGIN ATTEMPTS -------${NOCOLOR}"
echo "$ cat /var/log/auth.log"
echo -e "${BLUE}With su:${GRAY} grep \"Successful su for\"${NOCOLOR}"
cat /var/log/auth.log | grep "Successful su for" | tail -5 | cut -d ' ' -f 1-4,10-12 | column -t | grep -E --color 'root|'
echo -e "${BLUE}With password:${GRAY} grep \"Accepted password for\"${NOCOLOR}"
cat /var/log/auth.log | grep "Accepted password for" | tail -5 | cut -d ' ' -f 1-4,10,12,14,15 | column -t | grep -E --color 'root|'
echo -e "${BLUE}With key:${GRAY} grep \"Accepted publickey for\"${NOCOLOR}"
cat /var/log/auth.log | grep "Accepted publickey for" | tail -5 | cut -d ' ' -f 1-4,10,12,14,15 | column -t | grep -E --color 'root|'
echo && echo -e "${BLUE}------ FAILED LOGIN ATTEMPTS ------${NOCOLOR}"
echo "$ cat /var/log/auth.log"
echo -e "${BLUE}SSH invalid user:${GRAY} grep \"Failed password for invalid\"${NOCOLOR}"
cat /var/log/auth.log | grep "Failed password for invalid" | tail -5 | cut -d ' ' -f 1-4,12,14,16,17 | column -t
echo -e "${BLUE}SSH valid user:${GRAY} grep \"Failed password for\" | grep -v \"invalid\"${NOCOLOR}"
cat /var/log/auth.log | grep "Failed password for" | grep -v "invalid" | tail -10 | cut -d ' ' -f 1-4,10,12,14,15 | column -t
echo -n $(cat /var/log/auth.log | grep "Failed password" | wc -l)
echo " failed login attempts by SSH this week."
echo -e "${BLUE}Su:${GRAY} grep \"FAILED su\"${NOCOLOR}"
cat /var/log/auth.log | grep "FAILED su" | tail -10 | cut -d ' ' -f 1-4,9-11 | column -t | grep -E --color 'root|'
echo && echo -e "${BLUE}------ BANNED IPs ------${NOCOLOR}"
echo "$ iptables -S"
echo "$ geoiplookup [IP]"
iptables -S | grep REJECT | cut -d ' ' -f4 | cut -d '/' -f1 | xargs -I % sh -c 'echo -n "%:"; echo -n $(cat /var/log/auth.log | grep "Failed password" | grep % | wc -l) attempts this week:; geoiplookup %' {} | cut -d ':' -f 1-2,4 | column -t -s ':'
echo -n "Total: "
echo $(iptables -S | grep REJECT | wc -l)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment