Skip to content

Commit

Permalink
client: fix initialization of darwin client
Browse files Browse the repository at this point in the history
  • Loading branch information
loriwitt committed Nov 29, 2023
1 parent f0ba46c commit c23cb0f
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 7 deletions.
7 changes: 4 additions & 3 deletions src/rpcclient/rpcclient/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
6 changes: 2 additions & 4 deletions src/rpcclient/rpcclient/darwin/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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()
Expand Down
2 changes: 2 additions & 0 deletions src/rpcclient/rpcclient/structs/consts.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@
DT_SOCK = 12
DT_WHT = 14

RTLD_GLOBAL = -2
RTLD_NEXT = -1
RTLD_NOW = 2

SIGABRT = 6
Expand Down

0 comments on commit c23cb0f

Please sign in to comment.