无效的存储块长度。 Jython和请求库

时间:2019-10-01 17:00:12

标签: python python-2.7 jython burp jython-2.7

我目前正在构建burp扩展,并且在集成Jython(Burp在Java中,因此需要Jython)和请求库方面遇到了一些麻烦。

扩展的想法是检查是否某些URL(通过添加和终结点)在响应正文中返回某些文本。

我正在按照以下方式进行操作:

endpoints = ['a','b','c','d','e']

#I have a list of str urls

for URL in urlList:
    for endpoint in endpoints
        newURL = URL + endpoint + '?query={%0A%20%20%0A}'

        getResponse = requests.get(newURL)
        postResponse = requests.post(newURL)
        getResponseText = getResponse.text
        postResponseText = postResponse.text

        if ("Very specific error" in getResponseText):
            getEndpointFound = True

        if ("Very specific error" in postResponseText):
            postEndpointFound = True

奇怪的是,第一个通过的网址可以正常工作,但第二个却出现以下错误

getResponse = requests.get(newURL)
  File "C:\Python27\Lib\site-packages\requests\api.py", line 75, in get
    return request('get', url, params=params, **kwargs)
  File "C:\Python27\Lib\site-packages\requests\api.py", line 60, in request
    return session.request(method=method, url=url, **kwargs)
  File "C:\Python27\Lib\site-packages\requests\sessions.py", line 533, in request
    resp = self.send(prep, **send_kwargs)
  File "C:\Python27\Lib\site-packages\requests\sessions.py", line 686, in send
    r.content
  File "C:\Python27\Lib\site-packages\requests\models.py", line 828, in content
    self._content = b''.join(self.iter_content(CONTENT_CHUNK_SIZE)) or b''
  File "C:\Python27\Lib\site-packages\requests\models.py", line 750, in generate
    for chunk in self.raw.stream(chunk_size, decode_content=True):
  File "C:\Python27\Lib\site-packages\requests\models.py", line 750, in generate
    for chunk in self.raw.stream(chunk_size, decode_content=True):
  File "C:\Python27\Lib\site-packages\urllib3\response.py", line 560, in stream
    for line in self.read_chunked(amt, decode_content=decode_content):
  File "C:\Python27\Lib\site-packages\urllib3\response.py", line 766, in read_chunked
    decoded = self._flush_decoder()
  File "C:\Python27\Lib\site-packages\urllib3\response.py", line 408, in _flush_decoder
    return buf + self._decoder.flush()
  File "C:\Users\User\Desktop\BurpExtender\jython-standalone-2.7.1.jar\Lib\zlib.py", line 244, in flush
  File "C:\Users\User\Desktop\BurpExtender\jython-standalone-2.7.1.jar\Lib\zlib.py", line 281, in _get_inflate_data
zlib.error: java.util.zip.DataFormatException: invalid stored block lengths

起初,我认为这是关于URL列表的问题,因此我尝试提供一个URL。错误仍然出现。

当我尝试执行多个请求时,似乎正在发生,但是我不知道到底发生了什么,我不知道该怎么办?

1 个答案:

答案 0 :(得分:0)

嗯,这个帖子已经很老了,但我的团队刚刚遇到了同样的问题。

看起来 jython 中的 zlib 存在某种问题,这意味着我们已经压缩响应。

诀窍在于urllib3默认添加了Accept-Encoding: gzip, deflate,所以服务器被允许发送压缩响应,这会导致麻烦。

我们刚刚添加了 headers={'accept-encoding':None} 作为解决方法,并且效果很好。