Esempio n. 1
0
    def _analyze(self, widg):
        '''Handles the Analyze part.'''
        (request, postbody) = self.originalReq.get_both_texts()
        try:
            fg = helpers.coreWrap(fuzzygen.FuzzyGenerator, request, postbody)
        except fuzzygen.FuzzyError:
            return

        self.analyzefb.set_text("%d requests" % fg.calculate_quantity())
        self.analyzefb.set_sensitive(True)

        # raise the window only if preview is active
        if self.preview.get_active():
            PreviewWindow(self.w3af, self, fg)
Esempio n. 2
0
    def _saveEverything(self):
        '''Saves all the info to a profile.'''
        filename = self.panel.widg.get_children()[2].get_text()
        description = self.panel.widg.get_children()[0].get_text()
        if not filename:
            msg = "The configuration can't be saved, you need to insert a profile name!\n\n"
            dlg = gtk.MessageDialog(None, gtk.DIALOG_MODAL,
                                    gtk.MESSAGE_WARNING, gtk.BUTTONS_OK, msg)
            dlg.set_title('Missing info')
            dlg.run()
            dlg.destroy()
            return

        filename = cgi.escape(filename)
        try:
            helpers.coreWrap(self.w3af.profiles.save_current_to_new_profile,
                             filename, description)
        except w3afException:
            self.w3af.mainwin.sb(_("There was a problem saving the profile!"))
            return
        self.w3af.mainwin.profiles.load_profiles(filename)
        self.w3af.mainwin.sb(_("New profile created"))
        self.destroy()
Esempio n. 3
0
    def _analyze(self, widg):
        '''Handles the Analyze part.'''
        (request, postbody) = self.originalReq.get_both_texts()
        try:
            fg = helpers.coreWrap(fuzzygen.FuzzyGenerator, request, postbody)
        except fuzzygen.FuzzyError:
            return

        self.analyzefb.set_text("%d requests" % fg.calculate_quantity())
        self.analyzefb.set_sensitive(True)

        # raise the window only if preview is active
        if self.preview.get_active():
            PreviewWindow(self.w3af, self, fg)
Esempio n. 4
0
    def _saveEverything(self):
        '''Saves all the info to a profile.'''
        filename = self.panel.widg.get_children()[2].get_text()
        description = self.panel.widg.get_children()[0].get_text()
        if not filename:
            msg = "The configuration can't be saved, you need to insert a profile name!\n\n"
            dlg = gtk.MessageDialog(None, gtk.DIALOG_MODAL,
                                    gtk.MESSAGE_WARNING, gtk.BUTTONS_OK, msg)
            dlg.set_title('Missing info')
            dlg.run()
            dlg.destroy()
            return

        filename = cgi.escape(filename)
        try:
            helpers.coreWrap(self.w3af.profiles.save_current_to_new_profile,
                             filename, description)
        except w3afException:
            self.w3af.mainwin.sb(_("There was a problem saving the profile!"))
            return
        self.w3af.mainwin.profiles.load_profiles(filename)
        self.w3af.mainwin.sb(_("New profile created"))
        self.destroy()
Esempio n. 5
0
class QuestOptions(gtk.VBox):
    def __init__(self, w3af, wizard):
        self.w3af = w3af
        self.wizard = wizard
        super(QuestOptions, self).__init__()

        self.widg = gtk.Label("")
        self.pack_start(self.widg)
        self.activeQuestion = None

        self.show_all()

    def save_options(self):
        '''Saves the changed options.'''
        options = self.widg.options
        invalid = []

        for opt in options:
            #       Trying to reproduce bug
            #       https://sourceforge.net/tracker2/?func=detail&aid=2652434&group_id=170274&atid=853652
            #
            #       To get more info:
            try:
                opt.widg
            except Exception, e:
                raise Exception(str(e) + ' || ' + opt.get_name())
            # end of debugging code

            if hasattr(opt.widg, "is_valid"):
                if not opt.widg.is_valid():
                    invalid.append(opt.get_name())
        if invalid:
            msg = "The configuration can't be saved, there is a problem in the"
            msg += " following parameter(s):\n\n" + "\n-".join(invalid)
            dlg = gtk.MessageDialog(None, gtk.DIALOG_MODAL,
                                    gtk.MESSAGE_WARNING, gtk.BUTTONS_OK, msg)
            dlg.set_title('Configuration error')
            dlg.run()
            dlg.destroy()
            return

        for opt in options:
            opt.set_value(opt.widg.get_value())

        try:
            helpers.coreWrap(self.wizard.set_answer, options)
        except w3afException:
            return
        return True
Esempio n. 6
0
    def save_as_profile(self, widget=None):
        '''Copies the selected profile.'''
        if not self.w3af.mainwin.save_state_to_core(relaxedTarget=True):
            return

        dlg = entries.EntryDialog(_(
            "Save as..."), gtk.STOCK_SAVE_AS, [_("Name:"), _("Description:")])
        dlg.run()
        dlgResponse = dlg.inputtexts
        dlg.destroy()
        if dlgResponse is not None:
            filename, description = dlgResponse
            filename = cgi.escape(filename)
            try:
                profile_obj = helpers.coreWrap(self.w3af.profiles.save_current_to_new_profile, filename, description)
            except w3afException:
                self.w3af.mainwin.sb(
                    _("There was a problem saving the profile!"))
                return
            self.w3af.mainwin.sb(_("New profile created"))
            self.load_profiles(selected=profile_obj.get_name())
Esempio n. 7
0
    def _send_start(self, widg):
        '''Start sending the requests.'''
        (request, postbody) = self.originalReq.get_both_texts()
        try:
            fg = helpers.coreWrap(fuzzygen.FuzzyGenerator, request, postbody)
        except fuzzygen.FuzzyError:
            return

        quant = fg.calculate_quantity()
        if quant > 20:
            msg = "Are you sure you want to send %d requests?" % quant
            dlg = gtk.MessageDialog(None, gtk.DIALOG_MODAL,
                                    gtk.MESSAGE_WARNING, gtk.BUTTONS_YES_NO,
                                    msg)
            opt = dlg.run()
            dlg.destroy()
            if opt != gtk.RESPONSE_YES:
                return

        # Get the fix content length value
        fixContentLength = self._fix_content_lengthCB.get_active()

        # initial state
        self.result_ok = 0
        self.result_err = 0
        self._sendPaused = False
        self._sendStopped = False
        requestGenerator = fg.generate()

        # change the buttons
        self.sendPlayBut.change_internals("", gtk.STOCK_MEDIA_PAUSE,
                                          "Pauses the requests sending")
        self.sendPlayBut.disconnect(self.sPB_signal)
        self.sPB_signal = self.sendPlayBut.connect("clicked", self._send_pause)
        self.sSB_state.change(self, True)
        self.throbber.running(True)

        # let's send the requests!
        gobject.timeout_add(100, self._real_send, fixContentLength,
                            requestGenerator)
Esempio n. 8
0
    def _send_start(self, widg):
        '''Start sending the requests.'''
        (request, postbody) = self.originalReq.get_both_texts()
        try:
            fg = helpers.coreWrap(fuzzygen.FuzzyGenerator, request, postbody)
        except fuzzygen.FuzzyError:
            return

        quant = fg.calculate_quantity()
        if quant > 20:
            msg = "Are you sure you want to send %d requests?" % quant
            dlg = gtk.MessageDialog(None, gtk.DIALOG_MODAL, gtk.MESSAGE_WARNING, gtk.BUTTONS_YES_NO, msg)
            opt = dlg.run()
            dlg.destroy()
            if opt != gtk.RESPONSE_YES:
                return

        # Get the fix content length value
        fixContentLength = self._fix_content_lengthCB.get_active()

        # initial state
        self.result_ok = 0
        self.result_err = 0
        self._sendPaused = False
        self._sendStopped = False
        requestGenerator = fg.generate()

        # change the buttons
        self.sendPlayBut.change_internals(
            "", gtk.STOCK_MEDIA_PAUSE, "Pauses the requests sending")
        self.sendPlayBut.disconnect(self.sPB_signal)
        self.sPB_signal = self.sendPlayBut.connect("clicked", self._send_pause)
        self.sSB_state.change(self, True)
        self.throbber.running(True)

        # let's send the requests!
        gobject.timeout_add(
            100, self._real_send, fixContentLength, requestGenerator)
Esempio n. 9
0
    def save_as_profile(self, widget=None):
        '''Copies the selected profile.'''
        if not self.w3af.mainwin.save_state_to_core(relaxedTarget=True):
            return

        dlg = entries.EntryDialog(_("Save as..."), gtk.STOCK_SAVE_AS,
                                  [_("Name:"), _("Description:")])
        dlg.run()
        dlgResponse = dlg.inputtexts
        dlg.destroy()
        if dlgResponse is not None:
            filename, description = dlgResponse
            filename = cgi.escape(filename)
            try:
                profile_obj = helpers.coreWrap(
                    self.w3af.profiles.save_current_to_new_profile, filename,
                    description)
            except w3afException:
                self.w3af.mainwin.sb(
                    _("There was a problem saving the profile!"))
                return
            self.w3af.mainwin.sb(_("New profile created"))
            self.load_profiles(selected=profile_obj.get_name())
Esempio n. 10
0
        # use the empty profile
        try:
            self.w3af.profiles.use_profile(None)
        except w3afException, w3:
            dlg = gtk.MessageDialog(None, gtk.DIALOG_MODAL, gtk.MESSAGE_WARNING, gtk.BUTTONS_OK, str(w3))
            dlg.run()
            dlg.destroy()
            return
        self.w3af.mainwin.pcbody.reload(None)

        # save it
        filename, description = dlgResponse
        filename = cgi.escape(filename)
        try:
            profile_obj = helpers.coreWrap(
                self.w3af.profiles.save_current_to_new_profile,
                filename, description)
        except w3afException:
            #FIXME: This message should be more descriptive
            self.w3af.mainwin.sb(_("Problem hit!"))
            return
        self.w3af.mainwin.sb(_("New profile created"))
        self.load_profiles(selected=profile_obj.get_name())

        # get the activated plugins
        self.origActPlugins = self.w3af.mainwin.pcbody.get_activated_plugins()

        # update the mainwin buttons
        path = self.get_cursor()[0]
        newstatus = self._get_actionsSensitivity(path)
        self.w3af.mainwin.activate_profile_actions(newstatus)
Esempio n. 11
0
            self.w3af.profiles.use_profile(None)
        except w3afException, w3:
            dlg = gtk.MessageDialog(None, gtk.DIALOG_MODAL,
                                    gtk.MESSAGE_WARNING, gtk.BUTTONS_OK,
                                    str(w3))
            dlg.run()
            dlg.destroy()
            return
        self.w3af.mainwin.pcbody.reload(None)

        # save it
        filename, description = dlgResponse
        filename = cgi.escape(filename)
        try:
            profile_obj = helpers.coreWrap(
                self.w3af.profiles.save_current_to_new_profile, filename,
                description)
        except w3afException:
            #FIXME: This message should be more descriptive
            self.w3af.mainwin.sb(_("Problem hit!"))
            return
        self.w3af.mainwin.sb(_("New profile created"))
        self.load_profiles(selected=profile_obj.get_name())

        # get the activated plugins
        self.origActPlugins = self.w3af.mainwin.pcbody.get_activated_plugins()

        # update the mainwin buttons
        path = self.get_cursor()[0]
        newstatus = self._get_actionsSensitivity(path)
        self.w3af.mainwin.activate_profile_actions(newstatus)