IMECoreKeylogger is a research project dedicated to capturing Unicode character inputs (e.g., Chinese, Japanese) that traditional keyloggers often fail to detect. In Windows, especially for non-Latin input, characters may be composed via IME (Input Method Editor) or other frameworks like TSF (Text Services Framework), making them harder to intercept with standard keylogging techniques.
Disclaimer: This project is for research and educational purposes only. The author(s) do not assume responsibility for any malicious use of the code or ideas presented here.
Traditional keyloggers typically rely on capturing keystrokes through the Win32 message loop, which can be insufficient for capturing Unicode inputs from IMEs or TSF. IMECoreKeylogger aims to explore and demonstrate various techniques to intercept these inputs.
Why is it challenging to log Unicode inputs?
- When using IME or TSF, keystrokes are not immediately passed to the application as characters.
- Multiple keystrokes may be combined into a single character (e.g., composing Chinese characters via pinyin input).
- TSF abstracts input handling, making it difficult to intercept at the application level.
Windows primarily handles text input through three major layers:
-
Win32 Message Loop
- Typically uses
GetMessageandDispatchMessageto pass messages to aWindowProc. - Messages like
WM_CHARorWM_KEYDOWNare commonly intercepted here.
- Typically uses
-
IME (Input Method Editor)
- Processes keystrokes for complex character composition (e.g., Chinese, Japanese).
- Key events pass through:
WM_IME_STARTCOMPOSITIONWM_IME_COMPOSITIONWM_IME_ENDCOMPOSITION
- Finally,
WM_CHARsends the composed Unicode character to the application.
-
TSF (Text Services Framework)
- Integrates multiple text services system-wide.
- The TSF Manager coordinates text services (TIPs, including IME) and the application’s Text Store.
- Because TSF bypasses the direct message loop in many cases, conventional keylogging techniques may fail to capture these inputs.
The data flow can be segmented into three layers:
- Application: The end-user application.
- IMM (Input Method Manager): Manages IME communication.
- IME (Input Method Editor): Responsible for converting raw keystrokes to composed text.
IMECoreKeylogger explores several potential methods to capture Unicode inputs:
-
Injecting into the Foreground Application
- Inject a DLL into the foreground window to hook messages like
WM_CHAR/WM_IME_CHAR. - Pros: Straightforward to implement.
- Cons: Continuous injection may be detected by security software or the user.
- Inject a DLL into the foreground window to hook messages like
-
Driver-Level Interception
- Utilize a driver (potentially hooking into IMM) at ring0 to intercept
WM_CHAR. - Pros: More robust and harder to circumvent.
- Cons: Requires in-depth Windows driver development knowledge.
- Utilize a driver (potentially hooking into IMM) at ring0 to intercept
-
Replacing IME Files or user32.dll
- Replace or modify system IME libraries (or user32.dll) to intercept Unicode inputs.
- Pros: Centralized interception.
- Cons: Complex, OS-specific, and very high risk for system instability or detection.
Our current proof-of-concept focuses on the first approach—injecting into the foreground application to capture messages related to Unicode input. The prototype module can be found in the ForegroundWindowLogger directory.
Readme.md is translated by chat-gpt. Please raise an issue if you have any questions.