@@ -122,6 +122,8 @@ void heartbeat_thread(KeyAuth::api* instance);
122122void snapshot_text_hashes ();
123123bool text_hashes_ok ();
124124bool detour_suspect (const uint8_t * p);
125+ static bool entry_is_jmp_or_call (const void * fn);
126+ static bool entry_is_reg_jump (const void * fn);
125127bool import_addresses_ok ();
126128void snapshot_text_page_protections ();
127129bool text_page_protections_ok ();
@@ -3106,6 +3108,26 @@ bool detour_suspect(const uint8_t* p)
31063108 return false ;
31073109}
31083110
3111+ static bool entry_is_jmp_or_call (const void * fn)
3112+ {
3113+ if (!fn) return false ;
3114+ const uint8_t * p = reinterpret_cast <const uint8_t *>(fn);
3115+ if (p[0 ] == 0xE9 ) return true ; // jmp rel32
3116+ if (p[0 ] == 0xFF && p[1 ] == 0x25 ) return true ; // jmp [rip+imm32]
3117+ if (p[0 ] == 0xE8 ) return true ; // call rel32
3118+ if (p[0 ] == 0x68 && p[5 ] == 0xC3 ) return true ; // push imm32; ret
3119+ return false ;
3120+ }
3121+
3122+ static bool entry_is_reg_jump (const void * fn)
3123+ {
3124+ if (!fn) return false ;
3125+ const uint8_t * p = reinterpret_cast <const uint8_t *>(fn);
3126+ if (p[0 ] == 0xFF && (p[1 ] & 0xF8 ) == 0xE0 ) return true ; // jmp reg
3127+ if (p[0 ] == 0xFF && (p[1 ] & 0xF8 ) == 0xD0 ) return true ; // call reg
3128+ return false ;
3129+ }
3130+
31093131static bool addr_in_module (const void * addr, const wchar_t * module_name)
31103132{
31113133 HMODULE mod = module_name ? GetModuleHandleW (module_name) : GetModuleHandle (nullptr );
@@ -3381,6 +3403,16 @@ std::string KeyAuth::api::req(std::string data, const std::string& url) {
33813403 !func_region_ok (reinterpret_cast <const void *>(&check_section_integrity))) {
33823404 error (XorStr (" function region check failed, possible hook detected." ));
33833405 }
3406+ if (entry_is_jmp_or_call (reinterpret_cast <const void *>(&VerifyPayload)) ||
3407+ entry_is_jmp_or_call (reinterpret_cast <const void *>(&checkInit)) ||
3408+ entry_is_jmp_or_call (reinterpret_cast <const void *>(&integrity_check)) ||
3409+ entry_is_jmp_or_call (reinterpret_cast <const void *>(&check_section_integrity)) ||
3410+ entry_is_reg_jump (reinterpret_cast <const void *>(&VerifyPayload)) ||
3411+ entry_is_reg_jump (reinterpret_cast <const void *>(&checkInit)) ||
3412+ entry_is_reg_jump (reinterpret_cast <const void *>(&integrity_check)) ||
3413+ entry_is_reg_jump (reinterpret_cast <const void *>(&check_section_integrity))) {
3414+ error (XorStr (" entry-point hook detected (jmp/call stub)." ));
3415+ }
33843416 if (suspicious_processes_present () || suspicious_modules_present () || suspicious_windows_present ()) {
33853417 error (XorStr (" debugger/emulator/proxy detected." ));
33863418 }
@@ -4010,6 +4042,16 @@ void checkInit() {
40104042 !detour_suspect (reinterpret_cast <const uint8_t *>(&VerifyPayload)) &&
40114043 !detour_suspect (reinterpret_cast <const uint8_t *>(&checkInit)) &&
40124044 !detour_suspect (reinterpret_cast <const uint8_t *>(&error)) &&
4045+ !entry_is_jmp_or_call (reinterpret_cast <const void *>(&VerifyPayload)) &&
4046+ !entry_is_jmp_or_call (reinterpret_cast <const void *>(&checkInit)) &&
4047+ !entry_is_jmp_or_call (reinterpret_cast <const void *>(&error)) &&
4048+ !entry_is_jmp_or_call (reinterpret_cast <const void *>(&integrity_check)) &&
4049+ !entry_is_jmp_or_call (reinterpret_cast <const void *>(&check_section_integrity)) &&
4050+ !entry_is_reg_jump (reinterpret_cast <const void *>(&VerifyPayload)) &&
4051+ !entry_is_reg_jump (reinterpret_cast <const void *>(&checkInit)) &&
4052+ !entry_is_reg_jump (reinterpret_cast <const void *>(&error)) &&
4053+ !entry_is_reg_jump (reinterpret_cast <const void *>(&integrity_check)) &&
4054+ !entry_is_reg_jump (reinterpret_cast <const void *>(&check_section_integrity)) &&
40134055 prologues_ok () &&
40144056 func_region_ok (reinterpret_cast <const void *>(&VerifyPayload)) &&
40154057 func_region_ok (reinterpret_cast <const void *>(&checkInit)) &&
0 commit comments