Changeset 829

Show
Ignore:
Timestamp:
06/17/07 20:15:42 (6 years ago)
Author:
ggpolo
Message:

Inventory Viewer fixes

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • branch/ggpolo/umitInventory/viewer.py

    r828 r829  
    408408        self.daddy = daddy 
    409409        self.pages = [ ] 
    410          
    411         #if inv_activated: 
    412         #    self.append_inv() 
    413          
     410                 
    414411        self.__layout() 
    415  
    416  
     412         
     413        self.connect('grab-focus', self._update_page_text) 
     414         
     415    def _update_page_text(self, widget): 
     416        """ 
     417        When changing from an Inventory tab to another, I noticed some text was 
     418        missing but it would appear when text-view received 'grab-focus'. 
     419        I'm emitting this signal so text updates when changing Inventory tabs. 
     420        """ 
     421        cur_page = widget.get_current_page() 
     422        page = widget.get_nth_page(cur_page) 
     423        viewport = page.get_children()[0] 
     424        vbox = viewport.get_children()[0]  
     425        vbox_children = vbox.get_children() 
     426         
     427        textview = vbox_children[0] 
     428        textview.emit('grab-focus') 
     429         
     430         
    417431    def append_inv(self, title="Info", box=None): 
    418432        """ 
     
    457471        Remove a page from notebook and from self.pages 
    458472        """ 
    459         print button, page 
    460          
    461473        del self.pages[self.pages.index(text)] 
    462474        self.remove(page) 
     
    780792                box = self._load_inventory_data(title) 
    781793                p.append_inv(box=box) 
    782          
    783         """ 
    784         if not err: # tab wasn't in inventory tab 
    785             if data["host_addr"]: 
    786                 self._load_inventory_host_data(title, data["host_addr"]) 
    787                  
    788             else: 
    789                 pass 
    790                 #self._load_inventory_data(title) 
    791         """ 
    792                  
    793794                 
    794795     
     
    931932                for pd in pdata: 
    932933                    fpd = self.invdb.get_port_data_for_pdata_from_db(pd[2], pd[3],  
    933                                                                      pd[1]) 
    934                     if len(pdata) > 1: 
    935                         el = '\n\n' 
    936                     else: 
    937                         el = '\n' 
    938                          
    939                     temp += "Port No: %s, Protocol: %s, Port state: %s, \n\ 
     934                                                                     pd[1])                         
     935                    temp += "\nPort No: %s, Protocol: %s, Port state: %s, \n\ 
    940936Service product: %s, Service version: %s, Service extrainfo: %s, \n\ 
    941 Service name: %s%s" % (pd[0], fpd[0], fpd[1], fpd[2], fpd[3], fpd[4], fpd[7], el) 
     937Service name: %s\n" % (pd[0], fpd[0], fpd[1], fpd[2], fpd[3], fpd[4], fpd[7]) 
    942938                 
    943939                text.append(temp) # port data 
     
    945941                # get extraports data for this host 
    946942                epdata = self.invdb.get_extraports_data_for_host_from_db(base_hosts_data[host_count][1]) 
    947                 text.append("Extraports\n") 
    948                 text.append("Count: %d, State: %s" % (epdata[0], epdata[1])) 
     943                text.append("\nExtraports\n") 
     944                text.append("Count: %d, State: %s\n" % (epdata[0], epdata[1])) 
    949945                 
    950946                # get fingerprint info for host 
    951947                fpinfo = self.invdb.get_fingerprint_info_for_host_from_db(base_hosts_data[host_count][1]) 
    952948                if fpinfo: 
    953                     text.append("Uptime: %s, Last boot:%s\netc: %s" % (fpinfo[0], 
    954                                                                        fpinfo[1], 
    955                                                                        fpinfo[2:])) 
     949                    text.append("\nUptime: %s, Last boot: %s\n" % (fpinfo[0], 
     950                                                                   fpinfo[1])) 
     951                    text.append("TCP Sequence\n") 
     952                    text.append("Class: %s, Index: %s, Value: %s\n" % (fpinfo[2], 
     953                                                                     fpinfo[3], 
     954                                                                     fpinfo[4])) 
     955                    text.append("TCP TS Sequence\n") 
     956                    text.append("Class: %s, Value: %s\n" % (fpinfo[5], fpinfo[6])) 
     957                    text.append("IP ID Sequence\n") 
     958                    text.append("Class: %s, Value: %s\n" % (fpinfo[7], fpinfo[8])) 
    956959                     
    957960                # get osmatch info for host 
    958961                match = self.invdb.get_osmatch_for_host_from_db(base_hosts_data[host_count][1]) 
    959962                if match: 
    960                     text.append("Name: %s, Accuracy: %s, Line: %s" % (match[0], 
     963                    text.append("\nOS Match\n") 
     964                    text.append("Name: %s, Accuracy: %s, Line: %s\n" % (match[0], 
    961965                                                                      match[1], 
    962966                                                                      match[2])) 
     
    964968                # get osclasses for host 
    965969                classes = self.invdb.get_osclasses_for_host_from_db(base_hosts_data[host_count][1]) 
    966                 if classes: 
    967                     text.append(classes) 
     970                if len(classes): 
     971                    text.append("\nOS Classes\n") 
     972                for osclass in classes: 
     973                    text.append("Accuracy: %s, OS Gen: %s, OS Family: %s, \ 
     974OS Vendor: %s, OS Type: %s\n" % (osclass[0], osclass[1], osclass[2], osclass[3], 
     975                               osclass[4])) 
    968976                     
    969                 print text, text_buffer 
    970977                self.insert_text(text_buffer, text) 
    971978                self.attach_widgets(tview, item[1]) 
     
    974981                host_count += 1 
    975982            else: 
    976                 text.append("down") 
     983                text.append("Host down") 
    977984                self.insert_text(text_buffer, text) 
    978985                self.attach_widgets(tview, item[1]) 
    979986                box.pack_start(tview) 
    980                  
     987         
     988        box.show_all() 
    981989        sw = gtk.ScrolledWindow() 
    982990        sw.add_with_viewport(box) 
    983991        sw.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC) 
    984         sw.show_all() 
    985992     
    986993        return sw