From 7ba5509f5e98ec87acdb2fd5f9aef101090e4760 Mon Sep 17 00:00:00 2001 From: netanelc305 Date: Tue, 14 Nov 2023 00:43:34 -0800 Subject: [PATCH] WIP --- src/protos/gpt_construct_rpc.proto | 185 ++++++ src/protos/rpc.proto | 110 +++- src/rpcclient/rpcclient/client.py | 103 ++-- src/rpcclient/rpcclient/client_factory.py | 31 +- src/rpcclient/rpcclient/exceptions.py | 5 + src/rpcclient/rpcclient/protos/protosocket.py | 92 +++ src/rpcclient/rpcclient/protos/rpc_pb2.py | 122 ++-- src/rpcclient/rpcclient/protos/rpc_pb2.pyi | 511 ++++++++++++---- src/rpcserver/common.c | 102 ++-- src/rpcserver/common.h | 32 + src/rpcserver/darwin/darwin_class.m | 46 +- src/rpcserver/darwin/darwin_get_class_list.m | 60 +- src/rpcserver/darwin/darwin_object.m | 48 +- src/rpcserver/rpcserver.c | 548 ++++++++---------- 14 files changed, 1294 insertions(+), 701 deletions(-) create mode 100644 src/protos/gpt_construct_rpc.proto create mode 100644 src/rpcclient/rpcclient/protos/protosocket.py diff --git a/src/protos/gpt_construct_rpc.proto b/src/protos/gpt_construct_rpc.proto new file mode 100644 index 00000000..fe84eb6d --- /dev/null +++ b/src/protos/gpt_construct_rpc.proto @@ -0,0 +1,185 @@ +syntax = "proto3"; + +// Enum for cmd_type_t +enum CmdType { + CMD_EXEC = 0; + CMD_DLOPEN = 1; + CMD_DLCLOSE = 2; + CMD_DLSYM = 3; + CMD_CALL = 4; + CMD_PEEK = 5; + CMD_POKE = 6; + CMD_REPLY_ERROR = 7; + CMD_REPLY_PEEK = 8; + CMD_GET_DUMMY_BLOCK = 9; + CMD_CLOSE = 10; + CMD_REPLY_POKE = 11; + CMD_LISTDIR = 12; + CMD_SHOWOBJECT = 13; + CMD_SHOWCLASS = 14; + CMD_GET_CLASS_LIST = 15; +} + +// Enum for arch_t +enum ArchType { + ARCH_UNKNOWN = 0; + ARCH_ARM64 = 1; +} + +// Struct for protocol_handshake_t +message ProtocolHandshake { + int32 magic = 1; + ArchType arch = 2; + string sysname = 3; + string machine = 4; +} + +// Struct for cmd_exec_t +message CmdExec { + int32 background = 1; + repeated string argv = 2; + repeated string envp = 3; +} + +// Struct for cmd_dlopen_t +message CmdDlopen { + string filename = 1; + int32 mode = 2; +} + +// Struct for cmd_dlclose_t +message CmdDlclose { + int64 lib = 1; +} + +// Struct for cmd_dlsym_t +message CmdDlsym { + int64 lib = 1; + string symbol_name = 2; +} + +// Enum for argument_type_t +enum ArgumentType { + INTEGER = 0; + DOUBLE = 1; +} + +// Struct for argument_t +message Argument { + ArgumentType type = 1; + oneof value { + int64 int_value = 2; + double double_value = 3; + } +} + +// Struct for cmd_call_t +message CmdCall { + int64 address = 1; + int64 va_list_index = 2; + repeated Argument argv = 3; +} + +// Struct for cmd_peek_t +message CmdPeek { + int64 address = 1; + int64 size = 2; +} + +// Struct for cmd_poke_t +message CmdPoke { + int64 address = 1; + int64 size = 2; + bytes data = 3; +} + +// Struct for cmd_dirlist_t +message CmdDirlist { + string filename = 1; +} + +// Struct for cmd_showobject_t +message CmdShowobject { + int64 address = 1; +} + +// Struct for cmd_showclass_t +message CmdShowclass { + int64 address = 1; +} + +// Struct for listdir_entry_stat_t +message ListdirEntryStat { + int64 errno = 1; + int64 st_dev = 2; + int64 st_mode = 3; + int64 st_nlink = 4; + int64 st_ino = 5; + int64 st_uid = 6; + int64 st_gid = 7; + int64 st_rdev = 8; + int64 st_size = 9; + int64 st_blocks = 10; + int64 st_blksize = 11; + int64 st_atime = 12; + int64 st_mtime = 13; + int64 st_ctime = 14; +} + +// Struct for listdir_entry_t +message ListdirEntry { + int64 d_type = 1; + int64 d_namlen = 2; + ListdirEntryStat lstat = 3; + ListdirEntryStat stat = 4; +} + +// Struct for protocol_message_t +message ProtocolMessage { + int32 magic = 1; + CmdType cmd_type = 2; + oneof data { + CmdExec cmd_exec = 3; + CmdDlopen cmd_dlopen = 4; + CmdDlclose cmd_dlclose = 5; + CmdDlsym cmd_dlsym = 6; + CmdCall cmd_call = 7; + CmdPeek cmd_peek = 8; + CmdPoke cmd_poke = 9; + CmdDirlist cmd_dirlist = 10; + CmdShowobject cmd_showobject = 11; + CmdShowclass cmd_showclass = 12; + } +} + +// Struct for reply_protocol_message_t +message ReplyProtocolMessage { + int32 magic = 1; + CmdType cmd_type = 2; +} + +// Enum for exec_chunk_type_t +enum ExecChunkType { + CMD_EXEC_CHUNK_TYPE_STDOUT = 0; + CMD_EXEC_CHUNK_TYPE_ERRORCODE = 1; +} + +// Struct for exec_chunk_t +message ExecChunk { + ExecChunkType chunk_type = 1; + int32 size = 2; +} + +// Struct for return_registers_arm_t +message ReturnRegistersArm { + repeated int64 x = 1; + repeated double d = 2; +} + +// Struct for call_response_t +message CallResponse { + oneof return_values { + ReturnRegistersArm arm_registers = 1; + int64 return_value + } +} \ No newline at end of file diff --git a/src/protos/rpc.proto b/src/protos/rpc.proto index 7db78275..472b4d0b 100644 --- a/src/protos/rpc.proto +++ b/src/protos/rpc.proto @@ -2,23 +2,67 @@ syntax = "proto3"; package rpc; -enum CmdType { - CMD_EXEC = 0; - CMD_DLOPEN = 1; - CMD_DLCLOSE = 2; - CMD_DLSYM = 3; - CMD_CALL = 4; - CMD_PEEK = 5; - CMD_POKE = 6; - CMD_REPLY_ERROR = 7; - CMD_REPLY_PEEK = 8; - CMD_GET_DUMMY_BLOCK = 9; - CMD_CLOSE = 10; - CMD_REPLY_POKE = 11; - CMD_LISTDIR = 12; - CMD_SHOWOBJECT = 13; - CMD_SHOWCLASS = 14; - CMD_GET_CLASS_LIST = 15; + +message Command { + int32 magic = 1; + oneof type { + CmdExec exec = 2; + CmdDlopen dlopen = 3; + CmdDlclose dlclose = 4; + CmdDlsym dlsym = 5; + CmdCall call = 6; + CmdPeek peek = 7; + CmdPoke poke = 8; + CmdListDir listdir = 9; + CmdShowObject showobject = 10; + CmdShowClass showclass = 11; + CmdDummyBlock dummy_block = 12; + CmdClose close = 13; + CmdGetClassList class_list = 14; + } +} +message CmdDummyBlock{} + +// Todo +message CmdExec{ + bool background=1; + repeated string argv=2; + repeated string envp=3; +} +message CmdClose{} +message CmdGetClassList{} +message ResponsePoke{ + uint64 result = 1; +} + +message Response { + oneof type { + ResponseCmdExec exec = 1; + ResponseCmdExecChunk exec_chunk = 2; + ResponseDlopen dlopen = 3; + ResponseDlclose dlclose = 4; + ResponseDlsym dlsym = 5; + ResponsePeek peek = 6; + ResponsePoke poke = 7; + ResponseCall call = 8; + ResponseError error = 9; + ResponseDummyBlock dummy_block = 10; + ResponseShowObject show_object = 11; + ResponseGetClassList class_list = 12; + ResponseShowClass show_class = 13; + } +} + +message ResponseShowClass{ + string description = 1; +} +message ResponseDummyBlock{ + uint64 address = 1; + uint64 size = 2; +} +message ResponseError{ + string func_name = 1; + uint64 error_num=2; } enum CmdExecChunkType { @@ -45,32 +89,32 @@ message CmdExecChunk { message CmdDlopen { string filename = 1; - uint32 mode = 2; + int32 mode = 2; } message CmdDlclose { - uint64 lib = 1; + uint64 handle = 1; } message CmdDlsym { - uint64 lib = 1; + uint64 handle = 1; string symbol_name = 2; } message Argument { - uint64 type = 1; - uint64 value = 2; + oneof type{ + uint64 value=1; + string value=2; + double value=3; + } } message CmdCall { uint64 address = 1; uint64 va_list_index = 2; - uint64 argc = 3; - repeated Argument argv = 4; + repeated Argument argv = 3; } - - message ReturnRegistersArm { repeated uint64 x = 1; repeated uint64 d = 2; @@ -80,10 +124,13 @@ message CmdPeek { uint64 address = 1; uint64 size = 2; } +message ResponsePeek{ + bytes data =1; +} + message CmdPoke { uint64 address = 1; - uint64 size = 2; bytes data = 3; } @@ -121,6 +168,9 @@ message CmdShowObject { uint64 address = 1; } +message ResponseShowObject { + string description = 1; +} message CmdShowClass { uint64 address = 1; } @@ -136,19 +186,17 @@ message ResponseCmdExecChunk { } message ResponseDlopen { - uint32 err = 1; + uint64 handle = 1; } message ResponseDlclose { - uint32 err = 1; + uint32 res = 1; } message ResponseDlsym { uint64 ptr = 1; } -message ResponsePeek{} - message ResponseCall { oneof return_values { ReturnRegistersArm arm_registers = 1; diff --git a/src/rpcclient/rpcclient/client.py b/src/rpcclient/rpcclient/client.py index 4c87d29f..e532a7d6 100644 --- a/src/rpcclient/rpcclient/client.py +++ b/src/rpcclient/rpcclient/client.py @@ -1,6 +1,7 @@ import ast import builtins import contextlib +import ctypes import dataclasses import logging import os @@ -13,14 +14,10 @@ from select import select import IPython -from construct import Float16l, Float32l, Float64l, Int64sl, Int64ul -from traitlets.config import Config -from xonsh.built_ins import XSH -from xonsh.main import main as xonsh_main - import rpcclient +from construct import Int64ul from rpcclient.darwin.structs import exitcode_t, pid_t -from rpcclient.exceptions import ArgumentError, BadReturnValueError, InvalidServerVersionMagicError, \ +from rpcclient.exceptions import BadReturnValueError, InvalidServerVersionMagicError, \ RpcBrokenPipeError, RpcConnectionRefusedError, RpcFileExistsError, RpcFileNotFoundError, RpcIsADirectoryError, \ RpcNotADirectoryError, RpcNotEmptyError, RpcPermissionError, RpcResourceTemporarilyUnavailableError, \ ServerDiedError, SpawnError, SymbolAbsentError @@ -28,13 +25,20 @@ from rpcclient.lief import Lief from rpcclient.network import Network from rpcclient.processes import Processes -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.protocol import arch_t, cmd_type_t, \ + exec_chunk_t, exec_chunk_type_t, listdir_entry_t, MAGIC, protocol_handshake_t, protocol_message_t, \ + SERVER_MAGIC_VERSION from rpcclient.structs.consts import EAGAIN, ECONNREFUSED, EEXIST, EISDIR, ENOENT, ENOTDIR, ENOTEMPTY, EPERM, EPIPE from rpcclient.symbol import Symbol from rpcclient.symbols_jar import SymbolsJar from rpcclient.sysctl import Sysctl +from traitlets.config import Config +from xonsh.built_ins import XSH +from xonsh.main import main as xonsh_main + +from protocol import argument_type_t, call_response_t, call_response_t_size +from protos.protosocket import ProtoSocket +from protos.rpc_pb2 import Argument, CmdDummyBlock, Command tty_support = False try: @@ -97,7 +101,7 @@ 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: ProtoSocket, sysname: str, arch: arch_t, create_socket_cb: typing.Callable): self._arch = arch self._create_socket_cb = create_socket_cb self._sock = sock @@ -147,38 +151,29 @@ def arch(self): def dlopen(self, filename: str, mode: int) -> Symbol: """ call dlopen() at remote and return its handle. see the man page for more details. """ - message = protocol_message_t.build({ - 'cmd_type': cmd_type_t.CMD_DLOPEN, - 'data': {'filename': filename, 'mode': mode}, - }) + command = Command(magic=MAGIC) + command.dlopen.filename = filename + command.dlopen.mode = mode with self._protocol_lock: - self._sock.sendall(message) - address = Int64sl.parse(self._recvall(Int64sl.sizeof())) - return self.symbol(address) + response = self._sock.command_response(command) + return self.symbol(response.handle) def dlclose(self, lib: int): """ call dlclose() at remote and return its handle. see the man page for more details. """ - lib &= 0xffffffffffffffff - message = protocol_message_t.build({ - 'cmd_type': cmd_type_t.CMD_DLCLOSE, - 'data': {'lib': lib}, - }) + command = Command(magic=MAGIC) + command.dlclose.handle = lib with self._protocol_lock: - self._sock.sendall(message) - err = Int64sl.parse(self._recvall(Int64sl.sizeof())) - return err + response = self._sock.command_response(command) + return response.res def dlsym(self, lib: int, symbol_name: str): """ call dlsym() at remote and return its handle. see the man page for more details. """ - lib &= 0xffffffffffffffff - message = protocol_message_t.build({ - 'cmd_type': cmd_type_t.CMD_DLSYM, - 'data': {'lib': lib, 'symbol_name': symbol_name}, - }) + command = Command(magic=MAGIC) + command.dlsym.handle = ctypes.c_uint64(lib).value + command.dlsym.symbol_name = symbol_name with self._protocol_lock: - self._sock.sendall(message) - address = Int64sl.parse(self._recvall(Int64sl.sizeof())) - return address + response = self._sock.command_response(command) + return response.ptr def call(self, address: int, argv: typing.List[int] = None, return_float64=False, return_float32=False, return_float16=False, return_raw=False, va_list_index: int = 0xffff) -> Symbol: @@ -215,7 +210,7 @@ def call(self, address: int, argv: typing.List[int] = None, return_float64=False else: [self.symbols.free(f) for f in free_list] - raise ArgumentError(f'invalid parameter type: {arg}') + raise ctypes.ArgumentError(f'invalid parameter type: {arg}') message = protocol_message_t.build({ 'cmd_type': cmd_type_t.CMD_CALL, @@ -253,41 +248,29 @@ def call(self, address: int, argv: typing.List[int] = None, return_float64=False def peek(self, address: int, size: int) -> bytes: """ peek data at given address """ - message = protocol_message_t.build({ - 'cmd_type': cmd_type_t.CMD_PEEK, - 'data': {'address': address, 'size': size}, - }) + command = Command(magic=MAGIC) + command.peek.address = address + command.peek.size = size with self._protocol_lock: - self._sock.sendall(message) - reply = protocol_message_t.parse(self._recvall(reply_protocol_message_t.sizeof())) - if reply.cmd_type == cmd_type_t.CMD_REPLY_ERROR: - raise ArgumentError(f'failed to read {size} bytes from {address}') - return self._recvall(size) + response = self._sock.command_response(command) + return response.data def poke(self, address: int, data: bytes): """ poke data at given address """ - message = protocol_message_t.build({ - 'cmd_type': cmd_type_t.CMD_POKE, - 'data': {'address': address, 'size': len(data), 'data': data}, - }) + command = Command(magic=MAGIC) + command.poke.address = address + command.poke.data = data with self._protocol_lock: - self._sock.sendall(message) - reply = protocol_message_t.parse(self._recvall(reply_protocol_message_t.sizeof())) - if reply.cmd_type == cmd_type_t.CMD_REPLY_ERROR: - raise ArgumentError(f'failed to write {len(data)} bytes to {address}') + response = self._sock.command_response(command) + return response.result def get_dummy_block(self) -> Symbol: """ get an address for a stub block containing nothing """ - message = protocol_message_t.build({ - 'cmd_type': cmd_type_t.CMD_GET_DUMMY_BLOCK, - 'data': None, - }) - + command = Command(magic=MAGIC) + command.dummy_block.CopyFrom(CmdDummyBlock()) with self._protocol_lock: - self._sock.sendall(message) - result = dummy_block_t.parse(self._recvall(dummy_block_t.sizeof())) - - return self.symbol(result) + response = self._sock.command_response(command) + return self.symbol(response.adddress) def listdir(self, filename: str): """ get an address for a stub block containing nothing """ diff --git a/src/rpcclient/rpcclient/client_factory.py b/src/rpcclient/rpcclient/client_factory.py index ead81595..8b14d66a 100644 --- a/src/rpcclient/rpcclient/client_factory.py +++ b/src/rpcclient/rpcclient/client_factory.py @@ -9,13 +9,13 @@ import requests from rpcclient.client import Client -from rpcclient.exceptions import FailedToConnectError, InvalidServerVersionMagicError +from rpcclient.exceptions import FailedToConnectError from rpcclient.ios.client import IosClient from rpcclient.linux.client import LinuxClient from rpcclient.macos.client import MacosClient -from rpcclient.protocol import DEFAULT_PORT, SERVER_MAGIC_VERSION +from rpcclient.protocol import DEFAULT_PORT -import protos.rpc_pb2 as rpc_proto +from protos.protosocket import ProtoSocket PROJECT_URL = 'https://github.com/doronz88/rpc-project/archive/refs/heads/master.zip' RPCSERVER_SUBDIR = 'rpc-project-master/src/rpcserver' @@ -24,17 +24,6 @@ logger = logging.getLogger(__name__) -def recvall(sock, size: int) -> bytes: - buf = b'' - while size: - chunk = sock.recv(size) - if not chunk: - raise FailedToConnectError() - size -= len(chunk) - buf += chunk - return buf - - def create_local() -> typing.Union[Client, IosClient, MacosClient, LinuxClient]: if not HOMEDIR.exists(): with tempfile.TemporaryDirectory() as temp_dir: @@ -77,15 +66,11 @@ def tcp_connect() -> socket: def create_client(create_socket_cb: typing.Callable) -> typing.Union[Client, IosClient, MacosClient, LinuxClient]: sock = create_socket_cb() - raw = recvall(sock, 22) - handshake = rpc_proto.Handshake() - handshake.ParseFromString(raw) - if handshake.magic != SERVER_MAGIC_VERSION: - raise InvalidServerVersionMagicError(f'got {handshake.magic:x} instead of {SERVER_MAGIC_VERSION:x}') + proto_sock = ProtoSocket(sock) - sysname = handshake.sysname.lower() - machine = handshake.machine.lower() - arch = handshake.arch + sysname = proto_sock.handshake.sysname.lower() + machine = proto_sock.handshake.machine.lower() + arch = proto_sock.handshake.arch logging.info(f'connection uname.sysname: {sysname} uname.machine: {machine}') @@ -93,7 +78,7 @@ def create_client(create_socket_cb: typing.Callable) -> typing.Union[Client, Ios if machine.startswith('iphone'): return IosClient(sock, sysname, arch, create_socket_cb) else: - return MacosClient(sock, sysname, arch, create_socket_cb) + return MacosClient(proto_sock, sysname, arch, create_socket_cb) elif sysname == 'linux': return LinuxClient(sock, sysname, arch, create_socket_cb) diff --git a/src/rpcclient/rpcclient/exceptions.py b/src/rpcclient/rpcclient/exceptions.py index f7ac5bf2..3a5a0247 100644 --- a/src/rpcclient/rpcclient/exceptions.py +++ b/src/rpcclient/rpcclient/exceptions.py @@ -8,6 +8,11 @@ class InvalidServerVersionMagicError(RpcClientException): pass +class ResponseNotFoundError(RpcClientException): + """ server handshake failed due to an invalid magic """ + pass + + class ServerDiedError(RpcClientException): """ server became disconnected during an operation """ pass diff --git a/src/rpcclient/rpcclient/protos/protosocket.py b/src/rpcclient/rpcclient/protos/protosocket.py new file mode 100644 index 00000000..3772f6ad --- /dev/null +++ b/src/rpcclient/rpcclient/protos/protosocket.py @@ -0,0 +1,92 @@ +import struct +from socket import socket + +from rpcclient.exceptions import FailedToConnectError +from rpcclient.protocol import MAGIC +from rpcclient.protos.rpc_pb2 import CmdGetClassList, Command, Handshake, Response + +from exceptions import InvalidServerVersionMagicError, ResponseNotFoundError +from protocol import SERVER_MAGIC_VERSION + + +class ProtoSocket: + def __init__(self, sock): + self._sock = sock + self.handshake = None + self.do_handshake() + + def do_handshake(self): + self.handshake = Handshake() + size, buff = self.receive() + self.handshake.ParseFromString(buff) + if self.handshake.magic != SERVER_MAGIC_VERSION: + raise InvalidServerVersionMagicError(f'got {self.handshake.magic:x} instead of {SERVER_MAGIC_VERSION:x}') + + def command_response(self, command: Command): + self.send(command.SerializeToString()) + response = Response() + size, buff = self.receive() + command_type = command.WhichOneof('type') + response.ParseFromString(buff) + + # Iterate through all possible response types + if response.HasField(command_type): + resp = getattr(response, command_type.lower(), None) + elif response.HasField('error'): + resp = response.error + else: + raise ResponseNotFoundError() + return resp + # Handle unrecognized command or return a default response + + def receive(self): + size = struct.unpack(' None: + buff = struct.pack(' bytes: + buf = b'' + while size: + chunk = self._sock.recv(size) + if not chunk: + raise FailedToConnectError() + size -= len(chunk) + buf += chunk + return buf + + @staticmethod + def hex_dump(data): + hex_data = ' '.join([format(byte, '02X') for byte in data]) + print(hex_data) + + +def rpc_protobuf(): + sock = socket() + + sock.connect(('127.0.0.1', 5910)) + proto_sock = ProtoSocket(sock) + command = Command(magic=MAGIC) + command.peek.address = 0 + command.peek.size = 10 + response = proto_sock.command_response(command) + print(response) + + command.dlopen.filename = '/System/Library/Frameworks/CFNetwork.framework/CFNetwork' + command.dlopen.mode = 2 + response = proto_sock.command_response(command) + print(response) + + handle = response.handle + command.dlsym.handle = handle + command.dlsym.symbol_name = 'CFHTTPMessageCopySerializedMessage' + response = proto_sock.command_response(command) + print(response) + + command.class_list.CopyFrom(CmdGetClassList()) + response = proto_sock.command_response(command) + print(response) + print(response) diff --git a/src/rpcclient/rpcclient/protos/rpc_pb2.py b/src/rpcclient/rpcclient/protos/rpc_pb2.py index 7b6137a0..7d136dff 100644 --- a/src/rpcclient/rpcclient/protos/rpc_pb2.py +++ b/src/rpcclient/rpcclient/protos/rpc_pb2.py @@ -14,57 +14,85 @@ -DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile(b'\n\trpc.proto\x12\x03rpc\"U\n\tHandshake\x12\r\n\x05magic\x18\x01 \x01(\r\x12\x17\n\x04\x61rch\x18\x02 \x01(\x0e\x32\t.rpc.Arch\x12\x0f\n\x07sysname\x18\x03 \x01(\t\x12\x0f\n\x07machine\x18\x04 \x01(\t\"A\n\x0c\x43mdExecChunk\x12#\n\x04type\x18\x01 \x01(\x0e\x32\x15.rpc.CmdExecChunkType\x12\x0c\n\x04size\x18\x02 \x01(\r\"I\n\x14ResponseCmdExecChunk\x12#\n\x04type\x18\x01 \x01(\x0e\x32\x15.rpc.CmdExecChunkType\x12\x0c\n\x04size\x18\x02 \x01(\r\"+\n\tCmdDlopen\x12\x10\n\x08\x66ilename\x18\x01 \x01(\t\x12\x0c\n\x04mode\x18\x02 \x01(\r\"0\n\x0eResponseDlopen\x12\x10\n\x08\x66ilename\x18\x01 \x01(\t\x12\x0c\n\x04mode\x18\x02 \x01(\r\"\x19\n\nCmdDlclose\x12\x0b\n\x03lib\x18\x01 \x01(\x04\",\n\x08\x43mdDlsym\x12\x0b\n\x03lib\x18\x01 \x01(\x04\x12\x13\n\x0bsymbol_name\x18\x02 \x01(\t\"\'\n\x08\x41rgument\x12\x0c\n\x04type\x18\x01 \x01(\x04\x12\r\n\x05value\x18\x02 \x01(\x04\"\\\n\x07\x43mdCall\x12\x0f\n\x07\x61\x64\x64ress\x18\x01 \x01(\x04\x12\x15\n\rva_list_index\x18\x02 \x01(\x04\x12\x0c\n\x04\x61rgc\x18\x03 \x01(\x04\x12\x1b\n\x04\x61rgv\x18\x04 \x03(\x0b\x32\r.rpc.Argument\"i\n\x0cResponseCall\x12\x30\n\rarm_registers\x18\x01 \x01(\x0b\x32\x17.rpc.ReturnRegistersArmH\x00\x12\x16\n\x0creturn_value\x18\x02 \x01(\x04H\x00\x42\x0f\n\rreturn_values\"*\n\x12ReturnRegistersArm\x12\t\n\x01x\x18\x01 \x03(\x04\x12\t\n\x01\x64\x18\x02 \x03(\x04\"(\n\x07\x43mdPeek\x12\x0f\n\x07\x61\x64\x64ress\x18\x01 \x01(\x04\x12\x0c\n\x04size\x18\x02 \x01(\x04\"6\n\x07\x43mdPoke\x12\x0f\n\x07\x61\x64\x64ress\x18\x01 \x01(\x04\x12\x0c\n\x04size\x18\x02 \x01(\x04\x12\x0c\n\x04\x64\x61ta\x18\x03 \x01(\x0c\"\x1e\n\nCmdListDir\x12\x10\n\x08\x66ilename\x18\x01 \x01(\t\"\x87\x02\n\x10ListdirEntryStat\x12\x0e\n\x06\x65rrno1\x18\x01 \x01(\x04\x12\x0e\n\x06st_dev\x18\x02 \x01(\x04\x12\x0f\n\x07st_mode\x18\x03 \x01(\x04\x12\x10\n\x08st_nlink\x18\x04 \x01(\x04\x12\x0e\n\x06st_ino\x18\x05 \x01(\x04\x12\x0e\n\x06st_uid\x18\x06 \x01(\x04\x12\x0e\n\x06st_gid\x18\x07 \x01(\x04\x12\x0f\n\x07st_rdev\x18\x08 \x01(\x04\x12\x0f\n\x07st_size\x18\t \x01(\x04\x12\x11\n\tst_blocks\x18\n \x01(\x04\x12\x12\n\nst_blksize\x18\x0b \x01(\x04\x12\x11\n\tst_atime1\x18\x0c \x01(\x04\x12\x11\n\tst_mtime1\x18\r \x01(\x04\x12\x11\n\tst_ctime1\x18\x0e \x01(\x04\"\x95\x01\n\x0cListdirEntry\x12\r\n\x05magic\x18\x01 \x01(\x04\x12\x0c\n\x04type\x18\x02 \x01(\x04\x12\x0f\n\x07namelen\x18\x03 \x01(\x04\x12$\n\x05lstat\x18\x04 \x01(\x0b\x32\x15.rpc.ListdirEntryStat\x12#\n\x04stat\x18\x05 \x01(\x0b\x32\x15.rpc.ListdirEntryStat\x12\x0c\n\x04name\x18\x06 \x01(\t\" \n\rCmdShowObject\x12\x0f\n\x07\x61\x64\x64ress\x18\x01 \x01(\x04\"\x1f\n\x0c\x43mdShowClass\x12\x0f\n\x07\x61\x64\x64ress\x18\x01 \x01(\x04\"*\n\tObjcClass\x12\x0f\n\x07\x61\x64\x64ress\x18\x01 \x01(\x04\x12\x0c\n\x04name\x18\x02 \x01(\t\"7\n\x14ResponseGetClassList\x12\x1f\n\x07\x63lasses\x18\x01 \x03(\x0b\x32\x0e.rpc.ObjcClass*\xa6\x02\n\x07\x43mdType\x12\x0c\n\x08\x43MD_EXEC\x10\x00\x12\x0e\n\nCMD_DLOPEN\x10\x01\x12\x0f\n\x0b\x43MD_DLCLOSE\x10\x02\x12\r\n\tCMD_DLSYM\x10\x03\x12\x0c\n\x08\x43MD_CALL\x10\x04\x12\x0c\n\x08\x43MD_PEEK\x10\x05\x12\x0c\n\x08\x43MD_POKE\x10\x06\x12\x13\n\x0f\x43MD_REPLY_ERROR\x10\x07\x12\x12\n\x0e\x43MD_REPLY_PEEK\x10\x08\x12\x17\n\x13\x43MD_GET_DUMMY_BLOCK\x10\t\x12\r\n\tCMD_CLOSE\x10\n\x12\x12\n\x0e\x43MD_REPLY_POKE\x10\x0b\x12\x0f\n\x0b\x43MD_LISTDIR\x10\x0c\x12\x12\n\x0e\x43MD_SHOWOBJECT\x10\r\x12\x11\n\rCMD_SHOWCLASS\x10\x0e\x12\x16\n\x12\x43MD_GET_CLASS_LIST\x10\x0f*T\n\x10\x43mdExecChunkType\x12\x1e\n\x1a\x43MD_EXEC_CHUNK_TYPE_STDOUT\x10\x00\x12 \n\x1c\x43MD_EXEC_CHUNK_TYPE_EXITCODE\x10\x01*(\n\x04\x41rch\x12\x10\n\x0c\x41RCH_UNKNOWN\x10\x00\x12\x0e\n\nARCH_ARM64\x10\x01\x62\x06proto3') +DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile(b'\n\trpc.proto\x12\x03rpc\"\xeb\x03\n\x07\x43ommand\x12\r\n\x05magic\x18\x01 \x01(\x05\x12\x1c\n\x04\x65xec\x18\x02 \x01(\x0b\x32\x0c.rpc.CmdExecH\x00\x12 \n\x06\x64lopen\x18\x03 \x01(\x0b\x32\x0e.rpc.CmdDlopenH\x00\x12\"\n\x07\x64lclose\x18\x04 \x01(\x0b\x32\x0f.rpc.CmdDlcloseH\x00\x12\x1e\n\x05\x64lsym\x18\x05 \x01(\x0b\x32\r.rpc.CmdDlsymH\x00\x12\x1c\n\x04\x63\x61ll\x18\x06 \x01(\x0b\x32\x0c.rpc.CmdCallH\x00\x12\x1c\n\x04peek\x18\x07 \x01(\x0b\x32\x0c.rpc.CmdPeekH\x00\x12\x1c\n\x04poke\x18\x08 \x01(\x0b\x32\x0c.rpc.CmdPokeH\x00\x12\"\n\x07listdir\x18\t \x01(\x0b\x32\x0f.rpc.CmdListDirH\x00\x12(\n\nshowobject\x18\n \x01(\x0b\x32\x12.rpc.CmdShowObjectH\x00\x12&\n\tshowclass\x18\x0b \x01(\x0b\x32\x11.rpc.CmdShowClassH\x00\x12)\n\x0b\x64ummy_block\x18\x0c \x01(\x0b\x32\x12.rpc.CmdDummyBlockH\x00\x12\x1e\n\x05\x63lose\x18\r \x01(\x0b\x32\r.rpc.CmdCloseH\x00\x12*\n\nclass_list\x18\x0e \x01(\x0b\x32\x14.rpc.CmdGetClassListH\x00\x42\x06\n\x04type\"\x0f\n\rCmdDummyBlock\"9\n\x07\x43mdExec\x12\x12\n\nbackground\x18\x01 \x01(\x08\x12\x0c\n\x04\x61rgv\x18\x02 \x03(\t\x12\x0c\n\x04\x65nvp\x18\x03 \x03(\t\"\n\n\x08\x43mdClose\"\x11\n\x0f\x43mdGetClassList\"\x1e\n\x0cResponsePoke\x12\x0e\n\x06result\x18\x01 \x01(\x04\"\xab\x04\n\x08Response\x12$\n\x04\x65xec\x18\x01 \x01(\x0b\x32\x14.rpc.ResponseCmdExecH\x00\x12/\n\nexec_chunk\x18\x02 \x01(\x0b\x32\x19.rpc.ResponseCmdExecChunkH\x00\x12%\n\x06\x64lopen\x18\x03 \x01(\x0b\x32\x13.rpc.ResponseDlopenH\x00\x12\'\n\x07\x64lclose\x18\x04 \x01(\x0b\x32\x14.rpc.ResponseDlcloseH\x00\x12#\n\x05\x64lsym\x18\x05 \x01(\x0b\x32\x12.rpc.ResponseDlsymH\x00\x12!\n\x04peek\x18\x06 \x01(\x0b\x32\x11.rpc.ResponsePeekH\x00\x12!\n\x04poke\x18\x07 \x01(\x0b\x32\x11.rpc.ResponsePokeH\x00\x12!\n\x04\x63\x61ll\x18\x08 \x01(\x0b\x32\x11.rpc.ResponseCallH\x00\x12#\n\x05\x65rror\x18\t \x01(\x0b\x32\x12.rpc.ResponseErrorH\x00\x12.\n\x0b\x64ummy_block\x18\n \x01(\x0b\x32\x17.rpc.ResponseDummyBlockH\x00\x12.\n\x0bshow_object\x18\x0b \x01(\x0b\x32\x17.rpc.ResponseShowObjectH\x00\x12/\n\nclass_list\x18\x0c \x01(\x0b\x32\x19.rpc.ResponseGetClassListH\x00\x12,\n\nshow_class\x18\r \x01(\x0b\x32\x16.rpc.ResponseShowClassH\x00\x42\x06\n\x04type\"(\n\x11ResponseShowClass\x12\x13\n\x0b\x64\x65scription\x18\x01 \x01(\t\"3\n\x12ResponseDummyBlock\x12\x0f\n\x07\x61\x64\x64ress\x18\x01 \x01(\x04\x12\x0c\n\x04size\x18\x02 \x01(\x04\"5\n\rResponseError\x12\x11\n\tfunc_name\x18\x01 \x01(\t\x12\x11\n\terror_num\x18\x02 \x01(\x04\"U\n\tHandshake\x12\r\n\x05magic\x18\x01 \x01(\r\x12\x17\n\x04\x61rch\x18\x02 \x01(\x0e\x32\t.rpc.Arch\x12\x0f\n\x07sysname\x18\x03 \x01(\t\x12\x0f\n\x07machine\x18\x04 \x01(\t\"A\n\x0c\x43mdExecChunk\x12#\n\x04type\x18\x01 \x01(\x0e\x32\x15.rpc.CmdExecChunkType\x12\x0c\n\x04size\x18\x02 \x01(\r\"+\n\tCmdDlopen\x12\x10\n\x08\x66ilename\x18\x01 \x01(\t\x12\x0c\n\x04mode\x18\x02 \x01(\x05\"\x1c\n\nCmdDlclose\x12\x0e\n\x06handle\x18\x01 \x01(\x04\"/\n\x08\x43mdDlsym\x12\x0e\n\x06handle\x18\x01 \x01(\x04\x12\x13\n\x0bsymbol_name\x18\x02 \x01(\t\"\'\n\x08\x41rgument\x12\x0c\n\x04type\x18\x01 \x01(\x04\x12\r\n\x05value\x18\x02 \x01(\x04\"N\n\x07\x43mdCall\x12\x0f\n\x07\x61\x64\x64ress\x18\x01 \x01(\x04\x12\x15\n\rva_list_index\x18\x02 \x01(\x04\x12\x1b\n\x04\x61rgv\x18\x03 \x03(\x0b\x32\r.rpc.Argument\"*\n\x12ReturnRegistersArm\x12\t\n\x01x\x18\x01 \x03(\x04\x12\t\n\x01\x64\x18\x02 \x03(\x04\"(\n\x07\x43mdPeek\x12\x0f\n\x07\x61\x64\x64ress\x18\x01 \x01(\x04\x12\x0c\n\x04size\x18\x02 \x01(\x04\"\x1c\n\x0cResponsePeek\x12\x0c\n\x04\x64\x61ta\x18\x01 \x01(\x0c\"(\n\x07\x43mdPoke\x12\x0f\n\x07\x61\x64\x64ress\x18\x01 \x01(\x04\x12\x0c\n\x04\x64\x61ta\x18\x03 \x01(\x0c\"\x1e\n\nCmdListDir\x12\x10\n\x08\x66ilename\x18\x01 \x01(\t\"\x87\x02\n\x10ListdirEntryStat\x12\x0e\n\x06\x65rrno1\x18\x01 \x01(\x04\x12\x0e\n\x06st_dev\x18\x02 \x01(\x04\x12\x0f\n\x07st_mode\x18\x03 \x01(\x04\x12\x10\n\x08st_nlink\x18\x04 \x01(\x04\x12\x0e\n\x06st_ino\x18\x05 \x01(\x04\x12\x0e\n\x06st_uid\x18\x06 \x01(\x04\x12\x0e\n\x06st_gid\x18\x07 \x01(\x04\x12\x0f\n\x07st_rdev\x18\x08 \x01(\x04\x12\x0f\n\x07st_size\x18\t \x01(\x04\x12\x11\n\tst_blocks\x18\n \x01(\x04\x12\x12\n\nst_blksize\x18\x0b \x01(\x04\x12\x11\n\tst_atime1\x18\x0c \x01(\x04\x12\x11\n\tst_mtime1\x18\r \x01(\x04\x12\x11\n\tst_ctime1\x18\x0e \x01(\x04\"\x95\x01\n\x0cListdirEntry\x12\r\n\x05magic\x18\x01 \x01(\x04\x12\x0c\n\x04type\x18\x02 \x01(\x04\x12\x0f\n\x07namelen\x18\x03 \x01(\x04\x12$\n\x05lstat\x18\x04 \x01(\x0b\x32\x15.rpc.ListdirEntryStat\x12#\n\x04stat\x18\x05 \x01(\x0b\x32\x15.rpc.ListdirEntryStat\x12\x0c\n\x04name\x18\x06 \x01(\t\" \n\rCmdShowObject\x12\x0f\n\x07\x61\x64\x64ress\x18\x01 \x01(\x04\")\n\x12ResponseShowObject\x12\x13\n\x0b\x64\x65scription\x18\x01 \x01(\t\"\x1f\n\x0c\x43mdShowClass\x12\x0f\n\x07\x61\x64\x64ress\x18\x01 \x01(\x04\"\x1e\n\x0fResponseCmdExec\x12\x0b\n\x03pid\x18\x01 \x01(\r\"I\n\x14ResponseCmdExecChunk\x12#\n\x04type\x18\x01 \x01(\x0e\x32\x15.rpc.CmdExecChunkType\x12\x0c\n\x04size\x18\x02 \x01(\r\" \n\x0eResponseDlopen\x12\x0e\n\x06handle\x18\x01 \x01(\x04\"\x1e\n\x0fResponseDlclose\x12\x0b\n\x03res\x18\x01 \x01(\r\"\x1c\n\rResponseDlsym\x12\x0b\n\x03ptr\x18\x01 \x01(\x04\"i\n\x0cResponseCall\x12\x30\n\rarm_registers\x18\x01 \x01(\x0b\x32\x17.rpc.ReturnRegistersArmH\x00\x12\x16\n\x0creturn_value\x18\x02 \x01(\x04H\x00\x42\x0f\n\rreturn_values\"*\n\tObjcClass\x12\x0f\n\x07\x61\x64\x64ress\x18\x01 \x01(\x04\x12\x0c\n\x04name\x18\x02 \x01(\t\"7\n\x14ResponseGetClassList\x12\x1f\n\x07\x63lasses\x18\x01 \x03(\x0b\x32\x0e.rpc.ObjcClass*T\n\x10\x43mdExecChunkType\x12\x1e\n\x1a\x43MD_EXEC_CHUNK_TYPE_STDOUT\x10\x00\x12 \n\x1c\x43MD_EXEC_CHUNK_TYPE_EXITCODE\x10\x01*(\n\x04\x41rch\x12\x10\n\x0c\x41RCH_UNKNOWN\x10\x00\x12\x0e\n\nARCH_ARM64\x10\x01\x62\x06proto3') _globals = globals() _builder.BuildMessageAndEnumDescriptors(DESCRIPTOR, _globals) _builder.BuildTopDescriptorsAndMessages(DESCRIPTOR, 'rpc_pb2', _globals) if _descriptor._USE_C_DESCRIPTORS == False: DESCRIPTOR._options = None - _globals['_CMDTYPE']._serialized_start=1418 - _globals['_CMDTYPE']._serialized_end=1712 - _globals['_CMDEXECCHUNKTYPE']._serialized_start=1714 - _globals['_CMDEXECCHUNKTYPE']._serialized_end=1798 - _globals['_ARCH']._serialized_start=1800 - _globals['_ARCH']._serialized_end=1840 - _globals['_HANDSHAKE']._serialized_start=18 - _globals['_HANDSHAKE']._serialized_end=103 - _globals['_CMDEXECCHUNK']._serialized_start=105 - _globals['_CMDEXECCHUNK']._serialized_end=170 - _globals['_RESPONSECMDEXECCHUNK']._serialized_start=172 - _globals['_RESPONSECMDEXECCHUNK']._serialized_end=245 - _globals['_CMDDLOPEN']._serialized_start=247 - _globals['_CMDDLOPEN']._serialized_end=290 - _globals['_RESPONSEDLOPEN']._serialized_start=292 - _globals['_RESPONSEDLOPEN']._serialized_end=340 - _globals['_CMDDLCLOSE']._serialized_start=342 - _globals['_CMDDLCLOSE']._serialized_end=367 - _globals['_CMDDLSYM']._serialized_start=369 - _globals['_CMDDLSYM']._serialized_end=413 - _globals['_ARGUMENT']._serialized_start=415 - _globals['_ARGUMENT']._serialized_end=454 - _globals['_CMDCALL']._serialized_start=456 - _globals['_CMDCALL']._serialized_end=548 - _globals['_RESPONSECALL']._serialized_start=550 - _globals['_RESPONSECALL']._serialized_end=655 - _globals['_RETURNREGISTERSARM']._serialized_start=657 - _globals['_RETURNREGISTERSARM']._serialized_end=699 - _globals['_CMDPEEK']._serialized_start=701 - _globals['_CMDPEEK']._serialized_end=741 - _globals['_CMDPOKE']._serialized_start=743 - _globals['_CMDPOKE']._serialized_end=797 - _globals['_CMDLISTDIR']._serialized_start=799 - _globals['_CMDLISTDIR']._serialized_end=829 - _globals['_LISTDIRENTRYSTAT']._serialized_start=832 - _globals['_LISTDIRENTRYSTAT']._serialized_end=1095 - _globals['_LISTDIRENTRY']._serialized_start=1098 - _globals['_LISTDIRENTRY']._serialized_end=1247 - _globals['_CMDSHOWOBJECT']._serialized_start=1249 - _globals['_CMDSHOWOBJECT']._serialized_end=1281 - _globals['_CMDSHOWCLASS']._serialized_start=1283 - _globals['_CMDSHOWCLASS']._serialized_end=1314 - _globals['_OBJCCLASS']._serialized_start=1316 - _globals['_OBJCCLASS']._serialized_end=1358 - _globals['_RESPONSEGETCLASSLIST']._serialized_start=1360 - _globals['_RESPONSEGETCLASSLIST']._serialized_end=1415 + _globals['_CMDEXECCHUNKTYPE']._serialized_start=2887 + _globals['_CMDEXECCHUNKTYPE']._serialized_end=2971 + _globals['_ARCH']._serialized_start=2973 + _globals['_ARCH']._serialized_end=3013 + _globals['_COMMAND']._serialized_start=19 + _globals['_COMMAND']._serialized_end=510 + _globals['_CMDDUMMYBLOCK']._serialized_start=512 + _globals['_CMDDUMMYBLOCK']._serialized_end=527 + _globals['_CMDEXEC']._serialized_start=529 + _globals['_CMDEXEC']._serialized_end=586 + _globals['_CMDCLOSE']._serialized_start=588 + _globals['_CMDCLOSE']._serialized_end=598 + _globals['_CMDGETCLASSLIST']._serialized_start=600 + _globals['_CMDGETCLASSLIST']._serialized_end=617 + _globals['_RESPONSEPOKE']._serialized_start=619 + _globals['_RESPONSEPOKE']._serialized_end=649 + _globals['_RESPONSE']._serialized_start=652 + _globals['_RESPONSE']._serialized_end=1207 + _globals['_RESPONSESHOWCLASS']._serialized_start=1209 + _globals['_RESPONSESHOWCLASS']._serialized_end=1249 + _globals['_RESPONSEDUMMYBLOCK']._serialized_start=1251 + _globals['_RESPONSEDUMMYBLOCK']._serialized_end=1302 + _globals['_RESPONSEERROR']._serialized_start=1304 + _globals['_RESPONSEERROR']._serialized_end=1357 + _globals['_HANDSHAKE']._serialized_start=1359 + _globals['_HANDSHAKE']._serialized_end=1444 + _globals['_CMDEXECCHUNK']._serialized_start=1446 + _globals['_CMDEXECCHUNK']._serialized_end=1511 + _globals['_CMDDLOPEN']._serialized_start=1513 + _globals['_CMDDLOPEN']._serialized_end=1556 + _globals['_CMDDLCLOSE']._serialized_start=1558 + _globals['_CMDDLCLOSE']._serialized_end=1586 + _globals['_CMDDLSYM']._serialized_start=1588 + _globals['_CMDDLSYM']._serialized_end=1635 + _globals['_ARGUMENT']._serialized_start=1637 + _globals['_ARGUMENT']._serialized_end=1676 + _globals['_CMDCALL']._serialized_start=1678 + _globals['_CMDCALL']._serialized_end=1756 + _globals['_RETURNREGISTERSARM']._serialized_start=1758 + _globals['_RETURNREGISTERSARM']._serialized_end=1800 + _globals['_CMDPEEK']._serialized_start=1802 + _globals['_CMDPEEK']._serialized_end=1842 + _globals['_RESPONSEPEEK']._serialized_start=1844 + _globals['_RESPONSEPEEK']._serialized_end=1872 + _globals['_CMDPOKE']._serialized_start=1874 + _globals['_CMDPOKE']._serialized_end=1914 + _globals['_CMDLISTDIR']._serialized_start=1916 + _globals['_CMDLISTDIR']._serialized_end=1946 + _globals['_LISTDIRENTRYSTAT']._serialized_start=1949 + _globals['_LISTDIRENTRYSTAT']._serialized_end=2212 + _globals['_LISTDIRENTRY']._serialized_start=2215 + _globals['_LISTDIRENTRY']._serialized_end=2364 + _globals['_CMDSHOWOBJECT']._serialized_start=2366 + _globals['_CMDSHOWOBJECT']._serialized_end=2398 + _globals['_RESPONSESHOWOBJECT']._serialized_start=2400 + _globals['_RESPONSESHOWOBJECT']._serialized_end=2441 + _globals['_CMDSHOWCLASS']._serialized_start=2443 + _globals['_CMDSHOWCLASS']._serialized_end=2474 + _globals['_RESPONSECMDEXEC']._serialized_start=2476 + _globals['_RESPONSECMDEXEC']._serialized_end=2506 + _globals['_RESPONSECMDEXECCHUNK']._serialized_start=2508 + _globals['_RESPONSECMDEXECCHUNK']._serialized_end=2581 + _globals['_RESPONSEDLOPEN']._serialized_start=2583 + _globals['_RESPONSEDLOPEN']._serialized_end=2615 + _globals['_RESPONSEDLCLOSE']._serialized_start=2617 + _globals['_RESPONSEDLCLOSE']._serialized_end=2647 + _globals['_RESPONSEDLSYM']._serialized_start=2649 + _globals['_RESPONSEDLSYM']._serialized_end=2677 + _globals['_RESPONSECALL']._serialized_start=2679 + _globals['_RESPONSECALL']._serialized_end=2784 + _globals['_OBJCCLASS']._serialized_start=2786 + _globals['_OBJCCLASS']._serialized_end=2828 + _globals['_RESPONSEGETCLASSLIST']._serialized_start=2830 + _globals['_RESPONSEGETCLASSLIST']._serialized_end=2885 # @@protoc_insertion_point(module_scope) diff --git a/src/rpcclient/rpcclient/protos/rpc_pb2.pyi b/src/rpcclient/rpcclient/protos/rpc_pb2.pyi index 3d1e92de..eab82f1a 100644 --- a/src/rpcclient/rpcclient/protos/rpc_pb2.pyi +++ b/src/rpcclient/rpcclient/protos/rpc_pb2.pyi @@ -18,49 +18,6 @@ else: DESCRIPTOR: google.protobuf.descriptor.FileDescriptor -class _CmdType: - ValueType = typing.NewType("ValueType", builtins.int) - V: typing_extensions.TypeAlias = ValueType - -class _CmdTypeEnumTypeWrapper(google.protobuf.internal.enum_type_wrapper._EnumTypeWrapper[_CmdType.ValueType], builtins.type): - DESCRIPTOR: google.protobuf.descriptor.EnumDescriptor - CMD_EXEC: _CmdType.ValueType # 0 - CMD_DLOPEN: _CmdType.ValueType # 1 - CMD_DLCLOSE: _CmdType.ValueType # 2 - CMD_DLSYM: _CmdType.ValueType # 3 - CMD_CALL: _CmdType.ValueType # 4 - CMD_PEEK: _CmdType.ValueType # 5 - CMD_POKE: _CmdType.ValueType # 6 - CMD_REPLY_ERROR: _CmdType.ValueType # 7 - CMD_REPLY_PEEK: _CmdType.ValueType # 8 - CMD_GET_DUMMY_BLOCK: _CmdType.ValueType # 9 - CMD_CLOSE: _CmdType.ValueType # 10 - CMD_REPLY_POKE: _CmdType.ValueType # 11 - CMD_LISTDIR: _CmdType.ValueType # 12 - CMD_SHOWOBJECT: _CmdType.ValueType # 13 - CMD_SHOWCLASS: _CmdType.ValueType # 14 - CMD_GET_CLASS_LIST: _CmdType.ValueType # 15 - -class CmdType(_CmdType, metaclass=_CmdTypeEnumTypeWrapper): ... - -CMD_EXEC: CmdType.ValueType # 0 -CMD_DLOPEN: CmdType.ValueType # 1 -CMD_DLCLOSE: CmdType.ValueType # 2 -CMD_DLSYM: CmdType.ValueType # 3 -CMD_CALL: CmdType.ValueType # 4 -CMD_PEEK: CmdType.ValueType # 5 -CMD_POKE: CmdType.ValueType # 6 -CMD_REPLY_ERROR: CmdType.ValueType # 7 -CMD_REPLY_PEEK: CmdType.ValueType # 8 -CMD_GET_DUMMY_BLOCK: CmdType.ValueType # 9 -CMD_CLOSE: CmdType.ValueType # 10 -CMD_REPLY_POKE: CmdType.ValueType # 11 -CMD_LISTDIR: CmdType.ValueType # 12 -CMD_SHOWOBJECT: CmdType.ValueType # 13 -CMD_SHOWCLASS: CmdType.ValueType # 14 -CMD_GET_CLASS_LIST: CmdType.ValueType # 15 -global___CmdType = CmdType - class _CmdExecChunkType: ValueType = typing.NewType("ValueType", builtins.int) V: typing_extensions.TypeAlias = ValueType @@ -91,6 +48,262 @@ ARCH_UNKNOWN: Arch.ValueType # 0 ARCH_ARM64: Arch.ValueType # 1 global___Arch = Arch +@typing_extensions.final +class Command(google.protobuf.message.Message): + DESCRIPTOR: google.protobuf.descriptor.Descriptor + + MAGIC_FIELD_NUMBER: builtins.int + EXEC_FIELD_NUMBER: builtins.int + DLOPEN_FIELD_NUMBER: builtins.int + DLCLOSE_FIELD_NUMBER: builtins.int + DLSYM_FIELD_NUMBER: builtins.int + CALL_FIELD_NUMBER: builtins.int + PEEK_FIELD_NUMBER: builtins.int + POKE_FIELD_NUMBER: builtins.int + LISTDIR_FIELD_NUMBER: builtins.int + SHOWOBJECT_FIELD_NUMBER: builtins.int + SHOWCLASS_FIELD_NUMBER: builtins.int + DUMMY_BLOCK_FIELD_NUMBER: builtins.int + CLOSE_FIELD_NUMBER: builtins.int + CLASS_LIST_FIELD_NUMBER: builtins.int + magic: builtins.int + @property + def exec(self) -> global___CmdExec: ... + @property + def dlopen(self) -> global___CmdDlopen: ... + @property + def dlclose(self) -> global___CmdDlclose: ... + @property + def dlsym(self) -> global___CmdDlsym: ... + @property + def call(self) -> global___CmdCall: ... + @property + def peek(self) -> global___CmdPeek: ... + @property + def poke(self) -> global___CmdPoke: ... + @property + def listdir(self) -> global___CmdListDir: ... + @property + def showobject(self) -> global___CmdShowObject: ... + @property + def showclass(self) -> global___CmdShowClass: ... + @property + def dummy_block(self) -> global___CmdDummyBlock: ... + @property + def close(self) -> global___CmdClose: ... + @property + def class_list(self) -> global___CmdGetClassList: ... + def __init__( + self, + *, + magic: builtins.int = ..., + exec: global___CmdExec | None = ..., + dlopen: global___CmdDlopen | None = ..., + dlclose: global___CmdDlclose | None = ..., + dlsym: global___CmdDlsym | None = ..., + call: global___CmdCall | None = ..., + peek: global___CmdPeek | None = ..., + poke: global___CmdPoke | None = ..., + listdir: global___CmdListDir | None = ..., + showobject: global___CmdShowObject | None = ..., + showclass: global___CmdShowClass | None = ..., + dummy_block: global___CmdDummyBlock | None = ..., + close: global___CmdClose | None = ..., + class_list: global___CmdGetClassList | None = ..., + ) -> None: ... + def HasField(self, field_name: typing_extensions.Literal["call", b"call", "class_list", b"class_list", "close", b"close", "dlclose", b"dlclose", "dlopen", b"dlopen", "dlsym", b"dlsym", "dummy_block", b"dummy_block", "exec", b"exec", "listdir", b"listdir", "peek", b"peek", "poke", b"poke", "showclass", b"showclass", "showobject", b"showobject", "type", b"type"]) -> builtins.bool: ... + def ClearField(self, field_name: typing_extensions.Literal["call", b"call", "class_list", b"class_list", "close", b"close", "dlclose", b"dlclose", "dlopen", b"dlopen", "dlsym", b"dlsym", "dummy_block", b"dummy_block", "exec", b"exec", "listdir", b"listdir", "magic", b"magic", "peek", b"peek", "poke", b"poke", "showclass", b"showclass", "showobject", b"showobject", "type", b"type"]) -> None: ... + def WhichOneof(self, oneof_group: typing_extensions.Literal["type", b"type"]) -> typing_extensions.Literal["exec", "dlopen", "dlclose", "dlsym", "call", "peek", "poke", "listdir", "showobject", "showclass", "dummy_block", "close", "class_list"] | None: ... + +global___Command = Command + +@typing_extensions.final +class CmdDummyBlock(google.protobuf.message.Message): + DESCRIPTOR: google.protobuf.descriptor.Descriptor + + def __init__( + self, + ) -> None: ... + +global___CmdDummyBlock = CmdDummyBlock + +@typing_extensions.final +class CmdExec(google.protobuf.message.Message): + """Todo""" + + DESCRIPTOR: google.protobuf.descriptor.Descriptor + + BACKGROUND_FIELD_NUMBER: builtins.int + ARGV_FIELD_NUMBER: builtins.int + ENVP_FIELD_NUMBER: builtins.int + background: builtins.bool + @property + def argv(self) -> google.protobuf.internal.containers.RepeatedScalarFieldContainer[builtins.str]: ... + @property + def envp(self) -> google.protobuf.internal.containers.RepeatedScalarFieldContainer[builtins.str]: ... + def __init__( + self, + *, + background: builtins.bool = ..., + argv: collections.abc.Iterable[builtins.str] | None = ..., + envp: collections.abc.Iterable[builtins.str] | None = ..., + ) -> None: ... + def ClearField(self, field_name: typing_extensions.Literal["argv", b"argv", "background", b"background", "envp", b"envp"]) -> None: ... + +global___CmdExec = CmdExec + +@typing_extensions.final +class CmdClose(google.protobuf.message.Message): + DESCRIPTOR: google.protobuf.descriptor.Descriptor + + def __init__( + self, + ) -> None: ... + +global___CmdClose = CmdClose + +@typing_extensions.final +class CmdGetClassList(google.protobuf.message.Message): + DESCRIPTOR: google.protobuf.descriptor.Descriptor + + def __init__( + self, + ) -> None: ... + +global___CmdGetClassList = CmdGetClassList + +@typing_extensions.final +class ResponsePoke(google.protobuf.message.Message): + DESCRIPTOR: google.protobuf.descriptor.Descriptor + + RESULT_FIELD_NUMBER: builtins.int + result: builtins.int + def __init__( + self, + *, + result: builtins.int = ..., + ) -> None: ... + def ClearField(self, field_name: typing_extensions.Literal["result", b"result"]) -> None: ... + +global___ResponsePoke = ResponsePoke + +@typing_extensions.final +class Response(google.protobuf.message.Message): + DESCRIPTOR: google.protobuf.descriptor.Descriptor + + EXEC_FIELD_NUMBER: builtins.int + EXEC_CHUNK_FIELD_NUMBER: builtins.int + DLOPEN_FIELD_NUMBER: builtins.int + DLCLOSE_FIELD_NUMBER: builtins.int + DLSYM_FIELD_NUMBER: builtins.int + PEEK_FIELD_NUMBER: builtins.int + POKE_FIELD_NUMBER: builtins.int + CALL_FIELD_NUMBER: builtins.int + ERROR_FIELD_NUMBER: builtins.int + DUMMY_BLOCK_FIELD_NUMBER: builtins.int + SHOW_OBJECT_FIELD_NUMBER: builtins.int + CLASS_LIST_FIELD_NUMBER: builtins.int + SHOW_CLASS_FIELD_NUMBER: builtins.int + @property + def exec(self) -> global___ResponseCmdExec: ... + @property + def exec_chunk(self) -> global___ResponseCmdExecChunk: ... + @property + def dlopen(self) -> global___ResponseDlopen: ... + @property + def dlclose(self) -> global___ResponseDlclose: ... + @property + def dlsym(self) -> global___ResponseDlsym: ... + @property + def peek(self) -> global___ResponsePeek: ... + @property + def poke(self) -> global___ResponsePoke: ... + @property + def call(self) -> global___ResponseCall: ... + @property + def error(self) -> global___ResponseError: ... + @property + def dummy_block(self) -> global___ResponseDummyBlock: ... + @property + def show_object(self) -> global___ResponseShowObject: ... + @property + def class_list(self) -> global___ResponseGetClassList: ... + @property + def show_class(self) -> global___ResponseShowClass: ... + def __init__( + self, + *, + exec: global___ResponseCmdExec | None = ..., + exec_chunk: global___ResponseCmdExecChunk | None = ..., + dlopen: global___ResponseDlopen | None = ..., + dlclose: global___ResponseDlclose | None = ..., + dlsym: global___ResponseDlsym | None = ..., + peek: global___ResponsePeek | None = ..., + poke: global___ResponsePoke | None = ..., + call: global___ResponseCall | None = ..., + error: global___ResponseError | None = ..., + dummy_block: global___ResponseDummyBlock | None = ..., + show_object: global___ResponseShowObject | None = ..., + class_list: global___ResponseGetClassList | None = ..., + show_class: global___ResponseShowClass | None = ..., + ) -> None: ... + def HasField(self, field_name: typing_extensions.Literal["call", b"call", "class_list", b"class_list", "dlclose", b"dlclose", "dlopen", b"dlopen", "dlsym", b"dlsym", "dummy_block", b"dummy_block", "error", b"error", "exec", b"exec", "exec_chunk", b"exec_chunk", "peek", b"peek", "poke", b"poke", "show_class", b"show_class", "show_object", b"show_object", "type", b"type"]) -> builtins.bool: ... + def ClearField(self, field_name: typing_extensions.Literal["call", b"call", "class_list", b"class_list", "dlclose", b"dlclose", "dlopen", b"dlopen", "dlsym", b"dlsym", "dummy_block", b"dummy_block", "error", b"error", "exec", b"exec", "exec_chunk", b"exec_chunk", "peek", b"peek", "poke", b"poke", "show_class", b"show_class", "show_object", b"show_object", "type", b"type"]) -> None: ... + def WhichOneof(self, oneof_group: typing_extensions.Literal["type", b"type"]) -> typing_extensions.Literal["exec", "exec_chunk", "dlopen", "dlclose", "dlsym", "peek", "poke", "call", "error", "dummy_block", "show_object", "class_list", "show_class"] | None: ... + +global___Response = Response + +@typing_extensions.final +class ResponseShowClass(google.protobuf.message.Message): + DESCRIPTOR: google.protobuf.descriptor.Descriptor + + DESCRIPTION_FIELD_NUMBER: builtins.int + description: builtins.str + def __init__( + self, + *, + description: builtins.str = ..., + ) -> None: ... + def ClearField(self, field_name: typing_extensions.Literal["description", b"description"]) -> None: ... + +global___ResponseShowClass = ResponseShowClass + +@typing_extensions.final +class ResponseDummyBlock(google.protobuf.message.Message): + DESCRIPTOR: google.protobuf.descriptor.Descriptor + + ADDRESS_FIELD_NUMBER: builtins.int + SIZE_FIELD_NUMBER: builtins.int + address: builtins.int + size: builtins.int + def __init__( + self, + *, + address: builtins.int = ..., + size: builtins.int = ..., + ) -> None: ... + def ClearField(self, field_name: typing_extensions.Literal["address", b"address", "size", b"size"]) -> None: ... + +global___ResponseDummyBlock = ResponseDummyBlock + +@typing_extensions.final +class ResponseError(google.protobuf.message.Message): + DESCRIPTOR: google.protobuf.descriptor.Descriptor + + FUNC_NAME_FIELD_NUMBER: builtins.int + ERROR_NUM_FIELD_NUMBER: builtins.int + func_name: builtins.str + error_num: builtins.int + def __init__( + self, + *, + func_name: builtins.str = ..., + error_num: builtins.int = ..., + ) -> None: ... + def ClearField(self, field_name: typing_extensions.Literal["error_num", b"error_num", "func_name", b"func_name"]) -> None: ... + +global___ResponseError = ResponseError + @typing_extensions.final class Handshake(google.protobuf.message.Message): DESCRIPTOR: google.protobuf.descriptor.Descriptor @@ -133,24 +346,6 @@ class CmdExecChunk(google.protobuf.message.Message): global___CmdExecChunk = CmdExecChunk -@typing_extensions.final -class ResponseCmdExecChunk(google.protobuf.message.Message): - DESCRIPTOR: google.protobuf.descriptor.Descriptor - - TYPE_FIELD_NUMBER: builtins.int - SIZE_FIELD_NUMBER: builtins.int - type: global___CmdExecChunkType.ValueType - size: builtins.int - def __init__( - self, - *, - type: global___CmdExecChunkType.ValueType = ..., - size: builtins.int = ..., - ) -> None: ... - def ClearField(self, field_name: typing_extensions.Literal["size", b"size", "type", b"type"]) -> None: ... - -global___ResponseCmdExecChunk = ResponseCmdExecChunk - @typing_extensions.final class CmdDlopen(google.protobuf.message.Message): DESCRIPTOR: google.protobuf.descriptor.Descriptor @@ -169,36 +364,18 @@ class CmdDlopen(google.protobuf.message.Message): global___CmdDlopen = CmdDlopen -@typing_extensions.final -class ResponseDlopen(google.protobuf.message.Message): - DESCRIPTOR: google.protobuf.descriptor.Descriptor - - FILENAME_FIELD_NUMBER: builtins.int - MODE_FIELD_NUMBER: builtins.int - filename: builtins.str - mode: builtins.int - def __init__( - self, - *, - filename: builtins.str = ..., - mode: builtins.int = ..., - ) -> None: ... - def ClearField(self, field_name: typing_extensions.Literal["filename", b"filename", "mode", b"mode"]) -> None: ... - -global___ResponseDlopen = ResponseDlopen - @typing_extensions.final class CmdDlclose(google.protobuf.message.Message): DESCRIPTOR: google.protobuf.descriptor.Descriptor - LIB_FIELD_NUMBER: builtins.int - lib: builtins.int + HANDLE_FIELD_NUMBER: builtins.int + handle: builtins.int def __init__( self, *, - lib: builtins.int = ..., + handle: builtins.int = ..., ) -> None: ... - def ClearField(self, field_name: typing_extensions.Literal["lib", b"lib"]) -> None: ... + def ClearField(self, field_name: typing_extensions.Literal["handle", b"handle"]) -> None: ... global___CmdDlclose = CmdDlclose @@ -206,17 +383,17 @@ global___CmdDlclose = CmdDlclose class CmdDlsym(google.protobuf.message.Message): DESCRIPTOR: google.protobuf.descriptor.Descriptor - LIB_FIELD_NUMBER: builtins.int + HANDLE_FIELD_NUMBER: builtins.int SYMBOL_NAME_FIELD_NUMBER: builtins.int - lib: builtins.int + handle: builtins.int symbol_name: builtins.str def __init__( self, *, - lib: builtins.int = ..., + handle: builtins.int = ..., symbol_name: builtins.str = ..., ) -> None: ... - def ClearField(self, field_name: typing_extensions.Literal["lib", b"lib", "symbol_name", b"symbol_name"]) -> None: ... + def ClearField(self, field_name: typing_extensions.Literal["handle", b"handle", "symbol_name", b"symbol_name"]) -> None: ... global___CmdDlsym = CmdDlsym @@ -244,11 +421,9 @@ class CmdCall(google.protobuf.message.Message): ADDRESS_FIELD_NUMBER: builtins.int VA_LIST_INDEX_FIELD_NUMBER: builtins.int - ARGC_FIELD_NUMBER: builtins.int ARGV_FIELD_NUMBER: builtins.int address: builtins.int va_list_index: builtins.int - argc: builtins.int @property def argv(self) -> google.protobuf.internal.containers.RepeatedCompositeFieldContainer[global___Argument]: ... def __init__( @@ -256,34 +431,12 @@ class CmdCall(google.protobuf.message.Message): *, address: builtins.int = ..., va_list_index: builtins.int = ..., - argc: builtins.int = ..., argv: collections.abc.Iterable[global___Argument] | None = ..., ) -> None: ... - def ClearField(self, field_name: typing_extensions.Literal["address", b"address", "argc", b"argc", "argv", b"argv", "va_list_index", b"va_list_index"]) -> None: ... + def ClearField(self, field_name: typing_extensions.Literal["address", b"address", "argv", b"argv", "va_list_index", b"va_list_index"]) -> None: ... global___CmdCall = CmdCall -@typing_extensions.final -class ResponseCall(google.protobuf.message.Message): - DESCRIPTOR: google.protobuf.descriptor.Descriptor - - ARM_REGISTERS_FIELD_NUMBER: builtins.int - RETURN_VALUE_FIELD_NUMBER: builtins.int - @property - def arm_registers(self) -> global___ReturnRegistersArm: ... - return_value: builtins.int - def __init__( - self, - *, - arm_registers: global___ReturnRegistersArm | None = ..., - return_value: builtins.int = ..., - ) -> None: ... - def HasField(self, field_name: typing_extensions.Literal["arm_registers", b"arm_registers", "return_value", b"return_value", "return_values", b"return_values"]) -> builtins.bool: ... - def ClearField(self, field_name: typing_extensions.Literal["arm_registers", b"arm_registers", "return_value", b"return_value", "return_values", b"return_values"]) -> None: ... - def WhichOneof(self, oneof_group: typing_extensions.Literal["return_values", b"return_values"]) -> typing_extensions.Literal["arm_registers", "return_value"] | None: ... - -global___ResponseCall = ResponseCall - @typing_extensions.final class ReturnRegistersArm(google.protobuf.message.Message): DESCRIPTOR: google.protobuf.descriptor.Descriptor @@ -322,24 +475,36 @@ class CmdPeek(google.protobuf.message.Message): global___CmdPeek = CmdPeek +@typing_extensions.final +class ResponsePeek(google.protobuf.message.Message): + DESCRIPTOR: google.protobuf.descriptor.Descriptor + + DATA_FIELD_NUMBER: builtins.int + data: builtins.bytes + def __init__( + self, + *, + data: builtins.bytes = ..., + ) -> None: ... + def ClearField(self, field_name: typing_extensions.Literal["data", b"data"]) -> None: ... + +global___ResponsePeek = ResponsePeek + @typing_extensions.final class CmdPoke(google.protobuf.message.Message): DESCRIPTOR: google.protobuf.descriptor.Descriptor ADDRESS_FIELD_NUMBER: builtins.int - SIZE_FIELD_NUMBER: builtins.int DATA_FIELD_NUMBER: builtins.int address: builtins.int - size: builtins.int data: builtins.bytes def __init__( self, *, address: builtins.int = ..., - size: builtins.int = ..., data: builtins.bytes = ..., ) -> None: ... - def ClearField(self, field_name: typing_extensions.Literal["address", b"address", "data", b"data", "size", b"size"]) -> None: ... + def ClearField(self, field_name: typing_extensions.Literal["address", b"address", "data", b"data"]) -> None: ... global___CmdPoke = CmdPoke @@ -460,6 +625,21 @@ class CmdShowObject(google.protobuf.message.Message): global___CmdShowObject = CmdShowObject +@typing_extensions.final +class ResponseShowObject(google.protobuf.message.Message): + DESCRIPTOR: google.protobuf.descriptor.Descriptor + + DESCRIPTION_FIELD_NUMBER: builtins.int + description: builtins.str + def __init__( + self, + *, + description: builtins.str = ..., + ) -> None: ... + def ClearField(self, field_name: typing_extensions.Literal["description", b"description"]) -> None: ... + +global___ResponseShowObject = ResponseShowObject + @typing_extensions.final class CmdShowClass(google.protobuf.message.Message): DESCRIPTOR: google.protobuf.descriptor.Descriptor @@ -475,6 +655,105 @@ class CmdShowClass(google.protobuf.message.Message): global___CmdShowClass = CmdShowClass +@typing_extensions.final +class ResponseCmdExec(google.protobuf.message.Message): + DESCRIPTOR: google.protobuf.descriptor.Descriptor + + PID_FIELD_NUMBER: builtins.int + pid: builtins.int + def __init__( + self, + *, + pid: builtins.int = ..., + ) -> None: ... + def ClearField(self, field_name: typing_extensions.Literal["pid", b"pid"]) -> None: ... + +global___ResponseCmdExec = ResponseCmdExec + +@typing_extensions.final +class ResponseCmdExecChunk(google.protobuf.message.Message): + DESCRIPTOR: google.protobuf.descriptor.Descriptor + + TYPE_FIELD_NUMBER: builtins.int + SIZE_FIELD_NUMBER: builtins.int + type: global___CmdExecChunkType.ValueType + size: builtins.int + def __init__( + self, + *, + type: global___CmdExecChunkType.ValueType = ..., + size: builtins.int = ..., + ) -> None: ... + def ClearField(self, field_name: typing_extensions.Literal["size", b"size", "type", b"type"]) -> None: ... + +global___ResponseCmdExecChunk = ResponseCmdExecChunk + +@typing_extensions.final +class ResponseDlopen(google.protobuf.message.Message): + DESCRIPTOR: google.protobuf.descriptor.Descriptor + + HANDLE_FIELD_NUMBER: builtins.int + handle: builtins.int + def __init__( + self, + *, + handle: builtins.int = ..., + ) -> None: ... + def ClearField(self, field_name: typing_extensions.Literal["handle", b"handle"]) -> None: ... + +global___ResponseDlopen = ResponseDlopen + +@typing_extensions.final +class ResponseDlclose(google.protobuf.message.Message): + DESCRIPTOR: google.protobuf.descriptor.Descriptor + + RES_FIELD_NUMBER: builtins.int + res: builtins.int + def __init__( + self, + *, + res: builtins.int = ..., + ) -> None: ... + def ClearField(self, field_name: typing_extensions.Literal["res", b"res"]) -> None: ... + +global___ResponseDlclose = ResponseDlclose + +@typing_extensions.final +class ResponseDlsym(google.protobuf.message.Message): + DESCRIPTOR: google.protobuf.descriptor.Descriptor + + PTR_FIELD_NUMBER: builtins.int + ptr: builtins.int + def __init__( + self, + *, + ptr: builtins.int = ..., + ) -> None: ... + def ClearField(self, field_name: typing_extensions.Literal["ptr", b"ptr"]) -> None: ... + +global___ResponseDlsym = ResponseDlsym + +@typing_extensions.final +class ResponseCall(google.protobuf.message.Message): + DESCRIPTOR: google.protobuf.descriptor.Descriptor + + ARM_REGISTERS_FIELD_NUMBER: builtins.int + RETURN_VALUE_FIELD_NUMBER: builtins.int + @property + def arm_registers(self) -> global___ReturnRegistersArm: ... + return_value: builtins.int + def __init__( + self, + *, + arm_registers: global___ReturnRegistersArm | None = ..., + return_value: builtins.int = ..., + ) -> None: ... + def HasField(self, field_name: typing_extensions.Literal["arm_registers", b"arm_registers", "return_value", b"return_value", "return_values", b"return_values"]) -> builtins.bool: ... + def ClearField(self, field_name: typing_extensions.Literal["arm_registers", b"arm_registers", "return_value", b"return_value", "return_values", b"return_values"]) -> None: ... + def WhichOneof(self, oneof_group: typing_extensions.Literal["return_values", b"return_values"]) -> typing_extensions.Literal["arm_registers", "return_value"] | None: ... + +global___ResponseCall = ResponseCall + @typing_extensions.final class ObjcClass(google.protobuf.message.Message): DESCRIPTOR: google.protobuf.descriptor.Descriptor diff --git a/src/rpcserver/common.c b/src/rpcserver/common.c index 0830ba2d..6c54ce4a 100644 --- a/src/rpcserver/common.c +++ b/src/rpcserver/common.c @@ -10,10 +10,10 @@ #include "common.h" #ifdef __APPLE__ + #include -struct os_log_s -{ +struct os_log_s { int a; }; @@ -26,8 +26,7 @@ FILE *g_file = NULL; #define BT_BUF_SIZE (100) -void print_backtrace() -{ +void print_backtrace() { int nptrs; void *buffer[BT_BUF_SIZE]; char **strings; @@ -39,24 +38,20 @@ void print_backtrace() would produce similar output to the following: */ strings = backtrace_symbols(buffer, nptrs); - if (strings == NULL) - { + if (strings == NULL) { perror("backtrace_symbols"); return; } - for (int j = 0; j < nptrs; j++) - { + for (int j = 0; j < nptrs; j++) { trace("BACKTRACE:\t", "%s", strings[j]); } free(strings); } -void trace(const char *prefix, const char *fmt, ...) -{ - if (!g_stdout && !g_syslog) - { +void trace(const char *prefix, const char *fmt, ...) { + if (!g_stdout && !g_syslog) { return; } @@ -70,37 +65,31 @@ void trace(const char *prefix, const char *fmt, ...) sprintf(prefixed_line, "%s: %s", prefix, line); - if (g_stdout) - { + if (g_stdout) { puts(prefixed_line); fflush(stdout); } - if (g_syslog) - { + if (g_syslog) { #ifdef __APPLE__ os_log(&_os_log_default, "%{public}s", prefixed_line); #else // __APPLE__ syslog(LOG_DEBUG, "%s", prefixed_line); #endif // !__APPLE__ } - if (g_file) - { + if (g_file) { fprintf(g_file, "%s\n", prefixed_line); fflush(g_file); } } -bool recvall_ext(int sockfd, char *buf, size_t len, bool *disconnected) -{ +bool recvall_ext(int sockfd, char *buf, size_t len, bool *disconnected) { size_t total_bytes = 0; size_t bytes = 0; *disconnected = false; - while (len > 0) - { + while (len > 0) { bytes = recv(sockfd, buf + total_bytes, len, 0); - if (0 == bytes) - { + if (0 == bytes) { TRACE("client fd: %d disconnected", sockfd); *disconnected = true; return false; @@ -113,23 +102,30 @@ bool recvall_ext(int sockfd, char *buf, size_t len, bool *disconnected) return true; -error: + error: + return false; +} + +bool message_receive(int sockfd, char *buf, size_t *size) { + recv(sockfd, size, sizeof(size_t), 0); + CHECK(*size != 0); + recvall(sockfd, buf, *size); + return true; + error: return false; + } -bool recvall(int sockfd, char *buf, size_t len) -{ +bool recvall(int sockfd, char *buf, size_t len) { bool disconnected; return recvall_ext(sockfd, buf, len, &disconnected); } -bool sendall(int sockfd, const char *buf, size_t len) -{ +bool sendall(int sockfd, const char *buf, size_t len) { size_t total_bytes = 0; size_t bytes = 0; - while (len > 0) - { + while (len > 0) { bytes = send(sockfd, buf + total_bytes, len, MSG_NOSIGNAL); CHECK(bytes != -1); @@ -139,17 +135,49 @@ bool sendall(int sockfd, const char *buf, size_t len) return true; -error: + error: return false; } -bool writeall(int fd, const char *buf, size_t len) -{ +bool send_response(int sockfd, const Rpc__Response *response) { + bool ret = RPC_FAILURE; + size_t len = rpc__response__get_packed_size(response); + uint8_t *buffer = NULL; + CHECK(len > 0) + buffer = (uint8_t *) malloc(len * sizeof(uint8_t)); + CHECK(buffer != NULL) + rpc__response__pack(response, buffer); + CHECK(message_send(sockfd, buffer, len)) + ret = RPC_SUCCESS; + + error: + SAFE_FREE(buffer); + return ret; +} + +bool message_send(int sockfd, const uint8_t *buf, size_t len) { + bool ret = RPC_FAILURE; + + size_t total_bytes = 0; + size_t bytes = 0; + send(sockfd, &len, sizeof(size_t), MSG_NOSIGNAL); + while (len > 0) { + bytes = send(sockfd, buf + total_bytes, len, MSG_NOSIGNAL); + CHECK(bytes != -1); + + total_bytes += bytes; + len -= bytes; + } + ret = RPC_SUCCESS; + error: + return ret; +} + +bool writeall(int fd, const char *buf, size_t len) { size_t total_bytes = 0; size_t bytes = 0; - while (len > 0) - { + while (len > 0) { bytes = write(fd, buf + total_bytes, len); CHECK(bytes != -1); @@ -159,6 +187,6 @@ bool writeall(int fd, const char *buf, size_t len) return true; -error: + error: return false; } \ No newline at end of file diff --git a/src/rpcserver/common.h b/src/rpcserver/common.h index ee251748..7a162ee1 100644 --- a/src/rpcserver/common.h +++ b/src/rpcserver/common.h @@ -7,6 +7,7 @@ #include #include #include +#include "protos/rpc.pb-c.h" typedef unsigned char u8; typedef unsigned short u16; @@ -19,6 +20,25 @@ extern bool g_stdout; extern bool g_syslog; extern FILE *g_file; +#define RPC_SUCCESS (1) +#define RPC_FAILURE (0) + +// Macro to initialize response error with function name and error number +#define RESPONSE_ERROR(response) \ + Rpc__ResponseError error = RPC__RESPONSE_ERROR__INIT; \ + response.type_case = RPC__RESPONSE__TYPE_ERROR; \ + error.func_name = (char*) __func__; \ + error.error_num = errno; \ + response.error = &error + +#define SAFE_FREE(ptr) do { \ + if (ptr) { \ + free(ptr); \ + ptr = NULL; \ + } \ +} while(0) + + #define TRACE(...) trace(__PRETTY_FUNCTION__, __VA_ARGS__) #define CHECK(expression) \ if (!(expression)) \ @@ -32,10 +52,22 @@ extern FILE *g_file; } void print_backtrace(); + void trace(const char *prefix, const char *fmt, ...); + bool recvall_ext(int sockfd, char *buf, size_t len, bool *disconnected); + bool recvall(int sockfd, char *buf, size_t len); + bool sendall(int sockfd, const char *buf, size_t len); + bool writeall(int fd, const char *buf, size_t len); +bool message_send(int sockfd, const uint8_t *buf, size_t len); + +bool send_response(int sockfd, const Rpc__Response *response); + +bool message_receive(int sockfd, char *buf, size_t *size); + + #endif // __COMMON_H_ \ No newline at end of file diff --git a/src/rpcserver/darwin/darwin_class.m b/src/rpcserver/darwin/darwin_class.m index 6ca0ed7a..f8a9e9f1 100644 --- a/src/rpcserver/darwin/darwin_class.m +++ b/src/rpcserver/darwin/darwin_class.m @@ -4,16 +4,15 @@ #include #include -static NSDictionary* getClassDescription(Class objcClass) -{ - NSDictionary *classDescription = @{ - @"protocols": [NSMutableArray new], - @"ivars": [NSMutableArray new], - @"properties": [NSMutableArray new], - @"methods": [NSMutableArray new], - @"name": [NSString stringWithCString:class_getName(objcClass) encoding:NSUTF8StringEncoding], - @"address": [NSNumber numberWithLong:(uintptr_t)objcClass], - @"super": [NSNumber numberWithLong:(uintptr_t)class_getSuperclass(objcClass)], +static NSDictionary *getClassDescription(Class objcClass) { + NSDictionary *classDescription = @{ + @"protocols": [NSMutableArray new], + @"ivars": [NSMutableArray new], + @"properties": [NSMutableArray new], + @"methods": [NSMutableArray new], + @"name": [NSString stringWithCString:class_getName(objcClass) encoding:NSUTF8StringEncoding], + @"address": [NSNumber numberWithLong:(uintptr_t) objcClass], + @"super": [NSNumber numberWithLong:(uintptr_t) class_getSuperclass(objcClass)], }; addProtocolsToDictionary(objcClass, classDescription); @@ -24,28 +23,27 @@ return classDescription; } -static NSString* getClassDescriptionStr(Class objcClass) -{ +static NSString *getClassDescriptionStr(Class objcClass) { NSDictionary *classDescription = getClassDescription(objcClass); return getDictionaryJsonString(classDescription); } -int handle_showclass(int sockfd) -{ +int handle_showclass(int sockfd, Rpc__CmdShowClass *cmd) { TRACE("Entered showclass"); - cmd_showclass_t cmd; - CHECK(recvall(sockfd, (char *)&cmd, sizeof(cmd))); - NSString *response_str = getClassDescriptionStr((id)cmd.address); + Rpc__Response response = RPC__RESPONSE__INIT; + Rpc__ResponseShowClass resp_show_class = RPC__RESPONSE_SHOW_CLASS__INIT; + response.type_case = RPC__RESPONSE__TYPE_SHOW_CLASS; + + NSString *response_str = getClassDescriptionStr((id) cmd->address); + resp_show_class.description = (char *) [response_str UTF8String]; + response.show_class = &resp_show_class; TRACE("Sending response"); - size_t response_len = [response_str length]; - const char *response_cstr = [response_str UTF8String]; - CHECK(sendall(sockfd, (char *)&response_len, sizeof(response_len))); - CHECK(sendall(sockfd, response_cstr, response_len)); + send_response(sockfd, &response); TRACE("Sent response"); - return 0; + return RPC_SUCCESS; -error: + error: TRACE("Failed to show class"); - return -1; + return RPC_FAILURE; } diff --git a/src/rpcserver/darwin/darwin_get_class_list.m b/src/rpcserver/darwin/darwin_get_class_list.m index 7c82fe7c..40d7bd22 100644 --- a/src/rpcserver/darwin/darwin_get_class_list.m +++ b/src/rpcserver/darwin/darwin_get_class_list.m @@ -4,38 +4,48 @@ #include #include -int handle_get_class_list(int sockfd) -{ +int handle_get_class_list(int sockfd, Rpc__CmdGetClassList *cmd) { TRACE("handle_get_class_list"); + Rpc__Response response = RPC__RESPONSE__INIT; + Rpc__ResponseGetClassList resp_class_list = RPC__RESPONSE_GET_CLASS_LIST__INIT; + response.type_case = RPC__RESPONSE__TYPE_CLASS_LIST; + Class *class_list = NULL; + int ret = RPC_FAILURE; - Class* classes = NULL; u32 count = objc_getClassList(NULL, 0); - + if (count < 0) { + return ret; // TODO: return error? + } TRACE("reporting class list: %d", count); - CHECK(sendall(sockfd, (char *)&count, sizeof(count))); - - if (count > 0 ) { - classes = malloc(sizeof(Class) * count); - CHECK(classes != NULL); - count = objc_getClassList(classes, count); + resp_class_list.classes = malloc(sizeof(Rpc__ObjcClass *) * count); + CHECK(resp_class_list.classes != NULL); - for (int i=0; iaddress = (uint64_t) class_list[i]; + resp_class_list.classes[i]->name = strdup(name); } + resp_class_list.n_classes = count; + response.class_list = &resp_class_list; + send_response(sockfd, &response); + ret = RPC_SUCCESS; - TRACE("Failed to show class"); - return -1; + error: + if (resp_class_list.classes) { + for (int i = 0; i < resp_class_list.n_classes; i++) { + SAFE_FREE(resp_class_list.classes[i]->name); + SAFE_FREE(resp_class_list.classes[i]); + } + SAFE_FREE(resp_class_list.classes); + } + SAFE_FREE (class_list); +// TRACE("Failed to show class"); + return ret; } diff --git a/src/rpcserver/darwin/darwin_object.m b/src/rpcserver/darwin/darwin_object.m index 84aff6fa..0eb2569a 100644 --- a/src/rpcserver/darwin/darwin_object.m +++ b/src/rpcserver/darwin/darwin_object.m @@ -4,18 +4,17 @@ #include #include -static NSDictionary* getObjectData(id objcObject) -{ +static NSDictionary *getObjectData(id objcObject) { Class objcClass = [objcObject class]; NSDictionary *objectData = @{ - @"protocols": [NSMutableArray new], - @"ivars": [NSMutableArray new], - @"properties": [NSMutableArray new], - @"methods": [NSMutableArray new], - @"class_name": [NSString stringWithCString:class_getName(objcClass) encoding:NSUTF8StringEncoding], - @"class_address": [NSNumber numberWithUnsignedLongLong:(uintptr_t)objcClass], - @"class_super": [NSNumber numberWithLong:(uintptr_t)class_getSuperclass(objcClass)], + @"protocols": [NSMutableArray new], + @"ivars": [NSMutableArray new], + @"properties": [NSMutableArray new], + @"methods": [NSMutableArray new], + @"class_name": [NSString stringWithCString:class_getName(objcClass) encoding:NSUTF8StringEncoding], + @"class_address": [NSNumber numberWithUnsignedLongLong:(uintptr_t) objcClass], + @"class_super": [NSNumber numberWithLong:(uintptr_t) class_getSuperclass(objcClass)], }; addProtocolsToDictionary(objcClass, objectData); @@ -25,29 +24,30 @@ return objectData; } -static NSString* getObjectStr(id object) -{ +static NSString *getObjectStr(id object) { NSDictionary *objectData = getObjectData(object); return getDictionaryJsonString(objectData); } -bool handle_showobject(int sockfd) -{ +bool handle_showobject(int sockfd, Rpc__CmdShowObject *cmd) { TRACE("Entered showobject"); - cmd_showobject_t cmd; - CHECK(recvall(sockfd, (char *)&cmd, sizeof(cmd))); - TRACE("Calling objc_show_object with %p", cmd.address); - NSString *response_str = getObjectStr((id)cmd.address); + TRACE("Calling objc_show_object with %p", cmd->address); + + Rpc__Response response = RPC__RESPONSE__INIT; + Rpc__ResponseShowObject resp_show_object = RPC__RESPONSE_SHOW_OBJECT__INIT; + response.type_case = RPC__RESPONSE__TYPE_SHOW_OBJECT; + + NSString *response_str = getObjectStr((id) cmd->address); TRACE("Sending response"); - size_t response_len = [response_str length]; - const char *response_cstr = [response_str UTF8String]; - CHECK(sendall(sockfd, (char *)&response_len, sizeof(response_len))); - CHECK(sendall(sockfd, response_cstr, response_len)); + resp_show_object.description = (char *) [response_str UTF8String]; + response.show_object = &resp_show_object; + + send_response(sockfd, &response); TRACE("Sent response"); - return true; + return RPC_SUCCESS; -error: + error: TRACE("Failed to show object"); - return false; + return RPC_FAILURE; } diff --git a/src/rpcserver/rpcserver.c b/src/rpcserver/rpcserver.c index 0c5de3ba..fece4e85 100644 --- a/src/rpcserver/rpcserver.c +++ b/src/rpcserver/rpcserver.c @@ -28,11 +28,11 @@ #include #include "protos/rpc.pb-c.h" -int handle_showobject(int sockfd); +bool handle_showobject(int sockfd, Rpc__CmdShowObject *cmd); -int handle_showclass(int sockfd); +int handle_showclass(int sockfd, Rpc__CmdShowClass *cmd); -int handle_get_class_list(int sockfd); +int handle_get_class_list(int sockfd, Rpc__CmdGetClassList *cmd); #ifdef __APPLE__ @@ -50,9 +50,10 @@ int handle_get_class_list(int sockfd) { return 0; } #define DEFAULT_PORT ("5910") #define DEFAULT_SHELL ("/bin/sh") -#define USAGE ("Usage: %s [-p port] [-o (stdout|syslog|file:filename)] \n\ +#define USAGE ("Usage: %s [-p port] [-o (stdout|syslog|file:filename)][-d debug] \n\ -h show this help message \n\ -o output. can be all of the following: stdout, syslog and file:filename. can be passed multiple times \n\ +-d debug. The client's request will be handled within the same process, rather than spawning a new worker process to handle the request. \n\ \n\ Example usage: \n\ %s -p 5910 -o syslog -o stdout -o file:/tmp/log.txt\n") @@ -73,7 +74,7 @@ void *get_in_addr(struct sockaddr *sa) // get sockaddr, IPv4 or IPv6: } bool internal_spawn(bool background, char *const *argv, char *const *envp, pid_t *pid, int *master_fd) { - bool success = false; + bool ret = RPC_FAILURE; int slave_fd = -1; *master_fd = -1; *pid = INVALID_PID; @@ -121,23 +122,23 @@ bool internal_spawn(bool background, char *const *argv, char *const *envp, pid_t posix_spawnattr_destroy(&attr); posix_spawn_file_actions_destroy(&actions); - success = true; + ret = RPC_SUCCESS; error: if (slave_fd != -1) { close(slave_fd); } - if (!success) { + if (!ret) { if (*master_fd != -1) { close(*master_fd); } *pid = INVALID_PID; } - return success; + return ret; } bool spawn_worker_server(int client_socket, const char *argv[], int argc) { - bool success = false; + bool ret = RPC_FAILURE; // append -w to original argv int new_argc = argc + 1; @@ -160,21 +161,13 @@ bool spawn_worker_server(int client_socket, const char *argv[], int argc) { CHECK(pid != INVALID_PID); TRACE("Spawned Worker Process: %d", pid); - success = true; + ret = RPC_SUCCESS; error: posix_spawn_file_actions_destroy(&actions); free(new_argv); close(client_socket); - return success; -} - -bool send_reply(int sockfd, cmd_type_t type) { - protocol_message_t protocol_message = {.magic = MAGIC, .cmd_type = type}; - CHECK(sendall(sockfd, (char *) &protocol_message, sizeof(protocol_message))); - return true; - error: - return false; + return ret; } typedef struct { @@ -188,64 +181,36 @@ void thread_waitpid(pid_t pid) { waitpid(pid, &err, 0); } -bool handle_exec(int sockfd) { +bool handle_exec(int sockfd, Rpc__CmdExec *cmd) { + int ret = RPC_FAILURE; + u8 byte; pthread_t thread = 0; thread_notify_client_spawn_error_t *thread_params = NULL; pid_t pid = INVALID_PID; int master = -1; - int success = false; char **argv = NULL; char **envp = NULL; u32 argc; u32 envc; u8 background; - CHECK(recvall(sockfd, (char *) &background, sizeof(background))); - - CHECK(recvall(sockfd, (char *) &argc, sizeof(argc))); - CHECK(argc > 0); - - // +1 for additional NULL at end of list - size_t argv_size = (argc + 1) * sizeof(char *); - argv = (char **) malloc(argv_size * sizeof(char *)); - memset(argv, 0, argv_size * sizeof(char *)); - - for (u32 i = 0; i < argc; ++i) { - u32 len; - CHECK(recvall(sockfd, (char *) &len, sizeof(len))); - - // +1 for additional \0 at end of each string - size_t str_size = (len + 1) * sizeof(char); - argv[i] = malloc(str_size * sizeof(char)); - CHECK(argv[i] != NULL); - - CHECK(recvall(sockfd, argv[i], len * sizeof(char))); - argv[i][len] = '\0'; - } - - CHECK(recvall(sockfd, (char *) &envc, sizeof(envc))); - - // +1 for additional NULL at end of list - size_t envp_size = (envc + 1) * sizeof(char *); - envp = (char **) malloc(envp_size * sizeof(char *)); - memset(envp, 0, envp_size * sizeof(char *)); - - for (u32 i = 0; i < envc; ++i) { - u32 len; - CHECK(recvall(sockfd, (char *) &len, sizeof(len))); + Rpc__Response response = RPC__RESPONSE__INIT; + Rpc__ResponseCmdExec resp_exec = RPC__RESPONSE_CMD_EXEC__INIT; + response.type_case = RPC__RESPONSE__TYPE_EXEC; - // +1 for additional \0 at end of each string - size_t str_size = (len + 1) * sizeof(char); - envp[i] = malloc(str_size * sizeof(char)); - CHECK(envp[i] != NULL); + background = cmd->background; + argc = cmd->n_argv; + argv = cmd->argv; + envp = cmd->envp; - CHECK(recvall(sockfd, envp[i], len * sizeof(char))); - envp[i][len] = '\0'; - } + CHECK(argc > 0); CHECK(internal_spawn(background, (char *const *) argv, envc ? (char *const *) envp : environ, &pid, &master)); - CHECK(sendall(sockfd, (char *) &pid, sizeof(u32))); + + resp_exec.pid = pid; + response.exec = &resp_exec; + send_response(sockfd, &response); if (background) { CHECK(0 == pthread_create(&thread, NULL, (void *(*)(void *)) thread_waitpid, (void *) (intptr_t) pid)); @@ -308,7 +273,7 @@ bool handle_exec(int sockfd) { CHECK(sendall(sockfd, (const char *) &error, sizeof(error))); } - success = true; + ret = RPC_SUCCESS; error: if (thread_params) { @@ -319,25 +284,8 @@ bool handle_exec(int sockfd) { TRACE("invalid pid"); // failed to create process somewhere in the prolog, at least notify - sendall(sockfd, (char *) &pid, sizeof(u32)); - } - - if (argv) { - for (u32 i = 0; i < argc; ++i) { - if (argv[i]) { - free(argv[i]); - } - } - free(argv); - } - - if (envp) { - for (u32 i = 0; i < envc; ++i) { - if (envp[i]) { - free(envp[i]); - } - } - free(envp); + RESPONSE_ERROR(response); + send_response(sockfd, &response); } if (-1 != master) { @@ -347,51 +295,62 @@ bool handle_exec(int sockfd) { } } - return success; + return ret; } -bool handle_dlopen(int sockfd) { - int result = false; - cmd_dlopen_t cmd; - CHECK(recvall(sockfd, (char *) &cmd, sizeof(cmd))); - - u64 err = (u64) dlopen(cmd.filename, cmd.mode); - CHECK(sendall(sockfd, (char *) &err, sizeof(err))); - - result = true; - - error: - return result; +bool handle_dlopen(int sockfd, Rpc__CmdDlopen *cmd) { + int ret = RPC_FAILURE; + Rpc__Response response = RPC__RESPONSE__INIT; + Rpc__ResponseDlopen resp_dlopen = RPC__RESPONSE_DLOPEN__INIT; + response.type_case = RPC__RESPONSE__TYPE_DLOPEN; + uint64_t res = 0; + res = (uint64_t) dlopen(cmd->filename, cmd->mode); + if (!res) { + RESPONSE_ERROR(response); + } else { + resp_dlopen.handle = res; + response.dlopen = &resp_dlopen; + ret = RPC_SUCCESS; + } + send_response(sockfd, &response); + return ret; } -bool handle_dlclose(int sockfd) { - int result = false; - cmd_dlclose_t cmd; - CHECK(recvall(sockfd, (char *) &cmd, sizeof(cmd))); - - u64 err = (u64) dlclose((void *) cmd.lib); - CHECK(sendall(sockfd, (char *) &err, sizeof(err))); - - result = true; - - error: - return result; +bool handle_dlclose(int sockfd, Rpc__CmdDlclose *cmd) { + int ret = RPC_FAILURE; + Rpc__Response response = RPC__RESPONSE__INIT; + Rpc__ResponseDlclose resp_dlclose = RPC__RESPONSE_DLCLOSE__INIT; + response.type_case = RPC__RESPONSE__TYPE_DLCLOSE; + uint64_t res = 0; + res = (uint64_t) dlclose((void *) cmd->handle); + if (res == -1) { + RESPONSE_ERROR(response); + } else { + resp_dlclose.res = res; + response.dlclose = &resp_dlclose; + ret = RPC_SUCCESS; + } + send_response(sockfd, &response); + return ret; } -bool handle_dlsym(int sockfd) { - int result = false; - cmd_dlsym_t cmd; - CHECK(recvall(sockfd, (char *) &cmd, sizeof(cmd))); - - u64 ptr = (u64) dlsym((void *) cmd.lib, cmd.symbol_name); - CHECK(sendall(sockfd, (char *) &ptr, sizeof(ptr))); - - TRACE("%s = %p", cmd.symbol_name, ptr); - - result = true; - - error: - return result; +bool handle_dlsym(int sockfd, Rpc__CmdDlsym *cmd) { + int ret = RPC_FAILURE; + uint64_t res = 0; + Rpc__Response response = RPC__RESPONSE__INIT; + Rpc__ResponseDlsym resp_dlsym = RPC__RESPONSE_DLSYM__INIT; + response.type_case = RPC__RESPONSE__TYPE_DLSYM; + res = (uint64_t) dlsym((void *) cmd->handle, cmd->symbol_name); + if (!res) { + RESPONSE_ERROR(response); + } else { + resp_dlsym.ptr = res; + response.dlsym = &resp_dlsym; + ret = RPC_SUCCESS; + } + TRACE("%s = %p", cmd->symbol_name, res); + send_response(sockfd, &response); + return ret; } #ifdef __ARM_ARCH_ISA_A64 @@ -652,187 +611,115 @@ __asm__( #else -bool call_function(int sockfd, intptr_t address, size_t va_list_index, size_t argc, argument_t **p_argv) { - typedef u64 (*call_argc0_t)(); - typedef u64 (*call_argc1_t)(u64); - typedef u64 (*call_argc2_t)(u64, u64); - typedef u64 (*call_argc3_t)(u64, u64, u64); - typedef u64 (*call_argc4_t)(u64, u64, u64, u64); - typedef u64 (*call_argc5_t)(u64, u64, u64, u64, u64); - typedef u64 (*call_argc6_t)(u64, u64, u64, u64, u64, u64); - typedef u64 (*call_argc7_t)(u64, u64, u64, u64, u64, u64, u64); - typedef u64 (*call_argc8_t)(u64, u64, u64, u64, u64, u64, u64, u64); - typedef u64 (*call_argc9_t)(u64, u64, u64, u64, u64, u64, u64, u64, u64); - typedef u64 (*call_argc10_t)(u64, u64, u64, u64, u64, u64, u64, u64, u64, u64); - typedef u64 (*call_argc11_t)(u64, u64, u64, u64, u64, u64, u64, u64, u64, u64, u64); - - bool result = false; - s64 err; - - argument_t *argv = *p_argv; +typedef u64 (*call_argc_t)(u64, u64, u64, u64, u64, u64, u64, u64, u64, u64, u64); +bool call_function(int sockfd, intptr_t address, size_t va_list_index, size_t argc, Rpc__Argument **argv, + Rpc__ResponseCall *response) { + s64 return_val; TRACE("enter"); - - switch (argc) { - case 0: - err = ((call_argc0_t) address)(); - break; - case 1: - err = ((call_argc1_t) address)(argv[0].value); - break; - case 2: - err = ((call_argc2_t) address)(argv[0].value, argv[1].value); - break; - case 3: - err = ((call_argc3_t) address)(argv[0].value, argv[1].value, argv[2].value); - break; - case 4: - err = ((call_argc4_t) address)(argv[0].value, argv[1].value, argv[2].value, argv[3].value); - break; - case 5: - err = ((call_argc5_t) address)(argv[0].value, argv[1].value, argv[2].value, argv[3].value, argv[4].value); - break; - case 6: - err = ((call_argc6_t) address)(argv[0].value, argv[1].value, argv[2].value, argv[3].value, argv[4].value, - argv[5].value); - break; - case 7: - err = ((call_argc7_t) address)(argv[0].value, argv[1].value, argv[2].value, argv[3].value, argv[4].value, - argv[5].value, argv[6].value); - break; - case 8: - err = ((call_argc8_t) address)(argv[0].value, argv[1].value, argv[2].value, argv[3].value, argv[4].value, - argv[5].value, argv[6].value, argv[7].value); - break; - case 9: - err = ((call_argc9_t) address)(argv[0].value, argv[1].value, argv[2].value, argv[3].value, argv[4].value, - argv[5].value, argv[6].value, argv[7].value, argv[8].value); - break; - case 10: - err = ((call_argc10_t) address)(argv[0].value, argv[1].value, argv[2].value, argv[3].value, argv[4].value, - argv[5].value, argv[6].value, argv[7].value, argv[8].value, argv[9].value); - break; - case 11: - err = ((call_argc11_t) address)(argv[0].value, argv[1].value, argv[2].value, argv[3].value, argv[4].value, - argv[5].value, argv[6].value, argv[7].value, argv[8].value, argv[9].value, - argv[10].value); - break; + call_argc_t call = (call_argc_t) address; + u64 args[11] = {0}; + for (size_t i = 0; i < argc; i++) { + args[i] = argv[i]->value; } + return_val = call(args[0], args[1], args[2], args[3], args[4], args[5], args[6], args[7], args[8], args[9], + args[10]); + response->return_values_case = RPC__RESPONSE_CALL__RETURN_VALUES_RETURN_VALUE; + response->return_value = return_val; - call_response_t response = {0}; - response.return_values.return_value = err; - - CHECK(sendall(sockfd, (char *) &response, sizeof(response))); - - result = true; - - error: - return result; + return RPC_SUCCESS; } #endif // __ARM_ARCH_ISA_A64 -bool handle_call(int sockfd) { +bool handle_call(int sockfd, Rpc__CmdCall *cmd) { TRACE("enter"); + int ret = RPC_FAILURE; + s64 err = 0; - int result = false; argument_t *argv = NULL; - cmd_call_t cmd; - CHECK(recvall(sockfd, (char *) &cmd, sizeof(cmd))); - - argv = (argument_t *) malloc(sizeof(argument_t) * cmd.argc); - CHECK(recvall(sockfd, (char *) argv, sizeof(argument_t) * cmd.argc)); + Rpc__Response response = RPC__RESPONSE__INIT; + Rpc__ResponseCall resp_call = RPC__RESPONSE_CALL__INIT; + response.type_case = RPC__RESPONSE__TYPE_CALL; - TRACE("address: %p", cmd.address); - CHECK(call_function(sockfd, cmd.address, cmd.va_list_index, cmd.argc, (argument_t **) cmd.argv)); - - result = true; + TRACE("address: %p", cmd->address); + CHECK(call_function(sockfd, cmd->address, cmd->va_list_index, cmd->n_argv, cmd->argv, &resp_call)); + response.call = &resp_call; + send_response(sockfd, &response); + ret = RPC_SUCCESS; error: - if (argv) { - free(argv); - } - return result; + return ret; } -bool handle_peek(int sockfd) { +bool handle_peek(int sockfd, Rpc__CmdPeek *cmd) { TRACE("enter"); - s64 err = 0; - int result = false; - u64 *argv = NULL; - cmd_peek_t cmd; + int ret = RPC_FAILURE; + uint8_t *buffer = NULL; + Rpc__Response response = RPC__RESPONSE__INIT; + Rpc__ResponsePeek peek = RPC__RESPONSE_PEEK__INIT; + response.type_case = RPC__RESPONSE__TYPE_PEEK; #if defined(SAFE_READ_WRITES) && defined(__APPLE__) - vm_offset_t data = 0; mach_msg_type_number_t size; - - CHECK(recvall(sockfd, (char *)&cmd, sizeof(cmd))); - if (vm_read(mach_task_self(), cmd.address, cmd.size, &data, &size) == KERN_SUCCESS) - { - CHECK(send_reply(sockfd, CMD_REPLY_PEEK)); - CHECK(sendall(sockfd, (char *)cmd.address, cmd.size)); - CHECK(vm_deallocate(mach_task_self(), data, size) == KERN_SUCCESS); - } - else - { - CHECK(send_reply(sockfd, CMD_REPLY_ERROR)); + if (vm_read(mach_task_self(), cmd->address, cmd->size, (vm_offset_t *) &buffer, &size) == KERN_SUCCESS) { + peek.data.data = (uint8_t *) buffer; + peek.data.len = size; + response.peek = &peek; + send_response(sockfd, &response); + CHECK(vm_deallocate(mach_task_self(), (vm_address_t) buffer, size) == KERN_SUCCESS); + buffer = NULL; + } else { + RESPONSE_ERROR(response); + send_response(sockfd, &response); } + // TODO: Implement: #else // __APPLE__ - CHECK(recvall(sockfd, (char *) &cmd, sizeof(cmd))); - CHECK(send_reply(sockfd, CMD_REPLY_PEEK)); - CHECK(sendall(sockfd, (char *) cmd.address, cmd.size)); + buffer = (uint8_t *) malloc(cmd->size * sizeof(uint8_t)); + CHECK(buffer != NULL); + memcpy(buffer, (const uint8_t *) cmd->address, cmd->size); + peek.data.data = buffer; + peek.data.len = cmd->size; + response.peek = &peek; + send_response(sockfd, &response); + #endif // __APPLE__ - result = true; + ret = RPC_SUCCESS; error: - if (argv) { - free(argv); - } + SAFE_FREE(buffer); - return result; + return ret; } -bool handle_poke(int sockfd) { - TRACE("enter"); - s64 err = 0; - int success = false; - u64 *argv = NULL; +bool handle_poke(int sockfd, Rpc__CmdPoke *cmd) { + TRACE("Enter"); + int ret = RPC_FAILURE; char *data = NULL; - cmd_poke_t cmd; + Rpc__Response response = RPC__RESPONSE__INIT; + Rpc__ResponsePoke poke = RPC__RESPONSE_POKE__INIT; #if defined(SAFE_READ_WRITES) && defined(__APPLE__) - CHECK(recvall(sockfd, (char *)&cmd, sizeof(cmd))); - - // TODO: consider splitting recieve chunks - data = malloc(cmd.size); - CHECK(data); - CHECK(recvall(sockfd, data, cmd.size)); - - if (vm_write(mach_task_self(), cmd.address, (vm_offset_t)data, cmd.size) == KERN_SUCCESS) - { - CHECK(send_reply(sockfd, CMD_REPLY_POKE)); - } - else - { - CHECK(send_reply(sockfd, CMD_REPLY_ERROR)); + if (vm_write(mach_task_self(), cmd->address, (vm_offset_t) cmd->data.data, cmd->data.len) == KERN_SUCCESS) { + response.type_case = RPC__RESPONSE__TYPE_POKE; + poke.result = KERN_SUCCESS; + response.poke = &poke; + } else { + RESPONSE_ERROR(response); } + // TODO: Implement: #else // __APPLE__ CHECK(recvall(sockfd, (char *) &cmd, sizeof(cmd))); CHECK(recvall(sockfd, (char *) cmd.address, cmd.size)); CHECK(send_reply(sockfd, CMD_REPLY_POKE)); #endif // __APPLE__ - - success = true; + CHECK(send_response(sockfd, &response)); + ret = RPC_SUCCESS; error: - if (argv) { - free(argv); - } - if (data) { - free(data); - } - return success; + SAFE_FREE(data); + return ret; } // exported for client hooks @@ -850,12 +737,19 @@ bool get_false() { void (^dummy_block)(void) = ^{ }; -bool handle_get_dummy_block(int sockfd) { +bool handle_get_dummy_block(int sockfd, Rpc__CmdDummyBlock *cmd) { TRACE("enter"); - CHECK(sendall(sockfd, (const char *) &dummy_block, sizeof(&dummy_block))); - return true; + bool ret = RPC_FAILURE; + Rpc__Response response = RPC__RESPONSE__INIT; + Rpc__ResponseDummyBlock block = RPC__RESPONSE_DUMMY_BLOCK__INIT; + response.type_case = RPC__RESPONSE__TYPE_DUMMY_BLOCK; + block.address = (uint64_t) &dummy_block; + block.size = sizeof(&dummy_block); + response.dummy_block = █ + CHECK(send_response(sockfd, &response)); + ret = RPC_SUCCESS; error: - return false; + return ret; } #else // !__APPLE__ @@ -868,6 +762,7 @@ bool handle_get_dummy_block(int sockfd) #endif // __APPLE__ bool handle_listdir(int sockfd) { + TRACE("enter"); bool result = false; DIR *dirp = NULL; @@ -968,12 +863,21 @@ bool handle_listdir(int sockfd) { return result; } +int test(int a, int b, int c) { + printf("a = %d\n", a); + printf("b = %d\n", b); + printf("c = %d\n", c); + return a + b + c; +} + void handle_client(int sockfd) { bool disconnected = false; TRACE("enter. fd: %d", sockfd); struct utsname uname_buf; - uint8_t buff[1024] = {0}; + uint8_t buffer[BUFFERSIZE] = {0}; + size_t message_size; + CHECK(0 == uname(&uname_buf)); Rpc__Handshake handshake = RPC__HANDSHAKE__INIT; @@ -986,75 +890,81 @@ void handle_client(int sockfd) { #ifdef __ARM_ARCH_ISA_A64 handshake.arch = ARCH_ARM64; #endif - uint32_t size = rpc__handshake__pack(&handshake, buff); // TODO: CHCK MACRO - CHECK(sendall(sockfd, (char *) &buff, size)); + message_size = rpc__handshake__pack(&handshake, buffer); // TODO: CHCK MACRO + CHECK(message_send(sockfd, (const uint8_t *) &buffer, message_size)); while (true) { - protocol_message_t cmd; - TRACE("recv"); - if (!recvall_ext(sockfd, (char *) &cmd, sizeof(cmd), &disconnected)) { - goto error; - } - CHECK(cmd.magic == MAGIC); + Rpc__Command *cmd; + message_size = 0; + CHECK(message_receive(sockfd, (char *) &buffer, &message_size)) - TRACE("client fd: %d, cmd type: %d", sockfd, cmd.cmd_type); + TRACE("recv"); + cmd = rpc__command__unpack(NULL, message_size, buffer); + TRACE("client fd: %d, cmd type: %d", sockfd, cmd->type_case); + CHECK(cmd->magic == MAGIC); //TODO: is this needed? - switch (cmd.cmd_type) { - case CMD_EXEC: { - handle_exec(sockfd); + switch (cmd->type_case) { + case RPC__COMMAND__TYPE_EXEC: { + handle_exec(sockfd, cmd->exec); break; } - case CMD_DLOPEN: { - handle_dlopen(sockfd); + case RPC__COMMAND__TYPE_DLOPEN: { + handle_dlopen(sockfd, cmd->dlopen); break; } - case CMD_DLSYM: { - handle_dlsym(sockfd); + case RPC__COMMAND__TYPE_DLSYM: { + handle_dlsym(sockfd, cmd->dlsym); break; } - case CMD_CALL: { - handle_call(sockfd); + case RPC__COMMAND__TYPE_DLCLOSE: { + handle_dlclose(sockfd, cmd->dlclose); break; } - case CMD_PEEK: { - handle_peek(sockfd); + case RPC__COMMAND__TYPE_CALL: { + handle_call(sockfd, cmd->call); // TODO: Not fully implemented break; } - case CMD_POKE: { - handle_poke(sockfd); + case RPC__COMMAND__TYPE_PEEK: { + handle_peek(sockfd, cmd->peek); break; } - case CMD_GET_DUMMY_BLOCK: { - handle_get_dummy_block(sockfd); + case RPC__COMMAND__TYPE_POKE: { + handle_poke(sockfd, cmd->poke); break; } - case CMD_CLOSE: { - // client requested to close connection - goto error; + case RPC__COMMAND__TYPE_DUMMY_BLOCK: { + handle_get_dummy_block(sockfd, cmd->dummy_block); + break; } - case CMD_LISTDIR: { + case RPC__COMMAND__TYPE_LISTDIR: { handle_listdir(sockfd); break; } - case CMD_SHOWOBJECT: { - handle_showobject(sockfd); + case RPC__COMMAND__TYPE_SHOWOBJECT: { + handle_showobject(sockfd, cmd->showobject); break; } - case CMD_SHOWCLASS: { - handle_showclass(sockfd); + case RPC__COMMAND__TYPE_SHOWCLASS: { + handle_showclass(sockfd, cmd->showclass); break; } - case CMD_GET_CLASS_LIST: { - handle_get_class_list(sockfd); + case RPC__COMMAND__TYPE_CLASS_LIST: { + handle_get_class_list(sockfd, cmd->class_list); break; } + case RPC__COMMAND__TYPE_CLOSE: { // client requested to close connection + goto error; + } default: { - TRACE("unknown cmd: %d", cmd.cmd_type); + TRACE("unknown cmd: %d", cmd->type_case); } } + rpc__command__free_unpacked(cmd, NULL); } error: + SAFE_FREE(handshake.sysname); + SAFE_FREE(handshake.machine); close(sockfd); } @@ -1074,9 +984,14 @@ void signal_handler(int sig) { int main(int argc, const char *argv[]) { int opt; bool worker_spawn = false; + bool debug = false; char port[MAX_OPTION_LEN] = DEFAULT_PORT; + printf("main - %p\n", &main); + + printf("getpid - %p | res %d\n", &getpid, getpid()); + printf("test - %p \n", &test); - while ((opt = getopt(argc, (char *const *) argv, "hp:o:w")) != -1) { + while ((opt = getopt(argc, (char *const *) argv, "hp:o:w:d")) != -1) { switch (opt) { case 'p': { strncpy(port, optarg, sizeof(port) - 1); @@ -1102,6 +1017,10 @@ int main(int argc, const char *argv[]) { worker_spawn = true; break; } + case 'd': { + debug = true; + break; + } case 'h': case '?': default: /* '?' */ @@ -1130,8 +1049,10 @@ int main(int argc, const char *argv[]) { hints.ai_family = AF_INET6; // IPv4 addresses will be like ::ffff:127.0.0.1 struct addrinfo *servinfo; + CHECK(0 == getaddrinfo(NULL, port, &hints, &servinfo)); + struct addrinfo *servinfo2 = servinfo; // servinfo->ai_next; char ipstr[INET6_ADDRSTRLEN]; CHECK(inet_ntop(servinfo2->ai_family, get_in_addr(servinfo2->ai_addr), ipstr, sizeof(ipstr))); @@ -1160,17 +1081,16 @@ int main(int argc, const char *argv[]) { struct sockaddr_storage their_addr; // connector's address information socklen_t addr_size = sizeof(their_addr); int client_fd = accept(server_fd, (struct sockaddr *) &their_addr, &addr_size); - handle_client(client_fd); // TODO: REMOVE -// exit(0); -// -// CHECK(client_fd >= 0); -// CHECK(-1 != fcntl(client_fd, F_SETFD, FD_CLOEXEC)); -// -// char ipstr[INET6_ADDRSTRLEN]; -// CHECK(inet_ntop(their_addr.ss_family, get_in_addr((struct sockaddr *) &their_addr), ipstr, sizeof(ipstr))); -// TRACE("Got a connection from %s [%d]", ipstr, client_fd); -// -// CHECK(spawn_worker_server(client_fd, argv, argc)); + CHECK(client_fd >= 0); + CHECK(-1 != fcntl(client_fd, F_SETFD, FD_CLOEXEC)); + char ipstr[INET6_ADDRSTRLEN]; + CHECK(inet_ntop(their_addr.ss_family, get_in_addr((struct sockaddr *) &their_addr), ipstr, sizeof(ipstr))); + TRACE("Got a connection from %s [%d]", ipstr, client_fd); + if (debug) { + handle_client(client_fd); + continue; + } + CHECK(spawn_worker_server(client_fd, argv, argc)); } error: