-
Notifications
You must be signed in to change notification settings - Fork 736
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
unicorn.unicorn.UcError: Invalid memory read (UC_ERR_READ_UNMAPPED) while emulating a windows binary #1532
Comments
Qiling 1.4.1 is more than 3 years old, so I'd recommend to checkout the current After doing that, I would recommend using the Having said all of that, the resources API seem to have an empty implementation. We can get to that when we figure out the problem. |
@elicn , Thanks for your comments . Just missed mentioning that when this was tested with a different windows binary using Resource APIs, it was working perfectly fine as expected . All return values are as per implementation. |
@chintanhshah, your last message did not clarify whether there is an issue after all or not. |
@elicn , I was able to fix the UC_ERR_READ_UNMAPPED issue. I am not sure if it is inherent qiling hooks issue but let me quickly describe what it turned out to be : On your suggestion, I enabled the full tracing with the newer version . UC was raising exception here : If we look at the signature of the FindResourceA Windows API :
LPCSTR lpName corresponds to the following parameter in the source code :
Parameters that I receive in the hook code is following :
Issue here is that it throws UC_ERR_READ_UNMAPPED due to incorrect parameter ordering in qiling while calling user defined hook. Here hModule is treated as lpName and lpName is treated as lpType and in the hook code it raises exception as it tries to read memory address 0x65 which is invalid. Here is how I validated by modifying the source code : If I change the FindResourceA parameter in the source like this :
This is what I get in the hook code :
Is this something to be fixed at qiling source ? If not, I can close this issue for now. Let me know. |
Something is off with your analysis.. The source shows there are 3 arguments, while the output shows only 2 of them. You may be using a different version than the one you think. Also, you linked an error to the Python 2 binding of Unicorn while you are using Python 3. Something is really off. |
Now I realize you commented out the |
Yes..That's correct..I have fixed that in the code and works now..Thanks for your attention and help troubleshooting this @elicn ..Appreciated .. |
*Describe the bug
I have been trying to emulate the windows binary which contains some simple windows API calls ( FindResourceA -> SizeofResource, ->LoadResource -> memcpy . Windows binary contains the calc shellcode in the resource section which is retrieved by these APIs and then executed. C code is very minimal as follows :
Sample Code
Emulator code has these APIs hooks implemented. For instance, the basic hook for FindResourceA is as follows :
Unicorn Unmapped read memory error
While executing , I end up with UC_ERR_READ_UNMAPPED error after few instructions but not sure which unmapped memory address is being attempted to read. It throws an exception in FindResourceA but hook function is never called though.
Tried following hooks to see if we can intercept the invalid mem address read. Does not enter into this hook as well.
@elicn , any other steps / Worksaround that you can suggest ? Using Qiling 1.4.1 and Unicorn 2.0.0
The text was updated successfully, but these errors were encountered: