Re: simple program for freebsd



On Thu, 29 Jun 2006 16:10:16 -0400, "T.M. Sommers" <tms@xxxxxx> wrote:

Rumba Dancer wrote:
<snip>
so C-source would be:

char shellcode [] =
<snip>
int main(void)
{
int* ret;
ret = (int*) &ret + 2;

Huh?

(*ret) = (int) shellcode;

That last line does not somehow magically turn the char array
shellcode into executable code and execute it, which is what I
guess you think it does. Perhaps if you explained exactly what
you are trying to accomplish someone could help you.

return 0;
}

I can't believe no one else has answered already, but:

He presumably thinks, correctly, that it clobbers the return address
in the usual x86 calling convention's (that is, cdecl with bp link)
stack marker, so that when this function 'returns', as it does in the
next line, it jumps to the intruded (normally malicious) code.

This has been the canonical procedure for stack smash attacks (or just
bugs) since forever on machines with downward-growing stacks (nearly
all) and return address in that stack (many, including x86).


- David.Thompson1 at worldnet.att.net

.



Relevant Pages

  • Re: simple program for freebsd
    ... write.o: file format elf32-i386-freebsd ... int main ... That last line does not somehow magically turn the char array shellcode into executable code and execute it, which is what I guess you think it does. ...
    (comp.lang.asm.x86)
  • Re: possible?
    ... > may be some good reason why SMC is usually done on the stack. ... can be pure data (no executable code) by returning to ... chosen data. ...
    (alt.lang.asm)
  • Re: Buffer overflow exploits - general question
    ... >mention about resolving this security issue by making the stack ... >non-executable but it is a non-starter since it would break existing ... >for the stack to ever have executable code. ...
    (comp.os.linux.security)