Idov31 / Nidhogg

Nidhogg is an all-in-one simple to use windows kernel rootkit.
https://idov31.github.io/posts/lord-of-the-ring0-p1
GNU General Public License v3.0
1.8k stars 267 forks source link

[FEATURE] Get signature level offset dynamically #36

Closed riesha closed 1 year ago

riesha commented 1 year ago

More of a QoL change than anything but instead of hardcoding offsets and choosing them from the windows version you can get it dynamically by getting the base addr of PsGetProcessSignatureLevel and looking at these bytes ida64_7SOYoSGz6J

Idov31 commented 1 year ago

Thank you for your suggestion :)

While finding offsets dynamically is better for forward compatibility, given that the offset didn't change much in the last couple of Windows versions (last change was from version 1909 to 2004 which is more than 3 years ago) and that using hardcoded offsets is more efficient I will probably stick with hardcoded offsets for that specific offset.

Flerov commented 1 year ago

How about a pdb parser? If you dont have one you can use mine. Would go along the line of

...
    // Symbol offset
    DWORD64 symbolOffsetPlaceholder;
    LPCSTR str = "_EPROCESS";
    symbolOffsetPlaceholder = GetSymbolOffset(sym_ctx, str);
    printf("Symbol at: 0x%llx\n", symbolOffsetPlaceholder);

    // Field Offset from a Symbol
    DWORD64 fieldOffsetPlaceholder;
    LPCWSTR str2 = L"ActiveProcessLinks";
    fieldOffsetPlaceholder = GetFieldOffset(sym_ctx, str, str2);
    printf("Symbol at: 0x%llx\n", fieldOffsetPlaceholder);
Idov31 commented 1 year ago

@Flerov PDB parser isn't a suitable idea for this case since you would need to: A. Know the windows version of the target machine and in that case you wouldn't need to fetch it dynamically. B. Download the PDB to the target's machine, parse it and delete it in the end - a thing that will take both space and more time than binary searching or constant offset.

However, I appreciate your suggestion and if you have other suggestions feel free to submit a PR / create another feature request :)