Skip to content

Commit

Permalink
ROP: add base= argument for .chain() and .dump() (#1673)
Browse files Browse the repository at this point in the history
* Allow using specific base for ROP.chain() and ROP.dump()

* Update CHANGELOG.md
  • Loading branch information
152334H authored Sep 13, 2020
1 parent 9ccf404 commit 4dec08b
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 5 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ The table below shows which release corresponds to each branch, and what date th
- [#1654][1654] Docker images (`pwntools/pwntools:stable` etc) now use Python3 by default, and includes assemblers for a few common architectures
- Fix syscall instruction lists for SROP on `i386` and `amd64`
- Fix migration to another ROP
- [#1673][1673] Add `base=` argument to `ROP.chain()` and `ROP.dump()`

[1602]: https://github.com/Gallopsled/pwntools/pull/1602
[1606]: https://github.com/Gallopsled/pwntools/pull/1606
Expand All @@ -76,6 +77,7 @@ The table below shows which release corresponds to each branch, and what date th
[1644]: https://github.com/Gallopsled/pwntools/pull/1644
[1651]: https://github.com/Gallopsled/pwntools/pull/1651
[1654]: https://github.com/Gallopsled/pwntools/pull/1654
[1673]: https://github.com/Gallopsled/pwntools/pull/1673

## 4.3.0 (`beta`)

Expand Down
21 changes: 16 additions & 5 deletions pwnlib/rop/rop.py
Original file line number Diff line number Diff line change
Expand Up @@ -925,17 +925,28 @@ def build(self, base = None, description = None):
def find_stack_adjustment(self, slots):
self.search(move=slots * context.bytes)

def chain(self):
def chain(self, base=None):
"""Build the ROP chain
Arguments:
base(int):
The base address to build the rop-chain from. Defaults to
:attr:`base`.
Returns:
str containing raw ROP bytes
"""
return packing.flat(self.build())
return packing.flat(self.build(base=base))

def dump(self):
"""Dump the ROP chain in an easy-to-read manner"""
return self.build().dump()
def dump(self, base=None):
"""Dump the ROP chain in an easy-to-read manner
Arguments:
base(int):
The base address to build the rop-chain from. Defaults to
:attr:`base`.
"""
return self.build(base=base).dump()

def regs(self, registers=None, **kw):
if registers is None:
Expand Down

0 comments on commit 4dec08b

Please sign in to comment.