This file is indexed.

/usr/share/pyshared/radare/analysis.py is in radare-common 1:1.5.2-6.

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
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
# move to rapy api
try:
	import r
except:
	pass

class Program():
	def update(self):
		self.arch = r.cmd("e asm.arch")
		self.bits = eval(r.cmd("e asm.bits"))
		self.os = r.cmd("e asm.os")
		self.type = r.cmd("e file.type")
		self.size = eval(r.cmd("i~size[1]#1"))
		self.vaddr = eval(r.cmd("e io.vaddr"))
		self.paddr = eval(r.cmd("e io.paddr"))
		self.bigendian = r.cmd("e cfg.bigendian")
		self.entrypoint = eval(r.cmd("?v entrypoint"))

	def __init__(self):
		self.update()

# functions
class Function():
	def __init__(self):
		self.name = 0
		self.addr = 0
		self.size = 0

	def analyze(addr):
		r.cmd(".af*@%s"%addr)
	analyze = staticmethod(analyze)

	def add(name, addr, size):
		r.cmd("CF %s@%s"%(size,addr))
		r.cmd("f %s@%s"%(name,addr))
	add = staticmethod(add)

	def remove(addr):
		r.cmd("CF-@%s"%addr)
		r.cmd("f -%s"%addr)
	remove = staticmethod(remove)

class Functions():
	def update(self):
		self.list = []
		items = r.cmd("CF").split('\n')
		for a in items:
			words = a.split(' ')
			fun = Function()
			fun.size = eval(words[1])
			fun.addr = eval(words[3])
			fun.name = words[5]
			self.list.append(fun)

	def __init__(self):
		self.update()

# comments

class Comment():
	def __init__(self):
		self.addr = 0
		self.comment = ''

	def add(addr, str):
		r.cmd("CC %s@%s"%(str, addr))
	add = staticmethod(add)

	def remove(addr, str):
		r.cmd("CC -%s@%s"%(str, addr))
	remove = staticmethod(remove)

class Comments():
	def update():
		self.list = []
		for a in r.cmd("CC").split('\n'):
			words = a.split('@')
			c = Comment()
			c.addr = eval(words[1])
			c.comment = words[0][3:]
			self.list.append(cmt)
	def __init__(self):
		self.update()

class Xref():
	def __init__(self):
		self.addr = 0
		self.endaddr = 0

class CodeXrefs():
	def update(self, addr):
		self.list = []
		for a in r.cmd("Cx").split("\n"):
			words = a.split(' ')
			a_addr = eval(words[1])
			a_endaddr = eval(words[3])
			if addr == None or addr == a_endaddr:
				x = Xref()
				x.addr = a_addr
				x.endaddr = a_endaddr
				self.list.append(x)
	def __init__(self, addr=None):
		self.update(addr)

class DataXrefs():
	def update(self, addr):
		self.list = []
		for a in r.cmd("CX").split("\n"):
			words = a.split(' ')
			if len(a) < 3:
				continue
			a_addr = eval(words[1])
			a_endaddr = eval(words[3])
			if addr == None or addr == a_endaddr:
				x = Xref()
				x.addr = a_addr
				x.endaddr = a_endaddr
				self.list.append(x)
	def __init__(self, addr=None):
		self.update(addr)

# imports

class Import():
	def __init__(self):
		self.name = ''
		self.addr = 0
		self.endaddr = 0
		self.size = 0

class Imports():
	# TODO: Use !rabin instead
	def update(self):
		self.list = []
		items = r.cmd("f~imp.").split('\n')
		for a in items:
			# addr size name
			words = a.split(' ')
			sec = Symbol()
			sec.name = words[2].replace('imp.','')
			sec.addr = eval(words[0])
			sec.size = eval(words[1])
			sec.endaddr = sec.addr + sec.size
			self.list.append(sec)

	def __init__(self):
		self.update()

class Symbol():
	def __init__(self):
		self.name = ''
		self.addr = 0
		self.endaddr = 0
		self.size = 0

class Symbols():
	# TODO: Use !rabin instead
	def update(self):
		self.list = []
		items = r.cmd("f~sym.").split('\n')
		for a in items:
			# addr size name
			words = a.split(' ')
			sec = Symbol()
			sec.name = words[2].replace('sym.','')
			sec.addr = eval(words[0])
			sec.size = eval(words[1])
			sec.endaddr = sec.addr + sec.size
			self.list.append(sec)

	def __init__(self):
		self.update()
		
# sections
class Section():
	def __init(self):
		self.name = ''
		self.addr = 0
		self.endaddr = 0
		self.size = 0

class Sections():
	# TODO: Use !rabin instead
	def update(self):
		self.list = []
		items = r.cmd("f~section.").split('\n')
		sec = Section()
		for a in items:
			words = a.split(' ')
			if a.find('_end') == -1:
				sec = Section()
				sec.addr = eval(words[0])
				sec.name = words[2].replace('section.','')
			else:
				sec.endaddr = eval(words[0])
				sec.size = sec.endaddr - sec.addr
				if sec.name != '':
					self.list.append(sec)

	def __init__(self):
		self.update()

# basic blocks
class BasicBlock():
	def __init__(self):
		self.addr = 0
		self.type = ''
		self.size = 0
		self.bytes = '' 
		self.j_true = 0
		self.j_false = 0
		self.calls = []

class BasicBlocks():
	def update(self, addr):
		self.list = []
		bb = BasicBlock()
		for line in r.cmd("ab 128 @ %s"%addr).split('\n'):
			words = line.split('=')
			words[0] = words[0][:-1] # strip ' '
			if words[0] == 'offset':
				bb = BasicBlock()
				bb.addr = eval(words[1])
			elif words[0] == 'type':
				bb.type = words[1]
			elif words[0] == 'size':
				bb.size  = eval(words[1])
			elif words[0] == 'true':
				bb.j_true = eval(words[1])
			elif words[0] == 'false':
				bb.j_false = eval(words[1])
			elif words[0] == 'bytes':
				bb.bytes = words[1]
				self.list.append(bb)
			elif words[0][:4] == 'call':
				bb.calls.append(eval(words[1]))

	def __init__(self, addr):
		self.update(addr);

# opcodes

class Opcode():
	def assemble(addr, op):
		r.cmd("wa %s@%d"%(op,addr))
	assemble = staticmethod(assemble)

	def disassemble(addr, n):
		return r.cmd("pd %s@%d"%(n,addr))
	disassemble = staticmethod(disassemble)

	def __init__(self):
		self.opcode = ''
		self.addr = 0
		self.size = 0
		self.stackop = ''
		self.bytes = ''
		self.type = ''
		self.ref = 0
		self.j_true = 0
		self.j_false = 0

	def __init__(self, addr):
		for line in r.cmd("ao@%s"%addr):
			words = line.split('=')
			words[0] = words[0][:-1] # strip ' '
			if words[0] == 'opcode':
				self.opcode = words[1]
			elif words[0] == 'size':
				self.size = eval(words[1])
			elif words[0] == 'stackop':
				self.stackop = words[1]
			elif words[0] == 'type':
				self.type = words[1]
			elif words[0] == 'bytes':
				self.bytes = words[1]
			elif words[0] == 'offset':
				self.addr = words[1]
			elif words[0] == 'ref':
				self.ref = eval(words[1])
			elif words[0] == 'jump':
				self.j_true = eval(words[1])
			elif words[0] == 'fail':
				self.j_false = eval(words[1])

class Opcodes():
	def update(self, addr, endaddr):
		self.list = []
		while addr < endaddr:
			op = Opcode(addr)
			self.list.append(op)
			addr = addr + op.size

	def __init__(self, addr, endaddr):
		self.update(addr, endaddr)

# graph
class Graph():
	def make_dot(addr, file):
		r.cmd("s %s"%addr)
		r.cmd("agd %s"%file)
	make_dot = staticmethod(make_dot)

	def make_png(addr, file):
		r.cmd("s %s"%addr)
		r.cmd("agd %s.dot"%file)
		r.cmd("!!dot -Tpng -o %s %s.dot"%(file,file));
		r.cmd("!!rm %s.dot"%file);
	make_png = staticmethod(make_png)

	def add_node(addr, size, cmd):
		r.cmd("gun %s %s %s"%(addr, size, cmd))

	def add_edge(addr, endaddr):
		r.cmd("gue %s %s"%(addr, endaddr))

	def reset():
		r.cmd("gur")

	def view():
		r.cmd("guv")

	def dot(file):
		r.cmd("gud > %s"%file)
	add_node = staticmethod(add_node)
	add_edge = staticmethod(add_edge)
	reset = staticmethod(reset)
	view = staticmethod(view)
	
# vm
class VM():
	def __init__(self):
		print "VM : TODO"

def idc_import(file):
	r.cmd(".!rsc idc2rdb %s"%file)