make a nop sled, then put your payload at the end of it. https://www.corelan.be/index.php/2009/07/19/exploit-writing-tutorial-part-1-stack-based-overflows/ This is a very detailed way of how to do it. The payload is written in shell code which is kind of complicated. But this will show you the basics of an overflow.
If I recall correctly, http://insecure.org/stf/smashstack.html is also another tutorial on the topic.