本文整理汇总了Python中gdb.lookup_type方法的典型用法代码示例。如果您正苦于以下问题:Python gdb.lookup_type方法的具体用法?Python gdb.lookup_type怎么用?Python gdb.lookup_type使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类gdb
的用法示例。
在下文中一共展示了gdb.lookup_type方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: import gdb [as 别名]
# 或者: from gdb import lookup_type [as 别名]
def __init__(self, base_addr, size):
Thread.__init__(self)
self.base_addr = base_addr # the vector we are monitoring
self.size = size # its size
self.messages = Queue() # cross-thread communication
# store contents of vec
self.values = []
int_t = gdb.lookup_type('int')
for idx in range(0, size):
self.values.append(int((base_addr + idx).dereference().cast(int_t)))
self.animations = []
# Front end code
# These methods run in the gdb thread in response to breakpoints,
# and accept gdb.Value objects
# Updates for instrumented actions
示例2: __stackmap
# 需要导入模块: import gdb [as 别名]
# 或者: from gdb import lookup_type [as 别名]
def __stackmap(self, frame_items):
symbolmap = defaultdict(list)
if not frame_items:
return symbolmap
for i in frame_items:
name = i.symbol().name
addr = self._frame.read_var(name).address
if not addr == None:
# gdb.Value is not "hashable"; keys must be something else
# so here we use addr converted to int
sz = i.symbol().type.sizeof
# mark all dwords in the stack with this symbol
addr = addr.cast(gdb.lookup_type("void").pointer()) # cast to void*
# handle sub-dword quantities by just listing everything that overlaps
for saddr in range(addr, addr+sz, 0x8):
symbolmap[int(saddr)].append(i.symbol())
return symbolmap
# Now create a gdb command that prints the current stack:
示例3: Refresh
# 需要导入模块: import gdb [as 别名]
# 或者: from gdb import lookup_type [as 别名]
def Refresh():
"""looks up symbols within the inferior and caches their names / values.
If debugging information is only partial, this method does its best to
find as much information as it can, validation can be done using
IsSymbolFileSane.
"""
try:
GdbCache.DICT = gdb.lookup_type('PyDictObject').pointer()
GdbCache.TYPE = gdb.lookup_type('PyTypeObject').pointer()
except gdb.error as err:
# The symbol file we're using doesn't seem to provide type information.
pass
interp_head_name = GdbCache.FuzzySymbolLookup('interp_head')
if interp_head_name:
GdbCache.INTERP_HEAD = gdb.parse_and_eval(interp_head_name)
else:
# As a last resort, ask the inferior about it.
GdbCache.INTERP_HEAD = gdb.parse_and_eval('PyInterpreterState_Head()')
GdbCache.PENDINGBUSY = GdbCache.FuzzySymbolLookup('pendingbusy')
GdbCache.PENDINGCALLS_TO_DO = GdbCache.FuzzySymbolLookup('pendingcalls_to_do')
示例4: stop
# 需要导入模块: import gdb [as 别名]
# 或者: from gdb import lookup_type [as 别名]
def stop(self):
rdi = gdb.selected_frame().read_register('rdi') #XXX
return False
if rdi == 0 or rdi == ZERO_SIZE_PTR or rdi == 0x40000000: #XXX
return False
cache = rdi.cast(gdb.lookup_type('struct kmem_cache').pointer()).dereference()
cache = cache['name'].string()
name, pid = get_task_info()
if apply_filter(name, cache):
trace_info = 'kfree is freeing an object from cache ' + cache + ' on behalf of process "' + name + '", pid ' + str(pid)
salt_print(trace_info)
history.append(('kfree', cache, name, pid))
return False
示例5: ty
# 需要导入模块: import gdb [as 别名]
# 或者: from gdb import lookup_type [as 别名]
def ty(typename):
"""Return a gdb.Type object represents given `typename`.
For example, x.cast(ty('Buffer'))"""
if typename in TYPE_CACHE:
return TYPE_CACHE[typename]
m = re.match(r"^(\S*)\s*[*|&]$", typename)
if m is None:
tp = gdb.lookup_type(typename)
else:
if m.group(1).endswith('*'):
tp = gdb.lookup_type().pointer()
else:
tp = gdb.lookup_type().reference()
TYPE_CACHE[typename] = tp
return tp
示例6: get_gdb_type
# 需要导入模块: import gdb [as 别名]
# 或者: from gdb import lookup_type [as 别名]
def get_gdb_type(cls):
return gdb.lookup_type(cls._typename).pointer()
示例7: _PyObject_VAR_SIZE
# 需要导入模块: import gdb [as 别名]
# 或者: from gdb import lookup_type [as 别名]
def _PyObject_VAR_SIZE(typeobj, nitems):
if _PyObject_VAR_SIZE._type_size_t is None:
_PyObject_VAR_SIZE._type_size_t = gdb.lookup_type('size_t')
return ( ( typeobj.field('tp_basicsize') +
nitems * typeobj.field('tp_itemsize') +
(SIZEOF_VOID_P - 1)
) & ~(SIZEOF_VOID_P - 1)
).cast(_PyObject_VAR_SIZE._type_size_t)
示例8: get_attr_dict
# 需要导入模块: import gdb [as 别名]
# 或者: from gdb import lookup_type [as 别名]
def get_attr_dict(self):
'''
Get the PyDictObject ptr representing the attribute dictionary
(or None if there's a problem)
'''
try:
typeobj = self.type()
dictoffset = int_from_int(typeobj.field('tp_dictoffset'))
if dictoffset != 0:
if dictoffset < 0:
type_PyVarObject_ptr = gdb.lookup_type('PyVarObject').pointer()
tsize = int_from_int(self._gdbval.cast(type_PyVarObject_ptr)['ob_size'])
if tsize < 0:
tsize = -tsize
size = _PyObject_VAR_SIZE(typeobj, tsize)
dictoffset += size
assert dictoffset > 0
assert dictoffset % SIZEOF_VOID_P == 0
dictptr = self._gdbval.cast(_type_char_ptr) + dictoffset
PyObjectPtrPtr = PyObjectPtr.get_gdb_type().pointer()
dictptr = dictptr.cast(PyObjectPtrPtr)
return PyObjectPtr.from_pyobject_ptr(dictptr.dereference())
except RuntimeError:
# Corrupt data somewhere; fail safe
pass
# Not found, or some kind of error:
return None
示例9: proxyval
# 需要导入模块: import gdb [as 别名]
# 或者: from gdb import lookup_type [as 别名]
def proxyval(self, visited):
'''
Python's Include/longobjrep.h has this declaration:
struct _longobject {
PyObject_VAR_HEAD
digit ob_digit[1];
};
with this description:
The absolute value of a number is equal to
SUM(for i=0 through abs(ob_size)-1) ob_digit[i] * 2**(SHIFT*i)
Negative numbers are represented with ob_size < 0;
zero is represented by ob_size == 0.
where SHIFT can be either:
#define PyLong_SHIFT 30
#define PyLong_SHIFT 15
'''
ob_size = long(self.field('ob_size'))
if ob_size == 0:
return 0L
ob_digit = self.field('ob_digit')
if gdb.lookup_type('digit').sizeof == 2:
SHIFT = 15L
else:
SHIFT = 30L
digits = [long(ob_digit[i]) * 2**(SHIFT*i)
for i in safe_range(abs(ob_size))]
result = sum(digits)
if ob_size < 0:
result = -result
return result
示例10: __init__
# 需要导入模块: import gdb [as 别名]
# 或者: from gdb import lookup_type [as 别名]
def __init__(self):
gdb.Command.__init__(self, "boundary", gdb.COMMAND_OBSCURE)
self.long_int = gdb.lookup_type('unsigned long long')
self.THRESHOLD = 0x1000
示例11: __init__
# 需要导入模块: import gdb [as 别名]
# 或者: from gdb import lookup_type [as 别名]
def __init__(self):
self.long_int = gdb.lookup_type('unsigned long long')
print("--[ ROPMEMU framework - GDB utils ]--\n")
print("[+] Patching...")
# necessary patch to make Chuck work
self.patch = "set *(unsigned long long*)0xffffffff81352d33 = 0xc310c48348"
gdb.execute("%s" % self.patch)
# set the breakpoint
print("[+] Setting the breakpoint...")
self.msr_gadget_addr = "*0xffffffff810039a0"
self.sysenter_esp = 0x175
super(ChuckGetCopyPtr, self).__init__(self.msr_gadget_addr, gdb.BP_BREAKPOINT)
# Continue
print("[+] Back to the VM")
gdb.execute("c")
示例12: __init__
# 需要导入模块: import gdb [as 别名]
# 或者: from gdb import lookup_type [as 别名]
def __init__(self):
gdb.Command.__init__(self, "unrop", gdb.COMMAND_OBSCURE)
self.long_int = gdb.lookup_type('unsigned long long')
self.hw_context = OrderedDict()
示例13: __init__
# 需要导入模块: import gdb [as 别名]
# 或者: from gdb import lookup_type [as 别名]
def __init__(self):
gdb.Command.__init__(self, "spmonitor", gdb.COMMAND_OBSCURE)
self.long_int = gdb.lookup_type('unsigned long long')
示例14: _to_int
# 需要导入模块: import gdb [as 别名]
# 或者: from gdb import lookup_type [as 别名]
def _to_int(x):
try:
return int(gdb.parse_and_eval(x).cast(gdb.lookup_type("long")))
except BaseException as e:
print (e)
return None
示例15: before_stateshot
# 需要导入模块: import gdb [as 别名]
# 或者: from gdb import lookup_type [as 别名]
def before_stateshot(self):
self.vmmap = self._get_vmmap()
self.base_addr = self.vmmap[0][0]
sections = self._get_sections()
for start, end, name in sections:
if name == load_project().arch.got_section_name:
self.got = (start, end)
elif name == ".plt":
self.plt = (start, end)
elif name == ".idata":
self.plt = (start, end)
self.long_type = gdb.lookup_type("long")