仓酷云

 找回密码
 立即注册
搜索
热搜: 活动 交友 discuz
查看: 583|回复: 7
打印 上一主题 下一主题

[shell编程] 来一发shell步伐猎取互联网公司web server 信息

[复制链接]
变相怪杰 该用户已被删除
跳转到指定楼层
楼主
发表于 2015-1-14 20:14:45 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有帐号?立即注册

x
如果您觉得本篇CentOSLinux教程讲得好,请记得点击右边漂浮的分享程序,把好文章分享给你的好朋友们!一.成绩来历
想失掉以后互联网公司的webserver是哪一个范例的?(ApacheNginxLighttpd)以是编写此步伐。次要统计百度Googlealibabatencent(qq)taobaorenrensina京东凡客yahoo昌大网易搜狐畅游等公司的webserver。固然,也有大概失掉的是反向代办署理办事器。这得详细看公司的背景体系架构了。

二.步伐
1.源码
viab.sh

[c-sharp]viewplaincopyhttp://static.blog.csdn.net/scripts/ZeroClipboard/ZeroClipboard.swf



  • #!/bin/bash
  • #authorlongxibendi
  • #bloghttp://blog.csdn.net/longxibendi
  • #functiongetthewebserversinformationofcompanies
  • if[-e/tmp/web_server.log];then
  • rm-f/tmp/web_server.log
  • fi
  • if[-e/tmp/ab.log];then
  • rm-f/tmp/ab.log
  • fi
  • forcompany_nameintaobao360buydangdangvanclmbaobaoalibaba谷歌百度yahoosinasohuren
  • renchangyouwanmeisdo126163139
  • do
  • {
  • ab-n1-c1http://www.${company_name}.com/index.html|tee/tmp/ab_${company_name}.log2>&1
  • if[$?-eq0];then
  • printf"%15s,%20s/n""${company_name}.com","`cat/tmp/ab_${company_name}.log|grep"Server
  • Software"`">>/tmp/web_server.log
  • fi
  • sleep2
  • }&
  • done
  • wait
  • echo"ItisOK"



2.申明&实行步伐
经由过程ab网站主页,然后把失掉信息重定向到一个文件中,然后再从该文件中过滤信息,一致纪录到/tmp/web_server.log中

[c-sharp]viewplaincopyhttp://static.blog.csdn.net/scripts/ZeroClipboard/ZeroClipboard.swf



  • [root@localhostDesktop]#chmoda+xab.sh
  • [root@localhostDesktop]#./ab.sh>/dev/null




3.实行了局,经由过程检察/tmp/web_server.log失掉网站webserver信息(有多是反向代办署理办事器)

[c-sharp]viewplaincopyhttp://static.blog.csdn.net/scripts/ZeroClipboard/ZeroClipboard.swf



  • [root@localhostDesktop]#cat/tmp/web_server.log
  • 360buy.com,,ServerSoftware:jdws
  • taobao.com,,ServerSoftware:nginx
  • mbaobao.com,,ServerSoftware:
  • 百度.com,,ServerSoftware:BWS/1.0
  • renren.com,,ServerSoftware:nginx/0.7.67
  • 谷歌.com,,ServerSoftware:gws
  • changyou.com,,ServerSoftware:Apache
  • sina.com,,ServerSoftware:Apache/2.0.63
  • alibaba.com,,ServerSoftware:Apache/2.2.15
  • 126.com,,ServerSoftware:Apache
  • vancl.com,,ServerSoftware:Microsoft-IIS/6.0
  • wanmei.com,,ServerSoftware:nginx
  • sdo.com,,ServerSoftware:SVS
  • sohu.com,,ServerSoftware:SWS
  • dangdang.com,,ServerSoftware:nginx/0.7.61
  • yahoo.com,,ServerSoftware:YTS/1.20.0
  • 139.com,,ServerSoftware:Apache
  • 163.com,,ServerSoftware:nginx



4.复杂剖析了局
sohu.com用的webserver是SWS(这个有多是本人开辟的,有多是用的SWS)
谷歌.com用的webserver是gws
百度.com用的webserver是BWS
taobao.com用的webserver是nginx
另有良多,看3的了局


三.伪多线程与单历程剧本对照
1.先看单历程的步伐
vi1_ab.sh

[c-sharp]viewplaincopyhttp://static.blog.csdn.net/scripts/ZeroClipboard/ZeroClipboard.swf



  • #!/bin/bash
  • #authorlongxibendi
  • #bloghttp://blog.csdn.net/longxibendi
  • #functiongetthewebserversinformationofcompanies
  • if[-e/tmp/web_server.log];then
  • rm-f/tmp/web_server.log
  • fi
  • if[-e/tmp/ab.log];then
  • rm-f/tmp/ab.log
  • fi
  • forcompany_nameintaobao360buydangdangvanclmbaobaoalibaba谷歌百度yahoosinasohurenrenchangyouwanmeisdo126163139
  • do
  • #{
  • ab-n1-c1http://www.${company_name}.com/index.html|tee/tmp/ab.log2>&1
  • if[$?-eq0];then
  • printf"%10s,%20s/n""${company_name}.com","`cat/tmp/ab.log|grep"ServerSoftware"`">>/tmp/web_server.log
  • fi
  • #sleep3
  • #}&
  • done
  • wait
  • echo"ItisOK"



2.申明
下面的单历程步伐,只用一个历程完成,很复杂就不注释了。详细统计webserver完成与伪多线程步伐相似

3.两步伐实行效力对照

[c-sharp]viewplaincopyhttp://static.blog.csdn.net/scripts/ZeroClipboard/ZeroClipboard.swf



  • [root@localhostDesktop]#time-p./1_ab.sh>/dev/null
  • real12.54
  • user0.03
  • sys1.74
  • [root@localhostDesktop]#time-p./ab.sh>/dev/null
  • real11.20
  • user0.07
  • sys2.00



4.剖析
能够看到伪多线程步伐分明比单历程步伐快
实在,假如在实行ab.sh的时分能够ps-ef|grepab.sh一下,就会发明分歧了

<divclass="dp-highlighterbg_c-sharp"style="font-family:Consolas,CourierNew,Courier,mono,serif;background-color:rgb(231,229,220);width:700.9166870117188px;overflow:auto;padding-top:1px;margin:18px0px!important;">[c-sharp]viewplaincopyhttp://static.blog.csdn.net/scripts/ZeroClipboard/ZeroClipboard.swf


<olclass="dp-c"start="1"style="margin:0px0px1px45px!important;padding-right:0px;padding-left:0px;border:none;list-style-position:initial;list-style-image:initial;background-color:rgb(255,255,255);color:rgb(92,92,92);"><liclass="alt"style="margin:0px!important;padding:0px3px0px10px!important;border-style:nonenonenonesolid;border-left-width:3px;border-left-color:rgb(108,226,108);list-style:decimal-leading-zerooutside;color:inherit;line-height:18px;">[root@localhost~]#ps-ef|grepab.sh<listyle="margin:0px!important;padding:0px3px0px10px!important;border-style:nonenonenonesolid;border-left-width:3px;border-left-color:rgb(108,226,108);list-style:decimal-leading-zerooutside;background-color:rgb(248,248,248);line-height:18px;">root268465761102:15pts/100:00:00/bin/bash./ab.sh<liclass="alt"style="margin:0px!important;padding:0px3px0px10px!important;border-style:nonenonenonesolid;border-left-width:3px;border-left-color:rgb(108,226,108);list-style:decimal-leading-zerooutside;color:inherit;line-height:18px;">root2685426846002:15pts/100:00:00/bin/bash./ab.sh<listyle="margin:0px!important;padding:0px3px0px10px!important;border-style:nonenonenonesolid;border-left-width:3px;border-left-color:rgb(108,226,108);list-style:decimal-leading-zerooutside;background-color:rgb(248,248,248);line-height:18px;">root2685726846002:15pts/100:00:00/bin/bash./ab.sh<liclass="alt"style="margin:0px!important;padding:0px3px0px10px!important;border-style:nonenonenonesolid;border-left-width:3px;border-left-color:rgb(108,226,108);list-style:decimal-leading-zerooutside;color:inherit;line-height:18px;">root2685926846002:15pts/100:00:00/bin/bash./ab.sh<listyle="margin:0px!important;padding:0px3px0px10px!important;border-style:nonenonenonesolid;border-left-width:3px;border-left-color:rgb(108,226,108);list-style:decimal-leading-zerooutside;background-color:rgb(248,248,248);line-height:18px;">root2686526846002:15pts/100:00:00/bin/bash./ab.sh<liclass="alt"style="margin:0px!important;padding:0px3px0px10px!important;border-style:nonenonenonesolid;border-left-width:3px;border-left-color:rgb(108,226,108);list-style:decimal-leading-zerooutside;color:inherit;line-height:18px;">root2687126846002:15pts/100:00:00/bin/bash./ab.sh<listyle="margin:0px!important;padding:0px3px0px10px!important;border-style:nonenonenonesolid;border-left-width:3px;border-left-color:rgb(108,226,108);list-style:decimal-leading-zerooutside;background-color:rgb(248,248,248);line-height:18px;">root2687426846002:15pts/100:00:00/bin/bash./ab.sh<liclass="alt"style="margin:0px!important;padding:0px3px0px10px!important;border-style:nonenonenonesolid;border-left-width:3px;border-left-color:rgb(108,226,108);list-style:decimal-leading-zerooutside;color:inherit;line-height:18px;">root2687526846002:15pts/100:00:00/bin/bash./ab.sh<listyle="margin:0px!important;padding:0px3px0px10px!important;border-style:nonenonenonesolid;border-left-width:3px;border-left-color:rgb(108,226,108);list-style:decimal-leading-zerooutside;background-color:rgb(248,248,248);line-height:18px;">root2688626846002:15pts/100:00:00/bin/bash./ab.sh<liclass="alt"style="margin:0px!important;padding:0px3px0px10px!important;border-style:nonenonenonesolid;border-left-width:3px;border-left-color:rgb(108,226,108);list-style:decimal-leading-zerooutside;color:inherit;line-height:18px;">root2688926846002:15pts/100:00:00/bin/bash./ab.sh<listyle="margin:0px!important;padding:0px3px0px10px!important;border-style:nonenonenonesolid;border-left-width:3px;border-left-color:rgb(108,226,108);list-style:decimal-leading-zerooutside;background-color:rgb(248,248,248);line-height:18px;">root2689226846002:15pts/100:00:00/bin/bash./ab.sh
再现理想 该用户已被删除
沙发
发表于 2015-1-15 07:13:18 | 只看该作者

来一发shell步伐猎取互联网公司web server 信息

如果一定要用500以上的字来解释“晦涩”这个词,那么LZ是做到了的。
飘飘悠悠 该用户已被删除
板凳
发表于 2015-1-22 22:17:54 | 只看该作者
我感觉linux的学习,学习编程~!~!就去学习C语言编程!!
因胸联盟 该用户已被删除
地板
发表于 2015-1-31 16:01:03 | 只看该作者
放手去搞。尽量不要提问,运用搜索找答案,或者看wiki,从原理上理解操作系统的本质,而不是满足于使用几个技巧。尽量看英文资料。
变相怪杰 该用户已被删除
5#
 楼主| 发表于 2015-2-6 22:36:04 | 只看该作者
Linux?最大的优点在于其作为服务器的强大功能,同时支持多种应用程序及开发工具,所以Linux操作系统有着广泛的应用空间。
乐观 该用户已被删除
6#
发表于 2015-2-19 05:35:35 | 只看该作者
了解Linux的网络安全,系统的安全,用户的安全等。安全对于每位用户,管理员来说是非常重要的。
深爱那片海 该用户已被删除
7#
发表于 2015-3-6 13:26:12 | 只看该作者
对Linux命令熟悉后,你可以开始搭建一个小的Linux网络,这是最好的实践方法。Linux是网络的代名词,Linux网络服务功能非常强大,不论是邮件服务器、Web服务器、DNS服务器等都非常完善。
透明 该用户已被删除
8#
发表于 2015-3-20 12:02:20 | 只看该作者
说实话小时候没想过搞IT,也计算机了解也只是一些皮毛,至于什么UNIX,Linux,听过没见过,就更别说用过了。?
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|Archiver|手机版|仓酷云 鄂ICP备14007578号-2

GMT+8, 2024-5-11 19:11

Powered by Discuz! X3.2

© 2001-2013 Comsenz Inc.

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