mirror of https://github.com/pwndbg/pwndbg.git
Python27 fix
parent
bc6daee3f1
commit
aa654bf8fa
@ -0,0 +1,38 @@
|
|||||||
|
import __builtin__
|
||||||
|
import imp
|
||||||
|
import os
|
||||||
|
import sys
|
||||||
|
import types
|
||||||
|
import gdb
|
||||||
|
import pwndbg.commands
|
||||||
|
import pwndbg
|
||||||
|
|
||||||
|
_reload = __builtin__.reload
|
||||||
|
def rreload(module, paths=[''], mdict=None):
|
||||||
|
"""Recursively reload modules."""
|
||||||
|
name = module.__name__
|
||||||
|
|
||||||
|
if mdict is None:
|
||||||
|
mdict = {}
|
||||||
|
|
||||||
|
if module not in mdict:
|
||||||
|
mdict[module] = []
|
||||||
|
|
||||||
|
_reload(module)
|
||||||
|
|
||||||
|
for attribute_name in dir(module):
|
||||||
|
attribute = getattr(module, attribute_name)
|
||||||
|
|
||||||
|
if type(attribute) is not types.ModuleType: continue
|
||||||
|
if not attribute.__name__.startswith(name): continue
|
||||||
|
if attribute in mdict[module]: continue
|
||||||
|
|
||||||
|
mdict[module].append(attribute)
|
||||||
|
rreload(attribute, paths, mdict)
|
||||||
|
|
||||||
|
_reload(module)
|
||||||
|
|
||||||
|
@pwndbg.commands.Command
|
||||||
|
def reload(*a):
|
||||||
|
rreload(pwndbg)
|
||||||
|
|
||||||
@ -0,0 +1,20 @@
|
|||||||
|
import os
|
||||||
|
import gdb
|
||||||
|
import pwndbg.commands
|
||||||
|
|
||||||
|
@pwndbg.commands.Command
|
||||||
|
def rop(start=None, stop=None):
|
||||||
|
"""
|
||||||
|
Dump ROP gadgets.
|
||||||
|
|
||||||
|
Optionally specify an address to dump all gadgets in that memory
|
||||||
|
area, or also specify a stop address.
|
||||||
|
|
||||||
|
Searches executable mapped pages only.
|
||||||
|
"""
|
||||||
|
cmd = ['ROPgadget',
|
||||||
|
'--rawArch=x86',
|
||||||
|
'--rawMode=32',
|
||||||
|
'--binary=dump',
|
||||||
|
'--offset=0xdeadbeef']
|
||||||
|
os.system(' '.join(cmd))
|
||||||
@ -0,0 +1,26 @@
|
|||||||
|
# This hook is necessary for compatibility with Python2.7 versions of GDB
|
||||||
|
# since they cannot directly cast to integer a gdb.Value object that is
|
||||||
|
# not already an integer type.
|
||||||
|
import __builtin__
|
||||||
|
import gdb
|
||||||
|
import pwndbg.typeinfo
|
||||||
|
|
||||||
|
_int = __builtin__.int
|
||||||
|
|
||||||
|
# We need this class to get isinstance(7, xint) to return True
|
||||||
|
class IsAnInt(type):
|
||||||
|
def __instancecheck__(self, other):
|
||||||
|
return isinstance(other, _int)
|
||||||
|
|
||||||
|
class xint(__builtin__.int):
|
||||||
|
__metaclass__ = IsAnInt
|
||||||
|
def __new__(cls, value, *a, **kw):
|
||||||
|
if isinstance(value, gdb.Value):
|
||||||
|
if pwndbg.typeinfo.is_pointer(value):
|
||||||
|
value = value.cast(pwndbg.typeinfo.ulong)
|
||||||
|
else:
|
||||||
|
value = value.cast(pwndbg.typeinfo.long)
|
||||||
|
return _int(value, *a, **kw)
|
||||||
|
|
||||||
|
__builtin__.int = xint
|
||||||
|
globals()['int'] = xint
|
||||||
Loading…
Reference in new issue