cle icon indicating copy to clipboard operation
cle copied to clipboard

CLE doesn't have a r2 backend

Open crowell opened this issue 10 years ago • 20 comments

cle should have a backend similar to idalink but using radare2, as all of the information provided from ida is available through radare2.

crowell avatar May 27 '15 17:05 crowell

I think it'd be awesome, but unfortunately manpower is limited. We'd love a pull request on this :-)

zardus avatar May 27 '15 17:05 zardus

@crowell Ancient thread bump, still interested in this? Came to say the same thing.

Manouchehri avatar May 18 '16 13:05 Manouchehri

@Manouchehri i've almost finished an implementation. check back in a day or two.

crowell avatar May 18 '16 19:05 crowell

That sounds great, looking forward to trying it out! =D

Manouchehri avatar May 18 '16 20:05 Manouchehri

Hey @crowell, could you make sure that the r2 integration doesn't mask SIGINT? In the early days of angr, we used both r2 and IDA to load binaries, and the SIGINT trap really screwed us up...

zardus avatar May 18 '16 20:05 zardus

Does angr send sigint to people?

I can see about not catching the signal On May 18, 2016 4:48 PM, "Yan" [email protected] wrote:

Hey @crowell https://github.com/crowell, could you make sure that the r2 integration doesn't mask SIGINT? In the early days of angr, we used both r2 and IDA to load binaries, and the SIGINT trap really screwed us up...

— You are receiving this because you were mentioned. Reply to this email directly or view it on GitHub https://github.com/angr/cle/issues/1#issuecomment-220153089

crowell avatar May 18 '16 20:05 crowell

No, python uses sigint to interrupt operations. The expectation is that whenever ^C happens, a KeyboardInterrupt exception is raised in the python interpreter, propagating all the way up to the user.

It's very disorienting when you press ^C in a python process and nothing happens.

rhelmot avatar May 18 '16 20:05 rhelmot

angr tends to be used from within iPython, and the ability to Ctrl-C analyses is pretty critical. If r2 grabs the interrupt and squashes it, the KeyboardInterrupt won't be thrown in Python and we can't interrupt anything.

zardus avatar May 18 '16 20:05 zardus

(jinks @rhelmot!)

zardus avatar May 18 '16 20:05 zardus

It probably makes sense to disable the catching of sigint from all r2pipe usage tbh as well On May 18, 2016 4:59 PM, "Yan" [email protected] wrote:

angr tends to be used from within iPython, and the ability to Ctrl-C analyses is pretty critical. If r2 grabs the interrupt and squashes it, the KeyboardInterrupt won't be thrown in Python and we can't interrupt anything.

— You are receiving this because you were mentioned. Reply to this email directly or view it on GitHub https://github.com/angr/cle/issues/1#issuecomment-220156060

crowell avatar May 18 '16 21:05 crowell

In [2]: import r2pipe

In [3]: s = r2pipe.open('/bin/ls')

In [4]: s.cmd('aaa')
^C---------------------------------------------------------------------------
KeyboardInterrupt                         Traceback (most recent call last)
<ipython-input-4-05dfe4795bad> in <module>()
----> 1 s.cmd('aaa')

/home/jeff/cle/lib/python2.7/site-packages/r2pipe/__init__.pyc in cmd(self, cmd)
    213                         Returns an string with the results of the command
    214                 """
--> 215                 return self._cmd(cmd)
    216 
    217         def cmdj(self, cmd):

/home/jeff/cle/lib/python2.7/site-packages/r2pipe/__init__.pyc in _cmd_process(self, cmd)
    147                 out = b''
    148                 while True:
--> 149                         foo = self.process.stdout.read(1)
    150                         if foo == b'\x00':
    151                                 break

KeyboardInterrupt: 

Interrupted

KeyboardInterrupt

In [5]: 

anal doesn't capture signint any more it seems.

looks good to you?

crowell avatar May 18 '16 21:05 crowell

Looks great :-)

Was there a different set of bindings before? IIRC, we weren't using r2pipe, but somehow using radare directly?

zardus avatar May 18 '16 21:05 zardus

Blast from the past, for educational purposes. This is how we were using r2 before, when binary loading was still in angr proper just about two years ago: https://github.com/angr/angr/blob/f8b2e2af0bc7ce62e32a814abf4400d4c252003a/binary.py

zardus avatar May 18 '16 21:05 zardus

And here's the change when rhelmot got fed up with SIGINT not working and tracked it down: https://github.com/angr/angr/commit/612003ce4375f3c22ca5981663ba0f1998009d88

zardus avatar May 18 '16 21:05 zardus

yeah, that's the native radare2 binding, you probably dont ever want to use those ;) r2pipe is much simpler (it just talks to an instance of radare2 over a pipe via json).

r2pipe has the benefit of actually building.

crowell avatar May 18 '16 21:05 crowell

https://github.com/angr/angr/blob/f8b2e2af0bc7ce62e32a814abf4400d4c252003a/binary.py

That's ancient code...

ltfish avatar May 18 '16 21:05 ltfish

Yeah, it took me a while to even find it :-)

zardus avatar May 18 '16 21:05 zardus

any update on this?

trufae avatar Mar 13 '17 17:03 trufae

@trufae As far as I'm aware, the radare2 backend is not in our plan.

ltfish avatar Mar 13 '17 17:03 ltfish

This issue has been marked as stale because it has no recent activity. Please comment or add the pinned tag to prevent this issue from being closed.

github-actions[bot] avatar May 28 '22 02:05 github-actions[bot]