offensive-keylogger-arch
Skill1 starsChanged 50 days agoMITView on GitHub
Low-level keylogger architecture design: kernel driver hooks (WH_KEYBOARD_LL, SetWindowsHookEx), ETW-based input capture, user-mode vs kernel-mode approaches, stealth techniques, and data exfiltration. Use for understanding input capture mechanisms, EDR evasion research, or malware architecture analysis.
2 other projects use a version of this, 2 of them edited.
Adopted by
Most recently taken up by
- ajtazer/heckitedited, first seen Sep 11, 2026
- SnailSploit/Claude-Rededited, first seen Aug 6, 2026
Other versions2 projects use a version of this.
Word for word · 0
None found.
Edited · 2
- SnailSploit/Claude-Red★ 7.5k93% same
- ajtazer/heckit★ 293% same
Wrote their own version · 0
None found.
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository78 other files it gives its agents.
- offensive-active-directorySkill
- offensive-netexecSkill
- offensive-ai-securitySkill
- offensive-api-abuseSkill
- offensive-api-securitySkill
- offensive-jwtSkill
- offensive-oauthSkill
- offensive-cicd-pipelineSkill
- offensive-cicd-secretsSkill
- offensive-cloudSkill
- offensive-container-escapeSkill
- offensive-k8s-attacksSkill
- offensive-crypto-attacksSkill
- offensive-tls-attacksSkill
- offensive-basic-exploitationSkill
- offensive-crash-analysisSkill
- offensive-exploit-dev-courseSkill
- offensive-exploit-developmentSkill
- offensive-mitigationsSkill
- offensive-toctouSkill
- offensive-anti-forensicsSkill
- offensive-c2-frameworksSkill
- offensive-bug-identificationSkill
- offensive-fuzzing-courseSkill
- offensive-fuzzingSkill
- offensive-vuln-classesSkill
- offensive-advanced-redteamSkill
- offensive-edr-evasionSkill
- offensive-initial-accessSkill
- offensive-shellcodeSkill
- offensive-windows-boundariesSkill
- offensive-windows-mitigationsSkill
- offensive-iotSkill
- offensive-mobileSkill
- offensive-network-attacksSkill
- offensive-data-exfiltrationSkill
- offensive-lateral-movementSkill
- offensive-persistenceSkill
- offensive-linux-privescSkill
- offensive-windows-privescSkill
- offensive-osint-methodologySkill
- offensive-osintSkill
- offensive-phishingSkill
- offensive-social-engineeringSkill
- offensive-dependency-confusionSkill
- offensive-supply-chainSkill
- offensive-fast-checkingSkill
- offensive-reportingSkill
- offensive-business-logicSkill
- offensive-deserializationSkill
- offensive-file-uploadSkill
- offensive-graphqlSkill
- offensive-idorSkill
- offensive-open-redirectSkill
- offensive-parameter-pollutionSkill
- offensive-race-conditionSkill
- offensive-rceSkill
- offensive-request-smugglingSkill
- offensive-sqliSkill
- offensive-ssrfSkill
- The first 60 shown.
The file
We split this skill into the rules it gives an agent
10 rules. About 0 are common, 4 are distinctive, and 6 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈4
Distinctive · estimate
This author's own choices. Worth a look.
6
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 23
After Vista: The target process is added to a pending-load list inside win32k.
- Very specific: line 27
When the monitored event occurs (key press, window activation, etc.), win32k walks the hook chain inside the thread that owns the input …
- Distinctive: line 28
If the hook procedure lives in that process, the kernel simply calls the address inside the injected DLL.
- Very specific: line 29
If the procedure lives in another process (low-level case), the kernel marshals the raw parameters (KBDLLHOOKSTRUCT / MSLLHOOKSTRUCT) into …
- Distinctive: line 36
Low-level hooks: look stealthy because no foreign code is mapped, but they pin the installing thread and are trivially detected by their …
- Very specific: line 74
Start a background thread in our process or implement a PeekMessage / GetMessage loop.
- Very specific: line 75
Create a zero-sized message-only window (HWND_MESSAGE).
- Distinctive: line 106
Do AVs/EDRs really monitor it though?
- Distinctive: line 127
Not much else to say.
- Very specific: line 160
Use NtUserBuildHwndList/EnumWindows and re-implement the z-order heuristic to generate the list of all handles to all windows and call …
≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Case study of different keylogger implementations, how to implement them and their individual IOCs.
SetWindowHookEx
Majority of malware uses user32.dll!SetWindowHookEx to create a global hook event. this modifies an internal structure in win32k.sys.
Internally, SetWindowsHookEx is just a user-mode wrapper around NtUserSetWindowsHookEx (which itself wraps around zzzzNtUserSetWindowsHookEx) in win32k.sys. What happens after you call it depends on the hook type you request but the sequence is always the same four steps:
- Validate and allocate a hook record
win32k.syscreates an internalHOOKstructure, fills in the filter type, module handle, thread/desktop IDs, and inserts the structure at the head of the global hook chain for that type - Decide whether the hook procedure must live in the target process
- Low-level hooks (
WH_KEYBOARD_LL,WH_MOUSE_LL)
– NO injection.
– The system leaves the hook DLL in the original caller’s address space and simply delivers the event to that process via an internalWM_*message posted to its hidden “ghost” window . - All other global hooks (
WH_KEYBOARD,WH_CBT,WH_GETMESSAGE, …)
– YES injection required.
– For every process that satisfies the filter (same desktop, matching bitness),- In/before Vista:
win32kqueues an asynchronous load request tocsrss.exe, which in turn callsLoadLibraryExinside the target process, mapping the hook DLL and fixing up its entry point. - After Vista: The target process is added to a pending-load list inside
win32k; the first user-mode exit from kernel to that process takes the APC and callsLdrLoadDlldirectly. – The first time the target thread is about to return to user mode, the kernel APCs the loader, so the DLL’sDllMainruns in the context of the victim process.
- In/before Vista:
- Low-level hooks (
- Event routing at runtime
When the monitored event occurs (key press, window activation, etc.),win32kwalks the hook chain inside the thread that owns the input queue.- If the hook procedure lives in that process, the kernel simply calls the address inside the injected DLL.
- If the procedure lives in another process (low-level case), the kernel marshals the raw parameters (
KBDLLHOOKSTRUCT/MSLLHOOKSTRUCT) into an internal message and posts it to the installing thread’s message queue.
That thread must keep pumping messages; otherwise, the system blocks all further input for the desktop, which is why low-level hooks are so easy to detect by their side-effect on system responsiveness.
- Mandatory
CallNextHookEx
Each hook handler must callCallNextHookExto pass control down the chain.
Internally,CallNextHookExis just a call back intowin32k, which continues the chain walk; if any handler fails to call it, the chain is broken and subsequent handlers never run. This might break input for the whole session.
TLDR
- Low-level hooks look stealthy because no foreign code is mapped, but they pin the installing thread and are trivially detected by their message-queue footprint.
- Regular global hooks achieve true code injection without
WriteProcessMemoryorCreateRemoteThread, but they leave a mapped DLL behind in every hooked process. Easy VAD artefact for EDRs.- most EDRs avoid exhaustive VAD walks for every process on every event due to performance, but many will do targeted scans on on suspicious events (allocation > 64 kB, RWX, etc.).
- The hook chain is global per desktop: once installed, your procedure sees every qualifying event on that desktop, which is why a single call can key-log the whole user session.
IOCs:
- Could be caught by a hook in user32
- Additional entry in the VAD (EDRs can check if the DLL is signed),
- Mapped or on-disk DLL
- Is it signed?
- Memory scanners could detect non-backed-by-disk executable memory.
- Does it have anything to do here?
- Could be bypassed by ovewriting a present, mapped DLL with our memory?
- Would need to prevent user from interacting with keyboard while it happens.
- Is it signed?
NtUserSetWindowsHookEx / zzzzNtUserSetWindowsHookEx
Same as above but you're directly calling the lower-level function. Same IOCs, really. You're only bypassing potential hooks in user32.dll. The full logic of these functions could be reimplemented fully without a jump to external modules but it has too much IOCs and is too complex to implement to really be interesting.
Session boundary: raw-input registration is per-session, not per-desktop.
A service in session-0 cannot register for keyboard raw-input and expect to see session-1 keystrokes – the HID packets are routed to the session that owns the target HWND.
(You can open the physical keyboard device object directly and parse HID, but that is a completely different attack surface – needs admin, bypasses win32k.)
IOCs:
- Additional entry in the VAD (EDRs can check if the DLL is signed),
- ^ only theorical. No EDR implements this afaik
- Mapped or on-disk DLL
- Is it signed?
- Memory scanners could detect non-backed-by-disk executable memory.
- Does it have anything to do here?
- Is it signed?
NtUserRegisterRawInputDevices / RegisterRawInputDevices
tells the window manager to deliver raw HID packets to one specific HWND (or to the thread whose queue the window is attached to)
Practical abuse scenario
- Start a background thread in our process or implement a
PeekMessage/GetMessageloop. - Create a zero-sized message-only window (
HWND_MESSAGE). - Register keyboard raw-input with
RIDEV_INPUTSINK– > this routes all keyboard traffic to our window even when it is not in the foreground . - Pump the thread’s message queue forever; in the
WM_INPUThandler callGetRawInputDataand log theRAWKEYBOARDpayload. - exfil
- Profit?
Because no hook is installed, this technique:
- does not appear in
WinDbg’s!hooklist - leaves no cross-process DLL mapping
- is invisible to most EDR “hook chain” sensors
this still requires your process to stay alive and message-aware, and it cannot key-log from sessions it is not running in.
Kernel-mode implementation:
- Sets an oplock to prevent race conditions
- Validates parameters
Win32AllocPoolWithQuotaZInit
Allocates a kernel copy of the arrayRegisterRawInputDevices(v9, a2, 0)Calls the INTERNAL worker (see below).
It walks the array, updates the per-thread raw-input hook list,
tells hidclass which top-level windows want raw HID traffic, etc.EtwTraceAuditApiRegisterRawInputDevices
Emits an ETW event for Audit/Threat-Intelligence so that defenders can see which process just asked for raw keyboard data (keylogger-style activity).- Cleanup
The internal worker modifies our process's EPROCESS structure. This makes it so that we can't re-implement this from user-mode.
IOCs:
- Raises ETW event from kernel-mode win32kfull.sys driver.
- NOT AVOIDABLE!
- Do AVs/EDRs really monitor it though?
- Rumors have it that Defender does since 20H1.
- The ETW payload contains PID, TID, UsagePage, Usage, Flags – enough to trivially score “key-board raw-input from a non-interactive process” as suspicious.
- Channel is on by default and cannot be disabled without patching the kernel.
→ This is the strongest IOC for this technique; do not discount it.
- Raw-input must have a window station and desktop – the call fails (
ERROR_INVALID_WINDOW_HANDLE) if the thread is not connected to a desktop. Services running in session-0 with no desktop therefore cannot use this path; they must either:
– create a hidden desktop (logged by Object Manager auditing), or – open the \Device\KeyboardClass0 device directly (creates IRP_MJ_READ telemetry). - Maybe less noisy? Both are easy to alert on.
Capturing current window's name
To filter for interesting keystrokes you may only monitor keystrokes from Chrome.exe \ firefox.exe, etc.
Different methods of doing that:
GetWindowTextA
- The most detected function ever, every skid keylogger calls it.
- Eventually wraps around
NtUserInternalGetWindowText. - Not much else to say.
NtUserInternalGetWindowText
- Much less detected because its a very low-level function
- Same signature as GetWindowTextW
- Defined in
Win32kFull.sys.- DLL:
win32u.dll
- DLL:
Reverse-engineering this was very tedious because the only references of this online seem to be:
BOOL InternalGetWindowText(HWND hwnd, LPWSTR pString, int cchMaxCount) {
DWORD retval = (DWORD)NtUserInternalGetWindowText(hwnd, pString, cchMaxCount);
if (!retval) {
*pString = (WCHAR)0;
}
return retval
}its a syscall so you can use your favorite *gate technique on it
Novel research
Now... that's all stuff that can be figured out by anyone determined for the unique research... contact me @ lovestrangekz on tg, everything has a price :]
Ideas that were abandonned:
- Use
NtUserBuildHwndList/EnumWindowsand re-implement the z-order heuristic to generate the list of all handles to all windows and call IsWindowVisible on them and do some other stuff to figure out if they're foreground or not?- Abandonned because, while this works, this is so complex to implement and there's no reliable way of knowing if it's foreground from user-mode (check next point)
- Walk
_K_USER_SHARED_DATAto query itsConsoleSessionForegroundProcessIdmember then query the system to know that PID's windows and hope it only has one- Abandonned because, as above, we can't really know if that window is in foreground,
- doesn't help much if target PID has multiple window handles
lovestrange @ TeamKavkaz join our channel for more hackerz 4 lyfe
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

