On Fri, 13 Jul 2007, Darren J Moffat wrote:
> stevens wrote:
>> I want to write shellcode under solaris 10,but I found it that solaris 10
>> can't support compile static.How can I get assembly code from source code?
>
> Pass -S to the compiler, works for Sun Studio cc and GCC.
>
> Or if you want asm code out of a binary see dis(1).
>
> I don't see the relationship to static linking. Solaris does allow
> static linking we just don't ship static archive libraries for the
> system provided libraries.
Hmm, personally in a situation where someone says "I want to write
shellcode but [ don't even know how to look at assembly ]", the answer I
suggest is:
Start reading the compiler manpages, then any manpages referenced from
there, then any manpages within the same manpage subdirectory. Find out
that way how to get at the intermediate stages of a compile, and/or how to
do basic reverse engineering steps on a generated binary.
Once you've done that and you're comfortable compiling / assembling /
disassembling, start reading the platform ABI.
Once you've done that and grasped the basics of stacks and function
calling, go to shellcode.org and explain why (not) the code there works to
start a shell, and what exactly it does.
Once you've done that, create your own program:
#include <strings.h>
int main(int argc, char **argv)
{
char buf[40];
strcpy(buf, argv[1]);
return (strlen(buf));
}
and create the argument string that makes this start a "/bin/bash". Do
that for both SPARC and i86pc (32bit x86).
Once that works, do it for amd64 (64bit x86).
And if some of that does not ring a bell, then: Why on earth do you want
to write shellcode ?
FrankH.
_______________________________________________
opensolaris-code mailing list
[email protected]
http://mail.opensolaris.org/mailman/listinfo/opensolaris-code