当前位置: 首页>>代码示例>>Python>>正文


Python HistoryItem.read方法代码示例

本文整理汇总了Python中core.data.db.history.HistoryItem.read方法的典型用法代码示例。如果您正苦于以下问题:Python HistoryItem.read方法的具体用法?Python HistoryItem.read怎么用?Python HistoryItem.read使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在core.data.db.history.HistoryItem的用法示例。


在下文中一共展示了HistoryItem.read方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_delete

# 需要导入模块: from core.data.db.history import HistoryItem [as 别名]
# 或者: from core.data.db.history.HistoryItem import read [as 别名]
 def test_delete(self):
     i = random.randint(1, 499)
     url = url_object('http://w3af.com/a/b/c.php')
     fr = FuzzReq(url, dc={'a': ['1']})
     res = httpResponse(200, '<html>',{'Content-Type':'text/html'}, url, url)
     h1 = HistoryItem()
     h1.request = fr
     res.setId(i)
     h1.response = res
     h1.save()
     h1.delete(i)
     try:
         h2 = h1.read(i)
     except:
         h2 = None
     self.assertEqual(h2, None)
开发者ID:1d3df9903ad,项目名称:w3af,代码行数:18,代码来源:test_history.py

示例2: FullKBTree

# 需要导入模块: from core.data.db.history import HistoryItem [as 别名]
# 或者: from core.data.db.history.HistoryItem import read [as 别名]
class FullKBTree(KBTree):
    '''A tree showing all the info.

    This also gives a long description of the element when clicked.

    :param kbbrowser: The KB Browser
    :param filter: The filter to show which elements

    :author: Facundo Batista <facundobatista =at= taniquetil.com.ar>
    '''
    def __init__(self, w3af, kbbrowser, ifilter):
        super(FullKBTree, self).__init__(w3af, ifilter,
                                         'Knowledge Base', strict=False)
        self._historyItem = HistoryItem()
        self.kbbrowser = kbbrowser
        self.connect('cursor-changed', self._showDesc)
        self.show()

    def _showDesc(self, tv):
        '''Shows the description at the right

        :param tv: the treeview.
        '''
        (path, column) = tv.get_cursor()
        if path is None:
            return

        instance = self.get_instance(path)
        if not isinstance(instance, Info):
            return
        
        longdesc = instance.get_desc()
        self.kbbrowser.explanation.set_text(longdesc)

        success = False

        if instance.get_id():
            #
            # We have two different cases:
            #
            # 1) The object is related to ONLY ONE request / response
            # 2) The object is related to MORE THAN ONE request / response
            #
            # For 1), we show the classic view, and for 2) we show the classic
            # view with a "page control"
            #
            # Work:
            #
            if len(instance.get_id()) == 1:
                # There is ONLY ONE id related to the object
                # This is 1)
                self.kbbrowser.pagesControl.deactivate()
                self.kbbrowser._pageChange(0)
                self.kbbrowser.pagesControl.hide()
                self.kbbrowser.title0.hide()

                historyItem = self._historyItem.read(instance.get_id()[0])
                if historyItem:
                    self.kbbrowser.rrV.request.show_object(historyItem.request)
                    self.kbbrowser.rrV.response.show_object(
                        historyItem.response)

                    # Don't forget to highlight if neccesary
                    severity = instance.get_severity()
                    for s in instance.get_to_highlight():
                        self.kbbrowser.rrV.response.highlight(s, severity)

                    success = True
                else:
                    msg = _('Failed to find request/response with id'
                            '%s in the database.' % instance.get_id())
                    om.out.error(msg)
            else:
                # There are MORE THAN ONE ids related to the object
                # This is 2)
                self.kbbrowser.pagesControl.show()
                self.kbbrowser.title0.show()

                self.kbbrowser.req_res_ids = instance.get_id()
                self.kbbrowser.pagesControl.activate(
                    len(instance.get_id()))
                self.kbbrowser._pageChange(0)
                success = True

        if success:
            self.kbbrowser.rrV.set_sensitive(True)
        else:
            self.kbbrowser.rrV.request.clear_panes()
            self.kbbrowser.rrV.response.clear_panes()
            self.kbbrowser.rrV.set_sensitive(False)
开发者ID:HamzaKo,项目名称:w3af,代码行数:92,代码来源:scanrun.py

示例3: KBBrowser

# 需要导入模块: from core.data.db.history import HistoryItem [as 别名]
# 或者: from core.data.db.history.HistoryItem import read [as 别名]

#.........这里部分代码省略.........
            but.set_active(initial)
            but.connect("clicked", self.type_filter, signal)
            self.filters[signal] = initial
            but.show()
            filterbox.pack_start(but, expand=False, fill=False, padding=2)
        make_but("Vulnerabilities", "vuln", True)
        make_but("Informations", "info", True)
        filterbox.show()

        # the kb tree
        self.kbtree = FullKBTree(w3af, self, self.filters)

        # all in the first pane
        scrollwin21 = gtk.ScrolledWindow()
        scrollwin21.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
        scrollwin21.add(self.kbtree)
        scrollwin21.show()

        # the filter and tree box
        treebox = gtk.VBox()
        treebox.pack_start(filterbox, expand=False, fill=False)
        treebox.pack_start(scrollwin21)
        treebox.show()

        # the explanation
        explan_tv = gtk.TextView()
        explan_tv.set_editable(False)
        explan_tv.set_cursor_visible(False)
        explan_tv.set_wrap_mode(gtk.WRAP_WORD)
        self.explanation = explan_tv.get_buffer()
        explan_tv.show()
        scrollwin22 = gtk.ScrolledWindow()
        scrollwin22.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
        scrollwin22.add_with_viewport(explan_tv)
        scrollwin22.show()

        # The request/response viewer
        self.rrV = reqResViewer.reqResViewer(w3af, withAudit=False)
        self.rrV.set_sensitive(False)

        # Create the title label to show the request id
        self.title0 = gtk.Label()
        self.title0.show()

        # Create page changer to handle info/vuln objects that have MORE THAN ONE
        # related request/response
        self.pagesControl = entries.PagesControl(w3af, self._pageChange, 0)
        self.pagesControl.deactivate()
        self._pageChange(0)
        centerbox = gtk.HBox()
        centerbox.pack_start(self.pagesControl, True, False)

        # Add everything to a vbox
        vbox_rrv_centerbox = gtk.VBox()
        vbox_rrv_centerbox.pack_start(self.title0, False, True)
        vbox_rrv_centerbox.pack_start(self.rrV, True, True)
        vbox_rrv_centerbox.pack_start(centerbox, False, False)

        # and show
        vbox_rrv_centerbox.show()
        self.pagesControl.show()
        centerbox.show()

        # And now put everything inside the vpaned
        vpanedExplainAndView = entries.RememberingVPaned(
            w3af, "pane-kbbexplainview", 100)
        vpanedExplainAndView.pack1(scrollwin22)
        vpanedExplainAndView.pack2(vbox_rrv_centerbox)
        vpanedExplainAndView.show()

        # pack & show
        self.pack1(treebox)
        self.pack2(vpanedExplainAndView)
        self.show()

    def type_filter(self, button, ptype):
        '''Changes the filter of the KB in the tree.'''
        self.filters[ptype] = button.get_active()
        self.kbtree.set_filter(self.filters)

    def _pageChange(self, page):
        '''
        Handle the page change in the page control.
        '''
        # Only do something if I have a list of request and responses
        if self.req_res_ids:
            request_id = self.req_res_ids[page]
            try:
                historyItem = self._historyItem.read(request_id)
            except:
                # the request brought problems
                self.rrV.request.clear_panes()
                self.rrV.response.clear_panes()
                self.rrV.set_sensitive(False)
                self.title0.set_markup("<b>Error</b>")
            else:
                self.title0.set_markup("<b>Id: %d</b>" % request_id)
                self.rrV.request.show_object(historyItem.request)
                self.rrV.response.show_object(historyItem.response)
                self.rrV.set_sensitive(True)
开发者ID:HamzaKo,项目名称:w3af,代码行数:104,代码来源:scanrun.py

示例4: FuzzyRequests

# 需要导入模块: from core.data.db.history import HistoryItem [as 别名]
# 或者: from core.data.db.history.HistoryItem import read [as 别名]

#.........这里部分代码省略.........
        vbox.pack_start(centerbox, False, False, padding=5)

        # Show all!
        self._sendPaused = True
        self.vbox.pack_start(mainhbox)
        self.vbox.show()
        mainhbox.show()
        self.show()

    def _populate_popup(self, textview, menu):
        '''Populates the menu with the fuzzing items.'''
        menu.append(gtk.SeparatorMenuItem())
        main_generator_menu = gtk.MenuItem(_("Generators"))
        main_generator_menu.set_submenu(create_generator_menu(self))
        menu.append(main_generator_menu)
        menu.show_all()

    def _clearResponses(self, widg):
        '''Clears all the responses from the fuzzy window.'''
        self.responses = []
        self.resultReqResp.request.clear_panes()
        self.resultReqResp.response.clear_panes()
        self.resultReqResp.set_sensitive(False)
        self.clusterButton.set_sensitive(False)
        self.clearButton.set_sensitive(False)
        self.pagesControl.deactivate()

    def _clusterData(self, widg):
        '''Analyze if we can cluster the responses and do it.'''
        data = []
        for resp in self.responses:
            if resp[0]:
                reqid = resp[1]
                historyItem = self.historyItem.read(reqid)
                data.append(historyItem.response)

        if data:
            distance_function_selector(self.w3af, data)
        else:
            # Let the user know ahout the problem
            msg = "There are no HTTP responses available to cluster."
            dlg = gtk.MessageDialog(None, gtk.DIALOG_MODAL,
                                    gtk.MESSAGE_WARNING, gtk.BUTTONS_OK, msg)
            opt = dlg.run()
            dlg.destroy()

    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)

    def _send_stop(self, widg=None):
        '''Stop the requests being sent.'''
        self._sendStopped = True
        self.sendPlayBut.change_internals(
            "", gtk.STOCK_MEDIA_PLAY, "Sends the pending requests")
开发者ID:Adastra-thw,项目名称:w3af,代码行数:70,代码来源:fuzzy_requests.py

示例5: FullKBTree

# 需要导入模块: from core.data.db.history import HistoryItem [as 别名]
# 或者: from core.data.db.history.HistoryItem import read [as 别名]
class FullKBTree(kbtree.KBTree):
    '''A tree showing all the info.

    This also gives a long description of the element when clicked.

    @param kbbrowser: The KB Browser
    @param filter: The filter to show which elements

    @author: Facundo Batista <facundobatista =at= taniquetil.com.ar>
    '''
    def __init__(self, w3af, kbbrowser, ifilter):
        super(FullKBTree,self).__init__(w3af, ifilter, 'Knowledge Base', strict=False)
        self._historyItem = HistoryItem()
        self.kbbrowser = kbbrowser
        self.connect('cursor-changed', self._showDesc)
        self.show()

    def _showDesc(self, tv):
        '''Shows the description at the right

        @param tv: the treeview.
        '''
        (path, column) = tv.get_cursor()
        if path is None:
            return

        instance = self.getInstance(path)
        if hasattr(instance, "getDesc"):
            longdesc = str(instance.getDesc())
        else:
            longdesc = ""
        self.kbbrowser.explanation.set_text(longdesc)

        success = False
        if hasattr(instance, "getId" ):
            if instance.getId() is not None:
                #
                # We have two different cases:
                #
                # 1) The object is related to ONLY ONE request / response
                # 2) The object is related to MORE THAN ONE request / response
                #
                # For 1), we show the classic view, and for 2) we show the classic
                # view with a "page control"
                #
                # Work:
                #
                if len( instance.getId() ) == 1:
                    # There is ONLY ONE id related to the object
                    # This is 1)
                    self.kbbrowser.pagesControl.deactivate()
                    self.kbbrowser._pageChange(0)
                    self.kbbrowser.pagesControl.hide()
                    self.kbbrowser.title0.hide()

                    # This handles a special case, where the plugin writer made a mistake and
                    # failed to set an id to the info / vuln object:
                    if instance.getId()[0] is None:
                        raise Exception('Exception - The id should not be None! "' + str(instance._desc) + '".')
                        success = False
                    else:
                        # ok, we don't have None in the id:
                        historyItem = self._historyItem.read(instance.getId()[0])
                        if historyItem:
                            self.kbbrowser.rrV.request.showObject(historyItem.request)
                            self.kbbrowser.rrV.response.showObject(historyItem.response)
                            
                            # Don't forget to highlight if neccesary
                            severity = instance.getSeverity()
                            for s in instance.getToHighlight():
                                self.kbbrowser.rrV.response.highlight( s, severity )
                            
                            success = True
                        else:
                            om.out.error(_('Failed to find request/response with id: ') + str(instance.getId()) + _(' in the database.') )
                else:
                    # There are MORE THAN ONE ids related to the object
                    # This is 2)
                    self.kbbrowser.pagesControl.show()
                    self.kbbrowser.title0.show()

                    self.kbbrowser.req_res_ids = instance.getId()
                    self.kbbrowser.pagesControl.activate(len(instance.getId()))
                    self.kbbrowser._pageChange(0)
                    success = True

        if success:
            self.kbbrowser.rrV.set_sensitive(True)
        else:
            self.kbbrowser.rrV.request.clearPanes()
            self.kbbrowser.rrV.response.clearPanes()
            self.kbbrowser.rrV.set_sensitive(False)
开发者ID:adambaldwin2,项目名称:test,代码行数:94,代码来源:scanrun.py


注:本文中的core.data.db.history.HistoryItem.read方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。