OSEC

Neohapsis is currently accepting applications for employment. For more information, please visit our website www.neohapsis.com or email hr@neohapsis.com
 
Re: shellcode not executing if optimizations are on.

From: Luciano Miguel Ferreira Rocha (strangensk.no-ip.org)
Date: Wed Apr 30 2003 - 13:01:00 CDT


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