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

ret2csu seems broken #1941

Closed
JHeinzde opened this issue Jul 31, 2021 · 0 comments · Fixed by #1991
Closed

ret2csu seems broken #1941

JHeinzde opened this issue Jul 31, 2021 · 0 comments · Fixed by #1991

Comments

@JHeinzde
Copy link

If I try your example for ret2libcsu I get a syntax error:

Traceback (most recent call last):
  File "/home/jonathan/Projekte/CTF/uiuctf/./exploit.py", line 38, in <module>
    main()
  File "/home/jonathan/Projekte/CTF/uiuctf/./exploit.py", line 28, in main
    r.ret2csu(1, 2, 3, 4, 5, call=0xdeadbeef)
  File "/home/jonathan/.local/lib/python3.9/site-packages/pwnlib/rop/rop.py", line 1458, in ret2csu
    if elf.pie:
UnboundLocalError: local variabe 'elf' referenced before assignment

The offending code in rop.py looks like this:

        exes = (elf for elf in self.elfs if not elf.library and elf.bits == 64)
        if not exes:
            log.error('No non-library binaries in [elfs]')

        nonpie = csu = None
        for elf in exes:
            if not elf.pie:
                if '__libc_csu_init' in elf.symbols:
                    break
                nonpie = elf
            elif '__libc_csu_init' in elf.symbols:
                csu = elf

        if elf.pie:
            if nonpie:
                elf = nonpie
            elif csu:
                elf = csu

        from .ret2csu import ret2csu
        ret2csu(self, elf, edi, rsi, rdx, rbx, rbp, r12, r13, r14, r15, call)

I dont think that this is right since elf is never referenced before the if condition (it is in the for loop but the if is not inside the for loop).

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

Successfully merging a pull request may close this issue.

1 participant