Skip to content

Commit d679252

Browse files
0xFE4415peace-makerArusekk
authored
Fix ret2csu with PIE binaries (Gallopsled#2158)
* fix indentation * Allow ret2csu to find non-pie binaries * ret2csu: fix detection logic --------- Co-authored-by: peace-maker <[email protected]> Co-authored-by: Arusekk <[email protected]>
1 parent c397626 commit d679252

File tree

1 file changed

+7
-12
lines changed

1 file changed

+7
-12
lines changed

pwnlib/rop/rop.py

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1544,23 +1544,18 @@ def ret2csu(self, edi=Padding('edi'), rsi=Padding('rsi'),
15441544
# Prioritise non-PIE binaries so we can use _fini
15451545
exes = (elf for elf in self.elfs if not elf.library and elf.bits == 64)
15461546

1547-
nonpie = csu = None
1547+
csu = None
15481548
for elf in exes:
1549-
if not elf.pie:
1550-
if '__libc_csu_init' in elf.symbols:
1551-
break
1552-
nonpie = elf
1553-
elif '__libc_csu_init' in elf.symbols:
1549+
if '__libc_csu_init' in elf.symbols:
15541550
csu = elf
1551+
if not elf.pie:
1552+
break
1553+
1554+
if csu:
1555+
elf = csu
15551556
else:
15561557
log.error('No non-library binaries in [elfs]')
15571558

1558-
if elf.pie:
1559-
if nonpie:
1560-
elf = nonpie
1561-
elif csu:
1562-
elf = csu
1563-
15641559
from .ret2csu import ret2csu
15651560
ret2csu(self, elf, edi, rsi, rdx, rbx, rbp, r12, r13, r14, r15, call)
15661561

0 commit comments

Comments
 (0)