python http OPTIONS请求

通过发送http OPTIONS请求,可以获取 http允许的方法(我这里主要测试网站是否开启webDav),测试如下:

import urllib2
import json
import httplib

url='192.168.149.131'
def http_get():
    conn = httplib.HTTPConnection(url)
    conn.request("GET", "/iisstart.htm")
    ret = conn.getresponse()
    response = ret.read() 
    return response

def http_options():
    conn = httplib.HTTPConnection(url)
    conn.request("OPTIONS", "/")
    ret = conn.getresponse()
    print ret.msg.dict
    print ret.msg.dict['allow']

ret = http_options()
#ret2 = http_get()
#print ret

结果如下:

E:\>python isWebDav.py
{'content-length': '0', 'accept-ranges': 'none', 'ms-author-via': 'DAV', 'server': 'Microsoft-IIS/6.0', 'dav': '1, 2', 'dasl': '', 'allow': 'OPTIONS, TRACE, GET, HEAD, COPY, PROPFIND, SEARCH, LOCK, UNLOCK', 'cache-control': 'private', 'date': 'Wed, 29 Mar 2017 15:59:20 GMT', 'public': 'OPTIONS, TRACE, GET, HEAD, DELETE, PUT, POST, COPY, MOVE, MKCOL, PROPFIND, PROPPATCH, LOCK, UNLOCK, SEARCH'}
OPTIONS, TRACE, GET, HEAD, COPY, PROPFIND, SEARCH, LOCK, UNLOCK


你可能感兴趣的:(网络安全,漏洞挖掘)