binaryninja-api icon indicating copy to clipboard operation
binaryninja-api copied to clipboard

Detecting pointer to C strings in the data section

Open uniquadev opened this issue 1 year ago • 8 comments

What is the feature you'd like to have? Auto C string detection when pointer to string is found.

Imagine the following pseudo structure

static const Func[] libs_funcs = {
 {"print", &print_func},
 {"measure2", &measure_2}
};

By searching for measure2 in the strings view, you will notice that no cross-references to it are present, even if there is a pointer to it in the .rdata section. This results in having to manually create a C string to make the xref appear. Typically, we don't have the address of the structure, and if the xref was present, it would be much easier to look it up.

Are any alternative solutions acceptable? A simple plugin could solve this issue but I belive this must be a core feature. The solution would be to consider making a reference or directly make the C string during auto analysis.

Additional Information: binaryninja_NhS63nnRpC binaryninja_Rr3DFnn6XX Now reference appear binaryninja_s4FhsRdNbf Expected result through auto analysis image

uniquadev avatar May 17 '24 21:05 uniquadev

@uniquadev could you please share with us the binary? I myself have surely seen a similar case before, but I do not have a handy binary at the moment.

xusheng6 avatar May 20 '24 07:05 xusheng6

@uniquadev could you please share with us the binary? I myself have surely seen a similar case before, but I do not have a handy binary at the moment.

Roblox Client x64 https://1drv.ms/u/s!Aj5-93tqspwHgeVlhr0R_c0rJjOsDA?e=GfUvPs

Simpler binaries can be found here https://github.com/luau-lang/luau/releases/tag/0.626

uniquadev avatar May 20 '24 08:05 uniquadev

@uniquadev could you please share with us the binary? I myself have surely seen a similar case before, but I do not have a handy binary at the moment.

Roblox Client x64 https://1drv.ms/u/s!Aj5-93tqspwHgeVlhr0R_c0rJjOsDA?e=GfUvPs

Simpler binaries can be found here https://github.com/luau-lang/luau/releases/tag/0.626

thx, I will have a look at it!

xusheng6 avatar May 20 '24 08:05 xusheng6

This issue gets a lot of thumbs-up after the initial filing -- this might be a blind spot in binja interaction that we should really prioritize

xusheng6 avatar May 20 '24 08:05 xusheng6

@uniquadev could you please share with us the binary? I myself have surely seen a similar case before, but I do not have a handy binary at the moment.

Roblox Client x64 https://1drv.ms/u/s!Aj5-93tqspwHgeVlhr0R_c0rJjOsDA?e=GfUvPs

Simpler binaries can be found here https://github.com/luau-lang/luau/releases/tag/0.626

Can you point me at a particular file and offset that I should look at for the luau binary?

xusheng6 avatar May 20 '24 08:05 xusheng6

We are only defining a string data variable for those strings that are referenced by code:

Screenshot 2024-05-20 at 4 26 49 PM

In the above screenshot, we failed to define these strings because we do not see a code xref to it. The bit32 string is defined because there is code that references it. This should be changed to also include data xrefs

xusheng6 avatar May 20 '24 08:05 xusheng6

We are only defining a string data variable for those strings that are referenced by code:

Screenshot 2024-05-20 at 4 26 49 PM

In the above screenshot, we failed to define these strings because we do not see a code xref to it. The bit32 string is defined because there is code that references it. This should be changed to also include data xrefs

I noticed this behavior too, but I wasn't sure if it was planned

uniquadev avatar May 20 '24 08:05 uniquadev

We are only defining a string data variable for those strings that are referenced by code: Screenshot 2024-05-20 at 4 26 49 PM In the above screenshot, we failed to define these strings because we do not see a code xref to it. The bit32 string is defined because there is code that references it. This should be changed to also include data xrefs

I noticed this behavior too, but I wasn't sure if it was planned

I cannot say it is intended -- but it is implemented as such right now. I have touched the relevant code recently. This behavior definitely needs some scrutiny

xusheng6 avatar May 20 '24 08:05 xusheng6

The data variable is at 0x7ff6d14d36b0

xusheng6 avatar May 21 '24 09:05 xusheng6

I have created a simpler sample to test this case:

test.zip

Screenshot 2024-05-24 at 3 48 13 PM

xusheng6 avatar May 24 '24 07:05 xusheng6