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

Keep gadgets when setting registers via setattr/call #1891

Merged
merged 2 commits into from
Jun 19, 2021
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 @@ -70,6 +70,7 @@ The table below shows which release corresponds to each branch, and what date th
- [#1903][1903] Add zsh completion script
- [#1904][1904] Add bash completion script
- [#1906][1906] Defer import of several modules to save on startup time
- [#1891][1891] Keep ROP gadgets when setting registers via setattr/call

[1733]: https://github.com/Gallopsled/pwntools/pull/1733
[1876]: https://github.com/Gallopsled/pwntools/pull/1876
Expand All @@ -79,6 +80,7 @@ The table below shows which release corresponds to each branch, and what date th
[1903]: https://github.com/Gallopsled/pwntools/pull/1903
[1904]: https://github.com/Gallopsled/pwntools/pull/1904
[1906]: https://github.com/Gallopsled/pwntools/pull/1906
[1891]: https://github.com/Gallopsled/pwntools/pull/1891

## 4.6.0 (`beta`)

Expand Down
11 changes: 7 additions & 4 deletions pwnlib/rop/rop.py
Original file line number Diff line number Diff line change
Expand Up @@ -720,21 +720,24 @@ def __call__(self, *args, **kwargs):
>>> r = ROP(e)
>>> r(rax=0xdead, rdi=0xbeef, rsi=0xcafe)
>>> print(r.dump())
0x0000: 0x10000000
0x0000: 0x10000000 pop rax; pop rdi; pop rsi; ret
0x0008: 0xdead
0x0010: 0xbeef
0x0018: 0xcafe
>>> r = ROP(e)
>>> r({'rax': 0xdead, 'rdi': 0xbeef, 'rsi': 0xcafe})
>>> print(r.dump())
0x0000: 0x10000000
0x0000: 0x10000000 pop rax; pop rdi; pop rsi; ret
0x0008: 0xdead
0x0010: 0xbeef
0x0018: 0xcafe
"""
if len(args) == 1 and isinstance(args[0], dict):
for value, _ in self.setRegisters(args[0]):
self.raw(value)
for value, name in self.setRegisters(args[0]):
if isinstance(name, Gadget):
self.raw(name)
else:
self.raw(value)
else:
self(kwargs)

Expand Down