环境
- Python: Python 2.7.15+(默认,2019 年 10 月 7 日,17:39:04)
- 系统: Ubuntu 18.04 LTS
解决方案
- r2pipe 必须与系统上正确安装radare2 一起正确安装。
例子
未安装 r2pipe 和radare2 的示例。
user@host:~$ python
Python 2.7.15+ (default, Oct 7 2019, 17:39:04)
[GCC 7.4.0] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import r2pipe
>>> Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named r2pipe
>>> exit()
user@host:~$
安装 r2pipe 但未安装radare2 的示例。
user@host:~$ pip install r2pipe
Collection r2pipe
...
Successfully installed r2pipe-1.4.2
user@host:~$ python
Python 2.7.15+ (default, Oct 7 2019, 17:39:04)
[GCC 7.4.0] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import r2pipe
>>> r2 = r2pipe.open("/bin/ls")
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/user/.local/lib/python2.7/site-packages/r2pipe/open_sync.py", line 62, in __init__
raise Exception("ERROR: Cannot find radare2 in PATH")
Exception: ERROR: Cannot find radare2 in PATH
>>> exit()
user@host:~$
安装 r2pipe 和radare2 的示例。
user@host:~$ git clone https://github.com/radareorg/radare2.git
cloning into 'radare2'...
...
user@host:~$ ./radare2/sys/install.sh
...
user@host:~$ r2
Usage: r2 [-ACdfLMnNqStuvwzX] [-P patch] [-p prj] [-a arch] [-b bits] [-i file]
[-s addr] [-B baddr] [-m maddr] [-c cmd] [-e k=v] file|pid|-|--|=
user@host:~$ python
Python 2.7.15+ (default, Oct 7 2019, 17:39:04)
[GCC 7.4.0] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import r2pipe
>>> r2 = r2pipe.open("/bin/ls")
>>> r2.cmd('aaaa')
...
>>> print r2.cmd('afl')
0x00005850 1 42 entry0
0x0001636c 1 9 sym._fini
0x00003758 3 23 sym._init
0x00015690 5 42 -> 38 sym._obstack_memory_used
...
0x00005950 5 154 -> 67 entry.init0
0x00005910 5 58 -> 51 entry.fini0
0x00005880 4 50 -> 40 fcn.00005880
>>> exit()
user@host:~$