Skip to content

Instantly share code, notes, and snippets.

@cballou
Created December 17, 2013 17:10
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save cballou/8008588 to your computer and use it in GitHub Desktop.
Save cballou/8008588 to your computer and use it in GitHub Desktop.
Bash script to output recent activity in /var/log/auth.log which may be useful for finding nefarious users.
#!/bin/bash
#####################################################
# To run, simply: chmod +x medusa.sh && ./medusa.sh #
#####################################################
# Successful publickey connections
echo '==== Successful SSH Public Key Connections ===='
CONNECTIONS=`grep "sshd.*Accepted publickey" /var/log/auth.log`
while read -r line; do
echo $line;
done <<< "$CONNECTIONS"
echo ''
# Watch for sudo actions
echo '==== Recent Sudo Actions ===='
SUDOS=`grep "sudo.*TTY" /var/log/auth.log`
while read -r line; do
echo $line;
done <<< "$SUDOS"
echo ''
# Show failed brute force attempts
echo '==== Potential Brute Force Attempts ===='
BRUTE=`grep sshd.\*Failed /var/log/auth.log`
while read -r line; do
echo $line;
done <<< "$BRUTE"
echo ''
# Potential port scanners
echo '==== Potential Port Scanners ===='
SCANNERS=`grep sshd.*Did /var/log/auth.log`
while read -r line; do
echo $line;
done <<< "$SCANNERS"
echo ''
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment