Changeset 5906

Show
Ignore:
Timestamp:
04/09/11 18:14:45 (2 years ago)
Author:
luis
Message:

(Network Scanner - Bluetooth) Added Umit BT code. Thanks Niteesh Kumar for work. Now adapt to new structure is required

Location:
network-scanner/branches/BTIntegration
Files:
14 added
5 modified

Legend:

Unmodified
Added
Removed
  • network-scanner/branches/BTIntegration/share/umit/config/scan_profile.usp

    r5893 r5906  
    6464options = Disable ping,Ports to scan,Traceroute 
    6565 
     66[umitbluetooth] 
     67tool = umitbt 
     68description =  
     69hint =  
     70options = Umit Bluetooth Scan 
     71command = umitbluetooth 
     72annotation =''' 
     73 
    6674[Nmap Intense Scan] 
    6775tool = nmap 
  • network-scanner/branches/BTIntegration/share/umit/config/umit.conf

    r5893 r5906  
    66highlight = [65535, 65535, 65535] 
    77underline = 0 
     8 
     9[database] 
     10umit_decay = 60 
     11inventory_decay = 0 
    812 
    913[date_highlight] 
     
    3337modified = [63881, 42182, 13193] 
    3438 
     39[expose] 
     40host_list = 1 
     41show_toolbar = 1 
     42icons_toolbar_size = larger 
     43icons_toolbar = Both 
     44page_inside = 1 
     45details = 1 
     46 
    3547[filtered_port_highlight] 
    3648regex = \d{1,5}/.{1,5}\s+filtered\s+.* 
     
    4153underline = 0 
    4254 
     55[general_settings] 
     56log = File 
     57warnings = 1 
     58silent_root = 0 
     59splash = 1 
     60log_file = umit.log 
     61warnings_save = 1 
     62crash_report = 1 
     63 
    4364[hostname_highlight] 
    44 regex =  (\w{2,}://)?(([a-zA-Z0-9]|-)+\.)+([a-zA-Z]{2,}|com|org|net|gov|mil|biz|info|mobi|name|aero|jobs|museum)([\w\d#/])* 
     65regex = (\w{2,}://)?(([a-zA-Z0-9]|-)+\.)+([a-zA-Z]{2,}|com|org|net|gov|mil|biz|info|mobi|name|aero|jobs|museum)([\w\d#/])* 
    4566bold = 1 
    4667text = [0, 111, 65535] 
     
    4869highlight = [65535, 65535, 65535] 
    4970underline = 1 
     71 
     72[inventory] 
     73tips = True 
     74tabs_close_btn = True 
    5075 
    5176[ip_highlight] 
     
    5681highlight = [65535, 65535, 65535] 
    5782underline = 0 
     83 
     84[mapper] 
     85layout = 1 
     86zoom = 1.0 
     87lower_ring = 10 
     88frames = 60 
     89ring = 30 
     90interpolation = 1 
     91view = address;hostname;icon;ring;region;slow 
     92 
     93[network] 
     94username =  
     95hostname =  
     96proxy = 0 
     97password =  
     98port =  
    5899 
    59100[open_port_highlight] 
     
    71112nmap_command_path = nmap 
    72113 
     114[plugins] 
     115plugins =  
     116paths = /home/bastiao/Umit/svn/network-scanner/branches/BTIntegration/share/umit/config/plugins 
     117 
    73118[port_list_highlight] 
    74119regex = PORT\s+STATE\s+SERVICE(\s+VERSION)?\s.* 
     
    79124underline = 0 
    80125 
     126[profiles] 
     127profile = profile_editor.xml 
     128wizard = wizard.xml 
     129option = options.xml 
     130scan_profile = scan_profile.usp 
     131 
     132[script_manager] 
     133columns_order = I;Name;Type;Description;Author;Categories;ID 
     134columns_visible = I;Name;Type;ID 
     135http_proxy = :3128 
     136use_internal_editor = 1 
     137view_statusbar = 1 
     138view_description = 1 
     139ftp_proxy = :3128 
     140view_categories = 1 
     141external_command = gedit %%s 
     142view_toolbar = 1 
     143 
    81144[search] 
    82145search_db = 1 
     
    86149save_time = 60;days 
    87150 
    88 [general_settings] 
    89 splash = 1  
    90 warnings = 1 
    91 crash_report = 1 
    92 log = File 
    93 log_file = umit.log 
    94 warnings_save = 1 
    95 silent_root = 0 
    96  
    97 [expose] 
    98 icons_toolbar = Both 
    99 icons_toolbar_size = larger 
    100 show_toolbar = 1 
    101 host_list = 1 
    102 details = 1 
    103 page_inside = 1 
    104  
    105 [profiles] 
    106 profile = profile_editor.xml 
    107 wizard = wizard.xml 
    108 option = options.xml 
    109 scan_profile = scan_profile.usp 
    110  
    111 [network] 
    112 proxy = 0 
    113 hostname =  
    114 port =  
    115 username =  
    116 password =  
    117  
    118 [database] 
    119 umit_decay = 60 
    120 inventory_decay = 0 
    121  
    122 [inventory] 
    123 tips = True 
    124 tabs_close_btn = True 
    125  
    126 [script_manager] 
    127 columns_order = I;Name;Type;Description;Author;Categories;ID 
    128 columns_visible = I;Name;Type;ID 
    129 use_internal_editor = 1 
    130 view_toolbar = 1 
    131 view_description = 1 
    132 view_categories = 1 
    133 view_statusbar = 1 
    134 http_proxy = :3128 
    135 ftp_proxy = :3128 
    136 external_command = gedit %%s 
    137  
    138 [mapper] 
    139 frames = 60 
    140 interpolation = 1 
    141 layout = 1 
    142 zoom = 1.0 
    143 ring = 30 
    144 lower_ring = 10 
    145 view = address;hostname;icon;ring;region;slow 
  • network-scanner/branches/BTIntegration/umit/gui/FileChoosers.py

    r5893 r5906  
    4141        self.set_name(_("Umit Scan Profile (%s)") % pattern) 
    4242 
     43class ResultUmitBluetooth(gtk.FileFilter): 
     44    def __init__(self): 
     45        gtk.FileFilter.__init__(self) 
     46 
     47        pattern = "*.ubt" 
     48        self.add_pattern(pattern) 
     49        self.set_name(_("Umit bluetooth (%s)") % pattern) 
     50 
    4351class ResultsFileFilter(gtk.FileFilter): 
    4452    def __init__(self): 
     
    113121                                       action, buttons) 
    114122 
    115         for f in (ResultsFileFilter(), AllFilesFileFilter()): 
     123        for f in (ResultsFileFilter(), ResultUmitBluetooth(), AllFilesFileFilter()): 
    116124            self.add_filter(f) 
    117125 
  • network-scanner/branches/BTIntegration/umit/gui/MainWindow.py

    r5893 r5906  
    4141from umit.gui.FileChoosers import SaveResultsFileChooserDialog 
    4242from umit.gui.FileChoosers import ExportHTMLResultsFileChooserDialog 
    43 from umit.gui.ScanNotebook import ScanNotebook, ScanNotebookPage, NmapScanNotebookPage 
     43from umit.gui.ScanNotebook import ScanNotebook, ScanNotebookPage, NmapScanNotebookPage, ScanNotebookPageBT 
    4444from umit.gui.ScanPage import ScanPage 
    4545from umit.gui.ProfileEditor import ProfileEditor 
     
    272272               ('New Scan', 
    273273                gtk.STOCK_NEW, 
    274                 _('_New Scan'), 
     274                _('_New nmap Scan'), 
    275275                "<Control>T", 
    276                 _('Create a new Scan Tab'), 
     276                _('Create a new nmap Scan Tab'), 
    277277                self._new_scan_cb), 
    278278 
     
    10951095            log.debug(">>> Permissions to access file? %s" % os.access(filename, 
    10961096                                                                       os.R_OK)) 
     1097            base, ext = os.path.splitext(filename) 
     1098            if ext==".ubt" : 
     1099                current_page.toolbar.profile_entry.set_selected_profile("umitbluetooth") 
     1100                #scan_page.scan_result = ScanNotebookPageBT() 
     1101                scan_page.scan_result.on_load(filename) 
     1102                return 
    10971103 
    10981104            # Parse result 
     
    11401146    def _save_scan_results_cb(self, saving_page): 
    11411147        current_page = self._current_page() 
     1148        if current_page.toolbar.selected_profile=="umitbluetooth": 
     1149            current_page.scan_result.on_save() 
    11421150         
    11431151        try: 
  • network-scanner/branches/BTIntegration/umit/gui/ScanNotebook.py

    r5893 r5906  
    4747from umit.core.UmitConf import CommandProfile, ProfileNotFound, Profile 
    4848from umit.core.NmapParser import NmapParser 
     49from umit.scan.bt.core.ubt_parser import XMLDocument 
     50from umit.scan.bt.gui import btcore 
    4951from umit.core.Paths import Path 
    5052from umit.core.UmitLogging import log 
     
    309311            service.get('service_version', '')) 
    310312 
     313class ScanNotebookPageBT(HIGVBox): 
     314    __gsignals__ = { 
     315        'scan-finished' : (gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE, ()) 
     316    } 
     317 
     318    def __init__(self): 
     319        HIGVBox.__init__(self) 
     320        # The borders are consuming too much space on Maemo. Setting it to 
     321        # 0 pixels while on Maemo 
     322        if is_maemo(): 
     323            self.set_border_width(0) 
     324         
     325        self.set_spacing(0) 
     326        self.status = PageStatus() 
     327        self.status.set_empty() 
     328         
     329        self.changes = False 
     330        self.comments = {} 
     331        self.hosts = {} 
     332        self.services = {} 
     333 
     334        self.parsed = XMLDocument()#XXX file to be included for this ubt_parser.py 
     335        self.vpaned = gtk.VPaned() 
     336 
     337        self.__create_topbar() 
     338        self.__create_BT_MAP() 
     339        self.__create_SDPview() 
     340        self.__create_statusbar() 
     341         
     342        self.saved = False 
     343        self.saved_filename = '' 
     344 
     345        self._pack_expand_fill(self.vpaned) 
     346        self._pack_expand_fill(self.status_bar) 
     347 
     348        PluginEngine().core.emit('ScanNotebookPage-created', self) 
     349 
     350    def __create_topbar(self): 
     351        hbox1 = gtk.HBox() 
     352        #Progressbar 
     353        self.progb = gtk.ProgressBar() 
     354        self.progb.set_text("") 
     355        self.progb.set_fraction(0) 
     356        hbox1.pack_end(self.progb, False, False, 5) 
     357 
     358        #Button 
     359        self.scanbutton = gtk.Button("Probe Devices") 
     360        self.scanbutton.connect("clicked", self.enter_cb) 
     361        hbox1.pack_end(self.scanbutton, False, False, 0) 
     362 
     363        #toggle button 
     364        self.sdp_borwsing= gtk.ToggleButton(label="SDP Browsing", use_underline=False) 
     365        self.sdp_borwsing.connect("toggled", self.sdp_cb) 
     366 
     367        hbox1.pack_end(self.sdp_borwsing, False, False, 0) 
     368        self._pack_noexpand_nofill(hbox1) 
     369 
     370    def __create_BT_MAP(self): 
     371         
     372         # BT Map 
     373        self.scrolled_map = gtk.ScrolledWindow() 
     374        self.scrolled_map.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC) 
     375        self.mapmodel = gtk.ListStore(str, gtk.gdk.Pixbuf) 
     376        self.btmap =   gtk.IconView(self.mapmodel)       
     377        self.btmap.connect("item-activated", self.iconclick_cb) 
     378        self.btmap.set_text_column(0) 
     379        self.btmap.set_pixbuf_column(1) 
     380        self.scrolled_map.add(self.btmap) 
     381        self.vpaned.pack1(self.scrolled_map, True, True) 
     382 
     383    def __create_SDPview(self): 
     384        hbox2 = gtk.HBox() 
     385        # Labels   
     386        self.label = gtk.Label("Device Details\t\t\t\t\n\nName: " + "\nMAC: " + "\nManufacturer: ") 
     387        self.label.set_selectable(True) 
     388        self.label.set_alignment(0.4,0) 
     389        hbox2.pack_start(self.label, False) 
     390         
     391        # SDP View 
     392        self.scrolled_info = gtk.ScrolledWindow() 
     393        self.scrolled_info.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)        
     394        self.sdpview = gtk.TextView()    
     395        self.sdpview.set_editable(False) 
     396        self.sdpview.get_buffer().set_text("SDP Info\n\nNote: Option Disabled by Default. To enable SDP, select the SDP option under the Preference tab.") 
     397        self.scrolled_info.add(self.sdpview)     
     398        hbox2.pack_start(self.scrolled_info, True)       
     399        self.vpaned.pack2(hbox2, True, True) 
     400 
     401    def __create_statusbar(self): 
     402        # Statusbar 
     403        self.status_bar = gtk.Statusbar()       
     404        self.context_id = self.status_bar.get_context_id("Scan Status") 
     405        message_id = self.status_bar.push(self.context_id, "Idle") 
     406        self.status_bar.set_has_resize_grip(True) 
     407 
     408    def enter_cb(self, widget): 
     409        btcore.btcore().scan(self) 
     410 
     411    def iconclick_cb(self, path, action):         
     412        iter = self.btmap.get_cursor() 
     413        buffer = str(iter[0])[:2].replace("(","") 
     414        btid = int(buffer) 
     415        print "Clicked Icon: "+ str(buffer) 
     416        btcore.btcore().set_info(self, btid) 
     417        #outputs the location of the icon numerically 
     418 
     419    def sdp_cb(self, action): 
     420        # action has not toggled yet          
     421        text = ('Enabled', 'Disabled')[self.sdp_borwsing.get_active()==False]         
     422        message_id = self.status_bar.push(self.context_id, "SDP Browsing is %s"%text) 
     423        btcore.btcore().set_sdp(text)         
     424        return 
     425 
     426    def on_load(self, filename): 
     427        btcore.btcore().load_scan(self, filename) 
     428        
     429    def on_save(self): 
     430        btcore.btcore().save_scan(self) 
     431 
     432 
    311433 
    312434class ScanNotebookPage(HIGVBox): 
     
    541663        #log.debug(">>> Target: %s" % target) 
    542664         
    543         try: 
    544             cmd_profile = CommandProfile() 
    545             command = cmd_profile.get_command(profile) % target 
    546             del(cmd_profile) 
    547              
    548             # scan button must be enable if -iR or -iL options are passed 
    549             if command.find('-iR') != -1 or command.find('-iL') != -1: 
    550                 self.page.toolbar.scan_button.set_sensitive(True) 
    551  
    552                 # For these nmap options, target is unnecessary. 
    553                 # Removes unnecessary target from the command 
    554                 command = command.replace(target,'').strip() 
    555             elif target: 
    556                 self.page.toolbar.scan_button.set_sensitive(True) 
    557             else: 
    558                 self.page.toolbar.scan_button.set_sensitive(False) 
    559  
    560             self.command_toolbar.command = command 
    561         except ProfileNotFound: 
    562             pass 
    563             #self.profile_not_found_dialog() 
    564         except TypeError: 
    565             pass # That means that the command string conversion "%" didn't work 
     665        if profile == "umitbluetooth": 
     666            self.scan_result = ScanNotebookPageBT() 
     667            self.remove(self.get_children()[1]) 
     668            self.command_toolbar.command="umitbluetooth" 
     669            self.command_toolbar.set_sensitive(False) 
     670            self.toolbar.target_entry.set_sensitive(False) 
     671            self.toolbar.scan_button.set_sensitive(False) 
     672            self._pack_expand_fill(self.scan_result) 
     673            self.show_all() 
     674        else: 
     675            #self.scan_result = ScanResult() 
     676            #self.remove(self.get_children()[1]) 
     677            #self.command_toolbar.set_sensitive(True) 
     678            #self.toolbar.target_entry.set_sensitive(True) 
     679            #self._pack_expand_fill(self.scan_result) 
     680            #self.show_all() 
     681            try: 
     682                cmd_profile = CommandProfile() 
     683                command = cmd_profile.get_command(profile) % target 
     684                del(cmd_profile) 
     685                 
     686                # scan button must be enable if -iR or -iL options are passed 
     687                if command.find('-iR') != -1 or command.find('-iL') != -1: 
     688                    self.toolbar.scan_button.set_sensitive(True) 
     689 
     690                    # For these nmap options, target is unnecessary. 
     691                    # Removes unnecessary target from the command 
     692                    command = command.replace(target,'').strip() 
     693                elif target: 
     694                    self.page.toolbar.scan_button.set_sensitive(True) 
     695                else: 
     696                    self.page.toolbar.scan_button.set_sensitive(False) 
     697 
     698                self.command_toolbar.command = command 
     699            except ProfileNotFound: 
     700                pass 
     701                #self.profile_not_found_dialog() 
     702            except TypeError: 
     703                pass # That means that the command string conversion "%" didn't work 
    566704 
    567705    def __create_scan_result(self):