Add 32-bit support, i.e. libdeepstate32

This commit is contained in:
Peter Goodman
2017-12-13 21:53:33 -05:00
parent f4dd61f895
commit 7c585f5c44
4 changed files with 30 additions and 10 deletions
+13 -1
View File
@@ -44,10 +44,22 @@ add_library(${PROJECT_NAME} STATIC
src/lib/Stream.c
)
add_library(${PROJECT_NAME}32 STATIC
src/lib/DeepState.c
src/lib/Log.c
src/lib/Stream.c
)
target_compile_options(${PROJECT_NAME}32 PUBLIC -m32)
target_include_directories(${PROJECT_NAME}
PUBLIC SYSTEM "${CMAKE_SOURCE_DIR}/src/include"
)
target_include_directories(${PROJECT_NAME}32
PUBLIC SYSTEM "${CMAKE_SOURCE_DIR}/src/include"
)
# Install the
install(
DIRECTORY "${CMAKE_SOURCE_DIR}/src/include/deepstate"
@@ -56,7 +68,7 @@ install(
# Install the library
install(
TARGETS ${PROJECT_NAME}
TARGETS ${PROJECT_NAME} ${PROJECT_NAME}32
LIBRARY DESTINATION lib
ARCHIVE DESTINATION lib
)
+12 -4
View File
@@ -299,14 +299,16 @@ def main():
try:
project = angr.Project(
args.binary,
use_sim_procedures=True,
use_sim_procedures=False,
translation_cache=True,
support_selfmodifying_code=False,
auto_load_libs=True,
exclude_sim_procedures_list=['printf', '__printf_chk',
'vprintf', '__vprintf_chk',
'fprintf', '__fprintf_chk',
'vfprintf', '__vfprintf_chk'])
'vfprintf', '__vfprintf_chk',
'puts', 'abort', '__assert_fail',
'__stack_chk_fail'])
except Exception as e:
L.critical("Cannot create Angr instance on binary {}: {}".format(
args.binary, e))
@@ -327,12 +329,18 @@ def main():
addr_size_bits = entry_state.arch.bits
# Concretely execute up until `DeepState_InjectAngr`.
# Concretely execute up until `DeepState_Setup`.
concrete_manager = angr.SimulationManager(
project=project,
active_states=[entry_state])
concrete_manager.explore(find=setup_ea)
run_state = concrete_manager.found[0]
try:
run_state = concrete_manager.found[0]
except:
L.critical("Execution never hit `DeepState_Setup` in binary `{}`".format(
args.binary))
return 1
# Read the API table, which will tell us about the location of various
# symbols. Technically we can look these up with the `labels.lookup` API,
+3 -3
View File
@@ -325,10 +325,10 @@ def main():
try:
setup_ea = m._get_symbol_address('DeepState_Setup')
if not setup_ea:
raise Exception()
raise Exception("Could not find symbol")
except:
L.critical("Cannot find symbol `DeepState_Setup` in binary `{}`".format(
args.binary))
L.critical("Cannot find symbol `DeepState_Setup` in binary `{}`: {}".format(
args.binary, traceback.format_exc()))
return 1
setup_state = m._initial_state
+2 -2
View File
@@ -196,13 +196,13 @@ void _DeepState_StreamString(enum DeepState_LogLevel level, const char *format,
stream->size += size;
}
void DeepState_StreamPointer(enum DeepState_LogLevel level, void * val) {
void DeepState_StreamPointer(enum DeepState_LogLevel level, void *val) {
struct DeepState_Stream *stream = &(DeepState_Streams[level]);
stream->format[0] = '%';
stream->format[1] = 'p';
stream->format[2] = '\0';
DeepState_StreamUnpack(stream, (sizeof(void *) == 8 ? 'Q' : 'I'));
stream->value.as_uint64 = (uint64_t) val;
stream->value.as_uint64 = (uintptr_t) val;
_DeepState_StreamInt(level, stream->format, stream->unpack,
&(stream->value.as_uint64));
}