Merge pull request #1589 from guardicore/1537-constant-singleton-mutex-name

Remove custom singleton mutex name option
This commit is contained in:
Shreya Malviya 2021-11-16 11:49:02 +05:30 committed by GitHub
commit ada9237a8b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 6 additions and 16 deletions

View File

@ -23,6 +23,7 @@ Changelog](https://keepachangelog.com/en/1.0.0/).
- Checkbox for file logging. #1537 - Checkbox for file logging. #1537
- Remove serialization of config. #1537 - Remove serialization of config. #1537
- Checkbox that gave the option to not try to first move the dropper file. #1537 - Checkbox that gave the option to not try to first move the dropper file. #1537
- Custom singleton mutex name config option. #1589
### Fixed ### Fixed
- A bug in network map page that caused delay of telemetry log loading. #1545 - A bug in network map page that caused delay of telemetry log loading. #1545

View File

@ -99,9 +99,6 @@ class Configuration(object):
# sets whether or not the monkey is alive. if false will stop scanning and exploiting # sets whether or not the monkey is alive. if false will stop scanning and exploiting
alive = True alive = True
# string of the mutex name for single instance
singleton_mutex_name = "{2384ec59-0df8-4ab9-918c-843740924a28}"
# how long to wait between scan iterations # how long to wait between scan iterations
timeout_between_iterations = 100 timeout_between_iterations = 100

View File

@ -56,7 +56,6 @@
"smb_service_name": "InfectionMonkey", "smb_service_name": "InfectionMonkey",
"retry_failed_explotation": true, "retry_failed_explotation": true,
"self_delete_in_cleanup": true, "self_delete_in_cleanup": true,
"singleton_mutex_name": "{2384ec59-0df8-4ab9-918c-843740924a28}",
"skip_exploit_if_file_exist": false, "skip_exploit_if_file_exist": false,
"exploit_user_list": [], "exploit_user_list": [],
"exploit_password_list": [], "exploit_password_list": [],

View File

@ -3,11 +3,12 @@ import logging
import sys import sys
from abc import ABCMeta, abstractmethod from abc import ABCMeta, abstractmethod
from infection_monkey.config import WormConfiguration
logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)
SINGLETON_MUTEX_NAME = "{2384ec59-0df8-4ab9-918c-843740924a28}"
class _SystemSingleton(object, metaclass=ABCMeta): class _SystemSingleton(object, metaclass=ABCMeta):
@abstractmethod @abstractmethod
def try_lock(self): def try_lock(self):
@ -20,7 +21,7 @@ class _SystemSingleton(object, metaclass=ABCMeta):
class WindowsSystemSingleton(_SystemSingleton): class WindowsSystemSingleton(_SystemSingleton):
def __init__(self): def __init__(self):
self._mutex_name = r"Global\%s" % (WormConfiguration.singleton_mutex_name,) self._mutex_name = r"Global\%s" % (SINGLETON_MUTEX_NAME,)
self._mutex_handle = None self._mutex_handle = None
def try_lock(self): def try_lock(self):
@ -55,7 +56,7 @@ class WindowsSystemSingleton(_SystemSingleton):
class LinuxSystemSingleton(_SystemSingleton): class LinuxSystemSingleton(_SystemSingleton):
def __init__(self): def __init__(self):
self._unix_sock_name = str(WormConfiguration.singleton_mutex_name) self._unix_sock_name = str(SINGLETON_MUTEX_NAME)
self._sock_handle = None self._sock_handle = None
def try_lock(self): def try_lock(self):

View File

@ -8,13 +8,6 @@ INTERNAL = {
"title": "General", "title": "General",
"type": "object", "type": "object",
"properties": { "properties": {
"singleton_mutex_name": {
"title": "Singleton mutex name",
"type": "string",
"default": "{2384ec59-0df8-4ab9-918c-843740924a28}",
"description": "The name of the mutex used to determine whether the monkey is "
"already running",
},
"keep_tunnel_open_time": { "keep_tunnel_open_time": {
"title": "Keep tunnel open time", "title": "Keep tunnel open time",
"type": "integer", "type": "integer",

View File

@ -44,7 +44,6 @@
}, },
"internal": { "internal": {
"general": { "general": {
"singleton_mutex_name": "{2384ec59-0df8-4ab9-918c-843740924a28}",
"keep_tunnel_open_time": 60, "keep_tunnel_open_time": 60,
"monkey_dir_name": "monkey_dir", "monkey_dir_name": "monkey_dir",
"started_on_island": false "started_on_island": false