Skip to content

Commit

Permalink
Make setRegisters more robust
Browse files Browse the repository at this point in the history
Closes #1683
  • Loading branch information
Arusekk committed Aug 7, 2022
1 parent f084699 commit 0533ba0
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 2 deletions.
1 change: 1 addition & 0 deletions docs/source/rop/rop.rst
Expand Up @@ -15,6 +15,7 @@
from pwnlib.tubes.process import process
from pwnlib import shellcraft
from pwnlib.util.misc import which
import pwnlib.data

context.clear()

Expand Down
2 changes: 1 addition & 1 deletion pwnlib/rop/gadgets.py
Expand Up @@ -39,7 +39,7 @@ class Gadget(object):
move = 0

def __init__(self, address, insns, regs, move):
self.address = address
self.address = int(address)
self.insns = insns
self.regs = regs
self.move = move
Expand Down
6 changes: 5 additions & 1 deletion pwnlib/rop/rop.py
Expand Up @@ -1364,7 +1364,11 @@ def __getattr__(self, k):
regs.append(pop.match(insn).group(1))
sp_move += context.bytes
elif add.match(insn):
sp_move += int(add.match(insn).group(1), 16)
arg = int(add.match(insn).group(1), 16)
sp_move += arg
while arg >= context.bytes:
regs.append(hex(arg))
arg -= context.bytes
elif ret.match(insn):
sp_move += context.bytes
elif leave.match(insn):
Expand Down
1 change: 1 addition & 0 deletions pwnlib/shellcraft/__init__.py
Expand Up @@ -186,4 +186,5 @@ def find_module(self, fullname, path=None):

def load_module(self, fullname):
return sys.modules[fullname]

sys.meta_path.append(LazyImporter())
2 changes: 2 additions & 0 deletions pwnlib/tubes/process.py
Expand Up @@ -217,6 +217,8 @@ class process(tube):
#: Have we seen the process stop? If so, this is a unix timestamp.
_stop_noticed = 0

proc = None

def __init__(self, argv = None,
shell = False,
executable = None,
Expand Down

0 comments on commit 0533ba0

Please sign in to comment.