Пример #1
0
    def __init__(self, current_status, e, tb, enabled_plugins):
        assert isinstance(e, Exception)
        assert isinstance(current_status, CoreStatus)

        #
        # According to [0] it is not a good idea to keep references to tracebacks:
        #
        #   > traceback refers to a linked list of frames, and each frame has references
        #   > to lots of other stuff like the code object, the global dict, local dict,
        #   > builtin dict, ...
        #
        # [0] https://bugs.python.org/issue13831
        #
        # TODO: Remove the next line:
        self.traceback = tb

        self.exception = e
        self.exception_msg = str(e)
        self.exception_class = e.__class__.__name__

        # Extract the filename and line number where the exception was raised
        path, filename, self.function_name, self.lineno = get_exception_location(
            tb)
        self.filename = os.path.join(path, filename)

        # See add_traceback_string()
        if hasattr(e, 'original_traceback_string'):
            self.traceback_str = e.original_traceback_string
        else:
            self.traceback_str = ''.join(traceback.format_tb(tb))

        self.traceback_str = cleanup_bug_report(self.traceback_str)

        self.phase, self.plugin = current_status.latest_running_plugin()
        self.enabled_plugins = enabled_plugins

        #
        # Do not save the CoreStatus instance here without cleaning it first,
        # it will break serialization since the CoreStatus instances have
        # references to a w3afCore instance, which points to a Pool instance
        # that is NOT serializable.
        #
        self.status = current_status
        self.status.set_w3af_core(None)

        self.fuzzable_request = current_status.get_current_fuzzable_request(
            self.phase)
        self.fuzzable_request = cleanup_bug_report(str(self.fuzzable_request))
Пример #2
0
    def test_url_cleanup_with_path(self):

        target_url = URL("http://www.target.com/abc/")
        cf.cf.save("targets", [target_url])
        self.assertEqual(
            cleanup_bug_report("start http://www.target.com/abc/def end"), "start http://domain/path/foo/def end"
        )
Пример #3
0
    def _initialize_from_traceback(self, tb, store_tb):
        if store_tb:
            #
            # According to [0] it is not a good idea to keep references to tracebacks:
            #
            #   > traceback refers to a linked list of frames, and each frame has references
            #   > to lots of other stuff like the code object, the global dict, local dict,
            #   > builtin dict, ...
            #
            # [0] https://bugs.python.org/issue13831
            #
            # TODO: Remove the next line:
            self.traceback = tb

        # Extract the filename and line number where the exception was raised
        path, filename, self.function_name, self.lineno = get_exception_location(tb)
        if path is not None:
            self.filename = os.path.join(path, filename)

        # See add_traceback_string()
        if hasattr(self.exception, 'original_traceback_string'):
            traceback_string = self.exception.original_traceback_string
        else:
            traceback_string = ''.join(traceback.format_tb(tb))
            self.exception.original_traceback_string = traceback_string

        self.traceback_str = cleanup_bug_report(traceback_string)
Пример #4
0
 def test_cleanup_bug_report_simple(self):
     TESTS = [
         ("foo", "foo"),
         ("start /home/nsa/w3af/ end", "start /home/user/w3af/ end"),
         ("start C:\\Documents and Settings\\CIA\\ end", "start C:/user/ end"),
     ]
     for _input, _expected in TESTS:
         self.assertEqual(cleanup_bug_report(_input), _expected)
Пример #5
0
 def test_url_cleanup_with_path(self):
     target_url = URL('http://www.target.com/abc/')
     cf.cf.save('targets', [
         target_url,
     ])
     self.assertEqual(
         cleanup_bug_report('start http://www.target.com/abc/def end'),
         'start http://domain/path/foo/def end')
Пример #6
0
 def test_cleanup_bug_report_simple(self):
     TESTS = [
         ('foo', 'foo'),
         ('start /home/nsa/w3af/ end', 'start /home/user/w3af/ end'),
         ('start C:\\Documents and Settings\\CIA\\ end',
          'start C:/user/ end'),
     ]
     for _input, _expected in TESTS:
         self.assertEqual(cleanup_bug_report(_input), _expected)
Пример #7
0
    def __init__(self, current_status, e, tb, enabled_plugins):
        assert isinstance(e, Exception)
        assert isinstance(current_status, w3af_core_status)

        self.exception = e
        self.traceback = tb

        # Extract the filename and line number where the exception was raised
        filepath = traceback.extract_tb(tb)[-1][0]
        self.filename = basename(filepath)
        self.lineno, self.function_name = self._get_last_call_info(tb)

        self.traceback_str = ''.join(traceback.format_tb(tb))
        self.traceback_str = cleanup_bug_report(self.traceback_str)
        
        self.phase, self.plugin = current_status.latest_running_plugin()
        self.status = current_status
        self.enabled_plugins = enabled_plugins

        self.fuzzable_request = current_status.get_current_fuzzable_request(self.phase)
        self.fuzzable_request = cleanup_bug_report(str(self.fuzzable_request))
Пример #8
0
    def __init__(self, current_status, e, tb, enabled_plugins):
        assert isinstance(e, Exception)
        assert isinstance(current_status, w3af_core_status)

        self.exception = e
        self.traceback = tb

        # Extract the filename and line number where the exception was raised
        filepath = traceback.extract_tb(tb)[-1][0]
        self.filename = basename(filepath)
        self.lineno, self.function_name = self._get_last_call_info(tb)

        self.traceback_str = ''.join(traceback.format_tb(tb))
        self.traceback_str = cleanup_bug_report(self.traceback_str)

        self.phase, self.plugin = current_status.latest_running_plugin()
        self.status = current_status
        self.enabled_plugins = enabled_plugins

        self.fuzzable_request = current_status.get_current_fuzzable_request(self.phase)
        self.fuzzable_request = cleanup_bug_report(str(self.fuzzable_request))
Пример #9
0
    def _initialize_from_status(self, current_status):
        self.phase, self.plugin = current_status.latest_running_plugin()

        #
        # Do not save the CoreStatus instance here without cleaning it first,
        # it will break serialization since the CoreStatus instances have
        # references to a w3afCore instance, which points to a Pool instance
        # that is NOT serializable.
        #
        self.status = current_status
        self.status.set_w3af_core(None)

        self.fuzzable_request = current_status.get_current_fuzzable_request(self.phase)
        self.fuzzable_request = cleanup_bug_report(str(self.fuzzable_request))
Пример #10
0
def handle_crash(w3af_core, _type, value, tb, plugins=''):
    """Function to handle any exception that is not addressed explicitly."""
    if issubclass(_type, KeyboardInterrupt):
        handle_keyboardinterrupt(w3af_core)

    # Print the information to the console so everyone can see it
    exception = traceback.format_exception(_type, value, tb)
    exception = "".join(exception)
    print exception

    # Do not disclose user information in bug reports
    clean_exception = cleanup_bug_report(exception)

    # Save the info to a file for later analysis
    filename = create_crash_file(clean_exception)

    # Create the dialog that allows the user to send the bug to github
    bug_report_win = unhandled_bug_report.BugReportWindow(
        w3af_core, _('Bug detected!'), clean_exception, filename, plugins)

    # Blocks waiting for user interaction
    bug_report_win.show()
Пример #11
0
def handle_crash(w3af_core, _type, value, tb, plugins=''):
    """Function to handle any exception that is not addressed explicitly."""
    if issubclass(_type, KeyboardInterrupt):
        handle_keyboardinterrupt(w3af_core)

    # Print the information to the console so everyone can see it
    exception = traceback.format_exception(_type, value, tb)
    exception = "".join(exception)
    print exception

    # Do not disclose user information in bug reports
    clean_exception = cleanup_bug_report(exception)

    # Save the info to a file for later analysis
    filename = create_crash_file(clean_exception)

    # Create the dialog that allows the user to send the bug to github
    bug_report_win = unhandled_bug_report.BugReportWindow(w3af_core,
                                                            _('Bug detected!'),
                                                            clean_exception,
                                                            filename, plugins)

    # Blocks waiting for user interaction
    bug_report_win.show()
    def __init__(self, w3af_core, title, tback, fname, plugins):
        # Before doing anything else, cleanup the report to remove any
        # user information that might be present.
        tback = cleanup_bug_report(tback)

        simple_base_window.__init__(self)
        github_bug_report.__init__(self, tback, fname, plugins)

        # We got here because of an autogenerated bug, not because of the user
        # going to the Help menu and then clicking on "Report a bug"
        self.autogen = True

        # Set generic window settings
        self.set_modal(True)
        self.set_title(title)

        self.vbox = gtk.VBox()
        self.vbox.set_border_width(10)

        # the label for the title
        self.title_label = gtk.Label()
        self.title_label.set_line_wrap(True)
        label_text = _("<b>An unhandled exception was raised</b>")
        self.title_label.set_markup(label_text)
        self.title_label.show()

        # A gtk.TextView for the exception
        frame = gtk.Frame("Traceback")
        sw = gtk.ScrolledWindow()
        sw.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)

        self.text_view = gtk.TextView()
        self.text_view.set_size_request(150, 250)
        self.text_view.set_editable(False)
        self.text_view.set_wrap_mode(gtk.WRAP_CHAR)

        buffer = self.text_view.get_buffer()
        buffer.set_text(tback)

        sw.add(self.text_view)
        frame.add(sw)

        # the label for the rest of the message
        self.label = gtk.Label()
        self.label.set_line_wrap(True)
        label_text = _(
            "<i>All this info is in a file called '%s' for later"
            " review.</i>\n\nIf you wish, <b>you can contribute"
            "</b> to the w3af project and submit this bug to our"
            " bug tracking system from within this window. It is"
            " a simple <i>two step process</i>.\n\n"
            "w3af will only send the exception traceback and the"
            " version information to Github, no personal or "
            " confidential information is collected."
        )
        self.label.set_markup(label_text % fname)
        self.label.show()

        self.vbox.pack_start(self.title_label, True, True, 10)
        self.vbox.pack_start(frame, True, True)
        self.vbox.pack_start(self.label, True, True, 10)

        # the buttons
        self.hbox = gtk.HBox()

        self.butt_cancel = gtk.Button(stock=gtk.STOCK_CANCEL)
        self.butt_cancel.connect("clicked", self._handle_cancel)
        self.hbox.pack_start(self.butt_cancel, True, False)

        self.butt_send = gtk.Button(stock=gtk.STOCK_OK)
        self.butt_send.connect("clicked", self.report_bug)
        self.hbox.pack_start(self.butt_send, True, False)

        self.vbox.pack_start(self.hbox, True, False, 10)

        # self.resize(400,450)
        self.add(self.vbox)
        self.show_all()

        # This is a quick fix to get around the problem generated by "set_selectable"
        # that selects the text by default
        self.label.select_region(0, 0)
Пример #13
0
    def __init__(self, w3af_core, title, tback, fname, plugins):
        # Before doing anything else, cleanup the report to remove any
        # user information that might be present.
        tback = cleanup_bug_report(tback)

        simple_base_window.__init__(self)
        github_bug_report.__init__(self, tback, fname, plugins)

        # We got here because of an autogenerated bug, not because of the user
        # going to the Help menu and then clicking on "Report a bug"
        self.autogen = True

        # Set generic window settings
        self.set_modal(True)
        self.set_title(title)

        self.vbox = gtk.VBox()
        self.vbox.set_border_width(10)

        # the label for the title
        self.title_label = gtk.Label()
        self.title_label.set_line_wrap(True)
        label_text = _('<b>An unhandled exception was raised</b>')
        self.title_label.set_markup(label_text)
        self.title_label.show()

        # A gtk.TextView for the exception
        frame = gtk.Frame('Traceback')
        sw = gtk.ScrolledWindow()
        sw.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)

        self.text_view = gtk.TextView()
        self.text_view.set_size_request(150, 250)
        self.text_view.set_editable(False)
        self.text_view.set_wrap_mode(gtk.WRAP_CHAR)

        buffer = self.text_view.get_buffer()
        buffer.set_text(tback)

        sw.add(self.text_view)
        frame.add(sw)

        # the label for the rest of the message
        self.label = gtk.Label()
        self.label.set_line_wrap(True)
        label_text = _("<i>All this info is in a file called '%s' for later"
                       ' review.</i>\n\nIf you wish, <b>you can contribute'
                       '</b> to the w3af project and submit this bug to our'
                       ' bug tracking system from within this window. It is'
                       ' a simple <i>two step process</i>.\n\n'
                       'w3af will only send the exception traceback and the'
                       ' version information to Github, no personal or '
                       ' confidential information is collected.')
        self.label.set_markup(label_text % fname)
        self.label.show()

        self.vbox.pack_start(self.title_label, True, True, 10)
        self.vbox.pack_start(frame, True, True)
        self.vbox.pack_start(self.label, True, True, 10)

        # the buttons
        self.hbox = gtk.HBox()

        self.butt_cancel = gtk.Button(stock=gtk.STOCK_CANCEL)
        self.butt_cancel.connect("clicked", self._handle_cancel)
        self.hbox.pack_start(self.butt_cancel, True, False)

        self.butt_send = gtk.Button(stock=gtk.STOCK_OK)
        self.butt_send.connect("clicked", self.report_bug)
        self.hbox.pack_start(self.butt_send, True, False)

        self.vbox.pack_start(self.hbox, True, False, 10)

        #self.resize(400,450)
        self.add(self.vbox)
        self.show_all()

        # This is a quick fix to get around the problem generated by "set_selectable"
        # that selects the text by default
        self.label.select_region(0, 0)
Пример #14
0
 def test_url_cleanup_with_path(self):
 
     target_url = URL('http://www.target.com/abc/')
     cf.cf.save('targets', [target_url,] )
     self.assertEqual(cleanup_bug_report('start http://www.target.com/abc/def end'),
                      'start http://domain/path/foo/def end')