LinuxSir.cn,穿越时空的Linuxsir!

 找回密码
 注册
搜索
热搜: shell linux mysql
查看: 962|回复: 2

一个简单的bash+wget代 理搜索器

[复制链接]
发表于 2010-7-18 09:53:04 | 显示全部楼层 |阅读模式
#/bin/sh
ipfile="ip.txt"
lastipfile="lastip.txt"
port=(808 3128 8080)
web="www.baidu.com"
timeout=3
timetry=1
if [ -n $1 ];then
ip[0]=$1
else
ip[0]=`tail -n 1 $lastipfile`
fi
tip=${ip[0]}
for (( i=1;i<=4;i++ ));do
ip=${tip/*.}
tip=${tip%.*}
done

echo Enter q/Q for exit
while read -t 1 -n 1 q;
[ "$q" != "q" ] && [ "$q" != "Q" ];do
for (( i=1;i<=4;i++ ));do
tip=${ip}
ip=$[tip+1]
if [ ${ip} -lt 255 ];then
break
fi
ip=1
if [ $i -eq 5 ];then
echo finished search
exit
fi
done
ip[0]=${ip[4]}.${ip[3]}.${ip[2]}.${ip[1]}
echo ${ip[0]} > $lastipfile
ping -q -c 1 ${ip[0]}>/dev/null
if [ $? -ne 0 ];then
echo ${ip[0]} is poweroff
else
i=0
while [ -n "${port}" ];do
export http_proxy=${ip[0]}{port}
echo $http_proxy
wget -q -t $timetry -T $timeout -w $timeout $web
if [ $? -eq 0 ];then
echo $ip{port} >> $ipfile
fi
i=$[i+1]
done
fi
done
发表于 2010-7-19 16:02:50 | 显示全部楼层
解释一下这是做什么的??
回复 支持 反对

使用道具 举报

 楼主| 发表于 2010-7-19 21:07:42 | 显示全部楼层
通过wget测试www.baidu.com是否可以连接,来判断某段IP地址是否开启了808 3128 8080端口的代 理功能
可以这样命令
1)
bash proxysearch.sh 172.16.1.2
2)
echo 172.16.1.2 > lastipfile.txt
bash proxysearch.sh
搜索ip地址为172.16.1.2后的机器是否开启了http代 理功能,代 理端口是808 3128 8080中的哪一个
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

快速回复 返回顶部 返回列表