def __init__(self, parent=None, appicon=None): QtWidgets.QDialog.__init__(self, parent) self.setupUi(self) self.setWindowIcon(appicon) # Other interesting flags: QtCore.Qt.Tool | QtCore.Qt.BypassWindowManagerHint self._fw = Fw.Firewall.instance() self._nodes = Nodes.instance() self._notification_callback.connect(self._cb_notification_callback) self._notifications_sent = {} self.uuid = "" self.simple_port_idx = None self._nodes.nodesUpdated.connect(self._cb_nodes_updated) self.cmdClose.clicked.connect(self._cb_close_clicked) self.cmdAdd.clicked.connect(self._cb_add_clicked) self.cmdSave.clicked.connect(self._cb_save_clicked) self.cmdDelete.clicked.connect(self._cb_delete_clicked) self.helpButton.clicked.connect(self._cb_help_button_clicked) self.net_srv = NetworkServices() self.comboPorts.addItems(self.net_srv.to_array()) self.comboPorts.currentIndexChanged.connect( self._cb_combo_ports_index_changed)
def __init__(self, parent=None): QtWidgets.QDialog.__init__(self, parent, QtCore.Qt.WindowStaysOnTopHint) self._cfg = Config.get() self._nodes = Nodes.instance() self._db = Database.instance() self._notification_callback.connect(self._cb_notification_callback) self._notifications_sent = {} self.setupUi(self) self.dbFileButton.setVisible(False) self.dbLabel.setVisible(False) self.acceptButton.clicked.connect(self._cb_accept_button_clicked) self.applyButton.clicked.connect(self._cb_apply_button_clicked) self.cancelButton.clicked.connect(self._cb_cancel_button_clicked) self.popupsCheck.clicked.connect(self._cb_popups_check_toggled) self.dbFileButton.clicked.connect(self._cb_file_db_clicked) if QtGui.QIcon.hasThemeIcon("emblem-default") == False: self.applyButton.setIcon(self.style().standardIcon( getattr(QtWidgets.QStyle, "SP_DialogApplyButton"))) self.cancelButton.setIcon(self.style().standardIcon( getattr(QtWidgets.QStyle, "SP_DialogCloseButton"))) self.acceptButton.setIcon(self.style().standardIcon( getattr(QtWidgets.QStyle, "SP_DialogSaveButton"))) self.dbFileButton.setIcon(self.style().standardIcon( getattr(QtWidgets.QStyle, "SP_DirOpenIcon")))
def __init__(self, parent=None, _rule=None): super(RulesEditorDialog, self).__init__(parent) QtWidgets.QDialog.__init__(self, parent, QtCore.Qt.WindowStaysOnTopHint) self._notifications_sent = {} self._nodes = Nodes.instance() self._db = Database.instance() self._notification_callback.connect(self._cb_notification_callback) self._old_rule_name = None self.setupUi(self) self.buttonBox.button(QtWidgets.QDialogButtonBox.Reset).clicked.connect(self._cb_reset_clicked) self.buttonBox.button(QtWidgets.QDialogButtonBox.Close).clicked.connect(self._cb_close_clicked) self.buttonBox.button(QtWidgets.QDialogButtonBox.Apply).clicked.connect(self._cb_apply_clicked) self.buttonBox.button(QtWidgets.QDialogButtonBox.Help).clicked.connect(self._cb_help_clicked) self.selectListButton.clicked.connect(self._cb_select_list_button_clicked) self.protoCheck.toggled.connect(self._cb_proto_check_toggled) self.procCheck.toggled.connect(self._cb_proc_check_toggled) self.cmdlineCheck.toggled.connect(self._cb_cmdline_check_toggled) self.dstPortCheck.toggled.connect(self._cb_dstport_check_toggled) self.uidCheck.toggled.connect(self._cb_uid_check_toggled) self.dstIPCheck.toggled.connect(self._cb_dstip_check_toggled) self.dstHostCheck.toggled.connect(self._cb_dsthost_check_toggled) self.dstListsCheck.toggled.connect(self._cb_dstlists_check_toggled) if QtGui.QIcon.hasThemeIcon("emblem-default") == False: self.actionAllowRadio.setIcon(self.style().standardIcon(getattr(QtWidgets.QStyle, "SP_DialogApplyButton"))) self.actionDenyRadio.setIcon(self.style().standardIcon(getattr(QtWidgets.QStyle, "SP_DialogCancelButton"))) if _rule != None: self._load_rule(rule=_rule)
def __init__(self, parent=None, _rule=None, appicon=None): super(RulesEditorDialog, self).__init__(parent) QtWidgets.QDialog.__init__(self, parent, QtCore.Qt.WindowStaysOnTopHint) self._notifications_sent = {} self._nodes = Nodes.instance() self._db = Database.instance() self._notification_callback.connect(self._cb_notification_callback) self._old_rule_name = None self.setupUi(self) self.setWindowIcon(appicon) self.buttonBox.button( QtWidgets.QDialogButtonBox.Reset).clicked.connect( self._cb_reset_clicked) self.buttonBox.button( QtWidgets.QDialogButtonBox.Close).clicked.connect( self._cb_close_clicked) self.buttonBox.button( QtWidgets.QDialogButtonBox.Apply).clicked.connect( self._cb_apply_clicked) self.buttonBox.button(QtWidgets.QDialogButtonBox.Help).clicked.connect( self._cb_help_clicked) self.selectListButton.clicked.connect( self._cb_select_list_button_clicked) self.selectListRegexpButton.clicked.connect( self._cb_select_regexp_list_button_clicked) self.selectIPsListButton.clicked.connect( self._cb_select_ips_list_button_clicked) self.selectNetsListButton.clicked.connect( self._cb_select_nets_list_button_clicked) self.protoCheck.toggled.connect(self._cb_proto_check_toggled) self.procCheck.toggled.connect(self._cb_proc_check_toggled) self.cmdlineCheck.toggled.connect(self._cb_cmdline_check_toggled) self.dstPortCheck.toggled.connect(self._cb_dstport_check_toggled) self.uidCheck.toggled.connect(self._cb_uid_check_toggled) self.pidCheck.toggled.connect(self._cb_pid_check_toggled) self.dstIPCheck.toggled.connect(self._cb_dstip_check_toggled) self.dstHostCheck.toggled.connect(self._cb_dsthost_check_toggled) self.dstListsCheck.toggled.connect(self._cb_dstlists_check_toggled) self.dstListRegexpCheck.toggled.connect( self._cb_dstregexplists_check_toggled) self.dstListIPsCheck.toggled.connect(self._cb_dstiplists_check_toggled) self.dstListNetsCheck.toggled.connect( self._cb_dstnetlists_check_toggled) if QtGui.QIcon.hasThemeIcon("emblem-default"): return applyIcon = Icons.new("emblem-default") denyIcon = Icons.new("emblem-important") rejectIcon = Icons.new("window-close") self.actionAllowRadio.setIcon(applyIcon) self.actionDenyRadio.setIcon(denyIcon) self.actionRejectRadio.setIcon(rejectIcon) if _rule != None: self._load_rule(rule=_rule)
def __init__(self, app, on_exit): super(UIService, self).__init__() self.MENU_ENTRY_STATS = QtCore.QCoreApplication.translate("contextual_menu", "Statistics") self.MENU_ENTRY_FW_ENABLE = QtCore.QCoreApplication.translate("contextual_menu", "Enable") self.MENU_ENTRY_FW_DISABLE = QtCore.QCoreApplication.translate("contextual_menu", "Disable") self.MENU_ENTRY_HELP = QtCore.QCoreApplication.translate("contextual_menu", "Help") self.MENU_ENTRY_CLOSE = QtCore.QCoreApplication.translate("contextual_menu", "Close") self._cfg = Config.init() self._db = Database.instance() db_file=self._cfg.getSettings(self._cfg.DEFAULT_DB_FILE_KEY) db_status, db_error = self._db.initialize( dbtype=self._cfg.getInt(self._cfg.DEFAULT_DB_TYPE_KEY), dbfile=db_file ) if db_status is False: Message.ok( QtCore.QCoreApplication.translate("preferences", "Warning"), QtCore.QCoreApplication.translate("preferences", "The DB is corrupted and it's not safe to continue.<br>\ Remove, backup or recover the file before continuing.<br><br>\ Corrupted database file: {0}".format(db_file)), QtWidgets.QMessageBox.Warning) sys.exit(-1) self._db_sqlite = self._db.get_db() self._last_ping = None self._version_warning_shown = False self._asking = False self._connected = False self._fw_enabled = False self._path = os.path.abspath(os.path.dirname(__file__)) self._app = app self._on_exit = on_exit self._exit = False self._msg = QtWidgets.QMessageBox() self._prompt_dialog = PromptDialog() self._remote_lock = Lock() self._remote_stats = {} self._setup_interfaces() self._setup_icons() self._stats_dialog = StatsDialog(dbname="general", db=self._db) self._setup_tray() self._setup_slots() self._nodes = Nodes.instance() self._last_stats = {} self._last_items = { 'hosts':{}, 'procs':{}, 'addrs':{}, 'ports':{}, 'users':{} }
def __init__(self, tableName): self.tableName = tableName self._nodes = Nodes.instance() self._fw = Firewall.instance() self.lastColumnCount = len(self.headersAll) self.lastQueryArgs = () QStandardItemModel.__init__(self, 0, self.lastColumnCount) self.setHorizontalHeaderLabels(self.headersAll)
def __init__(self, parent=None, appicon=None): QtWidgets.QDialog.__init__(self, parent, QtCore.Qt.WindowStaysOnTopHint) self._themes = Themes.instance() self._saved_theme = "" self._cfg = Config.get() self._nodes = Nodes.instance() self._db = Database.instance() self._notification_callback.connect(self._cb_notification_callback) self._notifications_sent = {} self._desktop_notifications = DesktopNotifications() self.setupUi(self) self.setWindowIcon(appicon) self.dbFileButton.setVisible(False) self.dbLabel.setVisible(False) self.dbType = None self.acceptButton.clicked.connect(self._cb_accept_button_clicked) self.applyButton.clicked.connect(self._cb_apply_button_clicked) self.cancelButton.clicked.connect(self._cb_cancel_button_clicked) self.helpButton.clicked.connect(self._cb_help_button_clicked) self.popupsCheck.clicked.connect(self._cb_popups_check_toggled) self.dbFileButton.clicked.connect(self._cb_file_db_clicked) self.checkUIRules.toggled.connect(self._cb_check_ui_rules_toggled) self.cmdTimeoutUp.clicked.connect(lambda: self._cb_cmd_spin_clicked(self.spinUITimeout, self.SUM)) self.cmdTimeoutDown.clicked.connect(lambda: self._cb_cmd_spin_clicked(self.spinUITimeout, self.REST)) self.cmdDBMaxDaysUp.clicked.connect(lambda: self._cb_cmd_spin_clicked(self.spinDBMaxDays, self.SUM)) self.cmdDBMaxDaysDown.clicked.connect(lambda: self._cb_cmd_spin_clicked(self.spinDBMaxDays, self.REST)) self.cmdDBPurgesUp.clicked.connect(lambda: self._cb_cmd_spin_clicked(self.spinDBPurgeInterval, self.SUM)) self.cmdDBPurgesDown.clicked.connect(lambda: self._cb_cmd_spin_clicked(self.spinDBPurgeInterval, self.REST)) self.cmdTestNotifs.clicked.connect(self._cb_test_notifs_clicked) self.radioSysNotifs.clicked.connect(self._cb_radio_system_notifications) self.helpButton.setToolTipDuration(30 * 1000) if QtGui.QIcon.hasThemeIcon("emblem-default") == False: self.applyButton.setIcon(self.style().standardIcon(getattr(QtWidgets.QStyle, "SP_DialogApplyButton"))) self.cancelButton.setIcon(self.style().standardIcon(getattr(QtWidgets.QStyle, "SP_DialogCloseButton"))) self.acceptButton.setIcon(self.style().standardIcon(getattr(QtWidgets.QStyle, "SP_DialogSaveButton"))) self.dbFileButton.setIcon(self.style().standardIcon(getattr(QtWidgets.QStyle, "SP_DirOpenIcon"))) if QtGui.QIcon.hasThemeIcon("list-add") == False: self.cmdTimeoutUp.setIcon(self.style().standardIcon(getattr(QtWidgets.QStyle, "SP_ArrowUp"))) self.cmdTimeoutDown.setIcon(self.style().standardIcon(getattr(QtWidgets.QStyle, "SP_ArrowDown"))) self.cmdDBMaxDaysUp.setIcon(self.style().standardIcon(getattr(QtWidgets.QStyle, "SP_ArrowUp"))) self.cmdDBMaxDaysDown.setIcon(self.style().standardIcon(getattr(QtWidgets.QStyle, "SP_ArrowDown"))) self.cmdDBPurgesUp.setIcon(self.style().standardIcon(getattr(QtWidgets.QStyle, "SP_ArrowUp"))) self.cmdDBPurgesDown.setIcon(self.style().standardIcon(getattr(QtWidgets.QStyle, "SP_ArrowDown")))
def __init__(self, app, on_exit): super(UIService, self).__init__() self.MENU_ENTRY_STATS = QtCore.QCoreApplication.translate( "contextual_menu", "Statistics") self.MENU_ENTRY_FW_ENABLE = QtCore.QCoreApplication.translate( "contextual_menu", "Enable") self.MENU_ENTRY_FW_DISABLE = QtCore.QCoreApplication.translate( "contextual_menu", "Disable") self.MENU_ENTRY_HELP = QtCore.QCoreApplication.translate( "contextual_menu", "Help") self.MENU_ENTRY_CLOSE = QtCore.QCoreApplication.translate( "contextual_menu", "Close") self._cfg = Config.init() self._db = Database.instance() self._db.initialize( dbtype=self._cfg.getInt(self._cfg.DEFAULT_DB_TYPE_KEY), dbfile=self._cfg.getSettings(self._cfg.DEFAULT_DB_FILE_KEY)) self._db_sqlite = self._db.get_db() self._last_ping = None self._version_warning_shown = False self._asking = False self._connected = False self._fw_enabled = False self._path = os.path.abspath(os.path.dirname(__file__)) self._app = app self._on_exit = on_exit self._exit = False self._msg = QtWidgets.QMessageBox() self._prompt_dialog = PromptDialog() self._remote_lock = Lock() self._remote_stats = {} self._setup_interfaces() self._setup_icons() self._stats_dialog = StatsDialog(dbname="general", db=self._db) self._setup_tray() self._setup_slots() self._nodes = Nodes.instance() self._last_stats = {} self._last_items = { 'hosts': {}, 'procs': {}, 'addrs': {}, 'ports': {}, 'users': {} }
def __init__(self, parent=None, appicon=None, node=None): QtWidgets.QDialog.__init__(self, parent) self.setupUi(self) self.setWindowIcon(appicon) self.appicon = appicon # TODO: profiles are ready to be used. They need to be tested, and # create some default profiles (home, office, public, ...) self.comboProfile.setVisible(False) self.lblProfile.setVisible(False) self.secHighIcon = Icons.new("security-high") self.secMediumIcon = Icons.new("security-medium") self.secLowIcon = Icons.new("security-low") self.lblStatusIcon.setPixmap(self.secHighIcon.pixmap(96, 96)) self._fwrule_dialog = FwRuleDialog(appicon=self.appicon) self._cfg = Config.get() self._fw = Fw.Firewall.instance() self._nodes = Nodes.instance() self._fw_profiles = {} self._notification_callback.connect(self._cb_notification_callback) self._notifications_sent = {} self._nodes.nodesUpdated.connect(self._cb_nodes_updated) self.cmdNewRule.clicked.connect(self._cb_new_rule_clicked) self.cmdExcludeService.clicked.connect( self._cb_exclude_service_clicked) self.comboInput.currentIndexChanged.connect( lambda: self._cb_combo_policy_changed(self.COMBO_IN)) self.comboOutput.currentIndexChanged.connect( lambda: self._cb_combo_policy_changed(self.COMBO_OUT)) self.comboProfile.currentIndexChanged.connect( self._cb_combo_profile_changed) self.sliderFwEnable.valueChanged.connect(self._cb_enable_fw_changed) self.cmdClose.clicked.connect(self._cb_close_clicked) if QtGui.QIcon.hasThemeIcon("document-new"): return closeIcon = Icons.new("window-close") excludeIcon = Icons.new("go-jump") newIcon = Icons.new("document-new") self.cmdClose.setIcon(closeIcon) self.cmdExcludeService.setIcon(excludeIcon) self.cmdNewRule.setIcon(newIcon)
def __init__(self, parent=None, appicon=None): super(ProcessDetailsDialog, self).__init__(parent) QtWidgets.QDialog.__init__(self, parent, QtCore.Qt.WindowStaysOnTopHint) self.setWindowFlags(QtCore.Qt.Window) self.setupUi(self) self.setWindowIcon(appicon) self._app_name = None self._app_icon = None self._apps_parser = LinuxDesktopParser() self._nodes = Nodes.instance() self._notification_callback.connect(self._cb_notification_callback) self._nid = None self._pid = "" self._notifications_sent = {} self.cmdClose.clicked.connect(self._cb_close_clicked) self.cmdAction.clicked.connect(self._cb_action_clicked) self.comboPids.currentIndexChanged.connect(self._cb_combo_pids_changed) self.TABS[self.TAB_STATUS]['text'] = self.textStatus self.TABS[self.TAB_DESCRIPTORS]['text'] = self.textOpenedFiles self.TABS[self.TAB_IOSTATS]['text'] = self.textIOStats self.TABS[self.TAB_MAPS]['text'] = self.textMappedFiles self.TABS[self.TAB_STACK]['text'] = self.textStack self.TABS[self.TAB_ENVS]['text'] = self.textEnv self.TABS[self.TAB_DESCRIPTORS]['text'].setFont( QtGui.QFont("monospace")) self.iconStart = QtGui.QIcon.fromTheme("media-playback-start") self.iconPause = QtGui.QIcon.fromTheme("media-playback-pause") if QtGui.QIcon.hasThemeIcon("window-close") == False: self.cmdClose.setIcon(self.style().standardIcon( getattr(QtWidgets.QStyle, "SP_DialogCloseButton"))) self.iconStart = self.style().standardIcon( getattr(QtWidgets.QStyle, "SP_MediaPlay")) self.iconPause = self.style().standardIcon( getattr(QtWidgets.QStyle, "SP_MediaPause"))
def __init__(self, parent=None, appicon=None): QtWidgets.QDialog.__init__(self, parent) self.setupUi(self) self.setWindowIcon(appicon) # Other interesting flags: QtCore.Qt.Tool | QtCore.Qt.BypassWindowManagerHint self._fw = Fw.Firewall.instance() self._nodes = Nodes.instance() self._notification_callback.connect(self._cb_notification_callback) self._notifications_sent = {} self.uuid = "" self.simple_port_idx = None self._nodes.nodesUpdated.connect(self._cb_nodes_updated) self.cmdClose.clicked.connect(self._cb_close_clicked) self.cmdAdd.clicked.connect(self._cb_add_clicked) self.cmdSave.clicked.connect(self._cb_save_clicked) self.cmdDelete.clicked.connect(self._cb_delete_clicked) self.helpButton.clicked.connect(self._cb_help_button_clicked) self.net_srv = NetworkServices() self.comboPorts.addItems(self.net_srv.to_array()) self.comboPorts.currentIndexChanged.connect(self._cb_combo_ports_index_changed) if QtGui.QIcon.hasThemeIcon("emblem-default"): return saveIcon = Icons.new("document-save") delIcon = Icons.new("edit-delete") closeIcon = Icons.new("window-close") addIcon = Icons.new("list-add") helpIcon = Icons.new("help-browser") self.cmdSave.setIcon(saveIcon) self.cmdDelete.setIcon(delIcon) self.cmdClose.setIcon(closeIcon) self.cmdAdd.setIcon(addIcon) self.helpButton.setIcon(helpIcon)
def __init__(self, parent=None, appicon=None): QtWidgets.QDialog.__init__(self, parent, QtCore.Qt.WindowStaysOnTopHint) self._themes = Themes.instance() self._saved_theme = "" self._cfg = Config.get() self._nodes = Nodes.instance() self._db = Database.instance() self._notification_callback.connect(self._cb_notification_callback) self._notifications_sent = {} self._desktop_notifications = DesktopNotifications() self.setupUi(self) self.setWindowIcon(appicon) self.dbFileButton.setVisible(False) self.dbLabel.setVisible(False) self.dbType = None self.acceptButton.clicked.connect(self._cb_accept_button_clicked) self.applyButton.clicked.connect(self._cb_apply_button_clicked) self.cancelButton.clicked.connect(self._cb_cancel_button_clicked) self.helpButton.clicked.connect(self._cb_help_button_clicked) self.popupsCheck.clicked.connect(self._cb_popups_check_toggled) self.dbFileButton.clicked.connect(self._cb_file_db_clicked) self.checkUIRules.toggled.connect(self._cb_check_ui_rules_toggled) self.cmdTimeoutUp.clicked.connect(lambda: self._cb_cmd_spin_clicked(self.spinUITimeout, self.SUM)) self.cmdTimeoutDown.clicked.connect(lambda: self._cb_cmd_spin_clicked(self.spinUITimeout, self.REST)) self.cmdDBMaxDaysUp.clicked.connect(lambda: self._cb_cmd_spin_clicked(self.spinDBMaxDays, self.SUM)) self.cmdDBMaxDaysDown.clicked.connect(lambda: self._cb_cmd_spin_clicked(self.spinDBMaxDays, self.REST)) self.cmdDBPurgesUp.clicked.connect(lambda: self._cb_cmd_spin_clicked(self.spinDBPurgeInterval, self.SUM)) self.cmdDBPurgesDown.clicked.connect(lambda: self._cb_cmd_spin_clicked(self.spinDBPurgeInterval, self.REST)) self.cmdTestNotifs.clicked.connect(self._cb_test_notifs_clicked) self.radioSysNotifs.clicked.connect(self._cb_radio_system_notifications) self.helpButton.setToolTipDuration(30 * 1000) if QtGui.QIcon.hasThemeIcon("emblem-default"): return saveIcon = Icons.new("document-save") applyIcon = Icons.new("emblem-default") delIcon = Icons.new("edit-delete") closeIcon = Icons.new("window-close") openIcon = Icons.new("document-open") helpIcon = Icons.new("help-browser") addIcon = Icons.new("list-add") delIcon = Icons.new("list-remove") self.applyButton.setIcon(applyIcon) self.cancelButton.setIcon(closeIcon) self.acceptButton.setIcon(saveIcon) self.helpButton.setIcon(helpIcon) self.dbFileButton.setIcon(openIcon) self.cmdTimeoutUp.setIcon(addIcon) self.cmdTimeoutDown.setIcon(delIcon) self.cmdDBMaxDaysUp.setIcon(addIcon) self.cmdDBMaxDaysDown.setIcon(delIcon) self.cmdDBPurgesUp.setIcon(addIcon) self.cmdDBPurgesDown.setIcon(delIcon)
"Firewall": "iptables", "Stats": { "MaxEvents": 150, "MaxStats": 50 } } ''' class Connection: protocol = "tcp" src_ip = "127.0.0.1" src_port = "12345" dst_ip = "127.0.0.1" dst_host = "localhost" dst_port = "54321" user_id = 1000 process_id = 9876 process_path = "/bin/cmd" process_cwd = "/tmp" process_args = "/bin/cmd --parm1 test" process_env = [] db = Database.instance() db.initialize() Config.init() nodes = Nodes.instance() nodes._nodes["unix:/tmp/osui.sock"] = {'data': ClientConfig}
def __init__(self, parent=None): QObject.__init__(self) self._nodes = Nodes.instance() self.rules = Rules(self._nodes) self.chains = Chains(self._nodes)