コード例 #1
0
ファイル: blacklist.py プロジェクト: weisst/w3af
    def default_open(self, req):
        '''
        If blacklisted return an empty response, else return None, which means
        that this handler was unable to handle the request and the next one
        needs to be called. With this we want to indicate that the keepalive
        handler will be called.
        '''
        if self._is_blacklisted(req.url_object):
            nncr = new_no_content_resp(req.url_object)
            addinfo_inst = http_response_to_httplib(nncr)

            return addinfo_inst

        # This means: I don't know how to handle this, call the next opener
        return None
コード例 #2
0
ファイル: blacklist.py プロジェクト: zhuyue1314/w3af
    def default_open(self, req):
        """
        If blacklisted return an empty response, else return None, which means
        that this handler was unable to handle the request and the next one
        needs to be called. With this we want to indicate that the keepalive
        handler will be called.
        """
        if self._is_blacklisted(req.url_object):
            nncr = new_no_content_resp(req.url_object)
            addinfo_inst = http_response_to_httplib(nncr)

            return addinfo_inst

        # This means: I don't know how to handle this, call the next opener
        return None
コード例 #3
0
ファイル: blacklist.py プロジェクト: kam40oz/w3af
    def default_open(self, req):
        '''
        If blacklisted return an empty response, else return None, which means
        that this handler was unable to handle the request and the next one
        needs to be called. With this we want to indicate that the keepalive
        handler will be called.
        '''
        if self._is_blacklisted(req.url_object):
            nncr = new_no_content_resp(req.url_object)
            
            header_string = cStringIO.StringIO(str(nncr.get_headers()))
            headers = mimetools.Message(header_string)
            
            addinfo_inst = urllib.addinfourl(cStringIO.StringIO(nncr.get_body()),
                                             headers,
                                             nncr.get_url().url_string,
                                             code=nncr.get_code())
            addinfo_inst.msg = 'No content'
            
            return addinfo_inst

        # This means: I don't know how to handle this, call the next opener        
        return None
コード例 #4
0
ファイル: extended_urllib.py プロジェクト: kam40oz/w3af
            trace_str = traceback.format_exc()
            parsed_traceback = re.findall('File "(.*?)", line (.*?), in (.*)',
                                          trace_str)
            # Returns something similar to:
            #   [('trace_test.py', '9', 'one'), ('trace_test.py', '17', 'two'),
            #    ('trace_test.py', '5', 'abc')]
            #
            # Where ('filename', 'line-number', 'function-name')

            self._increment_global_error_count(e, parsed_traceback)

            # FIXME: Still need to figure out how to remove this call to
            #        new_no_content_resp and the call to
            #        CacheClass.store_in_cache
            resp = new_no_content_resp(original_url_inst)
            CacheClass.store_in_cache(req, resp)
            return resp

        else:
            # Everything went well!
            rdata = req.get_data()
            if not rdata:
                msg = ('%s %s returned HTTP code "%s"' %
                       (req.get_method(), urllib.unquote_plus(original_url), res.code))
            else:
                printable_data = urllib.unquote_plus(rdata)
                if len(rdata) > 75:
                    printable_data = '%s...' % printable_data[:75]
                    printable_data = printable_data.replace('\n', ' ')
                    printable_data = printable_data.replace('\r', ' ')
コード例 #5
0
ファイル: extended_urllib.py プロジェクト: crowforge/w3af
            trace_str = traceback.format_exc()
            parsed_traceback = re.findall('File "(.*?)", line (.*?), in (.*)',
                                          trace_str)
            # Returns something similar to:
            #   [('trace_test.py', '9', 'one'), ('trace_test.py', '17', 'two'),
            #    ('trace_test.py', '5', 'abc')]
            #
            # Where ('filename', 'line-number', 'function-name')

            self._increment_global_error_count(e, parsed_traceback)

            # FIXME: Still need to figure out how to remove this call to
            #        new_no_content_resp and the call to
            #        CacheClass.store_in_cache
            resp = new_no_content_resp(original_url_inst, add_id=True)
            
            # Translate to httplib
            httplib_resp = http_response_to_httplib(resp)
            
            CacheClass.store_in_cache(req, httplib_resp)
            return resp

        else:
            # Everything went well!
            rdata = req.get_data()
            if not rdata:
                msg = ('%s %s returned HTTP code "%s"' %
                       (req.get_method(), urllib.unquote_plus(original_url), res.code))
            else:
                printable_data = urllib.unquote_plus(rdata)