Skip to content

Commit 49bde7c

Browse files
Merge pull request #5 from leonav-unizar/interrogate-scan
Interrogate scan
2 parents d795f2b + 6a5f669 commit 49bde7c

File tree

5 files changed

+368
-16
lines changed

5 files changed

+368
-16
lines changed

CMakeLists.txt

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
cmake_minimum_required(VERSION 3.15)
22

33
set(CMAKE_SYSTEM_NAME Windows)
4-
project(KeyReaper VERSION 1.5.0)
4+
project(KeyReaper VERSION 1.6.0)
55
set(PROGRAM_NAME "KeyReaper")
66

77
set(MSVC True)
@@ -27,19 +27,13 @@ endif()
2727

2828
## Ease for includes
2929
add_library(common_includes INTERFACE)
30+
add_library(interrogate_include INTERFACE)
3031
target_include_directories(common_includes INTERFACE ${PROJECT_SOURCE_DIR}/include/keyreaper)
32+
target_include_directories(interrogate_include INTERFACE ${PROJECT_SOURCE_DIR}/include/interrogate)
3133

3234
# 3rd parties
3335
include(FetchContent)
3436

35-
# Interrogate
36-
FetchContent_Declare(
37-
interrogate
38-
URL https://sourceforge.net/projects/interrogate/files/interrogate/0.0.4/interrogate-0.0.4-source.tar.gz/download
39-
DOWNLOAD_EXTRACT_TIMESTAMP TRUE
40-
)
41-
FetchContent_MakeAvailable(interrogate)
42-
4337
# JSON library
4438
FetchContent_Declare(
4539
json
@@ -91,6 +85,7 @@ add_executable(${EXECUTABLE_NAME}
9185
${SOURCE_BASE_DIR}/config.cc
9286
${SOURCE_BASE_DIR}/program_result.cc
9387
${SOURCE_BASE_DIR}/key.cc
88+
${SOURCE_BASE_DIR}/interrogate/aes.cc
9489
${SOURCE_BASE_DIR}/scanners.cc
9590
${SOURCE_BASE_DIR}/key_scanner.cc
9691
${SOURCE_BASE_DIR}/injection/custom_ipc.cc
@@ -100,7 +95,7 @@ add_executable(${EXECUTABLE_NAME}
10095
)
10196

10297
# Link nlohmann/json to your executable
103-
target_link_libraries(${EXECUTABLE_NAME} PRIVATE nng nlohmann_json CLI11::CLI11 tomlplusplus::tomlplusplus common_includes ${TITAN_ENGINE_LIB})
98+
target_link_libraries(${EXECUTABLE_NAME} PRIVATE nng nlohmann_json CLI11::CLI11 tomlplusplus::tomlplusplus interrogate_include common_includes ${TITAN_ENGINE_LIB})
10499
# Executable output
105100
set_target_properties(${EXECUTABLE_NAME} PROPERTIES OUTPUT_NAME "${EXECUTABLE_NAME}_${ARCHITECTURE_APPEND}")
106101
# TitanEngine DLL dependency

include/interrogate/aes.h

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
#ifndef AES_INTERROGATE_H
2+
#define AES_INTERROGATE_H
3+
4+
#include <windows.h>
5+
#include <vector>
6+
#include <algorithm>
7+
8+
namespace interrogate {
9+
10+
typedef struct {
11+
unsigned int keytype, /* Keytype to be searched for */
12+
keysize, /* The key size that are to be searched for */
13+
wsize, /* The search window size */
14+
nofs, /* The number of symbols in our alphabet */
15+
bitmode, /* Bitmode boolean */
16+
verbose, /* Verbose mode */
17+
naivemode, /* Calculate true entropy */
18+
quickmode, /* Non-overlapping entropy windows */
19+
interval, /* Only search in interval (boolean) */
20+
from, /* Starting point */
21+
to, /* End point */
22+
cr3, /* CR3 offset in case recunstruction of mem */
23+
filelen, /* Input file length in bytes */
24+
bytethreshold; /* Threshold for bytecount */
25+
FILE *output_fp; /* Pointer to output file for statistics */
26+
float threshold; /* Entropy threshold */
27+
long count; /* Number of keys found */
28+
}
29+
interrogate_context;
30+
31+
void rotate(unsigned char *in);
32+
unsigned char rcon(unsigned char in);
33+
unsigned char gmul(unsigned char a, unsigned char b);
34+
unsigned char gmul_inverse(unsigned char in);
35+
unsigned char sbox(unsigned char in);
36+
void schedule_core(unsigned char *in, unsigned char i);
37+
void expand_key(unsigned char *in);
38+
void expand_key_192(unsigned char *in);
39+
void expand_key_256(unsigned char *in);
40+
41+
std::vector<std::vector<BYTE>> aes_search(interrogate_context* ctx, unsigned char* buffer);
42+
43+
} // namespace interrogate
44+
45+
#endif // AES_INTERROGATE_H

src/custom-ransomware/basic-ransomware.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,6 @@ void GenerateKeyChunck(HCRYPTPROV provider, ALG_ID alg, DWORD number_of_keys) {
277277
if (alg == CALG_RSA_KEYX || alg == CALG_RSA_SIGN) {
278278
printf(" [i] Asymmetric algorithm detected\n");
279279
data_len = 2048;
280-
getchar();
281280

282281
result = CryptExportKey(key, NULL, PRIVATEKEYBLOB, 0, buffer2, &data_len);
283282
if (result == 0) printf(" [x] Could not export the private pair\n");
@@ -450,7 +449,8 @@ int main(int argc, char* argv[]) {
450449

451450
// CheckAllBlockSizes(phProv);
452451
// GenerateKeyWithIV(phProv);
453-
GenerateKeyChunck(phProv, CALG_RSA_KEYX, 1);
452+
GenerateKeyChunck(phProv, CALG_AES_128, 1);
453+
getchar();
454454

455455
// create a hash object from the CSP (cryptographic service provider)
456456
HCRYPTHASH hHash;

0 commit comments

Comments
 (0)