Last active
March 15, 2019 16:52
-
-
Save raresteak/ea537dc433c8f00cbd09c20e02c6c4fe to your computer and use it in GitHub Desktop.
Enumerate users with sudo access on a system
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
############################################################################### | |
#Script Name : enumerate_sudo_users | |
#Description : Check which users on system can sudo with some form of | |
# privileged access. | |
#Author : Github raresteak | |
############################################################################### | |
[[ "$TRACE" ]] && set -x | |
[[ "$HEADER" ]] && echo "UserName,SystemName" # Useful for putting in a spreadsheet | |
main() { | |
if [[ $EUID -ne 0 ]]; then | |
echo "This script must be run as root" | |
exit 1 | |
fi | |
for user in $(compgen -u); do | |
(((sudo -l -U $user | grep "^User") | grep -v "not allowed") | awk {'print $2","$9'} ) | sed "s/://g" | |
done | |
} | |
main |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Run script as root.
Sample output is username comma servername