要扫描指定IP范围内的8006端口,并找到有HTTPS服务且是登录页面的内网IP,我们需要使用curl
命令来测试每个IP的8006端口是否提供HTTPS服务,并检查返回的内容是否是登录页面。
#!/bin/bash
# 定义起始和结束IP地址
start_ip="192.168.1.1"
end_ip="192.168.1.254"
# 定义PVE登录页面的关键词
login_keyword="Proxmox Virtual Environment"
# 循环遍历IP地址范围
for ((i=1; i<=254; i++))
do
ip="${start_ip%.*}.$i" # 构建当前的IP地址
# 使用curl连接测试,超时时间设置为5秒
curl_output=$(curl -s -m 5 -k "https://$ip:8006" | grep -i "$login_keyword")
# 如果返回内容包含登录页面的关键词,输出该IP地址
if [[ ! -z "$curl_output" ]]; then
echo "IP地址 $ip 的8006端口有HTTPS服务并且是登录页面"
fi
done