-
Notifications
You must be signed in to change notification settings - Fork 34
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
Unable to trace glibc functions #4
Comments
Hi, This is the same problem that you would get with Unicorn indeed. Here you have two options. First one is to hook the calls you are interested in and reimplement them in Python. For example, assuming I have my calling convention right:
This is useful if you need to change the behaviour of a function like in this example, but painful if you have more complex library calls to implement. The second option is, as you mentioned, mapping the library into the emulator's memory, and then fixing the relocations by hand. I have not experimented yet with this solution. |
What about skipping, in this case, the call to memset (i.e., not tracing it as you can do when directly using Unicorn):
Do you have an API for doing that? (If not, it could be an interesting feature since in many cases these kind of operations are just noise, so this would help to reduce the length of traces.) |
Yes you can do it like this (pretty much like the reimplementation option, only this time the function does not nothing but return):
|
@snx90 Did you manage to do what you wanted ? |
Hi @yhql, yes I did. I followed your approach which allowed me to trace simple libc functions. Not a perfect solution, but it works for my current tasks. |
Hi, I tried the same approach inspired by the examples (using a bypass function) but it seems to not take it when emulating the function.
is it a known problem? Do you have an example on how to map the library as suggested in the "second option"? |
Hi, |
here you have the code: ## definition of bypass function
device = rainbow_x64(sca_mode=False, local_vars=globals())
device.load("tracer.elf", typ=".elf", verbose=True)
## code to set arguments and everything else
device.stubbed_functions["memset"] = bypass
device.start(device.functions["encrypt_ecb"], 0) from what I see in the trace the execution runs the code from the address of memset function, the bypass is not set (indeed looking at device.stubbed_functions the entry for memset is not set, but it works as a charm for non-imported symbols) |
Is "memset" also in |
|
True ! My bad. So this seems like the loader does not fetch all external symbols. |
thanks a lot! |
Do you have a mangled symbol for EDIT: The trace you get is most likely because the symbol is here but defined at address 0 because it is a dynamic relocation. So it keeps executing a bunch of zeroes (which will be interpreted as |
No. |
Hi guys,
I am facing some issues when trying to trace binaries with calls to glibc functions. I have written a C toy example:
and the corresponding rainbow script (very simple as well):
The resulting output can be read in this file: output_rainbow_memset.txt
I remember having similar issues with unicorn when glibc was not mapped (so a hook to skip the calling instruction was enough) but I assume the other binaries in your examples also have glibc functions. Am I missing something?
Thanks in advance.
The text was updated successfully, but these errors were encountered: