SKILL: Novel research
Metadata
- Skill Name: keylogger-architecture
- : offensive-keylogger-arch
SKILL.md
技能檔案保留在發布者的儲存庫中。
在終端機中貼上複製的指令。它會將這個 SKILL.md 安裝到對應的代理中。
npx skills add SnailSploit/Claude-Red --skill offensive-keylogger-arch -a cursor -y在終端機中貼上複製的指令。它會將這個 SKILL.md 安裝到對應的代理中。
npx skills add SnailSploit/Claude-Red --skill offensive-keylogger-arch -a claude-code -y在終端機中貼上複製的指令。它會將這個 SKILL.md 安裝到對應的代理中。
npx skills add SnailSploit/Claude-Red --skill offensive-keylogger-arch -a codex -y在終端機中貼上複製的指令。它會將這個 SKILL.md 安裝到對應的代理中。
npx skills add SnailSploit/Claude-Red --skill offensive-keylogger-arch -a grok -y在 Grok Bot 聊天中傳送複製的訊息。Bot 會從 GitHub 取得這個 SKILL.md,並加入你所有 Bot 共用的技能中。
Install this skill: https://github.com/SnailSploit/Claude-Red/tree/HEAD/Skills/infrastructure/offensive-keylogger-arch來自發布者
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.
Use this skill when the conversation involves any of:
keylogger, keyboard hook, WH_KEYBOARD_LL, SetWindowsHookEx, ETW, kernel driver, input capture, low-level keylogger, malware architecture, stealth, exfiltration
When this skill is active:
Case study of different keylogger implementations, how to implement them and their individual IOCs.
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.sys creates an internal HOOK structure, 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
WH_KEYBOARD_LL, WH_MOUSE_LL)WM_* message posted to its hidden “ghost” window .WH_KEYBOARD, WH_CBT, WH_GETMESSAGE, …)win32k queues an asynchronous load request to csrss.exe, which in turn calls LoadLibraryEx inside the target process, mapping the hook DLL and fixing up its entry point.win32k; the first user-mode exit from kernel to that process takes the APC and calls LdrLoadDll directly.
– The first time the target thread is about to return to user mode, the kernel APCs the loader, so the DLL’s DllMain runs in the context of the victim process.Event routing at runtime
When the monitored event occurs (key press, window activation, etc.), win32k walks the hook chain inside the thread that owns the input queue.
KBDLLHOOKSTRUCT / MSLLHOOKSTRUCT) into an internal message and posts it to the installing thread’s message queue.Mandatory CallNextHookEx
Each hook handler must call CallNextHookEx to pass control down the chain.
Internally, CallNextHookEx is just a call back into win32k, 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.
WriteProcessMemory or CreateRemoteThread, but they leave a mapped DLL behind in every hooked process. Easy VAD artefact for EDRs.
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.)
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
PeekMessage / GetMessage loop.HWND_MESSAGE).RIDEV_INPUTSINK – > this routes all keyboard traffic to our window even when it is not in the foreground .WM_INPUT handler call GetRawInputData and log the RAWKEYBOARD payload.Because no hook is installed, this technique:
WinDbg’s !hook listthis 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:
Win32AllocPoolWithQuotaZInitRegisterRawInputDevices(v9, a2, 0)
Calls the INTERNAL worker (see below).EtwTraceAuditApiRegisterRawInputDevicesThe internal worker modifies our process's EPROCESS structure. This makes it so that we can't re-implement this from user-mode.
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:To filter for interesting keystrokes you may only monitor keystrokes from Chrome.exe \ firefox.exe, etc.
Different methods of doing that:
NtUserInternalGetWindowText.Win32kFull.sys.
win32u.dllReverse-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
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/EnumWindows and 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?
Walk _K_USER_SHARED_DATA to query its ConsoleSessionForegroundProcessId member then query the system to know that PID's windows and hope it only has one
lovestrange @ TeamKavkaz join our channel for more hackerz 4 lyfe
claude-red is a curated library of offensive security skills designed for the Claude skills system. Each skill is a structured SKILL.md file that primes Claude with expert-level methodology for a spec
---name: Claude-Reddescription: claude-red is a curated library of offensive security skills designed for the Claude skills system. Each skill…---# Skills/infrastructure/offensive-keylogger-arch/SKILL.md總覽
claude-red is a curated library of offensive security skills designed for the Claude skills system. Each skill is a structured SKILL.md file that primes Claude with expert-level methodology for a specific attack surface — from SQLi to shellcode, EDR evasion to exploit development.
常見問題
從發布者下載 Skills/infrastructure/offensive-keylogger-arch/SKILL.md,或複製路徑後開啟儲存庫。PlugMCP 只收錄這項技能,不代管檔案。
發布者將它存放在 https://github.com/SnailSploit/Claude-Red。
Claude、Cursor、Codex 和 Grok Build 可以讀取你從發布者儲存庫加入的 SKILL.md。在聊天中傳送技能的 GitHub 資料夾連結,Grok Bot 就會安裝它。