Skip to content

Commit f1df684

Browse files
committed
Merge branch 'main' into interrogate-scan
2 parents 50d85e2 + d795f2b commit f1df684

30 files changed

+1304
-967
lines changed

CMakeLists.txt

Lines changed: 32 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
cmake_minimum_required(VERSION 3.10)
1+
cmake_minimum_required(VERSION 3.15)
22

33
set(CMAKE_SYSTEM_NAME Windows)
4-
project(Craperv2 VERSION 1.0.1)
5-
set(PROGRAM_NAME "CRAPER")
4+
project(KeyReaper VERSION 1.5.0)
5+
set(PROGRAM_NAME "KeyReaper")
66

77
set(MSVC True)
88
set(CMAKE_CXX_STANDARD 20)
@@ -27,7 +27,7 @@ endif()
2727

2828
## Ease for includes
2929
add_library(common_includes INTERFACE)
30-
target_include_directories(common_includes INTERFACE ${PROJECT_SOURCE_DIR}/include/craper)
30+
target_include_directories(common_includes INTERFACE ${PROJECT_SOURCE_DIR}/include/keyreaper)
3131
target_include_directories(interrogate_include INTERFACE ${PROJECT_SOURCE_DIR}/include/interrogate)
3232

3333
# 3rd parties
@@ -60,6 +60,21 @@ FetchContent_Declare(
6060
)
6161
FetchContent_MakeAvailable(cli11_proj)
6262

63+
FetchContent_Declare(
64+
tomlplusplus
65+
GIT_REPOSITORY https://github.com/marzer/tomlplusplus.git
66+
GIT_TAG v3.4.0
67+
)
68+
FetchContent_MakeAvailable(tomlplusplus)
69+
70+
FetchContent_Declare(
71+
nng
72+
GIT_REPOSITORY https://github.com/nanomsg/nng.git
73+
GIT_TAG v1.10.1
74+
)
75+
FetchContent_MakeAvailable(nng)
76+
target_include_directories(common_includes INTERFACE ${nng_SOURCE_DIR}/include)
77+
6378
# TitanEngine
6479
set(TITAN_ENGINE_DIR "${CMAKE_SOURCE_DIR}/TitanEngine")
6580
set(TITAN_ENGINE_DLL "${TITAN_ENGINE_DIR}/TitanEngine_${ARCHITECTURE_APPEND}.dll")
@@ -68,7 +83,7 @@ include_directories(${TITAN_ENGINE_DIR})
6883

6984
### Binaries #############
7085

71-
set(EXECUTABLE_NAME "craper")
86+
set(EXECUTABLE_NAME "KeyReaper")
7287

7388
# Set version number
7489
configure_file(
@@ -78,17 +93,20 @@ configure_file(
7893
)
7994

8095
add_executable(${EXECUTABLE_NAME}
96+
${SOURCE_BASE_DIR}/config.cc
8197
${SOURCE_BASE_DIR}/program_result.cc
8298
${SOURCE_BASE_DIR}/key.cc
8399
${interrogate_SOURCE_DIR}/aes.c
84100
${SOURCE_BASE_DIR}/scanners.cc
85101
${SOURCE_BASE_DIR}/key_scanner.cc
102+
${SOURCE_BASE_DIR}/injection/custom_ipc.cc
103+
${SOURCE_BASE_DIR}/injection/injector.cc
86104
${SOURCE_BASE_DIR}/process_capturer.cc
87105
${CMAKE_CURRENT_BINARY_DIR}/main.cc
88106
)
89107

90108
# Link nlohmann/json to your executable
91-
target_link_libraries(${EXECUTABLE_NAME} PRIVATE nlohmann_json CLI11::CLI11 common_includes interrogate_include ${TITAN_ENGINE_LIB})
109+
target_link_libraries(${EXECUTABLE_NAME} PRIVATE nng nlohmann_json CLI11::CLI11 tomlplusplus::tomlplusplus interrogate_include common_includes ${TITAN_ENGINE_LIB})
92110
# Executable output
93111
set_target_properties(${EXECUTABLE_NAME} PROPERTIES OUTPUT_NAME "${EXECUTABLE_NAME}_${ARCHITECTURE_APPEND}")
94112
# TitanEngine DLL dependency
@@ -101,6 +119,7 @@ add_custom_command(TARGET ${EXECUTABLE_NAME} POST_BUILD
101119
set(EXECUTABLE_NAME "ransy")
102120
add_executable(${EXECUTABLE_NAME}
103121
${SOURCE_BASE_DIR}/key.cc
122+
${SOURCE_BASE_DIR}/cryptoapi.cc
104123
${SOURCE_BASE_DIR}/program_result.cc
105124
${SOURCE_BASE_DIR}/custom-ransomware/basic-ransomware.cc
106125
)
@@ -126,39 +145,22 @@ set_target_properties(${EXECUTABLE_NAME} PROPERTIES OUTPUT_NAME "${EXECUTABLE_NA
126145

127146

128147
# --- Injected DLL -----------------
129-
set(LIBRARY_NAME "evil")
148+
set(LIBRARY_NAME "injectable_server")
130149
add_library(${LIBRARY_NAME} SHARED
131150
${SOURCE_BASE_DIR}/program_result.cc
132-
${SOURCE_BASE_DIR}/injection/interproc_coms.cc
151+
${SOURCE_BASE_DIR}/cryptoapi.cc
152+
${SOURCE_BASE_DIR}/injection/custom_ipc.cc
133153
${SOURCE_BASE_DIR}/injection/cryptoapi_key_exporter.cc
134154
)
135-
target_link_libraries(${LIBRARY_NAME} PRIVATE common_includes)
155+
target_link_libraries(${LIBRARY_NAME} PRIVATE nng common_includes)
136156
set_target_properties(${LIBRARY_NAME} PROPERTIES OUTPUT_NAME "${LIBRARY_NAME}_${ARCHITECTURE_APPEND}")
137157

138158
# --- Test Injector ----------------
139159
set(EXECUTABLE_NAME "injector")
140160
add_executable(${EXECUTABLE_NAME}
141161
${SOURCE_BASE_DIR}/program_result.cc
142-
${SOURCE_BASE_DIR}/injection/interproc_coms.cc
143-
${SOURCE_BASE_DIR}/injection/injector.cc
162+
${SOURCE_BASE_DIR}/injection/custom_ipc.cc
163+
${SOURCE_BASE_DIR}/injection/injector_program.cc
144164
)
145-
target_link_libraries(${EXECUTABLE_NAME} PRIVATE common_includes)
146-
set_target_properties(${EXECUTABLE_NAME} PROPERTIES OUTPUT_NAME "${EXECUTABLE_NAME}_${ARCHITECTURE_APPEND}")
147-
148-
set(EXECUTABLE_NAME "test_client")
149-
add_executable(${EXECUTABLE_NAME}
150-
${SOURCE_BASE_DIR}/program_result.cc
151-
${SOURCE_BASE_DIR}/injection/interproc_coms.cc
152-
${SOURCE_BASE_DIR}/injection/test/test_client.cc
153-
)
154-
target_link_libraries(${EXECUTABLE_NAME} PRIVATE common_includes)
155-
set_target_properties(${EXECUTABLE_NAME} PROPERTIES OUTPUT_NAME "${EXECUTABLE_NAME}_${ARCHITECTURE_APPEND}")
156-
157-
set(EXECUTABLE_NAME "test_server")
158-
add_executable(${EXECUTABLE_NAME}
159-
${SOURCE_BASE_DIR}/program_result.cc
160-
${SOURCE_BASE_DIR}/injection/interproc_coms.cc
161-
${SOURCE_BASE_DIR}/injection/test/test_server.cc
162-
)
163-
target_link_libraries(${EXECUTABLE_NAME} PRIVATE common_includes)
165+
target_link_libraries(${EXECUTABLE_NAME} PRIVATE nng common_includes)
164166
set_target_properties(${EXECUTABLE_NAME} PROPERTIES OUTPUT_NAME "${EXECUTABLE_NAME}_${ARCHITECTURE_APPEND}")

README.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -68,9 +68,9 @@ It is split into two main subcommands (so far) which allows us to scan for keys
6868
and managing processes' execution `proc`. You can invoke the program with the help
6969
flag for further information.
7070
```
71-
PS C:\> .\craper_x86.exe --help
72-
CRAPER: cryptographic key recovery for live processes
73-
Usage: C:\craper_x86.exe [OPTIONS] SUBCOMMAND
71+
PS C:\> .\KeyReaper_x86.exe --help
72+
KeyReaper: cryptographic key recovery for live processes
73+
Usage: C:\KeyReaper_x86.exe [OPTIONS] SUBCOMMAND
7474
7575
Options:
7676
-h,--help Print this help message and exit
@@ -83,9 +83,9 @@ Subcommands:
8383
Subcommands have also a help menu with information.
8484

8585
```
86-
PS C:\> .\craper_x86.exe scan --help
86+
PS C:\> .\KeyReaper_x86.exe scan --help
8787
Scan for keys in the process
88-
Usage: C:\craper_x86.exe scan [OPTIONS]
88+
Usage: C:\KeyReaper_x86.exe scan [OPTIONS]
8989
9090
Options:
9191
-h,--help Print this help message and exit
@@ -102,7 +102,7 @@ Options:
102102

103103
An example execution:
104104
```
105-
PS C:\> .\craper_x86.exe scan -p 1717 -b ntpause -o "keys.json" --scanners crapi roundkey
105+
PS C:\> .\KeyReaper_x86.exe scan -p 1717 -b ntpause -o "keys.json" --scanners crapi roundkey
106106
```
107107

108108
## Library

include/craper/injection/interproc_coms.h

Lines changed: 0 additions & 84 deletions
This file was deleted.

include/keyreaper/config.h

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
#ifndef CONFIG_H_
2+
#define CONFIG_H_
3+
4+
#include <toml++/toml.hpp>
5+
#include <string>
6+
#include <program_result.h>
7+
8+
class Config {
9+
public:
10+
static Config& Instance(); // Singleton accessor
11+
12+
error_handling::ProgramResult Load(const std::string& filename);
13+
14+
std::wstring GetKeyExtractorDLLPath() const;
15+
16+
private:
17+
Config() = default; // Private constructor
18+
~Config() = default;
19+
20+
Config(const Config&) = delete;
21+
Config& operator=(const Config&) = delete;
22+
23+
std::string key_extractor_dll_;
24+
};
25+
26+
#endif // CONFIG_H_
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,26 @@ struct HCRYPTKEY {
5757
magic_s *magic; // XOR-ed
5858
};
5959

60+
/**
61+
* This function performs the necessary indirections
62+
* to get the pointer to the CRYPTKEY struct from
63+
* the HCRYPTKEY struct.
64+
* DON'T use it on a dump, as it does not calculate
65+
* the offsets.
66+
*/
67+
cryptoapi::key_data_s* GetKeyStruct(::HCRYPTKEY key);
68+
69+
/**
70+
* This function sets the exportable bit of an HCRYPTKEY
71+
* to be able to export it with CryptExportKey even if
72+
* it was not generated with the CRYPT_EXPORTABLE flag set.
73+
* Will work with any type of key, but bare in mind that
74+
* private pairs check other things too.
75+
* DO NOT use it on a dump, as it does not calculate
76+
* the offsets.
77+
*/
78+
void ForceExportBit(::HCRYPTKEY key);
79+
6080
} // namespace cryptoapi
6181
} // namespace key_scanner
6282

0 commit comments

Comments
 (0)