Since, the majority of buffer overflow exploits is dependent upon string operations, there are generally two methods of injecting the code. The first method is to put the attack code in the buffer that is being overflowed, then setting return address to the address of the buffer. The second method involves filling the buffer with random memory address and shell codes, placing the attack code after the return address on the stack, then overwriting the return address with an instruction in the normal code or in a system library that will jump control to the stack pointer, which would be pointing to the location just after the return address. The actual command to jump control to the stack pointer does not have to be present in the code, just the equivalent machine code byte
Since, the majority of buffer overflow exploits is dependent upon string operations, there are generally two methods of injecting the code. The first method is to put the attack code in the buffer that is being overflowed, then setting return address to the address of the buffer. The second method involves filling the buffer with random memory address and shell codes, placing the attack code after the return address on the stack, then overwriting the return address with an instruction in the normal code or in a system library that will jump control to the stack pointer, which would be pointing to the location just after the return address. The actual command to jump control to the stack pointer does not have to be present in the code, just the equivalent machine code byte