I want to write a script that allows me to pass a password to the su
command. The reason for this is to automate the process of logging into root from nonroot account. From my basic understanding of security, I know the dangers of this. I still need this to try to crack the root user password by reading passwords from a file.
I have heard about using the expect
command to automate interactions but I do not know how it works, or if it is applicable in this situation. Any information about using expect
would be greatly appreciated.
Please note that sudo
is not an option as my user is not on the sudoer list.
Things I've tried
- Passing the password in using pipes
Didn't work because of "su must be used from terminal"
type error
- Passing the password using echo
Whatever was echoed would simply show up after the password was entered
echo "passwd" | sudo -S your_command
?sudo
is not an option as my user is not on the sudoer list." . :)