tl;dr
memcpyinCPYgoes out-of-bounds of VM stack.- Abuse
memcpyto copy the register struct to stack and modify the values using stack operations and register operations. - Copy values back to the register struct, modifying the VM stack
bpandspregisters. - This migrates the VM stack to wherever you want, gaining arbitrary read and write.
- Leak
environpointer to get stack leak. - Migrate VM stack to
mainfunction’s stack to overwrite return address with ROP chain or one-gadget.