-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathCMakeLists.txt
More file actions
54 lines (45 loc) · 1.87 KB
/
Copy pathCMakeLists.txt
File metadata and controls
54 lines (45 loc) · 1.87 KB
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
cmake_minimum_required(VERSION 3.25)
project(damn_vulnerable_web_server CXX)
set(CMAKE_CXX_STANDARD 11)
# Add OpenSSL flags and include directories
find_package(OpenSSL REQUIRED)
include_directories(${OPENSSL_INCLUDE_DIR})
# Add your source files to the executable
add_executable(damn_vulnerable_web_server
main.cpp
mime_type_handler.cpp
request_logger.cpp
error_handling.cpp
authentication.cpp
base64.cpp
utils.cpp
session_manager.cpp
response_handler.cpp
)
option(ENABLE_ASLR "Enable Address Space Layout Randomization (ASLR)" OFF)
option(ENABLE_ASAN "Enable Address Sanitizer" OFF)
if(ENABLE_ASAN)
message(STATUS "Address Sanitizer Enabled")
target_compile_options(damn_vulnerable_web_server PRIVATE -fsanitize=address -g)
target_link_options(damn_vulnerable_web_server PRIVATE -fsanitize=address)
endif()
# Only apply flags after target is defined
if(ENABLE_ASLR)
message(STATUS "ASLR Enabled")
if(CMAKE_SYSTEM_NAME STREQUAL "Linux")
target_compile_options(damn_vulnerable_web_server PRIVATE -fstack-protector)
elseif(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
target_compile_options(damn_vulnerable_web_server PRIVATE -fstack-protector)
endif()
else()
message(STATUS "ASLR Disabled")
if(CMAKE_SYSTEM_NAME STREQUAL "Linux")
target_compile_options(damn_vulnerable_web_server PRIVATE -fno-stack-protector -z execstack -no-pie)
target_link_options(damn_vulnerable_web_server PRIVATE -no-pie)
elseif(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
target_compile_options(damn_vulnerable_web_server PRIVATE -fno-stack-protector)
target_link_options(damn_vulnerable_web_server PRIVATE "LINKER:-no_pie")
endif()
endif()
target_include_directories(damn_vulnerable_web_server PRIVATE ${OPENSSL_INCLUDE_DIR})
target_link_libraries(damn_vulnerable_web_server PRIVATE OpenSSL::SSL OpenSSL::Crypto)