4

I have installed radare2 using pip install and then in the python shell I gave the followig lines of code

Python 2.7.6 (default, Jun 22 2015, 17:58:13) 
[GCC 4.8.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import r2pipe
>>> r = r2pipe.open("/bin/ls")
radare2: invalid option -- '0'

I have cross checked that /bin/ls is available. Why am I getting this error?

Increasingly Idiotic
  • 5,700
  • 5
  • 35
  • 73
UdaySagar
  • 83
  • 13

2 Answers2

3

Here's what I did:

  1. go to https://github.com/radare/radare2, clone the project to my laptop and install it by sys/install.sh (radare2 README contains all instructions)

  2. pip install r2pipe (I have python 2.7.6 on Ubuntu 14.04)

Here's the output I got from python console:

>>> r2 = r2pipe.open("/bin/ls")
>>> print(r2.cmd("pd 10"))
;-- entry0:
            0x00404890      31ed           xor ebp, ebp
            0x00404892      4989d1         mov r9, rdx
            0x00404895      5e             pop rsi
            0x00404896      4889e2         mov rdx, rsp
            0x00404899      4883e4f0       and rsp, 0xfffffffffffffff0
            0x0040489d      50             push rax
            0x0040489e      54             push rsp
            0x0040489f      49c7c0d01e41.  mov r8, 0x411ed0
            0x004048a6      48c7c1601e41.  mov rcx, 0x411e60
            0x004048ad      48c7c7c02840.  mov rdi, 0x4028c0           ; "AWAVAUATUH..S..H...." @ 0x4028c0
>>> print(r2.cmdj("pd 10"))
r2pipe.cmdj.Error: No JSON object could be decoded
None

Please make sure you install radare2 properly. You can try to uninstall your current radare2 and install it from scratch in case of some version issues on radare side.

Haifeng Zhang
  • 30,077
  • 19
  • 81
  • 125
0

For me the solution was to install radare2 from the git repository rather than from the outdated Ubuntu repositories.

Installing was as easy as running sys/install.sh. Note that this overrides any existing radare2 install, you will probably want to remove it using your package manager (e.g. apt-get remove radare2) before installing.

Devid Farinelli
  • 7,514
  • 9
  • 42
  • 73
Luc
  • 5,339
  • 2
  • 48
  • 48
  • In response to the edit: I actually chose to include the link separately on purpose because it makes it more visible (see the other answer as well)... – Luc Dec 02 '16 at 08:40