How Shellcodes Work
Subject:   Problem compiling c example.
Date:   2006-05-22 07:25:54
From:   Kza
First C example:
char code[]=

main() {
int (*shell)();
(int)shell = code;

Gives compiler error:
shellApp.c: In function ‘main’:
shellApp.c:9: error: invalid lvalue in assignment

Main Topics Oldest First

Showing messages 1 through 2 of 2.

  • Problem compiling c example.
    2008-08-16 16:00:04  lwante [View]

    What gryzlo said is wrong... the problem here is that you are trying to cast and lvalue(left value) which is illegal. The solution is going to be casting the variable code on the line. Try this:

    shell = (int(*)()) code;

    What we are doing is here casting code to be a function pointer which returns an integer... in effect will eventually allows us to execute our "shellcode". I suggest reading "Smashing the Stack for fun and profit" by Aleph1 one.
  • Problem compiling c example.
    2006-05-22 12:56:19  gryzlo [View]

    Try another compiler, other than plain ISO C (gcc works well).