there is a protection mechanism in stack coined as nx stack(non executable) so shellcode cannot be runned directly from the stack instead you can use return to lib c attack to make it successful