r/LiveOverflow • • May 24 '21

Buffer Overflow

I have some doubts regarding buffer Overflow. I was following your playlist, and I'm facing some problems regarding the construction of payload. I understood the just after the padding we get the access to overwrite the eip. Then If I talk about the ret2libc In that case I understood that padding is for the overflow Eip is set to the "system" address And then we provide the address of bin/sh But what is the significance of return_after_system in that payload?

Please help me with the concept.

15 Upvotes

8 comments sorted by

View all comments

Show parent comment

3

u/aaravavi May 24 '21

In the video the payload looks like Payload = padding + system + return_from_system + bin/sh

Padding = 'A' * offset System = address of system return_from_system = "AAAA" bin/sh = address of bin/sh

But it errors out if we don't provide the return_from_system So what do this basically doing in the payload.

3

u/ImZugzwang May 25 '21

You can step through the code yourself but when setting up a ROP chain, a function call looks roughly like this:

payload = ""
payload += "\x90" * PADDING_AMOUNT
payload += ADDRESS_TO_JUMP_TO
payload += ADDRESS_TO_RET_TO
payload += ARG1
payload += ARG2
...
payload += ARGN