Skip to content

Commit 8fda365

Browse files
committed
Added hooking detection in auth.cpp for the req ( Request ) function
1 parent 3ef0703 commit 8fda365

File tree

2 files changed

+40
-0
lines changed

2 files changed

+40
-0
lines changed

Security.hpp

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,25 @@
55
#include <aclapi.h>
66
#include <bcrypt.h>
77

8+
9+
auto is_hooked = [](void* fn) -> bool {
10+
if (!fn) return true;
11+
12+
13+
BYTE bytes[5];
14+
memcpy(bytes, fn, 5);
15+
16+
17+
if (bytes[0] == 0xE9 || bytes[0] == 0xE8)
18+
return true;
19+
20+
if (bytes[0] == 0xFF && bytes[1] == 0x25)
21+
return true;
22+
23+
return false;
24+
};
25+
26+
827
// code submitted in pull request from https://github.com/sbtoonz, authored by KeePassXC https://github.com/keepassxreboot/keepassxc/blob/dab7047113c4ad4ffead944d5c4ebfb648c1d0b0/src/core/Bootstrap.cpp#L121
928
inline bool LockMemAccess()
1029
{

auth.cpp

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1694,6 +1694,27 @@ std::string KeyAuth::api::req(const std::string& data, const std::string& url) {
16941694
signature.clear();
16951695
signatureTimestamp.clear();
16961696

1697+
1698+
if (is_hooked((void*)&curl_easy_perform))
1699+
{
1700+
error("Hook detected in curl_easy_perform");
1701+
}
1702+
1703+
if (is_hooked((void*)&curl_easy_init))
1704+
{
1705+
error("Hook detected in curl_easy_init");
1706+
}
1707+
1708+
if (is_hooked((void*)&curl_easy_setopt))
1709+
{
1710+
error("Hook detected in curl_easy_setopt");
1711+
}
1712+
1713+
if (is_hooked((void*)&curl_easy_cleanup))
1714+
{
1715+
error("Hook detected in curl_easy_cleanup");
1716+
}
1717+
16971718
CURL* curl = curl_easy_init();
16981719
if (!curl) {
16991720
error(XorStr("CURL Initialization Failed!"));

0 commit comments

Comments
 (0)