“第 10 行:敏锐:找不到命令”是什么意思?我的 if 语句的意思是什么?
这是我的脚本:
#!/bin/bash
#read password.lst, hash each word, store in variable and check it against our hash
target_hash="14a4b8e7ae966e72a3a2c51633bfabc6"
password_lst=/usr/share/metasploit-framework/data/wordlists/password.lst
while IFS= read -r password
do
hashed_password=printf $password | /usr/bin/md5sum | cut -d " " -f 1
if [ $hashed_password == $target_hash ]
then
printf "==========================\n"
printf "Found Password: $password\n"
printf "==========================\n"
break
else
printf "Password: $password\n"
printf "Target hash: $target_hash\n"
printf "Current Hash: $hashed_password\n"
fi
done < "$password_lst"
目的是对文件 password.lst
中的每个单词进行哈希处理,对照 target_hash
检查它,如果正确,则输出正确的密码,直到循环到达那里,输出它当前正在处理的哈希值。
我在第 10 行和第 12 行不断收到错误。有谁知道可能出了什么问题以及如何修复它?
Here's my script:
#!/bin/bash
#read password.lst, hash each word, store in variable and check it against our hash
target_hash="14a4b8e7ae966e72a3a2c51633bfabc6"
password_lst=/usr/share/metasploit-framework/data/wordlists/password.lst
while IFS= read -r password
do
hashed_password=printf $password | /usr/bin/md5sum | cut -d " " -f 1
if [ $hashed_password == $target_hash ]
then
printf "==========================\n"
printf "Found Password: $password\n"
printf "==========================\n"
break
else
printf "Password: $password\n"
printf "Target hash: $target_hash\n"
printf "Current Hash: $hashed_password\n"
fi
done < "$password_lst"
The purpose is to hash each word in the file password.lst
, check it against the target_hash
and if it's correct, output the correct password and until the loop gets there, output what hash it's currently working on.
I keep getting errors in lines 10 and 12. Does anyone know what could be wrong and how I can fix it?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我认为这行代码并不像您想象的那样工作:
shell 将此视为:
hashed_password
设置为printf
,然后运行 $password< /code> (即展开变量并将值作为命令运行)并设置该环境变量
/usr/bin/md5sum
cut ....
我认为您想要的是评估整个事情并将结果分配给
hashed_pasword
?如果是这样,您需要使用这种形式:所以:
I think this line doesn't work the way you might think:
The shell sees this as:
hashed_password
toprintf
and then run$password
(that is, expand the variable and run the value as a command) with that env vars set/usr/bin/md5sum
cut ....
What I think you want is to evaluate the whole thing and assign the result into
hashed_pasword
? If so, you need to use this form:So: