python 服务器状态探测3种方法

来源:互联网 发布:虚拟机装mac蓝屏 编辑:程序博客网 时间:2024/05/16 01:49
1、关键字分析 
import os 
#https网站加-k
cmd = ''' (curl --no-keepalive --connect-timeout 18 --stderr - '''+urls[i]+''' | grep '''+urls[i+1]+''' >/dev/null) && echo 'ok' '''
os.popen3(cmd) 

2、 http head状态测试
import urllib2
 try:
       urllib2.urlopen(urls[i],context=context)
  except Exception, e:
... 

3、端口探测
import os 
cmd="nmap -sT -n -p 80,3389 --max-rtt-timeout 1 --max-scan-delay 1ms --host-timeout 2 " + server
(si, so, se) = os.popen3(cmd) 
t=so.readlines() 

if line.find('80')>=0 and line.find('open')>=0:
... 
0 0
原创粉丝点击