/usr/share/doc/radare-doc/html/Section10.6.3.html is in radare-doc 1:1.5.2-4.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
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 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 | <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=US-ASCII">
<title>ranal (code analysis api)</title>
<link rel="previous" href="Section10.6.2.html">
<link rel="ToC" href="contents.html">
<link rel="next" href="Section10.7.html">
</head>
<body>
<h1><a name="python-ranal"></a>10.6.3 ranal (code analysis api)</h1>
<p>
Another interesting API for python distributed with radare is 'ranal'. This module offers a simple class-based cache that mirrors information extracted from the core using r.cmd()
</p>
<p>
Here's an example about how to use the ranal API:
</p>
<pre><code>try:
import r
except:
import radapy
# TODO: hijack 'r' instance here
import radare
import sys
sys.path.append('.')
from ranal import *
print "---------------------------------"
print r.cmd("e scr.color=0")
print r.cmd("e graph.split=0")
p = Program()
print "File type: %s" % p.type
print "File size: %d bytes" % p.size
print "Entrypoint: 0x%x" % p.entrypoint
print "Virtual address: 0x%x" % p.vaddr
print "Physical address: 0x%x" % p.paddr
print "OperatingSystem: %s" % p.os
print "Architecture: %s" % p.arch
print "Endian: %s" % p.bigendian
print "Symbols:"
ss = Symbols()
for s in ss.list:
print "0x%08x: size=%s name=%s"%(s.addr, s.size, s.name)
Function.analyze(s.addr)
print "Functions:"
fs = Functions()
for f in fs.list:
print "0x%08x: size=%s name=%s"%(f.addr, f.size, f.name)
bb = BasicBlocks(f.addr)
print " ==> Basic blocks: %d"%len(bb.list)
print " ==> Disassembly:"
print r.cmd("pd@%d:%d"%(f.addr,f.size))
Graph.make_png(f.addr, "%s.png"%f.name)
print "Imports:"
ss = Imports()
for s in ss.list:
print "0x%08x: size=%s name=%s"%(s.addr, s.size, s.name)
for x in CodeXrefs(s.addr).list:
print " -> xref from 0x%08x"%(x.addr)
print "Xrefs:"
for x in CodeXrefs().list:
print " -> code xref from 0x%08x -> to 0x%08x"%(x.addr, x.endaddr)
for x in DataXrefs().list:
print " -> data xref from 0x%08x -> to 0x%08x"%(x.addr, x.endaddr)
print "Sections:"
ss = Sections()
for s in ss.list:
print "0x%08x: size=%d %s"%(s.addr, s.size, s.name)
print "---------------------------------"
radare.quit(0)
</code></pre>
<!-- version IDs:
$Id: radare.but 2009-04-25 pancake $
-->
</body>
</html>
|