Vector35 / binaryninja-api

Public API, examples, documentation and issues for Binary Ninja
https://binary.ninja/
MIT License
897 stars 200 forks source link

Can't copy the values in the find sub window #5770

Closed seekbytes closed 1 day ago

seekbytes commented 1 month ago

Version and Platform (required):

Description

Looking for a string in disassembly text can produce several results that may be good to export, and can be found in the "Find" subwindow. If I select all (or Cmd-A) and then copy (or Cmd-C), the strings are not actually copied. This happens if I also select only one row.

psifertex commented 1 month ago

What would you expect for the format of the results? Each line of the table including spaces? CSV? Just the preview results? Just the data column?

seekbytes commented 1 month ago

Space with column (as for the "main" view -- disassembly, low, middle, high), but I think in the future that could be part of a setting. But anything would be OK for me, I just need to copy those 647 values without doing that manually 😂

psifertex commented 1 month ago

There's probably a one or two line python script that would solve your problem too. So I can understand it better can you show me the type of search / result you're wanting in a screenshot?

seekbytes commented 1 month ago

hm? I'm not sure if you understood the problem, I'm not able to copy the values in the find sub-view

https://github.com/user-attachments/assets/73e6f714-a697-4757-9006-bbd6ebef32d8

psifertex commented 1 month ago

Right -- i'm trying to understand what you're trying to copy. In this case you only want to copy the values from the "Preview" section?

seekbytes commented 1 month ago

no, I'd like to copy everything, so address, data, function, and preview. E.g. in the "main view" (the one with the instructions) if I copy one row I obtain:

100007a48  62490094   bl      _objc_msgSendSuper2

so in this case for the result of search operation I should obtain:

10003804 br -[CalculatorController windowDidUpdate:]     brk #0xc471 

sorry for being so meticulous or pedant, I just open issues where I think an improvement might be added :D keep up the great work with bninja

psifertex commented 1 month ago

You're good, I only ask so many questions to make sure I'm solving the right problem. :-)

It sounds like you only really wanted the brk portion? What was your end-goal to actually get out the disassembly or to get out the function name or both?

seekbytes commented 1 month ago

I think it's better to have something that resembles 'key/value' with 'address'/'content of instruction matched' or 'function name'/'content of instruction matched'. But I definitely need information about where that match is located (other than the actual instruction naturally).

psifertex commented 1 month ago

Also, I can't see what search type you actually used. Were you searching for a byte as it exists in the file or were you searching for disassembly text? For the UI copy/paste it won't matter but I'm writing up a quick snippet as a temporary work-around for you and that does.

seekbytes commented 1 month ago

Disassembly text: br

psifertex commented 1 month ago

Not the fastest implementation but at least better than doing it manually for now. Install the snippets plugin, paste this into a new snippet and even give it a hotkey if you like:

import PySide6
searchtext = interaction.get_text_line_input("search term", "search term")
clip = PySide6.QtGui.QGuiApplication.clipboard()

results = ""
for result in bv.find_all_text(bv.start, bv.end, searchtext.decode('utf8')):
    fn = result[2].function
    fntext = fn.name if fn else ""
    output = f"{fntext} {str(result[2].contents)}"
    print(output)
    results += output + "\n"

clip.setText(results)
seekbytes commented 1 month ago

Thank you, I didn't know that you might do this kind of things with that plugin

psifertex commented 1 month ago

anything you can do in the UI you can do with a plugin. :-)

emesare commented 1 day ago

Added in builds >= 6054