-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2336 from biot-2131/T1110.001_II
T1110.001 updated two tests
- Loading branch information
Showing
2 changed files
with
104 additions
and
70 deletions.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
#!/bin/bash | ||
|
||
# This script loops through the PASSWORDS array passing each P -> password as | ||
# --stdin to the "sudo whoami" command, then checks the resulting output for the | ||
# username root to discover if the sudo command was passed the correct password | ||
# or not. Note: It assumes that the current user is a member of the sudo or | ||
# wheel group and can run sudo commands if the correct password is given. | ||
|
||
# Manual testing | ||
# :~$ P="one"; sudo -k && echo "$P" |sudo -S whoami | ||
# [sudo] password for {username}: Sorry, try again. | ||
# [sudo] password for {username}: | ||
# sudo: no password was provided | ||
# sudo: 1 incorrect password attempt | ||
# :~$ P="password123"; sudo -k && echo "$P" |sudo -S whoami | ||
# [sudo] password for {username}: root | ||
|
||
PASSWORDS=(one two three password123 five) | ||
touch /tmp/temp_file | ||
for P in ${PASSWORDS[@]} | ||
do | ||
sudo -k && echo "$P" |sudo -S whoami &>/tmp/temp_file | ||
if grep --quiet "root" /tmp/temp_file | ||
then | ||
echo "$(date +'%Y-%m-%dT%T%Z') exit: $? FOUND: sudo => $P" | ||
break | ||
else | ||
echo "$(date +'%Y-%m-%dT%T%Z') exit: $? TRIED: $P" | ||
fi | ||
sleep 2 | ||
done | ||
rm /tmp/temp_file |