Example #1
0
File: sed.py Project: weisst/w3af
    def mangle_response(self, response):
        '''
        This method mangles the response.

        :param response: This is the response to mangle.
        :return: A mangled version of the response.
        '''
        body = response.get_body()

        for regex, string in self._manglers['s']['b']:
            body = regex.sub(string, body)

        response.set_body(body)

        header_string = str(response.get_headers())

        for regex, string in self._manglers['s']['h']:
            header_string = regex.sub(string, header_string)

        try:
            mangled_header = Headers.from_string(header_string)
        except ValueError:
            error = 'Your header modifications created an invalid header'\
                    ' string that could NOT be parsed back to a Header object.'
            om.out.error(error)
        else:
            response.set_headers(mangled_header)

        if self._user_option_fix_content_len:
            response = self._fix_content_len(response)

        return response
Example #2
0
File: sed.py Project: weisst/w3af
    def mangle_request(self, request):
        '''
        This method mangles the request.

        :param request: This is the request to mangle.
        :return: A mangled version of the request.
        '''
        data = request.get_data()
        for regex, string in self._manglers['q']['b']:
            data = regex.sub(string, data)

        header_string = str(request.get_headers())
        
        for regex, string in self._manglers['q']['h']:
            header_string = regex.sub(string, header_string)
        
        headers_inst = Headers.from_string(header_string)

        return create_fuzzable_request_from_parts(
                                                  request.get_uri(),
                                                  request.get_method(),
                                                  data, headers_inst
                                                  )
Example #3
0
    def test_to_str_from_string(self):
        headers_from_obj = Headers([('a', 'b')])
        headers_from_str = Headers.from_string(str(headers_from_obj))

        self.assertEqual(headers_from_str, headers_from_obj)
Example #4
0
 def test_from_string(self):
     headers_from_str = Headers.from_string('a: b\r\n')
     headers_from_obj = Headers([('a', 'b')])
     self.assertEqual(headers_from_str, headers_from_obj)
Example #5
0
 def test_to_str_from_string(self):
     headers_from_obj = Headers([('a', 'b')])
     headers_from_str = Headers.from_string(str(headers_from_obj))
     
     self.assertEqual(headers_from_str, headers_from_obj)
Example #6
0
 def test_from_string(self):
     headers_from_str = Headers.from_string('a: b\r\n')
     headers_from_obj = Headers([('a', 'b')])
     self.assertEqual(headers_from_str, headers_from_obj)