Merge branch 'dockerize-this' of https://github.com/aaron-suarez/deepstate into dockerize-this

This commit is contained in:
agroce 2019-05-30 11:00:17 -07:00
commit ef5efe5d58
3 changed files with 110 additions and 2 deletions

View File

@ -19,6 +19,10 @@ if (NOT DEFINED BUILD_LIBFUZZER AND DEFINED ENV{BUILD_LIBFUZZER})
set(BUILD_LIBFUZZER "$ENV{BUILD_LIBFUZZER}")
endif()
if (NOT DEFINED BUILD_AFL AND DEFINED ENV{BUILD_AFL})
set(BUILD_AFL "$ENV{BUILD_AFL}")
endif()
if (NOT DEFINED BUILD_NOSTATIC AND DEFINED ENV{BUILD_NOSTATIC})
set(BUILD_NOSTATIC "$ENV{BUILD_NOSTATIC}")
endif()
@ -132,6 +136,26 @@ if (BUILD_LIBFUZZER)
)
endif()
if (BUILD_AFL)
add_library(${PROJECT_NAME}_AFL STATIC
src/lib/DeepState.c
src/lib/Log.c
src/lib/Option.c
src/lib/Stream.c
)
target_compile_options(${PROJECT_NAME}_AFL PUBLIC -mno-avx)
target_include_directories(${PROJECT_NAME}_AFL
PUBLIC SYSTEM "${CMAKE_SOURCE_DIR}/src/include"
)
install(
TARGETS ${PROJECT_NAME} ${PROJECT_NAME}_AFL
LIBRARY DESTINATION lib
ARCHIVE DESTINATION lib
)
endif()
set(SETUP_PY_IN "${CMAKE_SOURCE_DIR}/bin/setup.py.in")
set(SETUP_PY "${CMAKE_CURRENT_BINARY_DIR}/setup.py")

View File

@ -17,11 +17,16 @@ target_link_libraries(Crash deepstate)
if (BUILD_LIBFUZZER)
add_executable(Crash_LF Crash.cpp)
target_link_libraries(Crash_LF deepstate_LF)
target_link_libraries (Crash_LF "-fsanitize=fuzzer,undefined")
target_link_libraries(Crash_LF deepstate_LF)
target_link_libraries (Crash_LF "-fsanitize=fuzzer,undefined")
set_target_properties(Crash_LF PROPERTIES COMPILE_DEFINITIONS "LIBFUZZER")
endif()
if (BUILD_AFL)
add_executable(Crash_AFL Crash.cpp)
target_link_libraries(Crash_AFL deepstate_AFL)
endif()
add_executable(OneOf OneOf.cpp)
target_link_libraries(OneOf deepstate)
@ -32,6 +37,11 @@ if (BUILD_LIBFUZZER)
set_target_properties(OneOf_LF PROPERTIES COMPILE_DEFINITIONS "LIBFUZZER")
endif()
if (BUILD_AFL)
add_executable(OneOf_AFL OneOf.cpp)
target_link_libraries(OneOf_AFL deepstate_AFL)
endif()
add_executable(Fixture Fixture.cpp)
target_link_libraries(Fixture deepstate)
@ -42,6 +52,11 @@ if (BUILD_LIBFUZZER)
set_target_properties(Fixture_LF PROPERTIES COMPILE_DEFINITIONS "LIBFUZZER")
endif()
if (BUILD_AFL)
add_executable(Fixture_AFL Fixture.cpp)
target_link_libraries(Fixture_AFL deepstate_AFL)
endif()
add_executable(Primes Primes.cpp)
target_link_libraries(Primes deepstate)
@ -52,6 +67,11 @@ if (BUILD_LIBFUZZER)
set_target_properties(Primes_LF PROPERTIES COMPILE_DEFINITIONS "LIBFUZZER")
endif()
if (BUILD_AFL)
add_executable(Primes_AFL Primes.cpp)
target_link_libraries(Primes_AFL deepstate_AFL)
endif()
add_executable(Euler Euler.cpp)
target_link_libraries(Euler deepstate)
@ -62,6 +82,11 @@ if (BUILD_LIBFUZZER)
set_target_properties(Euler_LF PROPERTIES COMPILE_DEFINITIONS "LIBFUZZER")
endif()
if (BUILD_AFL)
add_executable(Euler_AFL Euler.cpp)
target_link_libraries(Euler_AFL deepstate_AFL)
endif()
add_executable(IntegerOverflow IntegerOverflow.cpp)
target_link_libraries(IntegerOverflow deepstate)
@ -72,6 +97,11 @@ if (BUILD_LIBFUZZER)
set_target_properties(IntegerOverflow_LF PROPERTIES COMPILE_DEFINITIONS "LIBFUZZER")
endif()
if (BUILD_AFL)
add_executable(IntegerOverflow_AFL IntegerOverflow.cpp)
target_link_libraries(IntegerOverflow_AFL deepstate_AFL)
endif()
add_executable(IntegerArithmetic IntegerArithmetic.cpp)
target_link_libraries(IntegerArithmetic deepstate)
@ -82,6 +112,11 @@ if (BUILD_LIBFUZZER)
set_target_properties(IntegerArithmetic_LF PROPERTIES COMPILE_DEFINITIONS "LIBFUZZER")
endif()
if (BUILD_AFL)
add_executable(IntegerArithmetic_AFL IntegerArithmetic.cpp)
target_link_libraries(IntegerArithmetic_AFL deepstate_AFL)
endif()
add_executable(Lists Lists.cpp)
target_link_libraries(Lists deepstate)
@ -92,6 +127,11 @@ if (BUILD_LIBFUZZER)
set_target_properties(Lists_LF PROPERTIES COMPILE_DEFINITIONS "LIBFUZZER")
endif()
if (BUILD_AFL)
add_executable(Lists_AFL Lists.cpp)
target_link_libraries(Lists_AFL deepstate_AFL)
endif()
add_executable(StreamingAndFormatting StreamingAndFormatting.cpp)
target_link_libraries(StreamingAndFormatting deepstate)
@ -102,6 +142,11 @@ if (BUILD_LIBFUZZER)
set_target_properties(StreamingAndFormatting_LF PROPERTIES COMPILE_DEFINITIONS "LIBFUZZER")
endif()
if (BUILD_AFL)
add_executable(StreamingAndFormatting_AFL StreamingAndFormatting.cpp)
target_link_libraries(StreamingAndFormatting_AFL deepstate_AFL)
endif()
add_executable(Runlen Runlen.cpp)
target_link_libraries(Runlen deepstate)
@ -112,6 +157,26 @@ if (BUILD_LIBFUZZER)
set_target_properties(Runlen_LF PROPERTIES COMPILE_DEFINITIONS "LIBFUZZER")
endif()
if (BUILD_AFL)
add_executable(Runlen_AFL Runlen.cpp)
target_link_libraries(Runlen_AFL deepstate_AFL)
endif()
add_executable(FromEclipser FromEclipser.cpp)
target_link_libraries(FromEclipser deepstate)
if (BUILD_LIBFUZZER)
add_executable(FromEclipser_LF FromEclipser.cpp)
target_link_libraries(FromEclipser_LF deepstate_LF)
target_link_libraries (FromEclipser_LF "-fsanitize=fuzzer,undefined")
set_target_properties(FromEclipser_LF PROPERTIES COMPILE_DEFINITIONS "LIBFUZZER")
endif()
if (BUILD_AFL)
add_executable(FromEclipser_AFL FromEclipser.cpp)
target_link_libraries(FromEclipser_AFL deepstate_AFL)
endif()
if (NOT APPLE)
add_executable(Squares Squares.c)
target_link_libraries(Squares deepstate)

19
examples/FromEclipser.cpp Normal file
View File

@ -0,0 +1,19 @@
#include <deepstate/DeepState.hpp>
using namespace deepstate;
#include <assert.h>
int vulnfunc(int32_t intInput, char * strInput) {
if (2 * intInput + 1 == 31337)
if (strcmp(strInput, "Bad!") == 0)
assert(0);
return 0;
}
TEST(FromEclipser, CrashIt) {
char *buf = (char*)DeepState_Malloc(9);
buf[8] = 0;
vulnfunc(*((int32_t*) &buf[0]), &buf[4]);
free(buf);
}