Chinaunix首页 | 论坛 | 博客
  • 博客访问: 2824809
  • 博文数量: 587
  • 博客积分: 6356
  • 博客等级: 准将
  • 技术积分: 6410
  • 用 户 组: 普通用户
  • 注册时间: 2008-10-23 10:54
个人简介

器量大者,福泽必厚

文章分类

全部博文(587)

文章存档

2019年(3)

2018年(1)

2017年(29)

2016年(39)

2015年(66)

2014年(117)

2013年(136)

2012年(58)

2011年(34)

2010年(50)

2009年(38)

2008年(16)

分类: LINUX

2012-05-15 11:59:41

写的很烂! 但可以使用!自己备份之用!
获取机器上所有的域名和其别名!
  1. [root@IDC-D-2255 bak_domain]# cat getalldomain.sh
  2. #!/bin/sh
  3. HOST_IP=`/sbin/ifconfig eth0 | grep 61.***.*** |awk '{print $2}'|awk -F: '{print $2}'`
  4. cp /vhost/Apache2Conf/httpd-vhosts.conf /vhost/bak_domain/
  5. cat /vhost/bak_domain/httpd-vhosts.conf | grep ServerAlias >/vhost/bak_domain/servername.txt
  6. sed -i -e 's/#//g' /vhost/bak_domain/servername.txt
  7. sed -i -e 's/attacked//g' /vhost/bak_domain/servername.txt
  8. sed -i -e 's/illegal//g' /vhost/bak_domain/servername.txt
  9. sed -i -e 's/muchcpu//g' /vhost/bak_domain/servername.txt
  10. sed -i -e 's/muchhttpd//g' /vhost/bak_domain/servername.txt
  11. sed -i -e 's/muchmysql//g' /vhost/bak_domain/servername.txt
  12. cat /vhost/bak_domain/servername.txt | grep "\." >/vhost/bak_domain/servernameall.txt
  13. cd /vhost/bak_domain/
  14. awk '{print $2}' /vhost/bak_domain/servernameall.txt >second.txt
  15. sed /^$/d /vhost/bak_domain/second.txt >/vhost/bak_domain/second1.txt
  16. awk '{print $3}' /vhost/bak_domain/servernameall.txt >three.txt
  17. sed /^$/d /vhost/bak_domain/three.txt >/vhost/bak_domain/three1.txt
  18. awk '{print $4}' /vhost/bak_domain/servernameall.txt >four.txt
  19. sed /^$/d /vhost/bak_domain/four.txt >/vhost/bak_domain/four1.txt
  20. awk '{print $5}' /vhost/bak_domain/servernameall.txt >five.txt
  21. sed /^$/d /vhost/bak_domain/five.txt >/vhost/bak_domain/five1.txt
  22. awk '{print $6}' /vhost/bak_domain/servernameall.txt >six.txt
  23. sed /^$/d /vhost/bak_domain/six.txt >/vhost/bak_domain/six1.txt
  24. awk '{print $7}' /vhost/bak_domain/servernameall.txt >seven.txt
  25. sed /^$/d /vhost/bak_domain/seven.txt >/vhost/bak_domain/seven1.txt
  26. awk '{print $8}' /vhost/bak_domain/servernameall.txt >eight.txt
  27. sed /^$/d /vhost/bak_domain/eight.txt >/vhost/bak_domain/eight1.txt
  28. awk '{print $9}' /vhost/bak_domain/servernameall.txt >nine.txt
  29. sed /^$/d /vhost/bak_domain/nine.txt >/vhost/bak_domain/nine1.txt
  30. awk '{print $10}' /vhost/bak_domain/servernameall.txt >ten.txt
  31. sed /^$/d /vhost/bak_domain/ten.txt >/vhost/bak_domain/ten1.txt
  32. cat /vhost/bak_domain/second1.txt >/vhost/bak_domain/domain.txt
  33. cat /vhost/bak_domain/three1.txt >>/vhost/bak_domain/domain.txt
  34. cat /vhost/bak_domain/four1.txt >>/vhost/bak_domain/domain.txt
  35. cat /vhost/bak_domain/five1.txt >>/vhost/bak_domain/domain.txt
  36. cat /vhost/bak_domain/six1.txt >>/vhost/bak_domain/domain.txt
  37. cat /vhost/bak_domain/seven1.txt >>/vhost/bak_domain/domain.txt
  38. cat /vhost/bak_domain/eight1.txt >>/vhost/bak_domain/domain.txt
  39. cat /vhost/bak_domain/nine1.txt >>/vhost/bak_domain/domain.txt
  40. cat /vhost/bak_domain/ten1.txt >>/vhost/bak_domain/domain.txt
  41. cat /vhost/bak_domain/domain.txt | sort -nr |uniq >${HOST_IP}.txt
  42. sed -i -e "s/^/$HOST_IP /g" /vhost/bak_domain/${HOST_IP}.txt
  43. rm -fr /vhost/bak_domain/second.txt /vhost/bak_domain/second1.txt /vhost/bak_domain/three.txt /vhost/bak_domain/three1.txt /vhost/bak_domain/four.txt /vhost/bak_domain/four1.txt /vhost/bak_domain/five.txt /vhost/bak_domain/five1.txt
  44. rm -fr /vhost/bak_domain/six.txt /vhost/bak_domain/six1.txt /vhost/bak_domain/seven.txt /vhost/bak_domain/seven1.txt /vhost/bak_domain/eight.txt /vhost/bak_domain/eight1.txt /vhost/bak_domain/nine.txt /vhost/bak_domain/nine1.txt /vhost/bak_domain/ten.txt /vhost/bak_domain/ten1.txt
  45. rm -fr /vhost/bak_domain/servername.txt /vhost/bak_domain/servernameall.txt /vhost/bak_domain/domain.txt
  46. rm -fr /vhost/bak_domain/httpd-vhosts.conf
获取要扫描的域名和别名:

  1. [root@IDC-D-2255 bak_domain]# cat getscandomain.sh
  2. #!/bin/sh
  3. HOST_IP=`/sbin/ifconfig eth0 | grep 61.***.*** |awk '{print $2}'|awk -F: '{print $2}'`
  4. cp /vhost/Apache2Conf/httpd-vhosts.conf /vhost/bak_domain/
  5. cat /vhost/bak_domain/httpd-vhosts.conf | grep ServerAlias | grep -v '#' >/vhost/bak_domain/servername.txt
  6. cat /vhost/bak_domain/servername.txt | grep "\." >/vhost/bak_domain/servernameall.txt
  7. cd /vhost/bak_domain
  8. awk '{print $2}' /vhost/bak_domain/servernameall.txt >second.txt
  9. sed /^$/d /vhost/bak_domain/second.txt >/vhost/bak_domain/second1.txt
  10. awk '{print $3}' /vhost/bak_domain/servernameall.txt >three.txt
  11. sed /^$/d /vhost/bak_domain/three.txt >/vhost/bak_domain/three1.txt
  12. awk '{print $4}' /vhost/bak_domain/servernameall.txt >four.txt
  13. sed /^$/d /vhost/bak_domain/four.txt >/vhost/bak_domain/four1.txt
  14. awk '{print $5}' /vhost/bak_domain/servernameall.txt >five.txt
  15. sed /^$/d /vhost/bak_domain/five.txt >/vhost/bak_domain/five1.txt
  16. awk '{print $6}' /vhost/bak_domain/servernameall.txt >six.txt
  17. sed /^$/d /vhost/bak_domain/six.txt >/vhost/bak_domain/six1.txt
  18. awk '{print $7}' /vhost/bak_domain/servernameall.txt >seven.txt
  19. sed /^$/d /vhost/bak_domain/seven.txt >/vhost/bak_domain/seven1.txt
  20. awk '{print $8}' /vhost/bak_domain/servernameall.txt >eight.txt
  21. sed /^$/d /vhost/bak_domain/eight.txt >/vhost/bak_domain/eight1.txt
  22. awk '{print $9}' /vhost/bak_domain/servernameall.txt >nine.txt
  23. sed /^$/d /vhost/bak_domain/nine.txt >/vhost/bak_domain/nine1.txt
  24. awk '{print $10}' /vhost/bak_domain/servernameall.txt >ten.txt
  25. sed /^$/d /vhost/bak_domain/ten.txt >/vhost/bak_domain/ten1.txt
  26. cat /vhost/bak_domain/second1.txt >/vhost/bak_domain/domain.txt
  27. cat /vhost/bak_domain/three1.txt >>/vhost/bak_domain/domain.txt
  28. cat /vhost/bak_domain/four1.txt >>/vhost/bak_domain/domain.txt
  29. cat /vhost/bak_domain/five1.txt >>/vhost/bak_domain/domain.txt
  30. cat /vhost/bak_domain/six1.txt >>/vhost/bak_domain/domain.txt
  31. cat /vhost/bak_domain/seven1.txt >>/vhost/bak_domain/domain.txt
  32. cat /vhost/bak_domain/eight1.txt >>/vhost/bak_domain/domain.txt
  33. cat /vhost/bak_domain/nine1.txt >>/vhost/bak_domain/domain.txt
  34. cat /vhost/bak_domain/ten1.txt >>/vhost/bak_domain/domain.txt
  35. cat /vhost/bak_domain/domain.txt | sort -nr |uniq |grep -v "\-auditing" >${HOST_IP}_scan_begin.txt
  36. sed -i -e "s/^www\.//g" ${HOST_IP}_scan_begin.txt
  37. rm -fr /vhost/bak_domain/second.txt /vhost/bak_domain/second1.txt /vhost/bak_domain/three.txt /vhost/bak_domain/three1.txt /vhost/bak_domain/four.txt /vhost/bak_domain/four1.txt /vhost/bak_domain/five.txt /vhost/bak_domain/five1.txt
  38. rm -fr /vhost/bak_domain/six.txt /vhost/bak_domain/six1.txt /vhost/bak_domain/seven.txt /vhost/bak_domain/seven1.txt /vhost/bak_domain/eight.txt /vhost/bak_domain/eight1.txt /vhost/bak_domain/nine.txt /vhost/bak_domain/nine1.txt /vhost/bak_domain/ten.txt /vhost/bak_domain/ten1.txt
  39. sed -i -e "s/^/$HOST_IP /g" /vhost/bak_domain/${HOST_IP}_scan_begin.txt
  40. cat /vhost/bak_domain/${HOST_IP}_scan_begin.txt | sort -nr |uniq > ${HOST_IP}_scan_final.txt
  41. mv /vhost/bak_domain/${HOST_IP}_scan_final.txt /vhost/bak_domain/${HOST_IP}_scan.txt
  42. rm -fr /vhost/bak_domain/{httpd-vhosts.conf,domain.txt,servername.txt,servernameall.txt}
  43. rm -fr /vhost/bak_domain/${HOST_IP}_scan_begin.txt
上传到一个ftp机器上,由上面的脚本统一处理:上传的脚本如下:

  1. [root@IDC-D-2255 bak_domain]# cat put.sh
  2. #!/bin/sh
  3. HOST_IP=`/sbin/ifconfig eth0 | grep 61.***.*** |awk '{print $2}'|awk -F: '{print $2}'`
  4. cd /vhost/bak_domain
  5. sh /vhost/bak_domain/getalldomain.sh
  6. sleep 30
  7. sh /vhost/bak_domain/getscandomain.sh
  8. sleep 30
  9. ftp -v -n 10.4.3.184 << END
  10. user wang**** qqq***,.
  11. binary
  12. hash
  13. cd /var/ftp
  14. lcd /vhost/bak_domain
  15. prompt
  16. mput ${HOST_IP}.txt ${HOST_IP}_scan.txt
  17. bye
  18. END
在184机器上,将所有的txt合成一个txt文件:

  1. #!/bin/bash
  2. file_dir=/var/ftp
  3. cd $file_dir
  4. Server_ip=`cat scanlist.txt`
  5. sleep 10
  6. rm $file_dir/domain_name_xin***_scan.txt
  7. for i in ${Server_ip}
  8. do
  9. cat $file_dir/$i >> domain_name_xin***_scan.txt
  10. done

  11. #zhongq** domain name
  12. Server_ip2=`ls 58.***.***`
  13. sleep 10
  14. rm $file_dir/domain_name_zhong.txt
  15. for i in ${Server_ip2}
  16. do
  17. cat $file_dir/$i >> domain_name_zhong.txt
  18. done
  19. cd $file_dir
  20. Server_ip2=`cat domainlist.txt`
  21. sleep 10
  22. rm $file_dir/All_domain_name_xin***.txt
  23. for i in ${Server_ip2}
  24. do
  25. cat $file_dir/$i >> All_domain_name_xin***.txt
  26. done
  27. cd $file_dir
  28. Server_ip3=`cat hongkongmachinelist.txt`
  29. sleep 10
  30. rm $file_dir/hongkong_domain_name_xin***.txt
  31. for i in ${Server_ip3}
  32. do
  33. cat $file_dir/$i >> hongkong_domain_name_xin***.txt
  34. done

  1. 相关list如下:这个地方写的有点死,不太好!
  2. IDC226[*****][1039] cat hongkongmachinelist.txt
  3. 175.***.***.162.txt
  4. 175.***.***.165.txt
  5. 175.***.***.183.txt
  6. IDC226[*****][1040] cat scanlist.txt
  7. 61.***.***.150_scan.txt
  8. 61.***.***.160_scan.txt
  9. 61.***.***.165_scan.txt
  10. 61.***.***.170_scan.txt
  11. 61.***.***.175_scan.txt
  12. 61.***.***.153_scan.txt
  13. 61.***.***.154_scan.txt
  14. 61.***.***.155_scan.txt
  15. 61.***.***.156_scan.txt
  16. 114.***.***.100_scan.txt
  17. 114.***.***.104_scan.txt
  18. IDC226[*****][1041] cat domainlist.txt
  19. 61.***.***.150.txt
  20. 61.***.***.160.txt
  21. 61.***.***.165.txt
  22. 61.***.***.170.txt
  23. 61.***.***.175.txt
  24. 61.***.***.153.txt
  25. 61.***.***.154.txt
  26. 61.***.***.155.txt
  27. 61.***.***.156.txt
  28. 114.***.***.100.txt
  29. 114.***.***.104.txt
发邮件部分:

  1. IDC-D-909[****][102] cat /usr/local/xncenter/confcenter/scripts/sendmail.sh
  2. #!/bin/sh
  3. ftp -v -n 61.***.***.184 <
  4. user wangy**** qqq***
  5. binary
  6. hash
  7. lcd /usr/local/xncenter/confcenter/scripts
  8. prompt
  9. mget domain_name_*.txt
  10. mget All_domain_name_*.txt
  11. mget hongkong_domain_name_****.txt
  12. bye
  13. END
  14. cd /usr/local/xncenter/confcenter/scripts
  15. /usr/local/bin/mutt -s "域名统计" -a domain_name_****_scan.txt -a All_domain_name_****.txt liuxiaojie@abc.com < /usr/local/xncenter/confcenter/scripts/content.txt
  16. /usr/local/bin/mutt -s "香港域名统计" -a hongkong_domain_name_****.txt liuxiaojie@****.com < /usr/local/xncenter/confcenter/scripts/content.txt
  17. /usr/local/bin/mutt -s "中***域名统计" -a domain_name_zhong.txt liuxiaojie@****.com < /usr/local/xncenter/confcenter/scripts/content_zhong.txt

阅读(1387) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~