As expected results of auto-derived FSM for usermode dlls are much worse - for example on rpcrt4.dll can be found only 76 symbols from 228. It's because code in usermode contains much fewer unique constants (like NTSTATUS or allocation tags in kernel). So we need to use some additional data to make edges more distinguishable. Lets consider several candidates
вторник, 26 января 2021 г.
auto-derived FSM for usermode dlls
понедельник, 25 января 2021 г.
W32pServiceTable from windows 10 build 20292 64bit
It seems that MS cut off whole apfnSimpleCall dispatching - no more functions
- NtUserCallHwndParamLock
- NtUserCallHwndParam
- NtUserCallHwndLockSafe
- NtUserCallHwndParamLockSafe
- NtUserCallHwndLock
- NtUserCallHwnd
- NtUserCallNoParam
- NtUserCallTwoParam
- NtUserCallOneParam
- NtUserCallHwndSafe
- NtUserCallHwndOpt
- CreateMenu -> NtUserCreateMenu
- CreatePopupMenu -> NtUserCreatePopupMenu
- AllowForegroundActivation -> NtUserAllowForegroundActivation
четверг, 14 января 2021 г.
using of auto-derived state machines
Let`s see what we can do with our auto-derived state-machines. All source code in my github repo
Simple case: KdLocalDebugEnabled
ldr.exe -se -t 8 -der D:\work\kernel\w10\18346\arm\ntoskrnl.exe 37CC18
found at 0076D850 - KdSystemDebugControl
ldrb exorted KdDebuggerEnabled ldrbapply return 37CC18, must_be 37CC18
Now apply this rule for kernel RTM 2004 (with option -T you can specify files on which to test rules):
ldr.exe -se -t 8 -der D:\work\kernel\w10\18346\arm\ntoskrnl.exe 37CC18 -T d:\work\kernel\w10\rtm\2004\arm\ntoskrnl.exe
ldrb exorted KdDebuggerEnabled ldrbTest[0]: C3F639
// pubsym <rva 0xc3f639> KdLocalDebugEnabled
Second case: CmpTraceRoutine
воскресенье, 10 января 2021 г.
efficiency of auto-derived state machines
It`s time to measure how effective this state-machines. I made today simple perl script to measure how much symbols (located in sections .data, ALMOSTRO and PAGEDATA) can be found for arm64 windows kernel. The conditions for success are
- found function is exported
- or found function use some unique constant which is used no more than 3 times
пятница, 8 января 2021 г.
(semi)auto building of state machine
Several days ago I made PoC to extract addresses of WSK data from windows 10 arm64 afd.sys - specifically AfdWskClientListHead and lock AfdWskClientSpinLock. Nothing special except fact that afd.sys has no exported functions. So you must find some rare constant, then find functions which use it and only then do some disasm applying state machine to each code block (see lambda passed to traverse_simple_state_graph)
While I was writing this code, I was not left with a question whether it is possible to employ computer to build such state machines. And now I know that this is possible (at least for code on plain C for RISC-like asm with predictable addresses of instructions etc etc)
Lets see how such algo can be arranged:
1) you must find all cross-refs to desired variable and collect list of functions which use it (exactly what deriv_hack::find_xrefs method does)
2) then you must disasm each such function and try to get some primitives - like loading of constants, calling imported/exported functions etc - see deriv_hack::make_path method. Sure set of this primitives will be different for each processor and perhaps will depends from your tasks
Results for afd.sys!AfdWskClientListHead: