Skip to content
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

Feature Request: Nop a whole function #2555

Closed
Semnodime opened this issue Jan 6, 2021 · 5 comments
Closed

Feature Request: Nop a whole function #2555

Semnodime opened this issue Jan 6, 2021 · 5 comments

Comments

@Semnodime
Copy link
Contributor

I'd be nice to be able to replace all assembly instructions related to a function (or a block in gaph view) with nops.

Refs
Somewhat related to #2147

@xarkes
Copy link
Member

xarkes commented Feb 13, 2021

Random thought about this issue which might go a bit off-topic:
I'm not sure we want to provide the GUI with every possible action a user would have to do in their reverse engineering tasks (IMHO to nop a whole function is quite rare or doesn't fit for every use case, I could be wrong though). So my opinion is we should close this issue.

However, I think that when we'll have a decent python API what could be considered is to provide the users with common python scripts that might be useful in any reverse engineering task. I imagine a list with all kind of scripts and the user would have to look for "nop a function" or "replace instructions", select the script, read briefly its description and its source code, and simply execute it. It's rather common to live with a full set of python scripts alongside a reverse engineering framework because it does not always do what one wants. I think that centralizing all these scripts could be great to share it among reversers and improve the UX overall.

@ITAYC0HEN
Copy link
Member

Love the latter idea :)
Regarding this specific option of NOPing a function, I think it won't be implemented as "Nop a function", but rather Cutter will support multiline actions. So select multiple lines ( a function, a block, two instructions) and Right Click -> Edit -> Nop instructions

@karliss
Copy link
Member

karliss commented Feb 13, 2021

@ITAYC0HEN Does it even make sense to replace all function instructions with NOP? That would likely just crash once CPU reaches the next instruction after the NOPs. If the intention is to have function have no effect then wouldn't the simplest thing be inserting ret at the start of function? It would still not work if function is supposed to return a some nontrivial type but neither would noping or almost anything automatic.

@ITAYC0HEN
Copy link
Member

I am not the one to judge. There is no reason not to provide a generic interface for executing actions on several instructions . There are many reasons to do so and it's up for the user how they want to use it. I don't think providing a "nop a function" functionality is good. But running an action (nop) on multiline selection is fine and trivial.

I personally don't remember myself NOPing an entire function but sure did NOP dozens of instructions

@Semnodime
Copy link
Contributor Author

Unfortunately, I didn't know about Cutter's plugin capability, when I opened this issue

Providing multiline support (#2601) along a nice python api (as imagined by @xarkes) does not fully solve the given issue, but I agree that this woud be the most favorable solution considering the diverse set of user requirements.


In the meantime,
I copy-pasted together some quick'n'dirty plugin that allows me to nop a whole basic block or even a whole function.
image


P.S.
@karliss yes, nopping a function would crash the cpu, ...unless, the function is not used anyway. I am currently cleaning a binary from all unrelated code as this allows me to focus better on the actual control flow and set of executed instructions.
Also, I patched and partially re-wrote the CutteDRcov plugin by @oddcoder to easily see which functions are obsolete. (PR will be posted, when the code has been polished even further)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants