Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ROP: add base= argument for .chain() and .dump() #1673

Merged
merged 2 commits into from
Sep 13, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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