bt_iis_log.sh
#!/bin/bash
#状态码
for code in \
100 101 \
200 201 202 203 204 205 206 \
300 301 302 303 304 305 306 307 \
400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 \
500 501 502 503 504 505 ;do
#状态码分析逻辑
for log in `find . -type f -name "*.log"` ;do
echo "分析状态码 $code $log $i"
cat $log | grep -E "\- $code" > $log.$code.txt
echo "清理空文件"
if [ ! -s $log.$code.txt ] ;then rm -f $log.$code.txt ; fi
echo "已清理空文件 $log.$code.txt"
done
done
#UA分析逻辑
ua=(Macintosh Windows compatible iPad iPod iPhone Android Linux Ubuntu Debian Kali x86 X11 Symbian Java Wayland Unknown)
for u in ${ua[*]}; do
echo $u
for txt in `find . -type f -name "*.txt"` ;do
echo -e "$txt \n分析 $u ua客户端"
cat $txt | grep $u > $txt.$u.txt
echo "清理空文件"
if [ ! -s $txt.$u.txt ] ;then rm -f $txt.$u.txt ; fi
done
done
#蜘蛛分析逻辑
spider=(Googlebot Baiduspider TwitterBot Bytespider bingbot Linespider AhrefsBot PetalBot BLEXBot DataForSeoBot DotBot DuckDuckGo MagiBot MojeekBot SemrushBot SurdotlyBot KomodiaBot Sogou YisouSpider 360Spider msnbot yandex)
for s in ${spider[*]}; do
echo $s
for txt in `find . -type f -name "*.txt"` ;do
echo -e "$txt \n分析 $s 蜘蛛行为"
cat $txt | grep $s > $txt.$s.txt
echo "清理空文件"
if [ ! -s $txt.$s.txt ] ;then rm -f $txt.$s.txt ; fi
done
done
#根据ip归类蜘蛛
for txt in `find . -type f -name "*.txt"` ;do
echo "分析 $txt 访问者ip情况"
for ip in `cat $txt | awk '{print $9}' | sort -n | uniq` ;do
echo "$txt 归类 $ip 访问行为"
cat $txt | grep $ip > $txt.$ip.txt
done
done
最后更新于