Install ngrep, and do something like
#!/bin/bash while [ 1 -eq 1 ]; do ngrep -p -q -n 1 -W none -d eth0 "Authorization: Basic [^ ]+" port 80 | \ while read line; do X=$(echo $line| sed -rn 's/.*Authorization: Basic ([^\.\[]+).*/\1/p') if [ ! -z "$" ]; then U=$(echo $DATA |base64 -d 2>/dev/null| cut -d: -f1) case "$" in john) tom) dick) harry) echo "Vendor $ login " | YOUR_ALERT_OR_MAIL_APP ;; *) # do nothing ;; esac fi done done
You could externalise the user names, or combine with AuthGroupFile or similar to only alert for users in a specific group. You can get the remote IP from the $line variable.
ngrep is at: http://ngrep.sourceforge.net/
Obviously it won't work for https, but it has the advantage of working across all vhosts regardless of logging configurations etc
Edit: improved