// shellcode="$(cat 22.bin)" ./strstr #include #include #if __i386__ const char *service = "\x0b"; // service const char * call = "\xcd\x80"; // int $0x80 #elif __x86_64__ const char *service = "\x3b"; // service const char * call = "\x0f\x05"; // syscall #else #error undefined arch!!! #endif int main(int argc, char *argv[], char *envp[]) { while (*envp) { if (strstr(*envp, service) && strstr(*envp, call)) { char *shellcode = strstr(*envp, "=") + 1; printf("shellcode[%zu] = %s\n", strlen(shellcode), shellcode); ((void(*)())shellcode)(); } ++envp; } printf("%s: shellcode not found!\n", argv[0]); }