python3基础学习(查看服务器开放的HTTP方法POC)

  查看服务器是否开放了不安全的HTTP方法,代码如下:

from http.client import HTTPConnection
import sys
import re

domain = HTTPConnection(sys.argv[1], int(sys.argv[2]))
domain.request('OPTIONS', sys.argv[3])
resp = domain.getresponse()

print('状态码:', resp.status)
print()
for name, value in resp.getheaders():
    if re.match('Allow',name):
        print(name, value)
    if re.match('Allow',name) and (re.match('.*PUT',value) or re.match('.*DELETE',value) or re.match('.*TRACE',value)):
        print('远端服务器开启了不安全的HTTP方法!')

  使用语法为:python3 xx.py 域名 端口 目录!运行实例如下:

C:\Python36>python3 不安全的http方法传输.py 218.201.202.249 80 /
状态码: 403

Allow GET, HEAD, POST, PUT, DELETE, OPTIONS
远端服务器开启了不安全的HTTP方法!
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章