From 1e6e2ecf9c58b726747ee55ea9932d9cc210145a Mon Sep 17 00:00:00 2001 From: Retr0-code Date: Tue, 7 Nov 2023 23:18:01 +0300 Subject: [PATCH] Reworked CMakeLists.txt Updated README.md --- CMakeLists.txt | 33 ++++++++++++++++++++++----------- README.md | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 68 insertions(+), 11 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index a1d3e2a..fb09342 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -7,15 +7,15 @@ project(hash_dumper ) # Initializing parameters -option(DEBUG "Sets compilation flags for debugging" OFF) -option(RELEASE "Sets compilation flags for optimized binary" OFF) -option(BUILD32 "Sets compilation flags for 32-bit mode" OFF) set(INSTALL_PREFIX /usr/local/bin CACHE PATH "Path for installed binaries") +set(BUILD_ARCH "amd64" CACHE STRING "Build architecture amd64/i386") +set(BUILD_CPU "RELEASE" CACHE STRING "Build target mode RELEASE/DEBUG") # Checking parameters set(CMAKE_INSTALL_PREFIX ${INSTALL_PREFIX}) -if ((DEBUG) AND (NOT RELEASE)) +# Add debug flags +if (BUILD_TARGET STREQUAL "DEBUG") if (CMAKE_C_COMPILER_ID STREQUAL "GNU") add_compile_options(-O0) add_compile_options(-ggdb) @@ -32,17 +32,28 @@ if ((DEBUG) AND (NOT RELEASE)) endif() -if ((NOT DEBUG) AND (RELEASE)) +# Add release flags +if (BUILD_TARGET STREQUAL "RELEASE") message(STATUS "Enabled release with -O3") add_compile_options(-O3) + add_compile_options(-s) endif() -if (BUILD32) - message(STATUS "Enabled 32-bit mode") +# Process build architectures +if (BUILD_ARCH STREQUAL "amd64") + message(STATUS "Build amd64 binary") + add_compile_options(-m64) + add_link_options(-m64) + set(CMAKE_LIBRARY_PATH /usr/lib/x86_64-linux-gnu) + include_directories(BEFORE /usr/include/x86_64-linux-gnu) +elseif (BUILD_ARCH STREQUAL "i386") + message(STATUS "Build i386 binary") add_compile_options(-m32) add_link_options(-m32) - SET(CMAKE_LIBRARY_PATH "/usr/lib/i386-linux-gnu") + set(CMAKE_LIBRARY_PATH /usr/lib/i386-linux-gnu) include_directories(BEFORE /usr/include/i386-linux-gnu) +else() + message(FATAL_ERROR "Unknown building architecture ${BUILD_ARCH}") endif() # Source code paths @@ -70,14 +81,14 @@ install(TARGETS ${PROJECT_NAME} DESTINATION .) message(STATUS "WARNING! Installation prefix ${CMAKE_INSTALL_PREFIX}") # Cleanup cache -unset(DEBUG CACHE) -unset(RELEASE CACHE) -unset(BUILD32 CACHE) unset(INSTALL_PREFIX CACHE) +unset(BUILD_ARCH CACHE) +unset(BUILD_TARGET CACHE) unset(CMAKE_LIBRARY_PATH CACHE) unset(CMAKE_INSTALL_PREFIX CACHE) +# Clear OpenSSL references unset(OPENSSL_FOUND CACHE) unset(OPENSSL_INCLUDE_DIR CACHE) unset(OPENSSL_CRYPTO_LIBRARY CACHE) diff --git a/README.md b/README.md index 38766cc..32146a1 100644 --- a/README.md +++ b/README.md @@ -39,6 +39,52 @@ For building required *OpenSSL >= 3.0 or OpenSSL 1.1.1* library. Use cmake to ge - [Running CMake with OpenSSL](https://stackoverflow.com/a/45548831) - [How to enable legacy provider?](https://github.com/openssl/openssl/issues/20112) +**Basic setup** + +Cloning repository + +```sh +$ git clone https://github.com/Retr0-code/hash-dumper +$ git submodule update --init +``` + +---- + +If You work alone + +```sh +$ git branch dev_ +$ git checkout dev_ +$ git push -u origin dev_ +``` + +**OR** + +If You work in a small team + +```sh +$ git checkout dev_ +$ git pull +``` + + +**Building using cmake** + +Use *BUILD_ARCH* parameter to specify architecture of output binary + +*Architectures:* + + - amd64 (default); + - i386; + +Use *BUILD_TARGET* parameter to specify compiling configuration + +*Configurations:* + + - RELEASE (default); + - DEBUG; + + ## Manual You can use this utility to dump NTLMv1/2 hashes from already compromised host by using `--realtime` flag