Skip to content

Add __setattr__ and __call__ interfaces to ROP for setting registers (closes #1636) #1688

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

Merged
merged 5 commits into from
Oct 1, 2020

Conversation

mariuszskon
Copy link
Contributor

This implements #1636 which introduces the __setattr__ interface for setting registers in ROP, one at a time:

    >>> context.clear(arch='amd64')
    >>> assembly = 'pop rax; pop rdi; pop rsi; ret; pop rax; ret;'
    >>> e = ELF.from_assembly(assembly)
    >>> r = ROP(e)
    >>> r.rax = 0xdead
    >>> r.rdi = 0xbeef
    >>> r.rsi = 0xcafe
    >>> print(r.dump())
    0x0000:       0x10000004 pop rax; ret
    0x0008:           0xdead
    0x0010:       0x10000001 pop rdi; pop rsi; ret
    0x0018:           0xbeef
    0x0020:      b'iaaajaaa' <pad rsi>
    0x0028:       0x10000002 pop rsi; ret
    0x0030:           0xcafe

As discussed, a more flexible __call__ interface has also been implemented:

    >>> context.clear(arch='amd64')
    >>> assembly = 'pop rax; pop rdi; pop rsi; ret; pop rax; ret;'
    >>> e = ELF.from_assembly(assembly)
    >>> r = ROP(e)
    >>> r(rax=0xdead, rdi=0xbeef, rsi=0xcafe)
    >>> print(r.dump())
    0x0000:       0x10000000
    0x0008:           0xdead
    0x0010:           0xbeef
    0x0018:           0xcafe
    >>> r = ROP(e)
    >>> r({'rax': 0xdead, 'rdi': 0xbeef, 'rsi': 0xcafe})
    >>> print(r.dump())
    0x0000:       0x10000000
    0x0008:           0xdead
    0x0010:           0xbeef
    0x0018:           0xcafe

@Arusekk Arusekk merged commit bcb6e06 into Gallopsled:dev Oct 1, 2020
@zachriggle
Copy link
Member

zachriggle commented Oct 3, 2020 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants