Exemplo n.º 1
0
def dis(num, addr=None):
	"""
	Disassemble 'num' opcodes from the current seek and returns the output
	"""
	if addr == None:
		return r.cmd("pd %d"%num)
	return r.cmd("pd %d @ 0x%x"%(num,addr))
Exemplo n.º 2
0
def str(addr=None):
	"""
	Returns a zero-terminated string found in current seek
	"""
	if addr == None:
		return r.cmd("pz").strip()
	return r.cmd("pz @ 0x%x"%addr).strip()
Exemplo n.º 3
0
def dis(num, addr=None):
    """
	Disassemble 'num' opcodes from the current seek and returns the output
	"""
    if addr == None:
        return r.cmd("pd %d" % num)
    return r.cmd("pd %d @ 0x%x" % (num, addr))
Exemplo n.º 4
0
def str(addr=None):
    """
	Returns a zero-terminated string found in current seek
	"""
    if addr == None:
        return r.cmd("pz").strip()
    return r.cmd("pz @ 0x%x" % addr).strip()
Exemplo n.º 5
0
def analyze_block(addr=None):
	"""
	Returns a hashtable containing the information of the analysis of the basic block found in the current seek.
	This is: 'offset', 'type', 'size', 'call#', 'n_calls', 'true', 'false' and 'bytes'
	"""
	if addr == None:
		return __str_to_hash(r.cmd("ab"))
	return __str_to_hash(r.cmd("ab @ 0x%x"%addr))
Exemplo n.º 6
0
def analyze_opcode(addr=None):
	"""
	Returns a hashtable containing the information of the analysis of the opcode in the current seek.
	This is: 'opcode', 'size', 'type', 'bytes', 'offset', 'ref', 'jump' and 'fail'
	"""
	if addr == None:
		return __str_to_hash(r.cmd("ao"))
	return __str_to_hash(r.cmd("ao @ 0x%x"%addr))
Exemplo n.º 7
0
def analyze_opcode(addr=None):
    """
	Returns a hashtable containing the information of the analysis of the opcode in the current seek.
	This is: 'opcode', 'size', 'type', 'bytes', 'offset', 'ref', 'jump' and 'fail'
	"""
    if addr == None:
        return __str_to_hash(r.cmd("ao"))
    return __str_to_hash(r.cmd("ao @ 0x%x" % addr))
Exemplo n.º 8
0
def analyze_block(addr=None):
    """
	Returns a hashtable containing the information of the analysis of the basic block found in the current seek.
	This is: 'offset', 'type', 'size', 'call#', 'n_calls', 'true', 'false' and 'bytes'
	"""
    if addr == None:
        return __str_to_hash(r.cmd("ab"))
    return __str_to_hash(r.cmd("ab @ 0x%x" % addr))
Exemplo n.º 9
0
	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"))
Exemplo n.º 10
0
 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"))
Exemplo n.º 11
0
	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)
Exemplo n.º 12
0
 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)
Exemplo n.º 13
0
def seek_history():
    ret = []
    list = r.cmd("u*").split("\n")
    for i in range(1, len(list)):
        w = list[i].split(" ")
        if len(w) > 3:
            t = {}
            t["addr"] = w[0].strip()
            ret.append(t)
    return ret
Exemplo n.º 14
0
def seek_history():
	ret = []
	list = r.cmd("u*").split("\n")
	for i in range(1, len(list)):
		w = list[i].split(" ")
		if len(w) > 3:
			t = {}
			t["addr"] = w[0].strip()
			ret.append(t)
	return ret
Exemplo n.º 15
0
 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)
Exemplo n.º 16
0
	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)
Exemplo n.º 17
0
 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)
Exemplo n.º 18
0
	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)
Exemplo n.º 19
0
	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)
Exemplo n.º 20
0
def dbg_backtrace():
	ret = []
	list = r.cmd("!bt").split("\n")
	for i in range(1, len(list)):
		w = list[i].split(" ")
		if len(w) > 3:
			t = {}
			t["addr"]    = long(w[1].strip(),16)
			t["framesz"] = long(w[2].strip(),10)
			t["varsz"]   = long(w[3].strip(),10)
			ret.append(t)
	return ret
Exemplo n.º 21
0
def flag_list(mask):
	ret = []
	list = r.cmd("f~%s"%mask).split("\n")
	for i in range(1, len(list)):
		w = list[i].split(" ")
		if len(w) > 3:
			t = {}
			t["addr"] = long(w[1].strip(),16)
			t["size"] = long(w[3].strip(),10)
			t["name"] = w[4].strip()
			ret.append(t)
	return ret
Exemplo n.º 22
0
def write_history():
    ret = []
    list = r.cmd("wu").split("\n")
    for i in range(1, len(list)):
        w = list[i].split(" ")
        if len(w) > 3:
            t = {}
            t["size"] = long(w[2].strip(), 10)
            t["addr"] = long(w[3].strip(), 16)
            # TODO moar nfo here
            ret.append(t)
    return ret
Exemplo n.º 23
0
def flag_list(mask):
    ret = []
    list = r.cmd("f~%s" % mask).split("\n")
    for i in range(1, len(list)):
        w = list[i].split(" ")
        if len(w) > 3:
            t = {}
            t["addr"] = long(w[1].strip(), 16)
            t["size"] = long(w[3].strip(), 10)
            t["name"] = w[4].strip()
            ret.append(t)
    return ret
Exemplo n.º 24
0
def dbg_backtrace():
    ret = []
    list = r.cmd("!bt").split("\n")
    for i in range(1, len(list)):
        w = list[i].split(" ")
        if len(w) > 3:
            t = {}
            t["addr"] = long(w[1].strip(), 16)
            t["framesz"] = long(w[2].strip(), 10)
            t["varsz"] = long(w[3].strip(), 10)
            ret.append(t)
    return ret
Exemplo n.º 25
0
 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)
Exemplo n.º 26
0
def write_history():
	ret = []
	list = r.cmd("wu").split("\n")
	for i in range(1, len(list)):
		w = list[i].split(" ")
		if len(w) > 3:
			t = {}
			t["size"] = long(w[2].strip(),10)
			t["addr"] = long(w[3].strip(),16)
			# TODO moar nfo here
			ret.append(t)
	return ret
Exemplo n.º 27
0
	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)
Exemplo n.º 28
0
 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)
Exemplo n.º 29
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])
Exemplo n.º 30
0
 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]))
Exemplo n.º 31
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])
Exemplo n.º 32
0
	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]))
Exemplo n.º 33
0
	def disassemble(addr, n):
		return r.cmd("pd %s@%d"%(n,addr))
Exemplo n.º 34
0
def dbg_free(addr):
    r.cmd("!free %s" % addr)
Exemplo n.º 35
0
	def remove(addr):
		r.cmd("CF-@%s"%addr)
		r.cmd("f -%s"%addr)
Exemplo n.º 36
0
def hash(algo, size):
    return r.cmd("#%s %d" % (algo, size))
Exemplo n.º 37
0
def trace_reset():
    r.cmd("at-")
Exemplo n.º 38
0
def trace_at(addr):
    return __str_to_hash(r.cmd("at %s" % addr))
Exemplo n.º 39
0
def dbg_register_get(name):
    r.cmd("!reg %s" % (name))
Exemplo n.º 40
0
	def make_dot(addr, file):
		r.cmd("s %s"%addr)
		r.cmd("agd %s"%file)
Exemplo n.º 41
0
	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);
Exemplo n.º 42
0
	def add_node(addr, size, cmd):
		r.cmd("gun %s %s %s"%(addr, size, cmd))
Exemplo n.º 43
0
	def remove(addr, str):
		r.cmd("CC -%s@%s"%(str, addr))
Exemplo n.º 44
0
	def add(addr, str):
		r.cmd("CC %s@%s"%(str, addr))
Exemplo n.º 45
0
	def add_edge(addr, endaddr):
		r.cmd("gue %s %s"%(addr, endaddr))
Exemplo n.º 46
0
def dbg_dump(name):
    r.cmd("!dump %s" % name)
Exemplo n.º 47
0
def dbg_restore(name):
    r.cmd("!restore %s" % name)
Exemplo n.º 48
0
	def analyze(addr):
		r.cmd(".af*@%s"%addr)
Exemplo n.º 49
0
def dbg_register_set(name, value):
    r.cmd("!reg %s=%s" % (name, value))
Exemplo n.º 50
0
def cmd(str):
    return r.cmd(str)
Exemplo n.º 51
0
def trace_list():
    return r.cmd("at*").split("\n")
Exemplo n.º 52
0
	def dot(file):
		r.cmd("gud > %s"%file)
Exemplo n.º 53
0
def trace_ranges():
    return r.cmd("at").split("\n")
Exemplo n.º 54
0
	def add(name, addr, size):
		r.cmd("CF %s@%s"%(size,addr))
		r.cmd("f %s@%s"%(name,addr))
Exemplo n.º 55
0
def graph(addr=None):
    if addr == None:
        r.cmd("ag")
    else:
        r.cmd("ag @ %s" % addr)
Exemplo n.º 56
0
	def reset():
		r.cmd("gur")
Exemplo n.º 57
0
def quit(num):
    r.cmd("q! %d" % num)
Exemplo n.º 58
0
def dbg_alloc(size):
    return r.cmd("!alloc %s" % size)
Exemplo n.º 59
0
def idc_import(file):
	r.cmd(".!rsc idc2rdb %s"%file)
Exemplo n.º 60
0
	def view():
		r.cmd("guv")