bash - 有什么方法可以在提到的脚本中只列出带有“YES”的密码
问题描述
有什么方法可以使用下面提到的脚本仅列出带有“YES”的密码。脚本看起来有效,但它提供了巨大的列表,包括密码 YES 和 NO。如果我们可以通过在脚本中使用 grep 过滤 o/p (echo $result) 但不确定如何通过,那就太好了。感谢这方面的帮助,因为我必须运行脚本并查找在 Prod 服务器中启用的密码
#!/usr/bin/env bash
# OpenSSL requires the port number.
SERVER=$1
DELAY=1
ciphers=$(openssl ciphers 'ALL:eNULL' | sed -e 's/:/ /g')
echo Obtaining cipher list from $(openssl version).
for cipher in ${ciphers[@]}
do
echo -n Testing $cipher...
result=$(echo -n | openssl s_client -cipher "$cipher" -connect $SERVER 2>&1)
if [[ "$result" =~ ":error:" ]] ; then
error=$(echo -n $result | cut -d':' -f6)
echo NO \($error\)
else
if [[ "$result" =~ "Cipher is ${cipher}" || "$result" =~ "Cipher :" ]] ; then
echo YES
else
echo UNKNOWN RESPONSE
echo $result
fi
fi
sleep $DELAY
done
解决方案
推荐阅读
- xcode - 需要了解 Xcode 的神秘崩溃报告
- python - 在 Python 中访问类之外的对象
- python - 转 `1+1==3` 在 Python 上返回 True
- javascript - javascript在初始化之前无法访问类
- python - 如何将字符串转换为操作?
- python - Calculate time difference in a Python dictionary
- javascript - 为什么我的 npm 包的所有文件都安装在 node_modules 中?
- r - 使用“未来”进行并行化的速度增益不佳
- pdf - Ghostscript 虚拟 PDF 打印机
- rust - 无需特征导入即可确保 API 一致性