Vulnerability Development mailing list archives

Re: shellcode not executing if optimizations are on.


From: Luciano Miguel Ferreira Rocha <strange () nsk no-ip org>
Date: Wed, 30 Apr 2003 19:01:00 +0100

On Wed, Apr 30, 2003 at 08:46:20AM -0700, wirepair wrote:
<snip>
#include <stdio.h>

int main(int argc, char **argv) {
      char shellcizode[] = 
<snip>
      ((void (*)(void))&shellcizode)();
<snip>
Now this only 
works IF optimizations are disabled. any hints??

Most probably the compiler assumes that the shellcizode has no effect and
removes the call.

You could try defining shellcizode as volatile in order to disable any
optimizations when dealing with it, or there may be some compiler pragma
to disable optimizations in some places.

Regards,
Luciano Rocha


Current thread: