Changeset 1258
- Timestamp:
- 08/05/07 03:29:21 (6 years ago)
- Location:
- branch/ggpolo
- Files:
-
- 1 removed
- 10 modified
- 1 copied
-
share/umit/config/scan_profile.usp (modified) (4 diffs)
-
share/umit/config/umit.conf (modified) (1 diff)
-
test/test_option_parser.py (modified) (1 diff)
-
test/test_umit_conf.py (copied) (copied from trunk/test/test_umit_conf.py)
-
umitCore/Email.py (modified) (1 diff)
-
umitCore/Logging.py (modified) (2 diffs)
-
umitCore/NmapOutputHighlight.py (deleted)
-
umitCore/UmitConf.py (modified) (17 diffs)
-
umitCore/UmitConfigParser.py (modified) (5 diffs)
-
umitGUI/MainWindow.py (modified) (1 diff)
-
umitGUI/NmapOutputViewer.py (modified) (1 diff)
-
umitInventory/TLBase.py (modified) (2 diffs)
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,Verbose5 command = nmap -T Aggressive -v -n %s6 annotation =7 8 1 [Intense Scan] 9 2 description = … … 13 6 annotation = 14 7 15 [Regular Scan]16 description =17 hint =18 options = Verbose19 command = nmap -v %s20 annotation =21 22 [Quick and verbose scan]23 description =24 hint =25 options = Watch packets,Verbose,Debug,Aggressive,Disable reverse DNS resolution26 command = nmap -d -T Aggressive --packet_trace -v -n %s27 annotation =28 29 8 [Operating System Detection] 30 9 description = … … 32 11 options = Operating system detection,Verbose 33 12 command = nmap -O -v %s 34 annotation =35 36 [Quick Services version detection]37 description =38 hint =39 options = Version detection,Aggressive,Verbose40 command = nmap -T Aggressive -sV -v %s41 13 annotation = 42 14 … … 53 25 options = Operating system detection,Aggressive,Verbose 54 26 command = nmap -T Aggressive -O -v %s 55 annotation = 27 annotation = 28 29 [Quick Scan] 30 description = 31 hint = 32 options = Disable reverse DNS resolution,Aggressive,Verbose 33 command = nmap -T Aggressive -v -n %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 41 annotation = 42 43 [Quick and verbose scan] 44 description = 45 hint = 46 options = Watch packets,Verbose,Debug,Aggressive,Disable reverse DNS resolution 47 command = nmap -d -T Aggressive --packet_trace -v -n %s 48 annotation = 49 50 [Regular Scan] 51 description = 52 hint = 53 options = Verbose 54 command = nmap -v %s 55 annotation = 56 -
branch/ggpolo/share/umit/config/umit.conf
r1179 r1258 24 24 25 25 [diff] 26 diff_mode = text 26 27 colored_diff = True 27 28 -
branch/ggpolo/test/test_option_parser.py
r1197 r1258 241 241 if __name__ == "__main__": 242 242 suite = unittest.TestLoader().loadTestsFromTestCase(TestUmitOptionParser) 243 unittest.TextTestRunner(verbos e=5).run(suite)243 unittest.TextTestRunner(verbosity=5).run(suite) -
branch/ggpolo/umitCore/Email.py
r1189 r1258 113 113 try: 114 114 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()) 117 116 118 117 self.email_server.sendmail(self.from_addr, -
branch/ggpolo/umitCore/Logging.py
r1254 r1258 20 20 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 21 21 22 import os 23 22 from os.path import isfile 24 23 from logging import Logger, StreamHandler, FileHandler, Formatter 25 24 from umitCore.UmitOptionParser import option_parser … … 63 62 Sets LOGLEVEL to 50, so every message is written. 64 63 """ 65 if os.path.isfile(file_output):64 if isfile(file_output): 66 65 return Log("Umit", 0, file_output) 67 66 else: -
branch/ggpolo/umitCore/UmitConf.py
r1215 r1258 26 26 27 27 from umitCore.Paths import Path 28 from umitCore.Logging import log 28 29 from umitCore.UmitConfigParser import UmitConfigParser 29 from umitCore.Logging import log30 30 from umitCore.I18N import _ 31 31 32 config_file = Path.config_file33 32 scan_profile = Path.scan_profile 34 33 … … 36 35 return open(Path.umit_version).read() 37 36 38 class UmitConf(UmitConfigParser, object): 39 def __init__(self, *args): 40 UmitConfigParser.__init__(self, *args) 41 self.read(config_file) 42 37 class UmitConf(object): 38 def __init__(self): 39 self.parser = Path.config_parser 40 41 def save_changes(self): 42 self.parser.save_changes() 43 43 44 def get_colored_diff(self): 44 45 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: 47 52 return False 48 53 return True 49 except:return True 54 except: 55 return True 50 56 51 57 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)) 56 62 57 63 def get_diff_mode(self): 58 try: return self. get('diff', 'diff_mode')64 try: return self.parser.get('diff', 'diff_mode') 59 65 except: return "compare" 60 66 61 67 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) 66 72 67 73 colored_diff = property(get_colored_diff, set_colored_diff) … … 70 76 71 77 class 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 75 80 76 81 self.section_name = "search" 77 if not self. has_section(self.section_name):82 if not self.parser.has_section(self.section_name): 78 83 self.create_section() 79 84 85 def save_changes(self): 86 self.parser.save_changes() 87 80 88 def create_section(self): 81 self. add_section(self.section_name)89 self.parser.add_section(self.section_name) 82 90 self.directory = "" 83 91 self.file_extension = "usr" … … 87 95 88 96 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) 90 98 91 99 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) 93 101 94 102 def boolean_sanity(self, attr): … … 97 105 attr == "true" or \ 98 106 attr == "1": 99 107 100 108 return 1 101 109 102 110 return 0 103 111 … … 167 175 def __init__(self, user_profile=None, *args): 168 176 UmitConfigParser.__init__(self, *args) 169 177 170 178 if not user_profile: 171 179 user_profile = scan_profile … … 173 181 fconf = open(user_profile, 'r') 174 182 self.readfp(fconf, user_profile) 175 183 176 184 fconf.close() 177 185 del(fconf) 178 186 179 187 self.attributes = {} 180 188 181 189 def _get_it(self, profile, attribute): 182 190 if profile: 183 self._ _verify_profile(profile)191 self._verify_profile(profile) 184 192 return self.get(profile, attribute) 185 193 return "" … … 187 195 def _set_it(self, profile, attribute, value=''): 188 196 if profile: 189 self._ _verify_profile(profile)197 self._verify_profile(profile) 190 198 return self.set(profile, attribute, value) 191 199 … … 207 215 self.save_changes() 208 216 209 def _ _verify_profile(self, profile_name):217 def _verify_profile(self, profile_name): 210 218 if profile_name not in self.sections(): 211 219 raise ProfileNotFound(profile_name) … … 266 274 267 275 268 class NmapOutputHighlight( UmitConfigParser,object):276 class NmapOutputHighlight(object): 269 277 setts = ["bold", "italic", "underline", "text", "highlight", "regex"] 270 278 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() 274 284 275 285 def __get_it(self, p_name): … … 277 287 278 288 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) \ 280 292 for prop in self.setts]) 281 293 except: … … 295 307 def __set_it(self, property_name, settings): 296 308 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]) \ 300 312 for pos in xrange(len(settings))] 301 313 … … 379 391 enable = True 380 392 try: 381 enable = self. get("output_highlight", "enable_highlight")393 enable = self.parser.get("output_highlight", "enable_highlight") 382 394 except NoSectionError: 383 self. set("output_highlight", "enable_highlight", str(True))395 self.parser.set("output_highlight", "enable_highlight", str(True)) 384 396 385 397 if enable == "False" or enable == "0" or enable == "": … … 389 401 def set_enable(self, enable): 390 402 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)) 392 404 else: 393 self. set("output_highlight", "enable_highlight", str(True))405 self.parser.set("output_highlight", "enable_highlight", str(True)) 394 406 395 407 date = property(get_date, set_date) … … 428 440 "text":[0, 1272, 28362], 429 441 "highlight":[65535, 65535, 65535], 430 "regex":"PORT\s+STATE\s+SERVICE(\s+VERSION)? \s.*"},442 "regex":"PORT\s+STATE\s+SERVICE(\s+VERSION)?[^\n]*"}, 431 443 "open_port":{"bold":str(True), 432 444 "italic":str(False), … … 454 466 "regex":"^(\w{2,}[\s]{,3}){,4}:"}} 455 467 456 class DiffColors(UmitConfigParser, object): 457 def __init__(self, *args): 458 UmitConfigParser.__init__(self, *args) 459 self.read(Path.config_file) 468 class DiffColors(object): 469 def __init__(self): 470 self.parser = Path.config_parser 460 471 self.section_name = "diff_colors" 461 472 473 def save_changes(self): 474 self.parser.save_changes() 475 462 476 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)) 464 478 465 479 def __set_it(self, property_name, settings): 466 480 settings = self.sanity_settings(settings) 467 self. set(self.section_name, property_name, settings)481 self.parser.set(self.section_name, property_name, settings) 468 482 469 483 def sanity_settings(self, settings): … … 520 534 521 535 if __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 20 20 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 21 21 22 from ConfigParser import ConfigParser, DEFAULTSECT 22 from os.path import exists 23 from ConfigParser import ConfigParser, DEFAULTSECT, NoOptionError, NoSectionError 24 from umitCore.Logging import log 23 25 24 26 class UmitConfigParser(ConfigParser): … … 28 30 def __init__(self, *args): 29 31 ConfigParser.__init__(self, *args) 32 self.paths_checked = [] 30 33 31 34 def set(self, section, option, value): … … 37 40 38 41 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 40 62 return self.filenames 63 41 64 42 65 def readfp(self, fp, filename=None): … … 53 76 filename = self.filenames[0] 54 77 else: 55 raise Exception("Wrong filename ")78 raise Exception("Wrong filename %s" % self.filenames) 56 79 self.write(open(filename, 'w')) 57 80 elif self.fp: … … 80 103 (key, str(value).replace('\n', '\n\t'))) 81 104 fp.write("\n") 105 106 def 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 123 def 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 1001 1001 def _show_help(self, action): 1002 1002 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) 1004 1010 1005 1011 def _exit_cb (self, widget=None, extra=None): -
branch/ggpolo/umitGUI/NmapOutputViewer.py
r1179 r1258 72 72 self.text_view = gtk.TextView () 73 73 self.btn_refresh = gtk.Button (stock=gtk.STOCK_REFRESH) 74 self.check_enable_color = gtk.CheckButton(_("Enable /DisableNmap output highlight"))74 self.check_enable_color = gtk.CheckButton(_("Enable Nmap output highlight")) 75 75 self.btn_output_properties = HIGButton(stock=gtk.STOCK_PREFERENCES) 76 76 self.hbox_buttons = gtk.HBox (spacing=5) -
branch/ggpolo/umitInventory/TLBase.py
r1246 r1258 22 22 from umitCore.I18N import _ 23 23 from umitCore.Paths import Path 24 from umitCore.UmitConfigParser import UmitConfigParser 24 #from umitCore.UmitConfigParser import UmitConfigParser # stopped working here 25 from ConfigParser import ConfigParser 25 26 26 27 from umitInventory.Calendar import CalendarManager … … 32 33 33 34 settings_file = Path.tl_conf 34 configparser = UmitConfigParser() 35 #configparser = UmitConfigParser() 36 configparser = ConfigParser() 35 37 configparser.read(settings_file) 36 38
