Changeset 5781

Show
Ignore:
Timestamp:
08/06/10 19:51:12 (3 years ago)
Author:
diogo
Message:

PreferencesWindow merge started

Location:
network-scanner/branches/GSoC2010
Files:
3 modified
13 copied

Legend:

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

    r5773 r5781  
    6464options = Disable ping,Ports to scan,Traceroute 
    6565 
    66 [Intense Scan] 
     66[Nmap Intense Scan] 
    6767tool = nmap 
    6868description =  
  • network-scanner/branches/GSoC2010/umit/core/UmitConf.py

    r5761 r5781  
    66# 
    77# Author: Adriano Monteiro Marques <adriano@umitproject.org> 
     8#         Luis A. Bastião Silva <luis.kop@gmail.com> 
    89# 
    910# This program is free software; you can redistribute it and/or modify 
     
    287288                'annotation':self.get_annotation(profile_name),\ 
    288289                'options':self.get_options(profile_name)} 
     290     
     291     
     292# Preferences 
     293 
     294 
     295""" 
     296General Settings Configuration class (Core) 
     297""" 
     298 
     299class GeneralSettingsConf(UmitConfigParser, object): 
     300    """  
     301    General Settings defining the settings like enable splash/warnings 
     302    nmap command, remove history (using targets, and recents class), etc 
     303    """ 
     304    def __init__(self): 
     305        """ Constructor generalsettings conf""" 
     306        self.parser = Path.config_parser 
     307        self.section_name = "general_settings" 
     308        if not self.parser.has_section(self.section_name): 
     309            self.create_section() 
     310        self.attributes = {}  
     311    def create_section(self): 
     312        print "creating general_settings section" 
     313        self.parser.add_section(self.section_name) 
     314        self.splash = True 
     315        self.warnings_extensions = False 
     316        self.silent_root = False 
     317        self.crash_report = True 
     318        self.log = "None" 
     319        self.warnings_save = True 
     320    def boolean_sanity(self, attr): 
     321        if attr == True or \ 
     322           attr == "True" or \ 
     323           attr == "true" or \ 
     324           attr == "1": 
     325 
     326            return 1 
     327 
     328        return 0 
     329 
     330    def _get_it(self, p_name, default): 
     331        return self.parser.get(self.section_name, p_name, default) 
     332 
     333    def _set_it(self, p_name, value): 
     334        self.parser.set(self.section_name, p_name, value) 
     335         
     336    def save_changes(self): 
     337        log.debug('call save changes') 
     338        self.parser.save_changes() 
     339         
     340    # API 
     341    def get_splash(self): 
     342        return self.boolean_sanity(self._get_it("splash", True)) 
     343    def set_splash(self, splash): 
     344        self._set_it("splash", self.boolean_sanity(splash)) 
     345     
     346    def set_warnings_extensions(self, extensions): 
     347        self._set_it("warnings", self.boolean_sanity(extensions)) 
     348    def get_warnings_extensions(self): 
     349        return self.boolean_sanity(self._get_it("warnings", True)) 
     350 
     351    def set_silent_root(self, root): 
     352        self._set_it("silent_root", self.boolean_sanity(root)) 
     353    def get_silent_root(self): 
     354        return self.boolean_sanity(self._get_it("silent_root", False)) 
     355    
     356    def set_crash_report(self, crash): 
     357        self._set_it("crash_report", self.boolean_sanity(crash)) 
     358    def get_crash_report(self): 
     359        return self.boolean_sanity(self._get_it("crash_report", True)) 
     360     
     361    def get_log(self): 
     362        """ 
     363        return str: (None, Debug or File) 
     364        """ 
     365        return self._get_it("log", "None") 
     366    def set_log(self, log): 
     367        self._set_it("log", log) 
     368         
     369    def get_log_file(self): 
     370        return self._get_it("log_file", "umit.log") 
     371    def set_log_file(self, filename): 
     372        self._set_it("log_file", filename) 
     373     
     374     
     375    def set_warnings_save(self, save): 
     376        self._set_it("warnings_save", self.boolean_sanity(save)) 
     377    def get_warnings_save(self): 
     378        return self.boolean_sanity(self._get_it("warnings_save", True)) 
     379         
     380    splash = property(get_splash, set_splash) 
     381    warnings_extensions = property(get_warnings_extensions, \ 
     382                                   set_warnings_extensions) 
     383    silent_root = property(get_silent_root, set_silent_root) 
     384    crash_report = property(get_crash_report, set_crash_report) 
     385    log = property(get_log, set_log) 
     386    log_file = property(get_log_file, set_log_file) 
     387    warnings_save = property(get_warnings_save, set_warnings_save)  
     388 
     389""" 
     390Expose settings  
     391""" 
     392 
     393class ExposeConf(UmitConfigParser, object): 
     394    """  
     395    Expose  
     396    """ 
     397    def __init__(self): 
     398        """ Constructor expose_settings conf""" 
     399        self.parser = Path.config_parser 
     400        self.section_name = "expose" 
     401        if not self.parser.has_section(self.section_name): 
     402            self.create_section() 
     403        self.attributes = {}  
     404    def create_section(self): 
     405        self.parser.add_section(self.section_name) 
     406        self.icons_toolbar = "Both" 
     407        self.show_toolbar = True 
     408        self.host_list = True 
     409        self.details = True 
     410        self.page_inside = True 
     411         
     412    def boolean_sanity(self, attr): 
     413        if attr == True or \ 
     414           attr == "True" or \ 
     415           attr == "true" or \ 
     416           attr == "1": 
     417 
     418            return 1 
     419 
     420        return 0 
     421 
     422    def _get_it(self, p_name, default): 
     423        return self.parser.get(self.section_name, p_name, default) 
     424 
     425    def _set_it(self, p_name, value): 
     426        self.parser.set(self.section_name, p_name, value) 
     427         
     428    def save_changes(self): 
     429        log.debug('call save changes') 
     430        self.parser.save_changes() 
     431         
     432    def get_icons_toolbar_size(self): 
     433        return self._get_it("icons_toolbar_size", "") 
     434    def set_icons_toolbar_size(self, icons): 
     435        self._set_it("icons_toolbar_size", icons) 
     436         
     437    def get_icons_toolbar(self): 
     438        return self._get_it("icons_toolbar", "") 
     439    def set_icons_toolbar(self, icons): 
     440        self._set_it("icons_toolbar", icons) 
     441             
     442    def get_show_toolbar(self): 
     443        return self.boolean_sanity(self._get_it("show_toolbar", True)) 
     444     
     445    def set_show_toolbar(self, toolbar): 
     446        self._set_it("show_toolbar", self.boolean_sanity(toolbar)) 
     447         
     448    def get_host_list(self): 
     449        return self.boolean_sanity(self._get_it("host_list", True)) 
     450     
     451    def set_host_list(self, hl): 
     452        self._set_it("host_list", self.boolean_sanity(hl))  
     453         
     454    def set_details(self, details): 
     455        self._set_it("details", self.boolean_sanity(details))  
     456    def get_details(self): 
     457        return self.boolean_sanity(self._get_it("details", True)) 
     458     
     459    def get_page_inside(self): 
     460        return self.boolean_sanity(self._get_it("page_inside", True)) 
     461     
     462    def set_page_inside(self, page): 
     463        self._set_it("page_inside", self.boolean_sanity(page))  
     464       
     465    icons_toolbar_size = property(get_icons_toolbar_size,set_icons_toolbar_size) 
     466    icons_toolbar = property(get_icons_toolbar,set_icons_toolbar) 
     467    show_toolbar = property(get_show_toolbar, set_show_toolbar) 
     468    host_list = property(get_host_list, set_host_list) 
     469    details = property(get_details, set_details) 
     470    page_inside = property(get_page_inside, set_page_inside) 
     471     
     472     
     473class ProfilesConf(UmitConfigParser, object): 
     474    """  
     475    Profiles 
     476    """ 
     477    def __init__(self): 
     478        """ Constructor profiles conf""" 
     479        self.parser = Path.config_parser 
     480        self.section_name = "profiles" 
     481        if not self.parser.has_section(self.section_name): 
     482            self.create_section() 
     483        self.attributes = {}  
     484    def create_section(self): 
     485        self.parser.add_section(self.section_name) 
     486 
     487    def _get_it(self, p_name, default): 
     488        return self.parser.get(self.section_name, p_name, default) 
     489 
     490    def _set_it(self, p_name, value): 
     491        self.parser.set(self.section_name, p_name, value) 
     492         
     493    def get_profile(self): 
     494        return self._get_it("profile", "") 
     495    def set_profile(self, profile): 
     496        self._set_it("profile", profile) 
     497         
     498    def get_wizard(self): 
     499        return self._get_it("wizard", "") 
     500    def set_wizard(self, wizard): 
     501        self._set_it("wizard", wizard) 
     502     
     503    def get_options(self): 
     504        return self._get_it("options", "") 
     505    def set_options(self, options): 
     506        self._set_it("options", options) 
     507         
     508    def get_scan_profiles(self): 
     509        return self._get_it("scan_profiles", "") 
     510    def set_scan_profiles(self, profile): 
     511        self._set_it("scan_profiles", profile) 
     512         
     513    profile = property(get_profile, set_profile) 
     514    scan_profiles = property(get_scan_profiles, set_scan_profiles) 
     515    options = property(get_options, set_options) 
     516    wizard = property(get_wizard, set_wizard) 
     517     
     518     
     519""" 
     520Network settings  
     521""" 
     522 
     523class NetworkConf(UmitConfigParser, object): 
     524    """  
     525    Network Settings 
     526    """ 
     527    def __init__(self): 
     528        """ Constructor network_settings conf""" 
     529        self.parser = Path.config_parser 
     530        self.section_name = "network" 
     531        if not self.parser.has_section(self.section_name): 
     532            self.create_section() 
     533        self.attributes = {}  
     534    def create_section(self): 
     535        self.parser.add_section(self.section_name) 
     536        self.proxy_enable = False  
     537        self.hostname = "" 
     538        self.port = "" 
     539        self.username = "" 
     540        self.password = "" 
     541         
     542    def boolean_sanity(self, attr): 
     543        if attr == True or \ 
     544           attr == "True" or \ 
     545           attr == "true" or \ 
     546           attr == "1": 
     547 
     548            return 1 
     549 
     550        return 0 
     551 
     552    def _get_it(self, p_name, default): 
     553        return self.parser.get(self.section_name, p_name, default) 
     554 
     555    def _set_it(self, p_name, value): 
     556        self.parser.set(self.section_name, p_name, value) 
     557         
     558    def save_changes(self): 
     559        log.debug('call save changes - network settings') 
     560        self.parser.save_changes() 
     561    
     562    # API 
     563     
     564    def get_proxy(self): 
     565        return self.boolean_sanity(self._get_it("proxy", False))    
     566    def set_proxy(self, proxy): 
     567        self._set_it("proxy", self.boolean_sanity(proxy)) 
     568     
     569    def get_hostname(self): 
     570        return self._get_it("hostname", "") 
     571    def set_hostname(self, hostname): 
     572        self._set_it("hostname", hostname) 
     573         
     574    def get_port(self): 
     575        return self._get_it("port", "80") 
     576    def set_port(self, port): 
     577        self._set_it("port", str(port)) 
     578         
     579    def get_username(self): 
     580        return self._get_it("username", "") 
     581    def set_username(self, username): 
     582        self._set_it("username", username) 
     583         
     584    def get_password(self): 
     585        return self._get_it("username", "") 
     586    def set_password(self, password): 
     587        self._set_it("password", password) 
     588         
     589     
     590         
     591    proxy = property(get_proxy, set_proxy) 
     592    hostname = property(get_hostname, set_hostname) 
     593    port = property(get_port, set_port) 
     594    username = property(get_username, set_username) 
     595    password = property(get_password, set_password)     
    289596 
    290597 
  • network-scanner/branches/GSoC2010/umit/core/UserConf.py

    r5342 r5781  
    4545recent_scans_content = ''' ''' 
    4646 
    47 scan_profile_content = '''[Quick Scan] 
     47scan_profile_content = '''[Nmap Quick Scan] 
     48tool = nmap 
    4849description =  
    4950hint =  
     
    5253annotation =  
    5354 
    54 [Intense Scan] 
     55[Nmap Intense Scan] 
     56tool = nmap 
    5557description =  
    5658hint =  
     
    5961annotation =  
    6062 
    61 [Regular Scan] 
     63[Nmap Regular Scan] 
     64tool = nmap 
    6265description =  
    6366hint =  
     
    6669annotation =  
    6770 
    68 [Quick and verbose scan] 
     71[Nmap Quick and verbose scan] 
     72tool = nmap 
    6973description =  
    7074hint =  
     
    7377annotation =  
    7478 
    75 [Operating System Detection] 
     79[Nmap Operating System Detection] 
     80tool = nmap 
    7681description =  
    7782hint =  
     
    8085annotation =  
    8186 
    82 [Quick Services version detection] 
     87[Nmap Quick Services version detection] 
     88tool = nmap 
    8389description =  
    8490hint =  
     
    8793annotation =  
    8894 
    89 [Quick Full version Detection Scan] 
     95[Nmap Quick Full version Detection Scan] 
     96tool = nmap 
    9097description =  
    9198hint =  
     
    94101annotation =  
    95102 
    96 [Quick Operating System detection] 
     103[Nmap Quick Operating System detection] 
     104tool = nmap 
    97105description =  
    98106hint =  
    99107options = Operating system detection,Aggressive,Verbose 
    100108command = nmap -T Aggressive -O -v %s 
    101 annotation =  ''' 
     109annotation =   
     110 
     111[Zion Honeyd Detection] 
     112tool = zion 
     113zion_id = 1 
     114description = Detect Honeyd using one TCP open port 
     115hint =  
     116annotation =  
     117 
     118[Zion OS Detection] 
     119tool = zion 
     120zion_id = 2 
     121description = Detect Operating System using one TCP open port 
     122hint =  
     123annotation =  
     124 
     125[Zion Prompt] 
     126tool = zion 
     127zion_id = 3 
     128description = Show a Zion prompt to allow user uses the backend 
     129hint =  
     130annotation =  
     131 
     132[Zion SYN Proxy Detection] 
     133tool = zion 
     134zion_id = 4 
     135description = Detect SYN Proxies using one TCP open port 
     136hint =  
     137annotation =''' 
    102138 
    103139profile_editor_content = '''<?xml version="1.0"?> 
  • network-scanner/branches/GSoC2010/umit/gui/FileChoosers.py

    r5761 r5781  
    6565        self.set_name(_("Umit HTML Diff (%s)") % pattern) 
    6666         
     67class HtmlFileFilter(gtk.FileFilter): 
     68    def __init__(self): 
     69        gtk.FileFilter.__init__(self) 
     70 
     71        pattern = "*.html" 
     72        self.add_pattern(pattern) 
     73        self.set_name(_("Umit HTML (%s)") % pattern)         
     74         
    6775class NSEFileFilter(gtk.FileFilter): 
    6876    def __init__(self): 
     
    118126        for f in (ResultsFileFilter(), AllFilesFileFilter()): 
    119127            self.add_filter(f) 
     128             
     129             
     130class ExportHTMLResultsFileChooserDialog(gtk.FileChooserDialog): 
     131    def __init__(self, title="", parent=None, 
     132                 action=gtk.FILE_CHOOSER_ACTION_SAVE, 
     133                 buttons=(gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL, 
     134                          gtk.STOCK_SAVE, gtk.RESPONSE_OK), backend=None): 
     135 
     136        gtk.FileChooserDialog.__init__(self, title, parent, action, buttons) 
     137 
     138        for f in (HtmlFileFilter(), AllFilesFileFilter()): 
     139            self.add_filter(f) 
     140             
    120141 
    121142class FullDiffiesFileChooserDialog(gtk.FileChooserDialog): 
  • network-scanner/branches/GSoC2010/umit/gui/MainWindow.py

    r5352 r5781  
    2929import xml.sax.saxutils 
    3030 
    31 from types import StringTypes 
    3231from time import time 
    3332from tempfile import mktemp 
     
    5655 
    5756from umit.interfaceeditor.Main import InterfaceEditor 
     57from umit.nsefacilitator.ScriptManager import ScriptManagerWindow 
    5858 
    5959from umit.gui.Help import show_help 
     
    379379                self._open_inv 
    380380            ), 
     381             
     382            # NSE 
     383 
     384            ('Script Manager', 
     385                gtk.STOCK_INDEX, 
     386                _('Script Manager'), 
     387                "<Control>M", 
     388                _('Manage available scripts'), 
     389                self._load_script_manager_cb 
     390            ), 
    381391 
    382392            # Scan Scheduler 
     
    464474                <menuitem action='Open Inv'/> 
    465475            </menu> 
     476            <menuitem action='Script Manager'/> 
    466477            </menu> 
    467478 
     
    821832                             scan, 
    822833                             self._load_recent_scan) 
    823                 new_rscan_xml += "<menuitem action='%s'/>\n" % \ 
    824                               xml.sax.saxutils.escape(scan) 
     834                new_rscan_xml += "<menuitem action=%s/>\n" % \ 
     835                              xml.sax.saxutils.quoteattr(scan) 
    825836                actions.append(new_rscan) 
    826837        new_rscan_xml += "<separator />\n" 
     
    14711482        self.wlist.append(self.diff_window) 
    14721483        self.diff_window.show_all() 
     1484         
     1485    def _load_script_manager_cb(self, widget = None, extra = None): 
     1486        self.script_manager_window = ScriptManagerWindow() 
     1487        self.script_manager_window.show_all()         
    14731488 
    14741489