diff --git a/src/rpcclient/rpcclient/client.py b/src/rpcclient/rpcclient/client.py index 4c87d29f..5dc23363 100644 --- a/src/rpcclient/rpcclient/client.py +++ b/src/rpcclient/rpcclient/client.py @@ -31,7 +31,8 @@ from rpcclient.protocol import MAGIC, SERVER_MAGIC_VERSION, arch_t, argument_type_t, call_response_t, \ call_response_t_size, cmd_type_t, dummy_block_t, exec_chunk_t, exec_chunk_type_t, listdir_entry_t, \ protocol_handshake_t, protocol_message_t, reply_protocol_message_t -from rpcclient.structs.consts import EAGAIN, ECONNREFUSED, EEXIST, EISDIR, ENOENT, ENOTDIR, ENOTEMPTY, EPERM, EPIPE +from rpcclient.structs.consts import EAGAIN, ECONNREFUSED, EEXIST, EISDIR, ENOENT, ENOTDIR, ENOTEMPTY, EPERM, EPIPE, \ + RTLD_NEXT from rpcclient.symbol import Symbol from rpcclient.symbols_jar import SymbolsJar from rpcclient.sysctl import Sysctl @@ -97,14 +98,14 @@ class Client: DEFAULT_ARGV = ['/bin/sh'] DEFAULT_ENVP = [] - def __init__(self, sock, sysname: str, arch: arch_t, create_socket_cb: typing.Callable): + def __init__(self, sock, sysname: str, arch: arch_t, create_socket_cb: typing.Callable, dlsym_global_handle=RTLD_NEXT): self._arch = arch self._create_socket_cb = create_socket_cb self._sock = sock self._old_settings = None self._endianness = '<' self._sysname = sysname - self._dlsym_global_handle = -1 # RTLD_NEXT + self._dlsym_global_handle = dlsym_global_handle self._protocol_lock = threading.Lock() self._logger = logging.getLogger(self.__module__) self._ipython_run_cell_hook_enabled = True diff --git a/src/rpcclient/rpcclient/darwin/client.py b/src/rpcclient/rpcclient/darwin/client.py index 30fd9808..766d6dc6 100644 --- a/src/rpcclient/rpcclient/darwin/client.py +++ b/src/rpcclient/rpcclient/darwin/client.py @@ -38,7 +38,7 @@ from rpcclient.darwin.xpc import Xpc from rpcclient.exceptions import CfSerializationError, GettingObjectiveCClassError, MissingLibraryError from rpcclient.protocol import arch_t, cmd_type_t, protocol_message_t -from rpcclient.structs.consts import RTLD_NOW +from rpcclient.structs.consts import RTLD_GLOBAL, RTLD_NOW from rpcclient.symbol import Symbol from rpcclient.symbols_jar import SymbolsJar @@ -73,9 +73,7 @@ class DyldImage: class DarwinClient(Client): def __init__(self, sock, sysname: str, arch: arch_t, create_socket_cb: typing.Callable): - super().__init__(sock, sysname, arch, create_socket_cb) - self._dlsym_global_handle = -2 # RTLD_GLOBAL - self._init_process_specific() + super().__init__(sock, sysname, arch, create_socket_cb, dlsym_global_handle=RTLD_GLOBAL) def _init_process_specific(self): super(DarwinClient, self)._init_process_specific() diff --git a/src/rpcclient/rpcclient/structs/consts.py b/src/rpcclient/rpcclient/structs/consts.py index ef607bef..2b5d7e55 100644 --- a/src/rpcclient/rpcclient/structs/consts.py +++ b/src/rpcclient/rpcclient/structs/consts.py @@ -55,6 +55,8 @@ DT_SOCK = 12 DT_WHT = 14 +RTLD_GLOBAL = -2 +RTLD_NEXT = -1 RTLD_NOW = 2 SIGABRT = 6