示例#1
0
文件: proxy.py 项目: daemon13/w3af
    def _create_fuzzable_request(self):
        '''
        Based on the attributes, return a fuzzable request object.

        Important variables used here:
            - self.headers : Stores the headers for the request
            - self.rfile : A file like object that stores the post_data
            - self.path : Stores the URL that was requested by the browser
        '''
        # See HTTPWrapperClass
        if hasattr(self.server, 'chainedHandler'):
            base_path = "https://" + self.server.chainedHandler.path
            path = base_path + self.path
        else:
            path = self.path

        fuzzable_request = FuzzableRequest(
            URL(path),
            self.command,
            Headers(self.headers.dict.items())
        )
        post_data = self._get_post_data()
        if post_data:
            fuzzable_request.set_data(post_data)
        return fuzzable_request
示例#2
0
    def _urllibReq2fr(self, request):
        '''
        Convert a urllib2 request object to a FuzzableRequest.
        Used in http_request.

        :param request: A urllib2 request obj.
        :return: A FuzzableRequest.
        '''
        headers = request.headers
        headers.update(request.unredirected_hdrs)
        fr = FuzzableRequest(request.url_object, request.get_method(), headers)
        fr.set_data(request.get_data() or '')
        return fr
示例#3
0
    def _urllibReq2fr(self, request):
        '''
        Convert a urllib2 request object to a FuzzableRequest.
        Used in http_request.

        :param request: A urllib2 request obj.
        :return: A FuzzableRequest.
        '''
        headers = request.headers
        headers.update(request.unredirected_hdrs)
        fr = FuzzableRequest(request.url_object,
                             request.get_method(),
                             headers)
        fr.set_data(request.get_data() or '')
        return fr
示例#4
0
    def test_dump_mangle(self):
        fr = FuzzableRequest(URL("http://www.w3af.com/"),\
                             headers=Headers([('Host','www.w3af.com'),]))

        expected = u'\r\n'.join([u'GET http://www.w3af.com/ HTTP/1.1',
                                 u'Host: www.w3af.com',
                                 u'',
                                 u''])
        
        self.assertEqual(fr.dump(), expected)
        
        fr.set_method('POST')
        fr.set_data('data=23')
        
        expected = u'\r\n'.join([u'POST http://www.w3af.com/ HTTP/1.1',
                                 u'Host: www.w3af.com',
                                 u'',
                                 u'data=23'])
        
        self.assertEqual(fr.dump(), expected)
示例#5
0
    def test_dump_mangle(self):
        fr = FuzzableRequest(URL("http://www.w3af.com/"),\
                             headers=Headers([('Host','www.w3af.com'),]))

        expected = u'\r\n'.join([
            u'GET http://www.w3af.com/ HTTP/1.1', u'Host: www.w3af.com', u'',
            u''
        ])

        self.assertEqual(fr.dump(), expected)

        fr.set_method('POST')
        fr.set_data('data=23')

        expected = u'\r\n'.join([
            u'POST http://www.w3af.com/ HTTP/1.1', u'Host: www.w3af.com', u'',
            u'data=23'
        ])

        self.assertEqual(fr.dump(), expected)