2019-05-21 08:01:14 -04:00
|
|
|
#!/bin/bash
|
|
|
|
## Copyright © 2015 Bret Human
|
2020-11-15 04:42:39 -05:00
|
|
|
## https://cynop.me/
|
2019-05-21 08:01:14 -04:00
|
|
|
##
|
|
|
|
## Documentation at:
|
2020-11-15 04:42:39 -05:00
|
|
|
## https://psi.cynop.me/Caffarius/trackdown
|
2019-05-21 08:01:14 -04:00
|
|
|
##
|
|
|
|
## For questions or comments write:
|
2020-11-15 04:42:39 -05:00
|
|
|
## info@cynop.me
|
2019-05-21 08:01:14 -04:00
|
|
|
#
|
|
|
|
# Logs into every server and reports if a user is on it
|
|
|
|
#
|
|
|
|
# Prereq: Next to nothing. SSH? Bash?
|
|
|
|
#
|
|
|
|
# If you don't have an ssh key in your ~/.ssh folder this
|
|
|
|
# is going to be a loooooooooooooooooooooooooooooooooooooo
|
|
|
|
# ooooooooooooooooooooooooooooooooooooong process for you.
|
|
|
|
|
|
|
|
usage () {
|
|
|
|
echo "usage: trackdown.sh -n username"
|
|
|
|
echo "You must specify a user to search for."
|
|
|
|
exit 1
|
|
|
|
}
|
|
|
|
|
|
|
|
# Get the username to hunt down.
|
|
|
|
while getopts "n:" option; do
|
|
|
|
case $option in
|
|
|
|
n) user=${OPTARG};;
|
|
|
|
esac
|
|
|
|
done
|
|
|
|
|
|
|
|
if [ -z "$user" ]; then
|
|
|
|
usage
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Clean up any previous runs...
|
|
|
|
rm foundPlaces > /dev/null 2>&1
|
|
|
|
|
|
|
|
# File containing a list of servers to hit:
|
|
|
|
list="serverList"
|
|
|
|
|
|
|
|
echo "Press CTRL-C to skip a server, CTRL-D to quit the script."
|
|
|
|
echo ""
|
|
|
|
|
|
|
|
# Loop ALL the servers!
|
|
|
|
for thisHereServer in $(< "$list") ; do
|
|
|
|
trap "echo CTRL-C was pressed" 2
|
|
|
|
trap "echo CTRL-D was pressed" 1
|
|
|
|
|
|
|
|
ssh $thisHereServer "id $user | grep uid" > /dev/null 2>&1 &&
|
|
|
|
echo "$user found on $thisHereServer" &&
|
|
|
|
echo "$user found on $thisHereServer" >> foundPlaces ||
|
|
|
|
echo "Nothing on $thisHereServer"
|
|
|
|
done
|