首页 > 解决方案 > 如何在 python 中发送 PURGE 方法并检查响应

问题描述

现在我创建一个项目。并尝试创建一个未经身份验证的缓存清除扫描程序。我试过这个但不工作

#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import os 
import requests
 
with open('new-target.txt', 'rb') as f: 
    L = f.seek(-2, os.SEEK_END) 
    
    while f.read(1) != b'\n': 
        f.seek(-2, os.SEEK_CUR) 
         
    a = f.readline().decode()
    
filepath = a

with open(filepath) as fp:
   line = fp.readline()
   cnt = 1
   while line:
       x = "{}".format(line.strip())
       
       resp = requests.purge(x + "/")
       responsee = resp.status_code
       
       if responsee == 200:
           print("\033[1;32;40m [Method - PURGE]      \033[0m 1;31;40m Vulnerable: \033" + x)

       line = fp.readline()
       cnt += 1

给出了这个错误:

回溯(最后一次调用):文件“/root/Masaüstü/Pentesting Tools/PURGE-PUT-Method-Scanner.py”,第 23 行,resp = requests.purge(x + "/") AttributeError: module 'requests ' 没有属性 'purge'

标签: python-3.xpython-requestspurge

解决方案


你得到的 Traceback 似乎很简单。您在这种情况下使用的模块请求不具有purge您尝试在第 23 行调用的该属性。

请参考文档中列出的方法:

https://docs.python-requests.org/en/latest/api/


推荐阅读