| 1 | #!/usr/bin/env python |
|---|
| 2 | # -*- coding: utf-8 -*- |
|---|
| 3 | # |
|---|
| 4 | # Copyright (C) 2005-2006 Insecure.Com LLC. |
|---|
| 5 | # Copyright (C) 2007-2008 Adriano Monteiro Marques |
|---|
| 6 | # |
|---|
| 7 | # Author: Adriano Monteiro Marques <adriano@umitproject.org> |
|---|
| 8 | # |
|---|
| 9 | # This program is free software; you can redistribute it and/or modify |
|---|
| 10 | # it under the terms of the GNU General Public License as published by |
|---|
| 11 | # the Free Software Foundation; either version 2 of the License, or |
|---|
| 12 | # (at your option) any later version. |
|---|
| 13 | # |
|---|
| 14 | # This program is distributed in the hope that it will be useful, |
|---|
| 15 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
|---|
| 16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|---|
| 17 | # GNU General Public License for more details. |
|---|
| 18 | # |
|---|
| 19 | # You should have received a copy of the GNU General Public License |
|---|
| 20 | # along with this program; if not, write to the Free Software |
|---|
| 21 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
|---|
| 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 | # Look for files relative to the script path to allow running within the build |
|---|
| 36 | # directory. |
|---|
| 37 | main_dir = os.path.abspath(os.path.dirname(sys.argv[0])) |
|---|
| 38 | if hasattr(sys, "frozen"): |
|---|
| 39 | main_dir = os.path.dirname(sys.executable) |
|---|
| 40 | |
|---|
| 41 | CONFIG_DIR = os.path.join(main_dir, "share", "umit", "config") |
|---|
| 42 | LOCALE_DIR = os.path.join(main_dir, "share", "locale") |
|---|
| 43 | MISC_DIR = os.path.join(main_dir, "share", "umit", "misc") |
|---|
| 44 | ICONS_DIR = os.path.join(main_dir, "share", "icons", "umit") |
|---|
| 45 | PIXMAPS_DIR = os.path.join(main_dir, "share", "pixmaps", "umit") |
|---|
| 46 | PLUGINS_DIR = os.path.join(main_dir, "share", "umit", "plugins") |
|---|
| 47 | DOCS_DIR = os.path.join(main_dir, "share", "doc", "umit") |
|---|
| 48 | |
|---|
| 49 | base_paths = dict(config_file = 'umit.conf', |
|---|
| 50 | config_dir = '.umit', |
|---|
| 51 | user_dir = os.path.join(HOME, '.umit'), |
|---|
| 52 | scan_profile = 'scan_profile.usp', |
|---|
| 53 | profile_editor = 'profile_editor.xml', |
|---|
| 54 | recent_scans = 'recent_scans.txt', |
|---|
| 55 | target_list = 'target_list.txt', |
|---|
| 56 | wizard = 'wizard.xml', |
|---|
| 57 | options = 'options.xml', |
|---|
| 58 | umit_opf = 'umit.opf', |
|---|
| 59 | umit_opt = 'umit.opt', |
|---|
| 60 | scripts_dir = os.path.join('share', 'scripts'), |
|---|
| 61 | pixmaps_dir = PIXMAPS_DIR, |
|---|
| 62 | plugins_dir = PLUGINS_DIR, |
|---|
| 63 | i18n_dir = LOCALE_DIR, |
|---|
| 64 | i18n_message_file = 'umit.mo', |
|---|
| 65 | scan_results_extension = 'usr', # comes from umit scan result |
|---|
| 66 | scan_profile_extension = 'usp', # comes from umit scan profile |
|---|
| 67 | user_home = HOME, |
|---|
| 68 | basic_search_sequence = [HOME, CURRENT_DIR], |
|---|
| 69 | config_search_sequence = [HOME, CURRENT_DIR], |
|---|
| 70 | pixmaps_search_sequence = [os.path.join(CURRENT_DIR, PIXMAPS_DIR), |
|---|
| 71 | HOME], |
|---|
| 72 | i18n_search_sequence = [os.path.join(CURRENT_DIR, LOCALE_DIR), HOME], |
|---|
| 73 | umitdb = "umit.db", |
|---|
| 74 | |
|---|
| 75 | # new generation database |
|---|
| 76 | umitdb_ng = "umitng.db", |
|---|
| 77 | |
|---|
| 78 | # timeline configuration |
|---|
| 79 | tl_conf = "timeline-settings.conf", |
|---|
| 80 | tl_colors_std = "tl_colors_evt_std.conf", |
|---|
| 81 | |
|---|
| 82 | # scheduler |
|---|
| 83 | sched_schemas = "scheduler-schemas.conf", |
|---|
| 84 | sched_profiles = "scheduler-profiles.conf", |
|---|
| 85 | sched_log = "scheduler.log", |
|---|
| 86 | |
|---|
| 87 | # smtp |
|---|
| 88 | smtp_schemas = "smtp-schemas.conf", |
|---|
| 89 | |
|---|
| 90 | services = "nmap-services", |
|---|
| 91 | services_dump = "services.dmp", |
|---|
| 92 | os_db = "nmap-os-db", |
|---|
| 93 | os_dump = "os_db.dmp", |
|---|
| 94 | os_fingerprints = "nmap-os-fingerprints", |
|---|
| 95 | umit_version = "umit_version", |
|---|
| 96 | os_classification = "os_classification.dmp") |
|---|
| 97 | |
|---|
| 98 | |
|---|
| 99 | if PLATFORM == 'linux2' or PLATFORM == 'linux1': |
|---|
| 100 | base_paths.update(dict(user_home = HOME, |
|---|
| 101 | basic_search_sequence = [os.path.join(HOME, base_paths['config_dir']), |
|---|
| 102 | '/opt/umit', HOME, CURRENT_DIR], |
|---|
| 103 | config_search_sequence = [os.path.join(HOME, base_paths['config_dir']), |
|---|
| 104 | CURRENT_DIR, '/etc'], |
|---|
| 105 | pixmaps_search_sequence = [os.path.join(CURRENT_DIR, PIXMAPS_DIR), |
|---|
| 106 | '/usr/share/pixmaps/umit', |
|---|
| 107 | '/opt/umit', HOME], |
|---|
| 108 | i18n_search_sequence = [os.path.join(CURRENT_DIR, LOCALE_DIR), |
|---|
| 109 | '/usr/share/locale', |
|---|
| 110 | HOME, CURRENT_DIR])) |
|---|
| 111 | elif PLATFORM == 'win32': |
|---|
| 112 | PROGRAM_FILES = os.environ.get("PROGRAMFILES", "\\") |
|---|
| 113 | UMIT_DIR = os.path.join(PROGRAM_FILES, "Umit") |
|---|
| 114 | PIXMAPS_DIR = os.path.join(UMIT_DIR, PIXMAPS_DIR) |
|---|
| 115 | |
|---|
| 116 | base_paths.update(dict(\ |
|---|
| 117 | basic_search_sequence = [UMIT_DIR, PROGRAM_FILES, HOME, CURRENT_DIR], |
|---|
| 118 | config_search_sequence = [UMIT_DIR, PROGRAM_FILES, HOME, CURRENT_DIR], |
|---|
| 119 | pixmaps_search_sequence = [PIXMAPS_DIR, PROGRAM_FILES, |
|---|
| 120 | os.path.join(CURRENT_DIR, PIXMAPS_DIR), |
|---|
| 121 | HOME], |
|---|
| 122 | i18n_search_sequence = [UMIT_DIR, PROGRAM_FILES, |
|---|
| 123 | os.path.join(CURRENT_DIR, LOCALE_DIR), HOME],)) |
|---|
| 124 | |
|---|
| 125 | elif PLATFORM == 'darwin': |
|---|
| 126 | base_paths.update(dict(user_home = HOME, |
|---|
| 127 | basic_search_sequence = [os.path.join(HOME, 'Applications'), |
|---|
| 128 | '/Local', '/Network', |
|---|
| 129 | '/System/Library', HOME])) |
|---|
| 130 | |
|---|