Changeset 1258

Show
Ignore:
Timestamp:
08/05/07 03:29:21 (6 years ago)
Author:
ggpolo
Message:

Merged with latest trunk version

Location:
branch/ggpolo
Files:
1 removed
10 modified
1 copied

Legend:

Unmodified
Added
Removed
  • branch/ggpolo/share/umit/config/scan_profile.usp

    r1179 r1258  
    1 [Quick Scan] 
    2 description =  
    3 hint =  
    4 options = Disable reverse DNS resolution,Aggressive,Verbose 
    5 command = nmap -T Aggressive -v -n %s 
    6 annotation =  
    7  
    81[Intense Scan] 
    92description =  
     
    136annotation =  
    147 
    15 [Regular Scan] 
    16 description =  
    17 hint =  
    18 options = Verbose 
    19 command = nmap -v %s 
    20 annotation =  
    21  
    22 [Quick and verbose scan] 
    23 description =  
    24 hint =  
    25 options = Watch packets,Verbose,Debug,Aggressive,Disable reverse DNS resolution 
    26 command = nmap -d -T Aggressive --packet_trace -v -n %s 
    27 annotation =  
    28  
    298[Operating System Detection] 
    309description =  
     
    3211options = Operating system detection,Verbose 
    3312command = nmap -O -v %s 
    34 annotation =  
    35  
    36 [Quick Services version detection] 
    37 description =  
    38 hint =  
    39 options = Version detection,Aggressive,Verbose 
    40 command = nmap -T Aggressive -sV -v %s 
    4113annotation =  
    4214 
     
    5325options = Operating system detection,Aggressive,Verbose 
    5426command = nmap -T Aggressive -O -v %s 
    55 annotation =   
     27annotation =  
     28 
     29[Quick Scan] 
     30description =  
     31hint =  
     32options = Disable reverse DNS resolution,Aggressive,Verbose 
     33command = nmap -T Aggressive -v -n %s 
     34annotation =  
     35 
     36[Quick Services version detection] 
     37description =  
     38hint =  
     39options = Version detection,Aggressive,Verbose 
     40command = nmap -T Aggressive -sV -v %s 
     41annotation =  
     42 
     43[Quick and verbose scan] 
     44description =  
     45hint =  
     46options = Watch packets,Verbose,Debug,Aggressive,Disable reverse DNS resolution 
     47command = nmap -d -T Aggressive --packet_trace -v -n %s 
     48annotation =  
     49 
     50[Regular Scan] 
     51description =  
     52hint =  
     53options = Verbose 
     54command = nmap -v %s 
     55annotation =  
     56 
  • branch/ggpolo/share/umit/config/umit.conf

    r1179 r1258  
    2424 
    2525[diff] 
     26diff_mode = text 
    2627colored_diff = True 
    2728 
  • branch/ggpolo/test/test_option_parser.py

    r1197 r1258  
    241241if __name__ == "__main__": 
    242242    suite = unittest.TestLoader().loadTestsFromTestCase(TestUmitOptionParser) 
    243     unittest.TextTestRunner(verbose=5).run(suite) 
     243    unittest.TextTestRunner(verbosity=5).run(suite) 
  • branch/ggpolo/umitCore/Email.py

    r1189 r1258  
    113113        try: 
    114114            mail = self.create_mail(subject, msg, attach) 
    115             #log.debug(">>> SENDMAIL \n%s" % mail.as_string()) 
    116             log.debug(">>> SENDING EMAIL...") 
     115            log.debug(">>> SENDMAIL \n%s" % mail.as_string()) 
    117116 
    118117            self.email_server.sendmail(self.from_addr,  
  • branch/ggpolo/umitCore/Logging.py

    r1254 r1258  
    2020# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 
    2121 
    22 import os 
    23  
     22from os.path import isfile 
    2423from logging import Logger, StreamHandler, FileHandler, Formatter 
    2524from umitCore.UmitOptionParser import option_parser 
     
    6362    Sets LOGLEVEL to 50, so every message is written. 
    6463    """ 
    65     if os.path.isfile(file_output): 
     64    if isfile(file_output): 
    6665        return Log("Umit", 0, file_output) 
    6766    else: 
  • branch/ggpolo/umitCore/UmitConf.py

    r1215 r1258  
    2626 
    2727from umitCore.Paths import Path 
     28from umitCore.Logging import log 
    2829from umitCore.UmitConfigParser import UmitConfigParser 
    29 from umitCore.Logging import log 
    3030from umitCore.I18N import _ 
    3131 
    32 config_file = Path.config_file 
    3332scan_profile = Path.scan_profile 
    3433 
     
    3635    return open(Path.umit_version).read() 
    3736 
    38 class UmitConf(UmitConfigParser, object): 
    39     def __init__(self, *args): 
    40         UmitConfigParser.__init__(self, *args) 
    41         self.read(config_file) 
    42          
     37class UmitConf(object): 
     38    def __init__(self): 
     39        self.parser = Path.config_parser 
     40 
     41    def save_changes(self): 
     42        self.parser.save_changes() 
     43 
    4344    def get_colored_diff(self): 
    4445        try: 
    45             cd = self.get('diff', 'colored_diff') 
    46             if cd == "False" or cd == "false" or cd == "0" or cd == "" or cd == False: 
     46            cd = self.parser.get('diff', 'colored_diff') 
     47            if cd == "False" or \ 
     48                cd == "false" or \ 
     49                cd == "0" or \ 
     50                cd == "" or \ 
     51                cd == False: 
    4752                return False 
    4853            return True 
    49         except:return True 
     54        except: 
     55            return True 
    5056 
    5157    def set_colored_diff(self, enable): 
    52         if not self.has_section('diff'): 
    53             self.add_section('diff') 
    54          
    55         self.set('diff', 'colored_diff', enable) 
     58        if not self.parser.has_section('diff'): 
     59            self.parser.add_section('diff') 
     60 
     61        self.parser.set('diff', 'colored_diff', str(enable)) 
    5662 
    5763    def get_diff_mode(self): 
    58         try: return self.get('diff', 'diff_mode') 
     64        try: return self.parser.get('diff', 'diff_mode') 
    5965        except: return "compare" 
    6066 
    6167    def set_diff_mode(self, diff_mode): 
    62         if not self.has_section('diff'): 
    63             self.add_section('diff') 
    64          
    65         self.set('diff', 'diff_mode', diff_mode) 
     68        if not self.parser.has_section('diff'): 
     69            self.parser.add_section('diff') 
     70         
     71        self.parser.set('diff', 'diff_mode', diff_mode) 
    6672 
    6773    colored_diff = property(get_colored_diff, set_colored_diff) 
     
    7076 
    7177class SearchConfig(UmitConfigParser, object): 
    72     def __init__(self, *args): 
    73         UmitConfigParser.__init__(self, *args) 
    74         self.read(config_file) 
     78    def __init__(self): 
     79        self.parser = Path.config_parser 
    7580 
    7681        self.section_name = "search" 
    77         if not self.has_section(self.section_name): 
     82        if not self.parser.has_section(self.section_name): 
    7883            self.create_section() 
    7984 
     85    def save_changes(self): 
     86        self.parser.save_changes() 
     87 
    8088    def create_section(self): 
    81         self.add_section(self.section_name) 
     89        self.parser.add_section(self.section_name) 
    8290        self.directory = "" 
    8391        self.file_extension = "usr" 
     
    8795 
    8896    def _get_it(self, p_name, default): 
    89         return self.get(self.section_name, p_name, default) 
     97        return self.parser.get(self.section_name, p_name, default) 
    9098 
    9199    def _set_it(self, p_name, value): 
    92         self.set(self.section_name, p_name, value) 
     100        self.parser.set(self.section_name, p_name, value) 
    93101         
    94102    def boolean_sanity(self, attr): 
     
    97105           attr == "true" or \ 
    98106           attr == "1": 
    99              
     107 
    100108            return 1 
    101          
     109 
    102110        return 0 
    103111 
     
    167175    def __init__(self, user_profile=None, *args): 
    168176        UmitConfigParser.__init__(self, *args) 
    169          
     177 
    170178        if not user_profile: 
    171179            user_profile = scan_profile 
     
    173181        fconf = open(user_profile, 'r') 
    174182        self.readfp(fconf, user_profile) 
    175          
     183 
    176184        fconf.close() 
    177185        del(fconf) 
    178          
     186 
    179187        self.attributes = {} 
    180188 
    181189    def _get_it(self, profile, attribute): 
    182190        if profile: 
    183             self.__verify_profile(profile) 
     191            self._verify_profile(profile) 
    184192            return self.get(profile, attribute) 
    185193        return "" 
     
    187195    def _set_it(self, profile, attribute, value=''): 
    188196        if profile: 
    189             self.__verify_profile(profile) 
     197            self._verify_profile(profile) 
    190198            return self.set(profile, attribute, value) 
    191199 
     
    207215        self.save_changes() 
    208216 
    209     def __verify_profile(self, profile_name): 
     217    def _verify_profile(self, profile_name): 
    210218        if profile_name not in self.sections(): 
    211219            raise ProfileNotFound(profile_name) 
     
    266274 
    267275 
    268 class NmapOutputHighlight(UmitConfigParser, object): 
     276class NmapOutputHighlight(object): 
    269277    setts = ["bold", "italic", "underline", "text", "highlight", "regex"] 
    270278     
    271     def __init__(self, *args): 
    272         UmitConfigParser.__init__(self, *args) 
    273         self.read(Path.config_file) 
     279    def __init__(self): 
     280        self.parser = Path.config_parser 
     281 
     282    def save_changes(self): 
     283        self.parser.save_changes() 
    274284 
    275285    def __get_it(self, p_name): 
     
    277287 
    278288        try: 
    279             return self.sanity_settings([self.get(property_name, prop, True) \ 
     289            return self.sanity_settings([self.parser.get(property_name, 
     290                                                         prop, 
     291                                                         True) \ 
    280292                                         for prop in self.setts]) 
    281293        except: 
     
    295307    def __set_it(self, property_name, settings): 
    296308        property_name = "%s_highlight" % property_name 
    297         settings = self.sanity_settings(settings) 
    298  
    299         [self.set(property_name, self.setts[pos], settings[pos]) \ 
     309        settings = self.sanity_settings(list(settings)) 
     310 
     311        [self.parser.set(property_name, self.setts[pos], settings[pos]) \ 
    300312         for pos in xrange(len(settings))] 
    301313 
     
    379391        enable = True 
    380392        try: 
    381             enable = self.get("output_highlight", "enable_highlight") 
     393            enable = self.parser.get("output_highlight", "enable_highlight") 
    382394        except NoSectionError: 
    383             self.set("output_highlight", "enable_highlight", str(True)) 
     395            self.parser.set("output_highlight", "enable_highlight", str(True)) 
    384396         
    385397        if enable == "False" or enable == "0" or enable == "": 
     
    389401    def set_enable(self, enable): 
    390402        if enable == False or enable == "0" or enable == None or enable == "": 
    391             self.set("output_highlight", "enable_highlight", str(False)) 
     403            self.parser.set("output_highlight", "enable_highlight", str(False)) 
    392404        else: 
    393             self.set("output_highlight", "enable_highlight", str(True)) 
     405            self.parser.set("output_highlight", "enable_highlight", str(True)) 
    394406 
    395407    date = property(get_date, set_date) 
     
    428440                            "text":[0, 1272, 28362], 
    429441                            "highlight":[65535, 65535, 65535], 
    430                             "regex":"PORT\s+STATE\s+SERVICE(\s+VERSION)?\s.*"}, 
     442                            "regex":"PORT\s+STATE\s+SERVICE(\s+VERSION)?[^\n]*"}, 
    431443                          "open_port":{"bold":str(True), 
    432444                            "italic":str(False), 
     
    454466                            "regex":"^(\w{2,}[\s]{,3}){,4}:"}} 
    455467 
    456 class DiffColors(UmitConfigParser, object): 
    457     def __init__(self, *args): 
    458         UmitConfigParser.__init__(self, *args) 
    459         self.read(Path.config_file) 
     468class DiffColors(object): 
     469    def __init__(self): 
     470        self.parser = Path.config_parser 
    460471        self.section_name = "diff_colors" 
    461472 
     473    def save_changes(self): 
     474        self.parser.save_changes() 
     475 
    462476    def __get_it(self, p_name): 
    463         return self.sanity_settings(self.get(self.section_name, p_name)) 
     477        return self.sanity_settings(self.parser.get(self.section_name, p_name)) 
    464478 
    465479    def __set_it(self, property_name, settings): 
    466480        settings = self.sanity_settings(settings) 
    467         self.set(self.section_name, property_name, settings) 
     481        self.parser.set(self.section_name, property_name, settings) 
    468482 
    469483    def sanity_settings(self, settings): 
     
    520534 
    521535if __name__ == "__main__": 
    522     d = DiffColors() 
    523  
    524     d.unchanged = [0, 0, 0] 
    525     d.added = [0, 0, 0] 
    526     d.modified = [0, 0, 0] 
    527     d.not_present = [0, 0, 0] 
    528  
    529     print d.unchanged 
    530     print d.added 
    531     print d.modified 
    532     print d.not_present 
    533      
    534     ''' 
    535     log.critical(scan_profile) 
    536     p = CommandProfile() 
    537     print p.get_profile("Quick Scan") 
    538  
    539     s_conf = SearchConfig() 
    540     print dir(s_conf) 
    541     print s_conf.directory 
    542     print s_conf.file_extension 
    543     print s_conf.save_time 
    544     print s_conf.store_results 
    545     print s_conf.search_db 
    546     print s_conf.converted_save_time 
    547  
    548  
    549     u = NmapOutputHighlight() 
    550     u.date = [1, 0, 0, [0, 0, 0], [65535, 65535, 65535], 
    551               "\d{4}-\d{2}-\d{2}\s\d{2}:\d{2}\s.{1,4}"] 
    552     u.hostname = [1, 0, 1, [0, 0, 0], [65535, 65535, 65535], "(\w+[\.]?)+"] 
    553     u.ip = [1, 0, 0, [0, 0, 0], [65535, 65535, 65535], 
    554             "[\d]{1,3}\.[\d]{1,3}\.[\d]{1,3}\.[\d]{1,3}"] 
    555     u.port_list = [1, 0, 0, [0, 0, 0], [65535, 65535, 65535], 
    556                    "PORT\s+STATE\s+SERVICE(\s+VERSION)?"] 
    557     u.open_port = [1, 0, 0, [0, 0, 0], [0, 65535, 0], "\d{1,5}/.{1,5}\sopen\s.*"] 
    558     u.closed_port = [1, 0, 0, [0, 0, 0], [65535, 0, 0], "\d{1,5}/.{1,5}\sclosed\s.*"] 
    559     u.filtered_port = [1, 0, 0, [0, 0, 0], [0, 65535, 65535], "\d{1,5}/.{1,5}\sfiltered\s.*"] 
    560     u.details = [1, 0, 0, [0, 0, 0], [65535, 65535, 65535], ".+:.+"] 
    561     u.enable = True 
    562  
    563     print "Date", u.date 
    564     print "Hostname", u.hostname 
    565     print "Ip", u.ip 
    566     print "Port list", u.port_list 
    567     print "Open port", u.open_port 
    568     print "Closed port", u.closed_port 
    569     print "Filtered port", u.filtered_port 
    570     print "Details", u.details 
    571  
    572     ''' 
     536    pass 
  • branch/ggpolo/umitCore/UmitConfigParser.py

    r1197 r1258  
    2020# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 
    2121 
    22 from ConfigParser import ConfigParser, DEFAULTSECT 
     22from os.path import exists 
     23from ConfigParser import ConfigParser, DEFAULTSECT, NoOptionError, NoSectionError 
     24from umitCore.Logging import log 
    2325 
    2426class UmitConfigParser(ConfigParser): 
     
    2830    def __init__(self, *args): 
    2931        ConfigParser.__init__(self, *args) 
     32        self.paths_checked = [] 
    3033 
    3134    def set(self, section, option, value): 
     
    3740 
    3841    def read(self, filenames): 
    39         self.filenames = ConfigParser.read(self, filenames)     
     42        if type(filenames) == type(""): 
     43            filenames = [filenames] 
     44 
     45        self.filenames = [] 
     46        for fn in filenames: 
     47            log.debug(">>>> Testing %s" % fn) 
     48            if fn not in self.paths_checked: 
     49                try: 
     50                    test_umit_conf_content(fn) 
     51                except AssertionError: 
     52                    continue 
     53 
     54            self.paths_checked.append(fn) 
     55            filename = ConfigParser.read(self, fn) 
     56            self.filenames = filename 
     57            break 
     58 
     59        if len(self.filenames) == 0: 
     60            raise Exception("Couldn't find any usable config file!") 
     61 
    4062        return self.filenames 
     63 
    4164 
    4265    def readfp(self, fp, filename=None): 
     
    5376                filename = self.filenames[0] 
    5477            else: 
    55                 raise Exception("Wrong filename") 
     78                raise Exception("Wrong filename %s" % self.filenames) 
    5679            self.write(open(filename, 'w')) 
    5780        elif self.fp: 
     
    80103                             (key, str(value).replace('\n', '\n\t'))) 
    81104            fp.write("\n") 
     105 
     106def test_umit_conf_content(filename): 
     107    parser = ConfigParser() 
     108    parser.read(filename) 
     109 
     110    # Paths section 
     111    section = "paths" 
     112    assert exists(get_or_false(parser, section, "config_file") or "") 
     113    assert exists(get_or_false(parser, section, "umit_icon") or "") 
     114    assert exists(get_or_false(parser, section, "locale_dir") or "") 
     115    assert exists(get_or_false(parser, section, "misc_dir") or "") 
     116    assert exists(get_or_false(parser, section, "icons_dir") or "") 
     117    assert exists(get_or_false(parser, section, "pixmaps_dir") or "") 
     118    assert exists(get_or_false(parser, section, "config_dir") or "") 
     119    assert exists(get_or_false(parser, section, "docs_dir") or "") 
     120    assert get_or_false(parser, section, "nmap_command_path") 
     121 
     122 
     123def get_or_false(parser, section, option): 
     124    try: 
     125        result = parser.get(section, option) 
     126        return result 
     127    except NoOptionError: 
     128        return False 
     129    except NoSectionError: 
     130        return False 
  • branch/ggpolo/umitGUI/MainWindow.py

    r1239 r1258  
    10011001    def _show_help(self, action): 
    10021002        import webbrowser 
    1003         webbrowser.open("file://%s" % os.path.join(Path.docs_dir, "help.html"), new=2) 
     1003 
     1004        new = 0 
     1005        if sys.hexversion >= 0x2050000: 
     1006            new = 2 
     1007 
     1008        webbrowser.open("file://%s" % os.path.join(Path.docs_dir, 
     1009                                                   "help.html"), new=new) 
    10041010 
    10051011    def _exit_cb (self, widget=None, extra=None): 
  • branch/ggpolo/umitGUI/NmapOutputViewer.py

    r1179 r1258  
    7272        self.text_view = gtk.TextView () 
    7373        self.btn_refresh = gtk.Button (stock=gtk.STOCK_REFRESH) 
    74         self.check_enable_color = gtk.CheckButton(_("Enable/Disable Nmap output highlight")) 
     74        self.check_enable_color = gtk.CheckButton(_("Enable Nmap output highlight")) 
    7575        self.btn_output_properties = HIGButton(stock=gtk.STOCK_PREFERENCES) 
    7676        self.hbox_buttons = gtk.HBox (spacing=5) 
  • branch/ggpolo/umitInventory/TLBase.py

    r1246 r1258  
    2222from umitCore.I18N import _ 
    2323from umitCore.Paths import Path 
    24 from umitCore.UmitConfigParser import UmitConfigParser 
     24#from umitCore.UmitConfigParser import UmitConfigParser # stopped working here 
     25from ConfigParser import ConfigParser 
    2526 
    2627from umitInventory.Calendar import CalendarManager 
     
    3233 
    3334settings_file = Path.tl_conf 
    34 configparser = UmitConfigParser() 
     35#configparser = UmitConfigParser() 
     36configparser = ConfigParser() 
    3537configparser.read(settings_file) 
    3638