我需要制作一个bash脚本,该脚本将根据扫描的地址为我提供对或错的列表。
现在我有这个简单的脚本
#!/bin/bash
input="/root/file1"
input2="/root/file2"
paste -d, file{1,2}.txt | while IFS=, read x y;
do nmap -sV --version-light --script ssl-poodle -p $y $x
if something(detects its vulnerable)
echo "true">>file3.txt
else (not vulnerable)
echo "false">>fie3.txt
done
易受攻击时,nmap返回的信息
ip的Nmap扫描报告
主机启动(延迟0.044秒)。
港口国服务版本
port / tcp open ssl / http Microsoft IIS
| ssl-贵宾犬:
|弱点:
| SSL POODLE信息泄漏
|状态:脆弱
有没有一种方法可以检测到弱势一词,或者最好的方法是什么?
最佳答案
#!/bin/bash
input="/root/file1"
input2="/root/file2"
paste -d, file{1,2}.txt | while IFS=, read x y;
do
nmap_output="$(nmap -sV --version-light --script ssl-poodle -p $y $x)"
if [ -n "$(echo "$nmap_output" | grep VULNERABLE)" ]
echo "true">>file3.txt
else
echo "false">>fie3.txt
done
说明
用这条线
nmap_output="$(nmap -sV --version-light --script ssl-poodle -p $y $x)"
您将
nmap
执行的输出保存到$nmap_output
变量。并且,有了这个:
if [ -n "$(echo "$nmap_output" | grep VULNERABLE)" ]
您正在检查nmap输出是否包含单词VULNREABLE。通过grep Nmap输出并仅保持VULNERABLE字行来实现。然后,它检查grepped的字符串是否不为空(
-n
开头的if
开关)。