I must say that I do everything exclusively for educational purposes.
I am trying to understand the methods of ROP programming. I found in the kernel something like this gadget:
mov esp, _addr_ ret
and handed over to him control.
In _addr_ , I have a stack frame prepared for some task (in fact, the addresses of the ROP gadgets are). And when I’ve done everything I’ve done, the question arises - what’s next? In general, as I understand it, you need to somehow restore the stack pointer, but I have been sitting for 2 days and could not think of anything.
mov esp, _addr_. - PinkTuxespto the data segment by the code from where you jumped into the “gadget”? - ߊߚߤߘcallcommand, that is, go once to a certain address. - Alexey Sarovsky