Skip to content

Commit

Permalink
Keep gadgets when setting registers via setattr/call (#1891)
Browse files Browse the repository at this point in the history
* Keep gadgets when setting registers via setattr/call

* Update changelog
  • Loading branch information
hackedd authored Jun 19, 2021
1 parent 684f06b commit 35260c4
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,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 @@ -81,6 +82,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

0 comments on commit 35260c4

Please sign in to comment.