Пример #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))
Пример #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()
Пример #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))
Пример #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()
Пример #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))
Пример #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))
Пример #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))
Пример #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))
Пример #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"))
Пример #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"))
Пример #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)
Пример #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)
Пример #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
Пример #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
Пример #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)
Пример #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)
Пример #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)
Пример #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)
Пример #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)
Пример #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
Пример #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
Пример #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
Пример #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
Пример #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
Пример #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)
Пример #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
Пример #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)
Пример #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)
Пример #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])
Пример #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]))
Пример #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])
Пример #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]))
Пример #33
0
	def disassemble(addr, n):
		return r.cmd("pd %s@%d"%(n,addr))
Пример #34
0
def dbg_free(addr):
    r.cmd("!free %s" % addr)
Пример #35
0
	def remove(addr):
		r.cmd("CF-@%s"%addr)
		r.cmd("f -%s"%addr)
Пример #36
0
def hash(algo, size):
    return r.cmd("#%s %d" % (algo, size))
Пример #37
0
def trace_reset():
    r.cmd("at-")
Пример #38
0
def trace_at(addr):
    return __str_to_hash(r.cmd("at %s" % addr))
Пример #39
0
def dbg_register_get(name):
    r.cmd("!reg %s" % (name))
Пример #40
0
	def make_dot(addr, file):
		r.cmd("s %s"%addr)
		r.cmd("agd %s"%file)
Пример #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);
Пример #42
0
	def add_node(addr, size, cmd):
		r.cmd("gun %s %s %s"%(addr, size, cmd))
Пример #43
0
	def remove(addr, str):
		r.cmd("CC -%s@%s"%(str, addr))
Пример #44
0
	def add(addr, str):
		r.cmd("CC %s@%s"%(str, addr))
Пример #45
0
	def add_edge(addr, endaddr):
		r.cmd("gue %s %s"%(addr, endaddr))
Пример #46
0
def dbg_dump(name):
    r.cmd("!dump %s" % name)
Пример #47
0
def dbg_restore(name):
    r.cmd("!restore %s" % name)
Пример #48
0
	def analyze(addr):
		r.cmd(".af*@%s"%addr)
Пример #49
0
def dbg_register_set(name, value):
    r.cmd("!reg %s=%s" % (name, value))
Пример #50
0
def cmd(str):
    return r.cmd(str)
Пример #51
0
def trace_list():
    return r.cmd("at*").split("\n")
Пример #52
0
	def dot(file):
		r.cmd("gud > %s"%file)
Пример #53
0
def trace_ranges():
    return r.cmd("at").split("\n")
Пример #54
0
	def add(name, addr, size):
		r.cmd("CF %s@%s"%(size,addr))
		r.cmd("f %s@%s"%(name,addr))
Пример #55
0
def graph(addr=None):
    if addr == None:
        r.cmd("ag")
    else:
        r.cmd("ag @ %s" % addr)
Пример #56
0
	def reset():
		r.cmd("gur")
Пример #57
0
def quit(num):
    r.cmd("q! %d" % num)
Пример #58
0
def dbg_alloc(size):
    return r.cmd("!alloc %s" % size)
Пример #59
0
def idc_import(file):
	r.cmd(".!rsc idc2rdb %s"%file)
Пример #60
0
	def view():
		r.cmd("guv")