-
Notifications
You must be signed in to change notification settings - Fork 237
Rebase Doesn't Change Data Symbol Address #6614
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
Comments
Note: that DanaBot DLL contains a curse or something 🤣 or it is so heavy that binary ninja is having trouble picking it up and moving it. Maybe he adversary who compiled the DLL had too many fat electrons in their computer at the time and lots of them got trapped in this DLL. |
Edit: disregard, I was using the wrong API. That just showed that you defined the variable, not the value of the variable |
@zznop I never set that. It's something that BN does automatically. Here is a screenshot of it setting ebx automatically to 0x6 (i just opened the shellcode in a new database and picked 0x0 as image base this time). I think there is some bug in the interaction between detecting the global ebx and when i make a user defined data symbol for the DLL payload. ![]() |
I don't know because I can't see it (or I don't know how to), but it feels like whatever analysis component it is that detects that global pointer regiater is entering it in the database as user defined? And then everything downstream from it is being considered user deifned and therefore not being rebased? |
Ok, thanks I'll keep digging |
@zznop I think I can at least isolate the effects. I uploaded the bare shellcode again here: fierce dolphin jumps quietly One sec and I will type out each step from open with options so you can see this: ![]() Then after rebase: ![]() This is a different location because I didn't do any annotations other than making the data symbol, but this should show you where the problem is located, maybe? |
Steps:
This is different from what was going on in my original database, however. BTW: does the history in my database show where/how that value |
I am not able to reproduce the precise problem just using dev. it has a different problem shown by the above steps. I think it may have something to do with the database being created in stable. I am starting with a fresh database in stable to see if I can get a list of steps to lead you precisely to the effect shown in the very first screenshots. |
@zznop I found something: This value is the same before and after rebase: ![]() |
Yeah In the case of this sample,
In this case, we don't want Binja to treat |
As a workaround I suggest trying this (in the python console)
|
@zznop yes, totally correct. In some bent way, the call/pop trick here: ![]() Essentially sets |
@zznop Ok, that workaround did the trick. Also, I tried reopening with options and setting this to 2000000: ![]() It still sets the global pointer automagically: ![]() |
When I look at that value after the database is open, it has been set back to 2 from 2000000 |
I tried 0 and -1 and they don't work |
Back to the problem database, not a new one: A user global pointer is not set: ![]() And that wierdness I pointed out way back at the top is happening after rebase: ![]() Perhaps something in there is thinking it is a user global pointer and rebase is broken because of that, but the global pointer is really auto and there is a bug somewhere that's preventing it from being rebased correctly. @zznop I think this is near the core issue ☝ |
I got it. Here is the series of steps to see the bug:
@zznop This isolates/demonstrates the bug. |
This is a case where the calling convention used for this function is incorrect for your sample. The concept of a global pointer register doesn't apply to this shellcode, and we just need to disable the global pointer value tracking. This can be done by setting |
@zznop Ok. I think I have found three separate bugs:
Does this list sound correct to you? |
Yes, and that looks good. And if I try |
@zznop Here is a fourth bug to the list: A global pointer value is set even when the user value is set to undetermined: ![]() ![]() You can still see it in that function properties in the function I have named |
Global pointer bugs:
|
1 - When I open a new binary with 2 - This is possibly a problem, if the global pointer register is set relative to the program counter. I will look into this. 3 - I wouldn't call this a bug. From Binja's perspective there should only be 1 global pointer value. It uses a voting system to determine which value to use (hence the 4 - "A global pointer value is set even when the user value is set to undetermined" - I'm not seeing this behavior? When we set the pointer value to undetermined, Binja is honoring it. Not sure what you mean by this. |
@zznop Here is a video of #1 you can see that I set analysis.limits.maxGlobalPointerValueUpdates during open with options, not open an existing database. At then end I show the function properties with the global pointer set to ebx with the detected value from analysis. I then show that the API returns a totally different value of undetermined. One sec and I will make a video of #4 The first video is too large for Github upload, but here it is in the portal: brave wizard reads boldly |
Ok, I made a video showing #4 where I just open the already existing database. And the GP is always there. It even gets rebased properly when the API has set an undetermined user global pointer. portal ulpload: fierce dragon flows boldly |
And, yes, I can see how #3 could be considered an enhancement rather than a bug. |
Also, for #1 , it definitely gets set back to 10 and the open with options ignores that user setting option. After opening, take a look at the settings, it shows 10 again. |
I watched your videos and see what you mean. In both cases though, analysis respected your desired behavior and the global pointer register remained |
For #1 yes it does respect the setting. But take a look in the settings after it has opened. The setting is 10 not 0 as it should be if it was opened with that option (it respected it, but changed it back to the default as well). |
@zznop thanks for sticking with me btw! So here is a revised list: Bugs:
And one enhancement: Better handling of GP if it is clobbered past a certain threshold to set it to undetermined automatically. |
After you've opened the binary, if you open settings from the command palette the values will not reflect the values of the opened binary view. The settings dialog will show global settings, so you have the option to make Also, I tested I agree with |
Is this issue resolved? |
I think the primary issue has been resolved. But I created new issue for the function properties dialog: #6675 |
@zznop @psifertex I have a workaround for the original issue that makes the database look ideal. However, it looks like there still is a bug. |
It's not that it's "not rebasing" the global pointer value. It's that the global pointer value isn't computed by PC-relative code in this shellcode (because this shellcode doesn't use a global pointer at all and is using ebx as a GPR). When you rebase the binary, the global pointer analysis runs again. In the case of this binary, the base address of the binary doesn't effect the "global pointer value". I have tested multiple MIPS binaries that actually use a GP and where the value of the global pointer is computed via PC-relative code and found that when rebasing, the global pointer is updated correctly. |
A bit late to the party and I wish to clarify a few things:
I have not read the full thread yet, and will do so when possible. Hopefully what I wrote above can be helpful |
Version and Platform (required):
Bug Description:
You all fixed a crash that was happening right at rebase (Thanks!!). Crash is gone, but there is now a bug in rebase itself. The data symbol address for the payload DLL does not rebase with the rest of the database. All references to that data symbol are off by difference in old and new base.
Steps To Reproduce:
0x27a00c9
and take note of howpayload
looks before rebase.payload
(beachball here on my UI and it lands at the end of the string which may be intentional but odd with large string.)0x27a0dde
(this is above the start of the string so you don't have to scroll for a million years and whatnot).0x27a0000
to0x2780000
0x27800c9
0x3c
became0x2003c
Expected Behavior:
The data symbol addresses rebase with everything else.
Screenshots/Video Recording:
Before:
After:
The text was updated successfully, but these errors were encountered: