When i execute binary i want their stack segment to be filled with special data. All i do is just write program that allocate huge buffer on a stack, call a lot of malloc and mmap and for example fill all this memory with ‘A’ character. Then i check and see that about 80% of whole memory are used by my program. Then i stop this program and start another program that just go through the stack and check values on stack. By i don’t see my ‘A’ character anyway. Can someone tell me how can i do it?
UPD Why i do is just because of one ctf. i mention task like.
int func() { int i; if(i == 0xdeadbeef) system("cat flag"); else func(); } int main() { func(); }
Advertisement
Answer
No, not without making heavy changes to the kernel. New anonymous pages are always zero-filled, and even if you could fill them with something else, there would be no reasonable way you could make them carry over data from old processes. Doing so would be a huge security hole in itself.