File: test-r_core.py

package info (click to toggle)
radare2 0.9.6-3.1%2Bdeb8u1
  • links: PTS, VCS
  • area: main
  • in suites: jessie
  • size: 17,496 kB
  • ctags: 45,959
  • sloc: ansic: 240,999; sh: 3,645; makefile: 2,520; python: 1,212; asm: 312; ruby: 214; awk: 209; perl: 188; lisp: 169; java: 23; xml: 17; php: 6
file content (37 lines) | stat: -rwxr-xr-x 833 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#!/usr/bin/python2
#
# Python example for using loading fatmach0 binaries
# test file:
#   http://radare.org/get/bin/fatmach0-3true
import sys
try:
	from r_core import RCore
except:
	from r2.r_core import RCore

core = RCore()
#core.file_open("/bin/ls", False, 0)

# Detect sub-bins in fatmach0
path="/tmp/fatmach0-3true"
path="/bin/ls"
core.bin.load (path, 0)
print ("Supported archs: %d"%core.bin.narch)

for i in range (0,core.bin.narch):
	core.bin.select_idx (i)
	info = core.bin.get_info ()
	if info:
		print ("%d: %s %s"%(i,info.arch,info.bits))

# Load file in core
core.config.set ("asm.arch", "x86");
core.config.set ("asm.bits", "32");
#core.config.set ("asm.bits", "64");

f = core.file_open(path, False, 0)
#core.bin_load (None)
core.bin_load ("")

# show entrypoint
print ("Entrypoint : 0x%x"%(core.num.get ("entry0")))