| 1 | ## |
|---|
| 2 | ## BasePaths.py |
|---|
| 3 | ## Login : <adriano@localhost.localdomain> |
|---|
| 4 | ## Started on Sat Apr 8 17:49:23 2006 Adriano Monteiro Marques |
|---|
| 5 | ## $Id$ |
|---|
| 6 | ## |
|---|
| 7 | ## Copyright (C) 2006 Adriano Monteiro Marques |
|---|
| 8 | ## This program is free software; you can redistribute it and/or modify |
|---|
| 9 | ## it under the terms of the GNU General Public License as published by |
|---|
| 10 | ## the Free Software Foundation; either version 2 of the License, or |
|---|
| 11 | ## (at your option) any later version. |
|---|
| 12 | ## |
|---|
| 13 | ## This program is distributed in the hope that it will be useful, |
|---|
| 14 | ## but WITHOUT ANY WARRANTY; without even the implied warranty of |
|---|
| 15 | ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|---|
| 16 | ## GNU General Public License for more details. |
|---|
| 17 | ## |
|---|
| 18 | ## You should have received a copy of the GNU General Public License |
|---|
| 19 | ## along with this program; if not, write to the Free Software |
|---|
| 20 | ## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
|---|
| 21 | ## |
|---|
| 22 | |
|---|
| 23 | import os |
|---|
| 24 | import os.path |
|---|
| 25 | import sys |
|---|
| 26 | |
|---|
| 27 | |
|---|
| 28 | ###################### |
|---|
| 29 | # Platform recognition |
|---|
| 30 | PLATFORM = sys.platform |
|---|
| 31 | HOME = os.path.expanduser("~") |
|---|
| 32 | #HOME = os.environ.get('HOME', '') |
|---|
| 33 | CURRENT_DIR = os.getcwd() |
|---|
| 34 | |
|---|
| 35 | |
|---|
| 36 | base_paths = dict(config_file = 'umit.conf', |
|---|
| 37 | config_dir = '.umit', |
|---|
| 38 | user_dir = os.path.join(HOME, '.umit'), |
|---|
| 39 | scan_profile = 'scan_profile.usp', |
|---|
| 40 | profile_editor = 'profile_editor.xml', |
|---|
| 41 | recent_scans = 'recent_scans.txt', |
|---|
| 42 | target_list = 'target_list.txt', |
|---|
| 43 | wizard = 'wizard.xml', |
|---|
| 44 | options = 'options.xml', |
|---|
| 45 | umit_op = 'umit.op', |
|---|
| 46 | umit_opf = 'umit.opf', |
|---|
| 47 | umit_opi = 'umit.opi', |
|---|
| 48 | umit_opt = 'umit.opt', |
|---|
| 49 | pixmaps_dir = os.path.join('share', 'pixmaps'), |
|---|
| 50 | scripts_dir = os.path.join('share', 'scripts'), |
|---|
| 51 | i18n_dir = os.path.join('share','locale'), |
|---|
| 52 | i18n_message_file = 'umit.mo', |
|---|
| 53 | scan_results_extension = 'usr', # comes from umit scan result |
|---|
| 54 | scan_profile_extension = 'usp', # comes from umit scan profile |
|---|
| 55 | user_home = HOME, |
|---|
| 56 | basic_search_sequence = [HOME, CURRENT_DIR], |
|---|
| 57 | config_search_sequence = [HOME, CURRENT_DIR], |
|---|
| 58 | pixmaps_search_sequence = [os.path.join(CURRENT_DIR, 'share', 'pixmaps'), |
|---|
| 59 | HOME], |
|---|
| 60 | i18n_search_sequence = [os.path.join(CURRENT_DIR, 'share', 'locale'), HOME], |
|---|
| 61 | umitdb = "umit.db", |
|---|
| 62 | |
|---|
| 63 | # new generation database |
|---|
| 64 | umitdb_ng = "umitng.db", |
|---|
| 65 | |
|---|
| 66 | # timeline configuration |
|---|
| 67 | tl_conf = "tl.conf", |
|---|
| 68 | tl_colors_std = "tl_colors_evt_std.conf", |
|---|
| 69 | |
|---|
| 70 | # scheduler |
|---|
| 71 | sched_schemas = "scheduler-schemas.conf", |
|---|
| 72 | sched_profiles = "scheduler-profiles.conf", |
|---|
| 73 | sched_control = "scheduler_control.py", |
|---|
| 74 | |
|---|
| 75 | services = "nmap-services", |
|---|
| 76 | services_dump = "services.dmp", |
|---|
| 77 | os_db = "nmap-os-db", |
|---|
| 78 | os_dump = "os_db.dmp", |
|---|
| 79 | os_fingerprints = "nmap-os-fingerprints", |
|---|
| 80 | umit_version = "umit_version", |
|---|
| 81 | os_classification = "os_classification.dmp") |
|---|
| 82 | |
|---|
| 83 | |
|---|
| 84 | if PLATFORM == 'linux2' or PLATFORM == 'linux1': |
|---|
| 85 | base_paths.update(dict(user_home = HOME, |
|---|
| 86 | basic_search_sequence = [os.path.join(HOME, base_paths['config_dir']), |
|---|
| 87 | '/opt/umit', HOME, CURRENT_DIR], |
|---|
| 88 | config_search_sequence = [os.path.join(HOME, base_paths['config_dir']), |
|---|
| 89 | CURRENT_DIR, '/etc'], |
|---|
| 90 | pixmaps_search_sequence = [os.path.join(CURRENT_DIR, |
|---|
| 91 | 'share', |
|---|
| 92 | 'pixmaps'), |
|---|
| 93 | '/usr/share/pixmaps', |
|---|
| 94 | '/opt/umit', HOME], |
|---|
| 95 | i18n_search_sequence = [os.path.join(CURRENT_DIR, 'share', 'locale'), |
|---|
| 96 | '/usr/share/locale', |
|---|
| 97 | HOME, CURRENT_DIR])) |
|---|
| 98 | elif PLATFORM == 'win32': |
|---|
| 99 | PROGRAM_FILES = os.environ.get("PROGRAMFILES", "\\") |
|---|
| 100 | UMIT_DIR = os.path.join(PROGRAM_FILES, "Umit") |
|---|
| 101 | PIXMAPS_DIR = os.path.join(UMIT_DIR, 'share', 'pixmaps') |
|---|
| 102 | |
|---|
| 103 | base_paths.update(dict(\ |
|---|
| 104 | basic_search_sequence = [UMIT_DIR, PROGRAM_FILES, HOME, CURRENT_DIR], |
|---|
| 105 | config_search_sequence = [UMIT_DIR, PROGRAM_FILES, HOME, CURRENT_DIR], |
|---|
| 106 | pixmaps_search_sequence = [PIXMAPS_DIR, PROGRAM_FILES, |
|---|
| 107 | os.path.join(CURRENT_DIR, 'share', 'pixmaps'), |
|---|
| 108 | HOME], |
|---|
| 109 | i18n_search_sequence = [UMIT_DIR, PROGRAM_FILES, |
|---|
| 110 | os.path.join(CURRENT_DIR, 'share', 'locale'), HOME],)) |
|---|
| 111 | |
|---|
| 112 | elif PLATFORM == 'darwin': |
|---|
| 113 | base_paths.update(dict(user_home = HOME, |
|---|
| 114 | basic_search_sequence = [os.path.join(HOME, 'Applications'), |
|---|
| 115 | '/Local', '/Network', |
|---|
| 116 | '/System/Library', HOME])) |
|---|
| 117 | |
|---|