Ejemplo n.º 1
0
    def _impact_done(self, event, impact):
        # Keep calling this from timeout_add until isSet
        if not event.isSet():
            return True
        # We stop the throbber, and hide it
        self.throbber.hide()
        self.throbber.running(False)

        # Analyze the impact
        if impact.ok:
            #   Lets check if we found any vulnerabilities
            #
            #   TODO: I should actually show ALL THE REQUESTS generated by
            #         audit plugins... not just the ones with vulnerabilities.
            #
            for result in impact.result:
                if result.get_id() is None:
                    continue

                for itemId in result.get_id():
                    historyItem = HistoryItem()
                    historyItem.load(itemId)
                    historyItem.update_tag(historyItem.tag +
                                           result.plugin_name)
                    historyItem.info = result.get_desc()
                    historyItem.save()
        else:
            if isinstance(impact.exception, HTTPRequestException):
                msg = 'Exception found while sending HTTP request. Original' \
                      ' exception is: "%s"' % impact.exception
            elif isinstance(impact.exception, ScanMustStopException):
                msg = 'Multiple exceptions found while sending HTTP requests.' \
                      ' Exception: "%s"' % impact.exception
            elif isinstance(impact.exception, BaseFrameworkException):
                msg = str(impact.exception)
            else:
                raise impact.exception

            # We stop the throbber, and hide it
            self.throbber.hide()
            self.throbber.running(False)
            gtk.gdk.threads_enter()
            helpers.FriendlyExceptionDlg(msg)
            gtk.gdk.threads_leave()

        return False
Ejemplo n.º 2
0
    def _impact_done(self, event, impact):
        # Keep calling this from timeout_add until isSet
        if not event.isSet():
            return True
        # We stop the throbber, and hide it
        self.throbber.hide()
        self.throbber.running(False)
        # Analyze the impact
        if impact.ok:
            #   Lets check if we found any vulnerabilities
            #
            #   TODO: I should actually show ALL THE REQUESTS generated by audit plugins...
            #               not just the ones with vulnerabilities.
            #
            for result in impact.result:

                # TODO: I'm not sure when this is None bug it appeared in Trac bug #167736
                if result.get_id() is not None:
                    for itemId in result.get_id():
                        historyItem = HistoryItem()
                        historyItem.load(itemId)
                        historyItem.update_tag(historyItem.tag +
                                               result.plugin_name)
                        historyItem.info = result.get_desc()
                        historyItem.save()
        else:
            if impact.exception.__class__ == BaseFrameworkException:
                msg = str(impact.exception)
            elif impact.exception.__class__ == ScanMustStopException:
                msg = "Stopped sending requests because " + \
                    str(impact.exception)
            elif impact.exception.__class__ == ScanMustStopOnUrlError:
                msg = "Not sending requests because " + str(impact.exception)
            else:
                raise impact.exception
            # We stop the throbber, and hide it
            self.throbber.hide()
            self.throbber.running(False)
            gtk.gdk.threads_enter()
            helpers.FriendlyExceptionDlg(msg)
            gtk.gdk.threads_leave()
        return False
Ejemplo n.º 3
0
    def _real_send(self, fixContentLength, requestGenerator):
        """This is the one that actually sends the requests, if corresponds.

        :param fixContentLength: if the length should be fixed by the core.
        :param requestGenerator: where to ask for the requests
        """
        if self._sendStopped:
            return False
        if self._sendPaused:
            return True

        try:
            realreq, realbody = requestGenerator.next()
        except StopIteration:
            # finished with all the requests!
            self._send_stop()
            return False

        # Clear any errors that might have been generated by previous runs
        # of this or other GUI tools
        self.w3af.uri_opener.clear()

        try:
            http_resp = self.w3af.uri_opener.send_raw_request(
                realreq, realbody, fixContentLength)
            error_msg = None
            self.result_ok += 1
        except HTTPRequestException as e:
            # One HTTP request failed
            error_msg = str(e)
            http_resp = None
            self.result_err += 1
        except ScanMustStopException as e:
            # Many HTTP requests failed and the URL library wants to stop
            error_msg = str(e)
            self.result_err += 1

            # Let the user know about the problem
            msg = "Stopped sending requests because of the following"\
                  " unexpected error:\n\n%s"

            helpers.FriendlyExceptionDlg(msg % error_msg)
            return False

        if http_resp is not None:
            self.responses.append((True, http_resp.get_id()))
        else:
            self.responses.append((False, realreq, realbody, error_msg))

        # always update the gtk stuff
        msg = "%d ok, %d errors"
        self.sendfb.set_sensitive(True)
        self.sendfb.set_text(msg % (self.result_ok, self.result_err))

        # activate and show
        self.resultReqResp.set_sensitive(True)
        self.clearButton.set_sensitive(True)
        if len(self.responses) >= 3:
            self.clusterButton.set_sensitive(True)
        self.pagesControl.activate(len(self.responses))
        self.page_change(0)
        return True