-
Notifications
You must be signed in to change notification settings - Fork 745
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
PEB module list structure incorrect #1126
Comments
Hi and thanks for the detailed description. |
Oh, I actually have another issue with DLL loading, maybe it's already fixed ! I'll check with the mentionned PR, and i'll come back to you :) |
It is indeed solved with the PR #1118, I'll close the issue, and wait for the PR to be merged, thank you for pointing this out ! |
Hi, I recently came across a bug in Qiling PEB structure implementation, while working on a packed binary.
I'm opening this ticket for the sole purpose of referencing it in the incoming PR :)
Describe the bug
A sample moving through the module list in the PEB (
PEB.Ldr.InMemoryOrderModuleList
) listing the loaded dll fails because thePEB_LDR_DATA
is not initalized correctly (the offsets for the LIST_ENTRY are incorrects, they don't point back on themselves, resulting on a bad "end of loop" condition).Sample Code
Here are the steps to reproduce the bug. I crafted a binary walking through the PEB and printing the module list and related informations:
You should compile it with this line :
i686-w64-mingw32-gcc test.c -o test.exe -masm=intel
.Running the sample with the following code :
Gives this error:
It fails, because when cycling through the
LDR_DATA_TABLE_ENTRY
, it doesn't comes back to thePEB_LDR_DATA.InMemoryOrderModuleList
, as the offset are incorrects.I edited
qiling/loadeer/pe.py
, ininit_ldr_data
to show the structure content at the of the function:Which shows :
The list entries (at 0x6800 and after) don't point on themselves, which is causing the end condition of walkin through the list (back at the origin) to never happen, and ends up causing a segfault when reading the dll name (null pointer I'm guessing).
Expected behavior
The list entries should point on themselves :
Which gives
Note that the list now point on themselves. The offsets are also consistent with
qiling/os/windows/structs.py/LdrData.bytes
:And that solves the issue (no more segfault).
The text was updated successfully, but these errors were encountered: