-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
21 changed files
with
560 additions
and
346 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
# Hermit Script | ||
|
||
## Calculate Module Hashes | ||
|
||
```sh | ||
g++ -o calc_hash_module calc_hash_module.cpp | ||
./calc_hash_module | ||
``` | ||
|
||
## Calculate Function Hashes | ||
|
||
```sh | ||
python3 calc_hash_func.py | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
#include <iostream> | ||
#include <ctype.h> | ||
#include <iomanip> | ||
#include <map> | ||
#include <string> | ||
#include <cstring> | ||
|
||
#define HASH_IV 0x35 | ||
#define RANDOM_ADDR 0xab10f29f | ||
|
||
char* toUpper(const char* str) | ||
{ | ||
size_t dwLen = strlen(str); | ||
char result[dwLen + 1]; | ||
|
||
for (size_t i = 0; i < dwLen; i++) | ||
{ | ||
result[i] = toupper(str[i]); | ||
} | ||
result[dwLen] = '\0'; | ||
|
||
return strdup(result); | ||
} | ||
|
||
unsigned long calcHash(const char* str) | ||
{ | ||
unsigned long hash = HASH_IV; | ||
const unsigned char* s = (const unsigned char*)str; | ||
|
||
while (*s) | ||
{ | ||
hash = hash * RANDOM_ADDR + (*s); | ||
*s++; | ||
} | ||
|
||
return hash & 0xFFFFFFFF; | ||
} | ||
|
||
int main() | ||
{ | ||
std::map<std::string, unsigned long> myMap; | ||
|
||
char modules[2][30] = {"kernel32.dll", "ntdll.dll"}; | ||
|
||
for (int i = 0; i < 2; i++) | ||
{ | ||
char* moduleUpper = modules[i]; | ||
|
||
// Make a key | ||
char buffer[100]; | ||
std::sprintf(buffer, "#define HASH_MODULE_%s", moduleUpper); | ||
std::string key(buffer); | ||
// Remvoe '.DLL' from the key. | ||
key = key.substr(0, key.length() - 4); | ||
|
||
myMap[key] = calcHash(modules[i]); | ||
} | ||
|
||
// Get max key length for the map. | ||
size_t maxLen = 0; | ||
for (const auto& pair : myMap) | ||
{ | ||
size_t keyLen = pair.first.length(); | ||
if (keyLen > maxLen) | ||
{ | ||
maxLen = keyLen; | ||
} | ||
} | ||
|
||
// Output | ||
for (const auto& pair : myMap) | ||
{ | ||
printf("%-*s 0x%lx\n", static_cast<int>(maxLen), pair.first.c_str(), pair.second); | ||
} | ||
} |
Oops, something went wrong.