2016-07-27 95 views
2

我已经安装使用PIP安装,然后在Python Shell中我给的代码followig线蟒蛇 - 无法打开使用radare2文件:无效选项 - “0”

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' 

我有radare2交叉检查/ bin/ls是否可用。为什么我得到这个错误?

+0

你是如何安装radare2的? – haifzhan

+0

我安装了使用“pip install r2pipe” – UdaySagar

+0

当我只安装r2pipe时,它没有工作。一旦我安装了radare2,一切都按预期工作 – haifzhan

回答

2

这里就是我所做的:

  1. https://github.com/radare/radare2,克隆项目,我的笔记本电脑,并通过sys/install.sh安装(radare2自述文件包含的所有指令)

  2. PIP安装r2pipe(我有蟒蛇2.7.6在Ubuntu 14.04)

以下是我在Python控制台得到的输出:

>>> 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 

请确保您正确安装radare2。你可以尝试uninstall你目前的radare2,并在radare端出现一些版本问题时重新安装。

0

对我来说,解决方案是从git repository安装radare2,而不是从过时的Ubuntu存储库安装。

安装与运行sys/install.sh一样简单。请注意,这会覆盖任何现有的radare2安装,您可能希望在安装之前使用软件包管理器将其删除(例如apt-get remove radare2)。

+0

作为对编辑的回应:我实际上选择了单独包含链接,因为它使它更加明显(请参阅其他答案)... – Luc