[Server] Support all hooks as StartNative field

Was trailofbits/ManticoreUI-Ghidra#34

PR Description:
Works towards trailofbits/ManticoreUI-Ghidra#22 and closes trailofbits/ManticoreUI-Ghidra#26 once trailofbits/ManticoreUI-Ghidra#35 is also merged

Now, hooks are passed alongside other Manticore arguments through the StartNative rpc. Hooks can have a HookType of FIND/AVOID/CUSTOM/GLOBAL

Custom and Global hooks are now also supported by the server
This commit is contained in:
kokrui
2022-09-27 10:11:23 -04:00
committed by Eric Kilmer
parent 47ffc3e990
commit d5648daadc
4 changed files with 77 additions and 131 deletions
+26 -36
View File
@@ -14,7 +14,7 @@ _sym_db = _symbol_database.Default()
DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile(b'\n\x15muicore/MUICore.proto\x12\x07muicore\" \n\rMUILogMessage\x12\x0f\n\x07\x63ontent\x18\x01 \x01(\t\":\n\x0eMUIMessageList\x12(\n\x08messages\x18\x02 \x03(\x0b\x32\x16.muicore.MUILogMessage\"Q\n\x08MUIState\x12\x10\n\x08state_id\x18\x03 \x01(\x05\x12\n\n\x02pc\x18\n \x01(\x04\x12\x11\n\tparent_id\x18\x1c \x01(\x05\x12\x14\n\x0c\x63hildren_ids\x18\x1d \x03(\x05\"\xe4\x01\n\x0cMUIStateList\x12(\n\ractive_states\x18\x04 \x03(\x0b\x32\x11.muicore.MUIState\x12)\n\x0ewaiting_states\x18\x05 \x03(\x0b\x32\x11.muicore.MUIState\x12(\n\rforked_states\x18\x06 \x03(\x0b\x32\x11.muicore.MUIState\x12)\n\x0e\x65rrored_states\x18\x07 \x03(\x0b\x32\x11.muicore.MUIState\x12*\n\x0f\x63omplete_states\x18\x08 \x03(\x0b\x32\x11.muicore.MUIState\"!\n\x11ManticoreInstance\x12\x0c\n\x04uuid\x18\t \x01(\t\"\x13\n\x11TerminateResponse\"\xad\x01\n\x0fNativeArguments\x12\x14\n\x0cprogram_path\x18\x0b \x01(\t\x12\x13\n\x0b\x62inary_args\x18\x10 \x03(\t\x12\x0c\n\x04\x65nvp\x18\x11 \x03(\t\x12\x16\n\x0esymbolic_files\x18\x12 \x03(\t\x12\x16\n\x0e\x63oncrete_start\x18\x13 \x01(\t\x12\x12\n\nstdin_size\x18\x14 \x01(\t\x12\x1d\n\x15\x61\x64\x64itional_mcore_args\x18\x15 \x01(\t\"\xac\x01\n\x0c\x45VMArguments\x12\x15\n\rcontract_path\x18\x0c \x01(\t\x12\x15\n\rcontract_name\x18\r \x01(\t\x12\x10\n\x08solc_bin\x18\x0e \x01(\t\x12\x10\n\x08tx_limit\x18\x16 \x01(\t\x12\x12\n\ntx_account\x18\x17 \x01(\t\x12\x1c\n\x14\x64\x65tectors_to_exclude\x18\x18 \x03(\t\x12\x18\n\x10\x61\x64\x64itional_flags\x18\x19 \x01(\t\"\x81\x01\n\x0e\x41\x64\x64ressRequest\x12\x0f\n\x07\x61\x64\x64ress\x18\x1a \x01(\x04\x12\x30\n\x04type\x18\x1b \x01(\x0e\x32\".muicore.AddressRequest.TargetType\",\n\nTargetType\x12\x08\n\x04\x46IND\x10\x00\x12\t\n\x05\x41VOID\x10\x01\x12\t\n\x05\x43LEAR\x10\x02\"\x10\n\x0eTargetResponse\",\n\x16ManticoreRunningStatus\x12\x12\n\nis_running\x18\x0f \x01(\x08\"\x13\n\x11StopServerRequest\"\x14\n\x12StopServerResponse2\xd6\x04\n\x0bManticoreUI\x12\x45\n\x0bStartNative\x12\x18.muicore.NativeArguments\x1a\x1a.muicore.ManticoreInstance\"\x00\x12?\n\x08StartEVM\x12\x15.muicore.EVMArguments\x1a\x1a.muicore.ManticoreInstance\"\x00\x12\x45\n\tTerminate\x12\x1a.muicore.ManticoreInstance\x1a\x1a.muicore.TerminateResponse\"\x00\x12\x43\n\x0cGetStateList\x12\x1a.muicore.ManticoreInstance\x1a\x15.muicore.MUIStateList\"\x00\x12G\n\x0eGetMessageList\x12\x1a.muicore.ManticoreInstance\x1a\x17.muicore.MUIMessageList\"\x00\x12V\n\x15\x43heckManticoreRunning\x12\x1a.muicore.ManticoreInstance\x1a\x1f.muicore.ManticoreRunningStatus\"\x00\x12I\n\x13TargetAddressNative\x12\x17.muicore.AddressRequest\x1a\x17.muicore.TargetResponse\"\x00\x12G\n\nStopServer\x12\x1a.muicore.StopServerRequest\x1a\x1b.muicore.StopServerResponse\"\x00\x62\x06proto3')
DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile(b'\n\x15muicore/MUICore.proto\x12\x07muicore\" \n\rMUILogMessage\x12\x0f\n\x07\x63ontent\x18\x01 \x01(\t\":\n\x0eMUIMessageList\x12(\n\x08messages\x18\x02 \x03(\x0b\x32\x16.muicore.MUILogMessage\"Q\n\x08MUIState\x12\x10\n\x08state_id\x18\x03 \x01(\x05\x12\n\n\x02pc\x18\n \x01(\x04\x12\x11\n\tparent_id\x18\x1c \x01(\x05\x12\x14\n\x0c\x63hildren_ids\x18\x1d \x03(\x05\"\xe4\x01\n\x0cMUIStateList\x12(\n\ractive_states\x18\x04 \x03(\x0b\x32\x11.muicore.MUIState\x12)\n\x0ewaiting_states\x18\x05 \x03(\x0b\x32\x11.muicore.MUIState\x12(\n\rforked_states\x18\x06 \x03(\x0b\x32\x11.muicore.MUIState\x12)\n\x0e\x65rrored_states\x18\x07 \x03(\x0b\x32\x11.muicore.MUIState\x12*\n\x0f\x63omplete_states\x18\x08 \x03(\x0b\x32\x11.muicore.MUIState\"!\n\x11ManticoreInstance\x12\x0c\n\x04uuid\x18\t \x01(\t\"\x13\n\x11TerminateResponse\"\x89\x01\n\x04Hook\x12\x0f\n\x07\x61\x64\x64ress\x18\x1a \x01(\x04\x12$\n\x04type\x18\x1b \x01(\x0e\x32\x16.muicore.Hook.HookType\x12\x11\n\tfunc_text\x18\x1f \x01(\t\"7\n\x08HookType\x12\x08\n\x04\x46IND\x10\x00\x12\t\n\x05\x41VOID\x10\x01\x12\n\n\x06\x43USTOM\x10\x02\x12\n\n\x06GLOBAL\x10\x03\"\xcb\x01\n\x0fNativeArguments\x12\x14\n\x0cprogram_path\x18\x0b \x01(\t\x12\x13\n\x0b\x62inary_args\x18\x10 \x03(\t\x12\x0c\n\x04\x65nvp\x18\x11 \x03(\t\x12\x16\n\x0esymbolic_files\x18\x12 \x03(\t\x12\x16\n\x0e\x63oncrete_start\x18\x13 \x01(\t\x12\x12\n\nstdin_size\x18\x14 \x01(\t\x12\x1d\n\x15\x61\x64\x64itional_mcore_args\x18\x15 \x01(\t\x12\x1c\n\x05hooks\x18\x1e \x03(\x0b\x32\r.muicore.Hook\"\xac\x01\n\x0c\x45VMArguments\x12\x15\n\rcontract_path\x18\x0c \x01(\t\x12\x15\n\rcontract_name\x18\r \x01(\t\x12\x10\n\x08solc_bin\x18\x0e \x01(\t\x12\x10\n\x08tx_limit\x18\x16 \x01(\t\x12\x12\n\ntx_account\x18\x17 \x01(\t\x12\x1c\n\x14\x64\x65tectors_to_exclude\x18\x18 \x03(\t\x12\x18\n\x10\x61\x64\x64itional_flags\x18\x19 \x01(\t\",\n\x16ManticoreRunningStatus\x12\x12\n\nis_running\x18\x0f \x01(\x08\"\x13\n\x11StopServerRequest\"\x14\n\x12StopServerResponse2\x8b\x04\n\x0bManticoreUI\x12\x45\n\x0bStartNative\x12\x18.muicore.NativeArguments\x1a\x1a.muicore.ManticoreInstance\"\x00\x12?\n\x08StartEVM\x12\x15.muicore.EVMArguments\x1a\x1a.muicore.ManticoreInstance\"\x00\x12\x45\n\tTerminate\x12\x1a.muicore.ManticoreInstance\x1a\x1a.muicore.TerminateResponse\"\x00\x12\x43\n\x0cGetStateList\x12\x1a.muicore.ManticoreInstance\x1a\x15.muicore.MUIStateList\"\x00\x12G\n\x0eGetMessageList\x12\x1a.muicore.ManticoreInstance\x1a\x17.muicore.MUIMessageList\"\x00\x12V\n\x15\x43heckManticoreRunning\x12\x1a.muicore.ManticoreInstance\x1a\x1f.muicore.ManticoreRunningStatus\"\x00\x12G\n\nStopServer\x12\x1a.muicore.StopServerRequest\x1a\x1b.muicore.StopServerResponse\"\x00\x62\x06proto3')
@@ -24,14 +24,13 @@ _MUISTATE = DESCRIPTOR.message_types_by_name['MUIState']
_MUISTATELIST = DESCRIPTOR.message_types_by_name['MUIStateList']
_MANTICOREINSTANCE = DESCRIPTOR.message_types_by_name['ManticoreInstance']
_TERMINATERESPONSE = DESCRIPTOR.message_types_by_name['TerminateResponse']
_HOOK = DESCRIPTOR.message_types_by_name['Hook']
_NATIVEARGUMENTS = DESCRIPTOR.message_types_by_name['NativeArguments']
_EVMARGUMENTS = DESCRIPTOR.message_types_by_name['EVMArguments']
_ADDRESSREQUEST = DESCRIPTOR.message_types_by_name['AddressRequest']
_TARGETRESPONSE = DESCRIPTOR.message_types_by_name['TargetResponse']
_MANTICORERUNNINGSTATUS = DESCRIPTOR.message_types_by_name['ManticoreRunningStatus']
_STOPSERVERREQUEST = DESCRIPTOR.message_types_by_name['StopServerRequest']
_STOPSERVERRESPONSE = DESCRIPTOR.message_types_by_name['StopServerResponse']
_ADDRESSREQUEST_TARGETTYPE = _ADDRESSREQUEST.enum_types_by_name['TargetType']
_HOOK_HOOKTYPE = _HOOK.enum_types_by_name['HookType']
MUILogMessage = _reflection.GeneratedProtocolMessageType('MUILogMessage', (_message.Message,), {
'DESCRIPTOR' : _MUILOGMESSAGE,
'__module__' : 'muicore.MUICore_pb2'
@@ -74,6 +73,13 @@ TerminateResponse = _reflection.GeneratedProtocolMessageType('TerminateResponse'
})
_sym_db.RegisterMessage(TerminateResponse)
Hook = _reflection.GeneratedProtocolMessageType('Hook', (_message.Message,), {
'DESCRIPTOR' : _HOOK,
'__module__' : 'muicore.MUICore_pb2'
# @@protoc_insertion_point(class_scope:muicore.Hook)
})
_sym_db.RegisterMessage(Hook)
NativeArguments = _reflection.GeneratedProtocolMessageType('NativeArguments', (_message.Message,), {
'DESCRIPTOR' : _NATIVEARGUMENTS,
'__module__' : 'muicore.MUICore_pb2'
@@ -88,20 +94,6 @@ EVMArguments = _reflection.GeneratedProtocolMessageType('EVMArguments', (_messag
})
_sym_db.RegisterMessage(EVMArguments)
AddressRequest = _reflection.GeneratedProtocolMessageType('AddressRequest', (_message.Message,), {
'DESCRIPTOR' : _ADDRESSREQUEST,
'__module__' : 'muicore.MUICore_pb2'
# @@protoc_insertion_point(class_scope:muicore.AddressRequest)
})
_sym_db.RegisterMessage(AddressRequest)
TargetResponse = _reflection.GeneratedProtocolMessageType('TargetResponse', (_message.Message,), {
'DESCRIPTOR' : _TARGETRESPONSE,
'__module__' : 'muicore.MUICore_pb2'
# @@protoc_insertion_point(class_scope:muicore.TargetResponse)
})
_sym_db.RegisterMessage(TargetResponse)
ManticoreRunningStatus = _reflection.GeneratedProtocolMessageType('ManticoreRunningStatus', (_message.Message,), {
'DESCRIPTOR' : _MANTICORERUNNINGSTATUS,
'__module__' : 'muicore.MUICore_pb2'
@@ -139,22 +131,20 @@ if _descriptor._USE_C_DESCRIPTORS == False:
_MANTICOREINSTANCE._serialized_end=475
_TERMINATERESPONSE._serialized_start=477
_TERMINATERESPONSE._serialized_end=496
_NATIVEARGUMENTS._serialized_start=499
_NATIVEARGUMENTS._serialized_end=672
_EVMARGUMENTS._serialized_start=675
_EVMARGUMENTS._serialized_end=847
_ADDRESSREQUEST._serialized_start=850
_ADDRESSREQUEST._serialized_end=979
_ADDRESSREQUEST_TARGETTYPE._serialized_start=935
_ADDRESSREQUEST_TARGETTYPE._serialized_end=979
_TARGETRESPONSE._serialized_start=981
_TARGETRESPONSE._serialized_end=997
_MANTICORERUNNINGSTATUS._serialized_start=999
_MANTICORERUNNINGSTATUS._serialized_end=1043
_STOPSERVERREQUEST._serialized_start=1045
_STOPSERVERREQUEST._serialized_end=1064
_STOPSERVERRESPONSE._serialized_start=1066
_STOPSERVERRESPONSE._serialized_end=1086
_MANTICOREUI._serialized_start=1089
_MANTICOREUI._serialized_end=1687
_HOOK._serialized_start=499
_HOOK._serialized_end=636
_HOOK_HOOKTYPE._serialized_start=581
_HOOK_HOOKTYPE._serialized_end=636
_NATIVEARGUMENTS._serialized_start=639
_NATIVEARGUMENTS._serialized_end=842
_EVMARGUMENTS._serialized_start=845
_EVMARGUMENTS._serialized_end=1017
_MANTICORERUNNINGSTATUS._serialized_start=1019
_MANTICORERUNNINGSTATUS._serialized_end=1063
_STOPSERVERREQUEST._serialized_start=1065
_STOPSERVERREQUEST._serialized_end=1084
_STOPSERVERRESPONSE._serialized_start=1086
_STOPSERVERRESPONSE._serialized_end=1106
_MANTICOREUI._serialized_start=1109
_MANTICOREUI._serialized_end=1632
# @@protoc_insertion_point(module_scope)
+39 -36
View File
@@ -106,6 +106,40 @@ class TerminateResponse(google.protobuf.message.Message):
) -> None: ...
global___TerminateResponse = TerminateResponse
class Hook(google.protobuf.message.Message):
DESCRIPTOR: google.protobuf.descriptor.Descriptor
class _HookType:
ValueType = typing.NewType('ValueType', builtins.int)
V: typing_extensions.TypeAlias = ValueType
class _HookTypeEnumTypeWrapper(google.protobuf.internal.enum_type_wrapper._EnumTypeWrapper[Hook._HookType.ValueType], builtins.type):
DESCRIPTOR: google.protobuf.descriptor.EnumDescriptor
FIND: Hook._HookType.ValueType # 0
AVOID: Hook._HookType.ValueType # 1
CUSTOM: Hook._HookType.ValueType # 2
GLOBAL: Hook._HookType.ValueType # 3
class HookType(_HookType, metaclass=_HookTypeEnumTypeWrapper):
pass
FIND: Hook.HookType.ValueType # 0
AVOID: Hook.HookType.ValueType # 1
CUSTOM: Hook.HookType.ValueType # 2
GLOBAL: Hook.HookType.ValueType # 3
ADDRESS_FIELD_NUMBER: builtins.int
TYPE_FIELD_NUMBER: builtins.int
FUNC_TEXT_FIELD_NUMBER: builtins.int
address: builtins.int
type: global___Hook.HookType.ValueType
func_text: typing.Text
def __init__(self,
*,
address: builtins.int = ...,
type: global___Hook.HookType.ValueType = ...,
func_text: typing.Text = ...,
) -> None: ...
def ClearField(self, field_name: typing_extensions.Literal["address",b"address","func_text",b"func_text","type",b"type"]) -> None: ...
global___Hook = Hook
class NativeArguments(google.protobuf.message.Message):
DESCRIPTOR: google.protobuf.descriptor.Descriptor
PROGRAM_PATH_FIELD_NUMBER: builtins.int
@@ -115,6 +149,7 @@ class NativeArguments(google.protobuf.message.Message):
CONCRETE_START_FIELD_NUMBER: builtins.int
STDIN_SIZE_FIELD_NUMBER: builtins.int
ADDITIONAL_MCORE_ARGS_FIELD_NUMBER: builtins.int
HOOKS_FIELD_NUMBER: builtins.int
program_path: typing.Text
@property
def binary_args(self) -> google.protobuf.internal.containers.RepeatedScalarFieldContainer[typing.Text]: ...
@@ -125,6 +160,8 @@ class NativeArguments(google.protobuf.message.Message):
concrete_start: typing.Text
stdin_size: typing.Text
additional_mcore_args: typing.Text
@property
def hooks(self) -> google.protobuf.internal.containers.RepeatedCompositeFieldContainer[global___Hook]: ...
def __init__(self,
*,
program_path: typing.Text = ...,
@@ -134,8 +171,9 @@ class NativeArguments(google.protobuf.message.Message):
concrete_start: typing.Text = ...,
stdin_size: typing.Text = ...,
additional_mcore_args: typing.Text = ...,
hooks: typing.Optional[typing.Iterable[global___Hook]] = ...,
) -> None: ...
def ClearField(self, field_name: typing_extensions.Literal["additional_mcore_args",b"additional_mcore_args","binary_args",b"binary_args","concrete_start",b"concrete_start","envp",b"envp","program_path",b"program_path","stdin_size",b"stdin_size","symbolic_files",b"symbolic_files"]) -> None: ...
def ClearField(self, field_name: typing_extensions.Literal["additional_mcore_args",b"additional_mcore_args","binary_args",b"binary_args","concrete_start",b"concrete_start","envp",b"envp","hooks",b"hooks","program_path",b"program_path","stdin_size",b"stdin_size","symbolic_files",b"symbolic_files"]) -> None: ...
global___NativeArguments = NativeArguments
class EVMArguments(google.protobuf.message.Message):
@@ -168,41 +206,6 @@ class EVMArguments(google.protobuf.message.Message):
def ClearField(self, field_name: typing_extensions.Literal["additional_flags",b"additional_flags","contract_name",b"contract_name","contract_path",b"contract_path","detectors_to_exclude",b"detectors_to_exclude","solc_bin",b"solc_bin","tx_account",b"tx_account","tx_limit",b"tx_limit"]) -> None: ...
global___EVMArguments = EVMArguments
class AddressRequest(google.protobuf.message.Message):
DESCRIPTOR: google.protobuf.descriptor.Descriptor
class _TargetType:
ValueType = typing.NewType('ValueType', builtins.int)
V: typing_extensions.TypeAlias = ValueType
class _TargetTypeEnumTypeWrapper(google.protobuf.internal.enum_type_wrapper._EnumTypeWrapper[AddressRequest._TargetType.ValueType], builtins.type):
DESCRIPTOR: google.protobuf.descriptor.EnumDescriptor
FIND: AddressRequest._TargetType.ValueType # 0
AVOID: AddressRequest._TargetType.ValueType # 1
CLEAR: AddressRequest._TargetType.ValueType # 2
class TargetType(_TargetType, metaclass=_TargetTypeEnumTypeWrapper):
pass
FIND: AddressRequest.TargetType.ValueType # 0
AVOID: AddressRequest.TargetType.ValueType # 1
CLEAR: AddressRequest.TargetType.ValueType # 2
ADDRESS_FIELD_NUMBER: builtins.int
TYPE_FIELD_NUMBER: builtins.int
address: builtins.int
type: global___AddressRequest.TargetType.ValueType
def __init__(self,
*,
address: builtins.int = ...,
type: global___AddressRequest.TargetType.ValueType = ...,
) -> None: ...
def ClearField(self, field_name: typing_extensions.Literal["address",b"address","type",b"type"]) -> None: ...
global___AddressRequest = AddressRequest
class TargetResponse(google.protobuf.message.Message):
DESCRIPTOR: google.protobuf.descriptor.Descriptor
def __init__(self,
) -> None: ...
global___TargetResponse = TargetResponse
class ManticoreRunningStatus(google.protobuf.message.Message):
DESCRIPTOR: google.protobuf.descriptor.Descriptor
IS_RUNNING_FIELD_NUMBER: builtins.int
-33
View File
@@ -44,11 +44,6 @@ class ManticoreUIStub(object):
request_serializer=muicore_dot_MUICore__pb2.ManticoreInstance.SerializeToString,
response_deserializer=muicore_dot_MUICore__pb2.ManticoreRunningStatus.FromString,
)
self.TargetAddressNative = channel.unary_unary(
'/muicore.ManticoreUI/TargetAddressNative',
request_serializer=muicore_dot_MUICore__pb2.AddressRequest.SerializeToString,
response_deserializer=muicore_dot_MUICore__pb2.TargetResponse.FromString,
)
self.StopServer = channel.unary_unary(
'/muicore.ManticoreUI/StopServer',
request_serializer=muicore_dot_MUICore__pb2.StopServerRequest.SerializeToString,
@@ -95,12 +90,6 @@ class ManticoreUIServicer(object):
context.set_details('Method not implemented!')
raise NotImplementedError('Method not implemented!')
def TargetAddressNative(self, request, context):
"""Missing associated documentation comment in .proto file."""
context.set_code(grpc.StatusCode.UNIMPLEMENTED)
context.set_details('Method not implemented!')
raise NotImplementedError('Method not implemented!')
def StopServer(self, request, context):
"""Missing associated documentation comment in .proto file."""
context.set_code(grpc.StatusCode.UNIMPLEMENTED)
@@ -140,11 +129,6 @@ def add_ManticoreUIServicer_to_server(servicer, server):
request_deserializer=muicore_dot_MUICore__pb2.ManticoreInstance.FromString,
response_serializer=muicore_dot_MUICore__pb2.ManticoreRunningStatus.SerializeToString,
),
'TargetAddressNative': grpc.unary_unary_rpc_method_handler(
servicer.TargetAddressNative,
request_deserializer=muicore_dot_MUICore__pb2.AddressRequest.FromString,
response_serializer=muicore_dot_MUICore__pb2.TargetResponse.SerializeToString,
),
'StopServer': grpc.unary_unary_rpc_method_handler(
servicer.StopServer,
request_deserializer=muicore_dot_MUICore__pb2.StopServerRequest.FromString,
@@ -262,23 +246,6 @@ class ManticoreUI(object):
options, channel_credentials,
insecure, call_credentials, compression, wait_for_ready, timeout, metadata)
@staticmethod
def TargetAddressNative(request,
target,
options=(),
channel_credentials=None,
call_credentials=None,
insecure=False,
compression=None,
wait_for_ready=None,
timeout=None,
metadata=None):
return grpc.experimental.unary_unary(request, target, '/muicore.ManticoreUI/TargetAddressNative',
muicore_dot_MUICore__pb2.AddressRequest.SerializeToString,
muicore_dot_MUICore__pb2.TargetResponse.FromString,
options, channel_credentials,
insecure, call_credentials, compression, wait_for_ready, timeout, metadata)
@staticmethod
def StopServer(request,
target,
+12 -26
View File
@@ -77,8 +77,6 @@ class MUIServicer(ManticoreUIServicer):
"""Initializes the dict that keeps track of all created manticore instances, as well as avoid/find address set"""
self.manticore_instances: Dict[str, ManticoreWrapper] = {}
self.avoid: Set[int] = set()
self.find: Set[int] = set()
self.stop_event: Event = stop_event
manticore_logger = logging.getLogger("manticore")
@@ -171,12 +169,6 @@ class MUIServicer(ManticoreUIServicer):
if parsed.assertions:
m.load_assertions(parsed.assertions)
def avoid_f(state: StateBase):
state.abandon()
for addr in self.avoid:
m.add_hook(addr, avoid_f)
def find_f(state: StateBase):
bufs = state.solve_one_n_batched(state.input_symbols)
for symbol, buf in zip(state.input_symbols, bufs):
@@ -185,8 +177,18 @@ class MUIServicer(ManticoreUIServicer):
m.kill()
state.abandon()
for addr in self.find:
m.add_hook(addr, find_f)
def avoid_f(state: StateBase):
state.abandon()
for hook in native_arguments.hooks:
if hook.type == Hook.HookType.FIND:
m.add_hook(hook.address, find_f)
elif hook.type == Hook.HookType.AVOID:
m.add_hook(hook.address, avoid_f)
elif hook.type == Hook.HookType.CUSTOM:
exec(hook.func_text, {"addr": hook.address, "m": m})
elif hook.type == Hook.HookType.GLOBAL:
exec(hook.func_text, {"m": m})
except Exception as e:
print(e)
@@ -318,22 +320,6 @@ class MUIServicer(ManticoreUIServicer):
m_wrapper.manticore_object.kill()
return TerminateResponse()
def TargetAddressNative(
self, address_request: AddressRequest, context: _Context
) -> TargetResponse:
"""Sets addresses in the binary to find/avoid, or clears address status.
Values set will be used for subsequent Start calls.
Currently, implementation is based on MUI's Binary Ninja plugin."""
if address_request.type == AddressRequest.TargetType.FIND:
self.find.add(address_request.address)
elif address_request.type == AddressRequest.TargetType.AVOID:
self.avoid.add(address_request.address)
elif address_request.type == AddressRequest.TargetType.CLEAR:
self.avoid.remove(address_request.address)
self.find.remove(address_request.address)
return TargetResponse()
def GetStateList(
self, mcore_instance: ManticoreInstance, context: _Context
) -> MUIStateList: