查看服務器是否開放了不安全的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方法!