【问题标题】:What is a <versionspec> inspection error in PyCharm?PyCharm 中的 <versionspec> 检查错误是什么?
【发布时间】:2020-10-22 08:18:18
【问题描述】:

试图构建一个使用来自用户的请求文件的程序。 当我尝试解析名为 POST.txt 的文件时,出现错误:

<versionspec>, RequirementsTokenType.COMMENT, RequirementsTokenType.EOL, RequirementsTokenType.LSBRACE, RequirementsTokenType.SEMICOLON or RequirementsTokenType.WHITE_SPACE expected, got '/'

看起来它将请求文件转换为需求文件,但我不知道为什么,我只是将来自 burpsuite 的请求粘贴并保存到 .txt 文件中。 到目前为止,当我处理请求文件时,它运行良好。

这是请求:

POST /forum/ HTTP/1.1
Host: localhost
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Firefox/78.0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8
Accept-Language: en-US,en;q=0.5
Accept-Encoding: gzip, deflate
Content-Type: application/x-www-form-urlencoded
Content-Length: 31
Origin: http://localhost
DNT: 1
Connection: close
Referer: http://localhost/forum/
Cookie: PHPSESSID=f42ec9c38b762bb6f9856f5e99963610
Upgrade-Insecure-Requests: 1

l_username=l33t&l_password=1337

这就是我的程序到现在为止的样子(如果我的请求文件没有被解析,就无法真正移动):

import argparse
import requests
import Burpee.burpee as burp
import re

MARKER = input("What are the markers for the variables (Default: '$'): ") or '$'

parser = argparse.ArgumentParser(description = 'sniper.py, Allows 1 set of payloads, runs by order '
                                               'in all the marked positions, one at a time.')
parser.add_argument('request_file', help = 'Request file with marked variables (POST or GET)')

args         = parser.parse_args()
request_file = args.request_file

headers, POST_data = burp.parse_request(request_file)
METHOD = burp.get_method_and_resource(request_file)[0]  # Sets METHOD (POST \ GET)

marked_vars = []
with open(request_file, 'r') as request_f:
    lines = request_f.readlines()
    for line in lines:
        marked = re.findall('\$(.*?)\$', line)
        for var in marked:
            marked_vars.append(var)
    print(marked_vars)

destination = burp.get_method_and_resource(request_file)[1]  # Where the referer sends the request

还有 + 我在 PyCharm 中遇到的检查错误:

<versionspec>, RequirementsTokenType.COMMENT, RequirementsTokenType.EOL, RequirementsTokenType.LSBRACE, RequirementsTokenType.SEMICOLON or RequirementsTokenType.WHITE_SPACE expected, got '/'

我这辈子都没见过这种检查。我该如何解决这个问题?

【问题讨论】:

  • PyCharm 似乎将您的文件解释为 requirements file - 您可能配置错误。
  • PyCharm 检查与您遇到的异常没有任何关系。你有某种错误。发布整个异常输出,包括完整的、未经编辑的堆栈跟踪。另外,告诉我们Burpee 是什么。
  • @user2357112supportsMonica 看起来它确实将 POST.txt 解释为要求,但为什么...在文件被删除后发生异常,因此没关系。发生异常是因为文件被删除,这就是我得到“列表索引超出范围”的原因,因为它试图从文件中读取。 Burpee 是解析请求文件的模块:Burpee-GitHub
  • 为什么要以 w+ 模式打开这个文件?
  • lmao ye这应该是'r',我的错这就是它被删除的原因......

标签: python-3.x request pycharm burp


【解决方案1】:

我在使用文本文件时遇到了同样的问题,但显然 PyCharm 无法识别 '.txt' 扩展名。

尝试创建一个没有扩展名的新文件,然后尝试解析它。

它对我有用,所以如果这对你有用,请告诉我。

【讨论】:

    猜你喜欢
    • 2018-09-24
    • 2014-08-20
    • 1970-01-01
    • 2012-01-14
    • 2023-04-09
    • 2014-08-07
    • 1970-01-01
    • 2020-01-30
    • 1970-01-01
    相关资源
    最近更新 更多