## 密码列表,空格分隔
pwd_lists="passwd1 passwd2 passwd3 passwd4 passwd5"
## 记录找到的密码
psss_history_file="pwd_history.txt"
funTstPass(){
for pwd_list in ${pwd_lists}
do
sshpass -p ${pwd_list} ssh -o StrictHostKeyChecking=no centos@${test_ip} "exit" || sshpass -p ${pwd_list} ssh -o StrictHostKeyChecking=no root@${test_ip} "exit"
if [ $? -eq 0 ];then
echo -e "\n[ Success ] IP=\"$test_ip\" password=\"${pwd_list}\" "
echo "$test_ip ${pwd_list}" >> ${psss_history_file}
break
else
echo "[ Failure ] password=\"${pwd_list}\""
fi
done
}
cat hostip.txt | while read rows
do
test_ip=$rows
funTstPass
done:
+ pwd_lists="passwd1 passwd2 passwd3 passwd4 passwd5"
+ psss_history_file=pwd_history.txt
+ cat hostip.txt
+ read rows
+ test_ip=10.0.0.50
+ funTstPass
+ for pwd_list in ${pwd_lists}
+ sshpass -p 'passwd1' ssh -o StrictHostKeyChecking=no centos@10.0.0.50 exit
Permission denied, please try again.
+ sshpass -p 'passwd1' ssh -o StrictHostKeyChecking=no root@10.0.0.50 exit
+ '[' 0 -eq 0 ']'
+ echo -e '\n[ Success ] IP="10.0.0.50" password="passwd1" '
[ Success ] IP="10.0.0.50" password="passwd1"
+ echo '10.0.0.50 passwd1'
+ break
+ read rows
这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。
V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。
V2EX is a community of developers, designers and creative people.