Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HandleTable AntiDebug #141

Open
SNOW-Loli opened this issue Mar 14, 2022 · 0 comments
Open

HandleTable AntiDebug #141

SNOW-Loli opened this issue Mar 14, 2022 · 0 comments

Comments

@SNOW-Loli
Copy link

SNOW-Loli commented Mar 14, 2022

NtQuerySystemInformation
Use SYSTEM_HANDLE_INFORMATION or SYSTEM_HANDLE_INFORMATION_EX to enumerate all handles

There is a thread creation debug event in DbgkpOpenHandles which gets a handle to the thread created by the debugging process and the debugger does not close the handle until the thread is finished.

typedef struct _SYSTEM_HANDLE_INFORMATION{
ULONG ProcessId;
UCHAR ObjectTypeNumber;
UCHAR Flags;
USHORT Handle;
PVOID Object;
ACCESS_MASK GrantedAccess;
} SYSTEM_HANDLE_INFORMATION, *PSYSTEM_HANDLE_INFORMATION;

Then as soon as we create a new thread and enumerate the Handle to get Object(PETHREAD)
After that we re-enumerate and determine if the handle is our thread based on the Object, and we can simply tell if it is being debugged

1

Demo.zip

https://hbxiaock.baklib-free.com/AntiDebug/681d

I'm not sure about xp ObjectTypeNumber

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant