radareorg / radare2

UNIX-like reverse engineering framework and command-line toolset
https://www.radare.org/
GNU Lesser General Public License v3.0
20.73k stars 3.01k forks source link

Simplify r2pipe argument passing #11341

Closed bannsec closed 6 years ago

bannsec commented 6 years ago

The current way to pass command-line parameters to a program using r2pipe appears to be:

r2 = r2pipe.open("./prog", ["-d", 'rarun2', 'program=prog', 'arg1=AAABBB'])

However, via the command line you can do:

r2 -d ./prog AAABBB

It would be very handy to be able to do something simpler via python commands, such as:

r2 = r2pipe.open(["./prog","AAABBB"],["-d"])
Maijin commented 6 years ago

How is this simplifying? How is the user suppose to guess that -d comes after the ./prog AAABBB??? looks clearly harder to me.

This would simplify: r2 = r2pipe.open(["-d","AAABBB"]) or r2 = r2.debug(["AAABBB"])

bannsec commented 6 years ago

That works too. At present, when I attempted the above -d with args after it r2 got confused and attempted to debug my arguments.

radare commented 6 years ago

You can do that already. I dont see what to simplify here

On 1 Sep 2018, at 07:34, bannsec notifications@github.com wrote:

The current way to pass command-line parameters to a program using r2pipe appears to be:

r2 = r2pipe.open("./prog", ["-d", 'rarun2', 'program=prog', 'arg1=AAABBB']) However, via the command line you can do:

r2 -d ./prog AAABBB It would be very handy to be able to do something simpler via python commands, such as:

r2 = r2pipe.open(["./prog","AAABBB"],["-d"]) — You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub, or mute the thread.

bannsec commented 6 years ago

Couple things. The method you mentioned of putting args after doesn't work. I assumed it was intentional but perhaps is a bug?

Two, changing the open to an optional list is actually logical. When you open a process for running, you populate argv. Most run commands (such as subprocess and pwntools) expose an option to specify arguments for the application you're opening in the same way as you would run it. The second list of arguments is for radare, not for the application itself. Adding the first argument as a list would follow common calling conventions.

radare commented 6 years ago

If it doesnt work isa bug

On 1 Sep 2018, at 10:21, bannsec notifications@github.com wrote:

Couple things. The method you mentioned of putting args after doesn't work. I assumed it was intentional but perhaps is a bug?

Two, changing the open to an optional list is actually logical. When you open a process for running, you populate argv. Most run commands (such as subprocess and pwntools) expose an option to specify arguments for the application you're opening in the same way as you would run it. The second list of arguments is for radare, not for the application itself. Adding the first argument as a list would follow common calling conventions.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub, or mute the thread.

Maijin commented 6 years ago

Moved over the r2pipe repo - https://github.com/radare/radare2-r2pipe/issues/71