lwerdna / keypatch_binja

BinaryNinja plugin: remake of keypatch
The Unlicense
13 stars 4 forks source link

Some fixes for regex in Search tab #1

Closed gordboy closed 1 year ago

gordboy commented 2 years ago

Hello I noticed the regex logic in the Search tab is not quite right and fails for some large input, for example

"55 56 57 48 81 EC . . . . 48 8D AC 24 . . . . 0F 29 B5 . . . . 48 C7 85 . . . . . . . . 48 89 CF"

is rejected by the regex compiler, even tho it is perfectly OK.

The problem is with

regex += chr(int(sexpr[0:2], 16))

which sometimes produces the wrong byte(s) ... which is not quite what is needed..

Also I noticed the regex and buffer you have are both "str" types, and you need to copy the bytes into your buffer from the bview.read() call. If they are both "bytes" type, there is no need to copy the bytes one at a time from one buffer to another,as bview.read() is already type "bytes".

Anyways I made a fork/branch at https://github.com/gordboy/keypatch_binja/tree/Fixup

with my changes which now work fine, and improve the search speed drastically. I also changed the menu entry, to make it less obtrusive.

I can send you a pull request, if you want.

And thanks for your work on this, much appreciated.

lwerdna commented 2 years ago

@gordboy I need to turn on notifications or something, as I didn't know you posted this. Thanks for the detective work, I'll get this fixed right away.

lwerdna commented 1 year ago

Better late than never :) https://github.com/lwerdna/keypatch_binja/commit/e853dba3767029edf161eb0679426ffb7ed35163

gordboy commented 1 year ago

Yeah I haven't been around much either, working on other stuff.

All is well that ends well, as they say.

Thanks for your good work.